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