use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class AbstractLayer method zoomToLayer.
public void zoomToLayer() {
final Project project = getProject();
if (project != null) {
final GeometryFactory geometryFactory = project.getGeometryFactory();
final BoundingBox layerBoundingBox = getBoundingBox();
final BoundingBox boundingBox = layerBoundingBox.convert(geometryFactory).clipToCoordinateSystem().expandPercent(0.1);
project.setViewBoundingBox(boundingBox);
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class GeometryStyleRenderer method renderGeometry.
public static final void renderGeometry(final Viewport2D viewport, final Graphics2D graphics, final Geometry geometry, final GeometryStyle style) {
if (geometry != null) {
final BoundingBox viewExtent = viewport.getBoundingBox();
if (!viewExtent.isEmpty()) {
final GeometryFactory viewGeometryFactory = viewport.getGeometryFactory2dFloating();
for (int i = 0; i < geometry.getGeometryCount(); i++) {
final Geometry part = geometry.getGeometry(i);
final BoundingBox partExtent = part.getBoundingBox();
if (partExtent.intersects(viewExtent)) {
final Geometry convertedPart = part.convertGeometry(viewGeometryFactory);
if (convertedPart instanceof Point) {
final Point point = (Point) convertedPart;
MarkerStyleRenderer.renderMarker(viewport, graphics, point, style, 0);
} else if (convertedPart instanceof LineString) {
final LineString lineString = (LineString) convertedPart;
renderLineString(viewport, graphics, lineString, style);
} else if (convertedPart instanceof Polygon) {
final Polygon polygon = (Polygon) convertedPart;
renderPolygon(viewport, graphics, polygon, style);
}
}
}
}
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class GeometryStyleRenderer method renderGeometryOutline.
public static final void renderGeometryOutline(final Viewport2D viewport, final Graphics2D graphics, final Geometry geometry, final GeometryStyle style) {
if (geometry != null) {
final BoundingBox viewExtent = viewport.getBoundingBox();
if (!viewExtent.isEmpty()) {
final GeometryFactory viewGeometryFactory = viewport.getGeometryFactory2dFloating();
for (int i = 0; i < geometry.getGeometryCount(); i++) {
final Geometry part = geometry.getGeometry(i);
final BoundingBox partExtent = part.getBoundingBox();
if (partExtent.intersects(viewExtent)) {
final Geometry convertedPart = part.convertGeometry(viewGeometryFactory);
if (convertedPart instanceof Point) {
final Point point = (Point) convertedPart;
MarkerStyleRenderer.renderMarker(viewport, graphics, point, style, 0);
} else if (convertedPart instanceof LineString) {
final LineString lineString = (LineString) convertedPart;
renderLineString(viewport, graphics, lineString, style);
} else if (convertedPart instanceof Polygon) {
final Polygon polygon = (Polygon) convertedPart;
for (final LinearRing ring : polygon.rings()) {
renderLineString(viewport, graphics, ring, style);
}
}
}
}
}
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class AbstractTiledLayerRenderer method propertyChange.
@Override
public void propertyChange(final PropertyChangeEvent event) {
final Object newValue = event.getNewValue();
if (newValue instanceof BoundingBox) {
final BoundingBox newBoundingBox = (BoundingBox) newValue;
synchronized (this.cachedTiles) {
final List<T> mapTiles = new ArrayList<>(this.cachedTiles.keySet());
final GeometryFactory newGeometryFactory = newBoundingBox.getGeometryFactory();
for (final T mapTile : mapTiles) {
final BoundingBox boundingBox = mapTile.getBoundingBox();
final GeometryFactory geometryFactory = boundingBox.getGeometryFactory();
if (!geometryFactory.equals(newGeometryFactory) || !newBoundingBox.intersects(boundingBox)) {
this.cachedTiles.remove(mapTile);
}
}
}
} else if (!TILES_LOADED.equals(event.getPropertyName())) {
clearCachedTiles();
}
if (!(event.getSource() instanceof Layer)) {
firePropertyChange(event);
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class WebMercatorTileCacheLayer method getOverlappingMapTiles.
@Override
public List<WebMercatorTileCacheMapTile> getOverlappingMapTiles(final Viewport2D viewport) {
final List<WebMercatorTileCacheMapTile> tiles = new ArrayList<>();
try {
final double metresPerPixel = viewport.getMetresPerPixel();
final int zoomLevel = this.client.getZoomLevel(metresPerPixel);
final double resolution = getResolution(viewport);
final BoundingBox geographicBoundingBox = viewport.getBoundingBox().convert(GEOMETRY_FACTORY).intersection(MAX_BOUNDING_BOX);
final double minX = geographicBoundingBox.getMinX();
final double minY = geographicBoundingBox.getMinY();
final double maxX = geographicBoundingBox.getMaxX();
final double maxY = geographicBoundingBox.getMaxY();
// Tiles start at the North-West corner of the map
final int minTileY = this.client.getTileY(zoomLevel, maxY);
final int maxTileY = this.client.getTileY(zoomLevel, minY);
final int minTileX = this.client.getTileX(zoomLevel, minX);
final int maxTileX = this.client.getTileX(zoomLevel, maxX);
for (int tileY = minTileY; tileY <= maxTileY; tileY++) {
for (int tileX = minTileX; tileX <= maxTileX; tileX++) {
final WebMercatorTileCacheMapTile tile = new WebMercatorTileCacheMapTile(this, zoomLevel, resolution, tileX, tileY);
tiles.add(tile);
}
}
} catch (final Throwable e) {
Logs.error(this, "Error getting tile envelopes", e);
}
return tiles;
}
Aggregations