Search in sources :

Example 91 with BoundingBox

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);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 92 with 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);
                    }
                }
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon) Paint(java.awt.Paint) Point(com.revolsys.geometry.model.Point)

Example 93 with BoundingBox

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);
                        }
                    }
                }
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing) Paint(java.awt.Paint) Point(com.revolsys.geometry.model.Point)

Example 94 with BoundingBox

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);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) Layer(com.revolsys.swing.map.layer.Layer)

Example 95 with BoundingBox

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;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList)

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