Search in sources :

Example 31 with LinearRing

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

the class IsValidOp method checkHolesNotNested.

/**
 * Tests that no hole is nested inside another hole.
 * This routine assumes that the holes are disjoint.
 * To ensure this, holes have previously been tested
 * to ensure that:
 * <ul>
 * <li>they do not partially overlap
 *      (checked by <code>checkRelateConsistency</code>)
 * <li>they are not identical
 *      (checked by <code>checkRelateConsistency</code>)
 * </ul>
 */
private boolean checkHolesNotNested(final Polygon p, final GeometryGraph graph) {
    final IndexedNestedRingTester nestedTester = new IndexedNestedRingTester(graph);
    for (int i = 0; i < p.getHoleCount(); i++) {
        final LinearRing innerHole = p.getHole(i);
        nestedTester.add(innerHole);
    }
    final boolean isNonNested = nestedTester.isNonNested();
    if (isNonNested) {
        return true;
    } else {
        addError(new TopologyValidationError(TopologyValidationError.NESTED_HOLES, nestedTester.getNestedPoint()));
        return false;
    }
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing) Point(com.revolsys.geometry.model.Point)

Example 32 with LinearRing

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

the class WKBReader method readPolygon.

private Polygon readPolygon(final GeometryFactory geometryFactory) throws IOException {
    final int ringCount = this.dis.readInt();
    final List<LinearRing> rings = new ArrayList<>();
    for (int i = 0; i < ringCount; i++) {
        final LinearRing ring = readLinearRing(geometryFactory);
        rings.add(ring);
    }
    return geometryFactory.polygon(rings);
}
Also used : ArrayList(java.util.ArrayList) LinearRing(com.revolsys.geometry.model.LinearRing) Point(com.revolsys.geometry.model.Point)

Example 33 with LinearRing

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

the class GeoJsonRecordWriter method coordinatesPolygon.

private void coordinatesPolygon(final Polygon polygon) {
    this.out.startList(false);
    this.out.indent();
    final LineString shell = polygon.getShell();
    coordinatesLineString(shell.toCounterClockwise());
    for (final LinearRing hole : polygon.holes()) {
        this.out.endAttribute();
        this.out.indent();
        coordinatesLineString(hole.toClockwise());
    }
    this.out.endList();
}
Also used : LineString(com.revolsys.geometry.model.LineString) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 34 with LinearRing

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

the class GmlGeometryReader method readPolygon.

private Polygon readPolygon(final GeometryFactory geometryFactory) throws XMLStreamException {
    int axisCount = 2;
    final GeometryFactory factory = getGeometryFactory(geometryFactory);
    final List<LinearRing> rings = new ArrayList<>();
    final int depth = this.in.getDepth();
    while (this.in.skipToStartElements(depth, Gml.OUTER_BOUNDARY_IS, Gml.INNER_BOUNDARY_IS)) {
        final LinearRing ring = readLinearRing(factory);
        if (ring != null) {
            axisCount = Math.max(axisCount, ring.getAxisCount());
            rings.add(ring);
        }
    }
    final Polygon polygon = factory.convertAxisCount(axisCount).polygon(rings);
    return polygon;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ArrayList(java.util.ArrayList) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point)

Example 35 with LinearRing

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

the class ArcGisRestServerFeatureIterator method parseMultiPolygon.

public static Geometry parseMultiPolygon(final GeometryFactory geometryFactory, final MapEx properties) {
    final List<Polygon> polygons = new ArrayList<>();
    final List<LinearRing> rings = new ArrayList<>();
    final List<List<List<Number>>> paths = properties.getValue("rings", Collections.emptyList());
    for (final List<List<Number>> points : paths) {
        final LinearRing ring = geometryFactory.linearRing(points);
        if (ring.isClockwise()) {
            if (!rings.isEmpty()) {
                final Polygon polygon = geometryFactory.polygon(rings);
                polygons.add(polygon);
            }
            rings.clear();
        }
        rings.add(ring);
    }
    if (!rings.isEmpty()) {
        final Polygon polygon = geometryFactory.polygon(rings);
        polygons.add(polygon);
    }
    return geometryFactory.geometry(polygons);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing)

Aggregations

LinearRing (com.revolsys.geometry.model.LinearRing)95 Polygon (com.revolsys.geometry.model.Polygon)53 Point (com.revolsys.geometry.model.Point)44 ArrayList (java.util.ArrayList)21 LineString (com.revolsys.geometry.model.LineString)19 Geometry (com.revolsys.geometry.model.Geometry)14 Polygonal (com.revolsys.geometry.model.Polygonal)11 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)9 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 Lineal (com.revolsys.geometry.model.Lineal)7 Punctual (com.revolsys.geometry.model.Punctual)6 List (java.util.List)4 NoSuchElementException (java.util.NoSuchElementException)4 IOException (java.io.IOException)3 MCPointInRing (com.revolsys.geometry.algorithm.MCPointInRing)2 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 Vertex (com.revolsys.geometry.model.vertex.Vertex)2 BigDecimal (java.math.BigDecimal)2 PointInRing (com.revolsys.geometry.algorithm.PointInRing)1 EdgeRing (com.revolsys.geometry.geomgraph.EdgeRing)1