Search in sources :

Example 71 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class UtmRectangularMapGrid method getTiles.

@Override
public List<RectangularMapTile> getTiles(final BoundingBox boundingBox) {
    final com.revolsys.geometry.model.BoundingBox envelope = boundingBox.convert(getGeometryFactory());
    final List<RectangularMapTile> tiles = new ArrayList<>();
    final int minXCeil = (int) Math.ceil(envelope.getMinX() / this.tileWidth);
    final double minX = minXCeil * this.tileWidth;
    final int maxXCeil = (int) Math.ceil(envelope.getMaxX() / this.tileWidth) + 1;
    final int minYFloor = (int) Math.floor(envelope.getMinY() / this.tileHeight);
    final double minY = minYFloor * this.tileHeight;
    final int maxYCeil = (int) Math.ceil(envelope.getMaxY() / this.tileHeight);
    final int numX = maxXCeil - minXCeil;
    final int numY = maxYCeil - minYFloor;
    if (numX > 8 || numY > 8) {
        return tiles;
    }
    for (int y = 0; y < numY; y++) {
        final double lat = minY + y * this.tileHeight;
        for (int x = 0; x < numX; x++) {
            final double lon = minX + x * this.tileWidth;
            final RectangularMapTile tile = getTileByLocation(lon, lat);
            tiles.add(tile);
        }
    }
    return tiles;
}
Also used : ArrayList(java.util.ArrayList) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 72 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class UtmRectangularMapGrid method getTileByName.

@Override
public RectangularMapTile getTileByName(final String mapTileName) {
    final BoundingBox boundingBox = getBoundingBox(mapTileName);
    final double lon = boundingBox.getMaxX();
    final double lat = boundingBox.getMinY();
    final String tileName = getMapTileName(lon, lat);
    final String formattedMapTileName = getFormattedMapTileName(mapTileName);
    return new SimpleRectangularMapTile(this, formattedMapTileName, tileName, boundingBox);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 73 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class BoundingBoxTaskSplitter method run.

@Override
public void run() {
    preRun();
    try {
        if (this.boundingBox != null) {
            final GeometryFactory geometryFactory = this.boundingBox.getGeometryFactory();
            final double xInc = this.boundingBox.getWidth() / this.numX;
            final double yInc = this.boundingBox.getHeight() / this.numY;
            double y = this.boundingBox.getMinY();
            for (int j = 0; j < this.numX; j++) {
                double x = this.boundingBox.getMinX();
                for (int i = 0; i < this.numX; i++) {
                    final BoundingBox cellBoundingBox = geometryFactory.newBoundingBox(x, y, x + xInc, y + yInc);
                    if (this.preparedBoundary == null || this.preparedBoundary.intersects(cellBoundingBox.toPolygon(50))) {
                        if (this.logScriptInfo) {
                            Logs.info(this, "Processing bounding box " + cellBoundingBox.toPolygon(1));
                        }
                        execute(cellBoundingBox);
                    }
                    x += xInc;
                }
                y += yInc;
            }
        }
    } finally {
        postRun();
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 74 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class Nts1000000RectangularMapGrid method getTiles.

@Override
public List<RectangularMapTile> getTiles(final BoundingBox boundingBox) {
    final BoundingBox envelope = boundingBox.convert(getGeometryFactory());
    final List<RectangularMapTile> tiles = new ArrayList<>();
    final int minXCeil = (int) Math.ceil(envelope.getMinX() / this.tileWidth);
    final double minX = minXCeil * this.tileWidth;
    final int maxXCeil = (int) Math.ceil(envelope.getMaxX() / this.tileWidth) + 1;
    final int minYFloor = (int) Math.floor(envelope.getMinY() / this.tileHeight);
    final double minY = minYFloor * this.tileHeight;
    final int maxYCeil = (int) Math.ceil(envelope.getMaxY() / this.tileHeight);
    final int numX = maxXCeil - minXCeil;
    final int numY = maxYCeil - minYFloor;
    final int max = 100;
    if (numX > max || numY > max) {
        Logs.error(this, "Request would return too many tiles width=" + numX + " (max=" + max + ") height=" + numY + "(max=" + max + ").");
        return tiles;
    }
    for (int y = 0; y < numY; y++) {
        final double lat = minY + y * this.tileHeight;
        for (int x = 0; x < numX; x++) {
            final double lon = minX + x * this.tileWidth;
            final RectangularMapTile tile = getTileByLocation(lon, lat);
            tiles.add(tile);
        }
    }
    return tiles;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList)

Example 75 with BoundingBox

use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.

the class Nts1000000RectangularMapGrid method getTileByLocation.

@Override
public RectangularMapTile getTileByLocation(final double x, final double y) {
    final String mapTileName = getMapTileName(x, y);
    final String formattedMapTileName = getFormattedMapTileName(mapTileName);
    final BoundingBox boundingBox = getBoundingBox(mapTileName);
    return new SimpleRectangularMapTile(this, formattedMapTileName, mapTileName, boundingBox);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Aggregations

BoundingBox (com.revolsys.geometry.model.BoundingBox)307 Point (com.revolsys.geometry.model.Point)83 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)76 ArrayList (java.util.ArrayList)45 Geometry (com.revolsys.geometry.model.Geometry)41 LineString (com.revolsys.geometry.model.LineString)26 List (java.util.List)26 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)19 Polygon (com.revolsys.geometry.model.Polygon)14 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)14 Project (com.revolsys.swing.map.layer.Project)14 CreateListVisitor (com.revolsys.visitor.CreateListVisitor)12 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)11 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)11 Edge (com.revolsys.geometry.graph.Edge)10 HashMap (java.util.HashMap)10 Record (com.revolsys.record.Record)9 Graphics2D (java.awt.Graphics2D)9 MapEx (com.revolsys.collection.map.MapEx)8 LinearRing (com.revolsys.geometry.model.LinearRing)8