Search in sources :

Example 16 with Polygon

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

the class PolygonVertex method getCoordinate.

@Override
public double getCoordinate(final int axisIndex) {
    final Polygon polygon = getPolygon();
    final LinearRing ring = polygon.getRing(this.ringIndex);
    if (ring == null) {
        return java.lang.Double.NaN;
    } else {
        return ring.getCoordinate(this.vertexIndex, axisIndex);
    }
}
Also used : Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 17 with Polygon

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

the class Buffer method buffer.

private static Geometry buffer(final Noder noder, final GeometryFactory precisionModel, final Geometry geometry, final double distance, final BufferParameters parameters) {
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    final OffsetCurveSetBuilder curveSetBuilder = new OffsetCurveSetBuilder(geometry, distance, precisionModel, parameters);
    final List<NodedSegmentString> curves = curveSetBuilder.getCurves();
    if (curves.size() == 0) {
        return geometryFactory.polygon();
    } else {
        final EdgeList edgeList = new EdgeList();
        computeNodedEdges(noder, edgeList, curves);
        final PlanarGraph graph = new PlanarGraph(new OverlayNodeFactory());
        final List<Edge> edges = edgeList.getEdges();
        graph.addEdges(edges);
        final List<BufferSubgraph> subgraphList = newSubgraphs(graph);
        final PolygonBuilder polyBuilder = new PolygonBuilder(geometryFactory);
        buildSubgraphs(subgraphList, polyBuilder);
        final List<Polygon> polygons = polyBuilder.getPolygons();
        if (polygons.size() == 0) {
            return geometryFactory.polygon();
        } else {
            final Geometry resultGeom = geometryFactory.buildGeometry(polygons);
            return resultGeom;
        }
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) OverlayNodeFactory(com.revolsys.geometry.operation.overlay.OverlayNodeFactory) EdgeList(com.revolsys.geometry.geomgraph.EdgeList) Geometry(com.revolsys.geometry.model.Geometry) PlanarGraph(com.revolsys.geometry.geomgraph.PlanarGraph) NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) Polygon(com.revolsys.geometry.model.Polygon) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) PolygonBuilder(com.revolsys.geometry.operation.overlay.PolygonBuilder)

Example 18 with Polygon

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

the class DistanceWithPoints method computeContainmentDistance.

private boolean computeContainmentDistance(final List<Point> locations, final List<Polygon> polygons) {
    for (final Point point : locations) {
        final double x = point.getX();
        final double y = point.getY();
        for (final Polygon polygon : polygons) {
            if (computeContainmentDistance(polygon, x, y)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon)

Example 19 with Polygon

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

the class BufferDistanceValidator method getPolygonLines.

private Geometry getPolygonLines(final Geometry geometry) {
    final List<LineString> lines = new ArrayList<>();
    for (final Polygon polygon : geometry.getGeometries(Polygon.class)) {
        lines.addAll(polygon.getRings());
    }
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    return geometryFactory.geometry(lines);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList) Polygon(com.revolsys.geometry.model.Polygon)

Example 20 with Polygon

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

the class DistanceToPointFinder method computeDistance.

public static void computeDistance(final Geometry geometry, final Point pt, final PointPairDistance ptDist) {
    if (geometry instanceof LineString) {
        computeDistance(geometry, pt, ptDist);
    } else if (geometry instanceof Polygon) {
        computeDistance(geometry, pt, ptDist);
    } else if (geometry.isGeometryCollection()) {
        for (int i = 0; i < geometry.getGeometryCount(); i++) {
            final Geometry g = geometry.getGeometry(i);
            computeDistance(g, pt, ptDist);
        }
    } else {
        // assume geom is Point
        ptDist.setMinimum(geometry.getPoint(), pt);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineString(com.revolsys.geometry.model.LineString) Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point)

Aggregations

Polygon (com.revolsys.geometry.model.Polygon)147 Point (com.revolsys.geometry.model.Point)66 LinearRing (com.revolsys.geometry.model.LinearRing)54 LineString (com.revolsys.geometry.model.LineString)39 Geometry (com.revolsys.geometry.model.Geometry)34 ArrayList (java.util.ArrayList)30 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)22 Polygonal (com.revolsys.geometry.model.Polygonal)17 BoundingBox (com.revolsys.geometry.model.BoundingBox)14 Punctual (com.revolsys.geometry.model.Punctual)12 Test (org.junit.Test)12 Lineal (com.revolsys.geometry.model.Lineal)11 BaseCloseable (com.revolsys.io.BaseCloseable)7 List (java.util.List)7 PolygonEditor (com.revolsys.geometry.model.editor.PolygonEditor)6 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)6 Vertex (com.revolsys.geometry.model.vertex.Vertex)6 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)3 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)3 Graphics2D (java.awt.Graphics2D)3