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;
}
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);
}
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();
}
}
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;
}
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);
}
Aggregations