use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class GeometryGraph method addGeometry.
public void addGeometry(Geometry geometry) {
geometry = getGeometryFactory().geometry(geometry);
final Map<String, Object> properties = new LinkedHashMap<>();
final int geometryIndex = this.geometries.size();
properties.put("geometryIndex", geometryIndex);
this.geometries.add(geometry);
for (int partIndex = 0; partIndex < geometry.getGeometryCount(); partIndex++) {
properties.put("partIndex", partIndex);
final Geometry part = geometry.getGeometry(partIndex);
if (part instanceof Point) {
final Point point = (Point) part;
this.points.add(point);
} else if (part instanceof LineString) {
final LineString line = (LineString) part;
final LineString points = line;
properties.put("type", "LineString");
addEdges(points, properties);
} else if (part instanceof Polygon) {
final Polygon polygon = (Polygon) part;
int ringIndex = 0;
for (final LinearRing ring : polygon.rings()) {
properties.put("ringIndex", ringIndex++);
if (ringIndex == 0) {
properties.put("type", "PolygonShell");
} else {
properties.put("type", "PolygonHole");
}
addEdges(ring, properties);
}
properties.remove("ringIndex");
}
}
this.boundingBox = this.boundingBox.expandToInclude(geometry);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class EdgeRing method toPolygon.
public Polygon toPolygon(final GeometryFactory geometryFactory) {
final List<LinearRing> rings = new ArrayList<>();
rings.add(getLinearRing());
for (int i = 0; i < this.holes.size(); i++) {
final LinearRing ring = this.holes.get(i).getLinearRing();
rings.add(ring);
}
final Polygon poly = geometryFactory.polygon(rings);
return poly;
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class GeometryGraph method addPolygon.
private void addPolygon(final Polygon p) {
addPolygonRing(p.getShell(), Location.EXTERIOR, Location.INTERIOR);
for (int i = 0; i < p.getHoleCount(); i++) {
final LinearRing hole = p.getHole(i);
// Holes are topologically labelled opposite to the shell, since
// the interior of the polygon lies on their opposite side
// (on the left, if the hole is oriented CW)
addPolygonRing(hole, Location.INTERIOR, Location.EXTERIOR);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PolygonSegment method next.
@Override
public Segment next() {
final Polygon polygon = this.polygon;
this.segmentIndex++;
while (this.ringIndex < polygon.getRingCount()) {
final LinearRing ring = polygon.getRing(this.ringIndex);
if (this.segmentIndex < ring.getSegmentCount()) {
return this;
} else {
this.ringIndex++;
this.segmentIndex = 0;
}
}
throw new NoSuchElementException();
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PolygonEditor method newGeometry.
@Override
public Polygon newGeometry() {
final int ringCount = this.editors.size();
final LinearRing[] rings = new LinearRing[ringCount];
int ringIndex = 0;
for (final LinearRingEditor editor : this.editors) {
rings[ringIndex++] = editor.newGeometry();
}
final GeometryFactory geometryFactory = getGeometryFactory();
if (this.polygon == null) {
return geometryFactory.polygon(rings);
} else {
return this.polygon.newPolygon(geometryFactory, rings);
}
}
Aggregations