use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class MultiPolygonSegment method next.
@Override
public Segment next() {
this.segmentIndex++;
final Polygonal polygonal = this.polygonal;
final int geometryCount = polygonal.getGeometryCount();
while (this.partIndex < geometryCount) {
final Polygon polygon = getPolygon();
final int ringCount = polygon.getRingCount();
while (this.ringIndex < ringCount) {
final LinearRing ring = polygon.getRing(this.ringIndex);
if (this.segmentIndex < ring.getSegmentCount()) {
return this;
} else {
this.ringIndex++;
this.segmentIndex = 0;
}
}
this.partIndex++;
this.ringIndex = 0;
this.segmentIndex = 0;
}
throw new NoSuchElementException();
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class PolygonSegment method hasNext.
@Override
public boolean hasNext() {
if (getGeometry().isEmpty()) {
return false;
} else {
final Polygon polygon = this.polygon;
int ringIndex = this.ringIndex;
int segmentIndex = this.segmentIndex;
while (ringIndex < polygon.getRingCount()) {
final LinearRing ring = polygon.getRing(ringIndex);
if (segmentIndex + 1 < ring.getSegmentCount()) {
return true;
} else {
ringIndex++;
segmentIndex = 0;
}
}
return false;
}
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class Densifier method densify.
private static Polygon densify(final Polygon polygon, final double distanceTolerance) {
// Attempt to fix invalid geometries
final GeometryFactory geometryFactory = polygon.getGeometryFactory();
final List<LinearRing> rings = new ArrayList<>();
for (final LinearRing ring : polygon.rings()) {
final LinearRing newRing = densify(ring, distanceTolerance);
rings.add(newRing);
}
final Polygon newPolygon = geometryFactory.polygon(rings);
return (Polygon) newPolygon.buffer(0);
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class ConnectedInteriorTester method visitShellInteriors.
/**
* Mark all the edges for the edgeRings corresponding to the shells
* of the input polygons.
* Only ONE ring gets marked for each shell - if there are others which remain unmarked
* this indicates a disconnected interior.
*/
private void visitShellInteriors(final Geometry g, final PlanarGraph graph) {
if (g instanceof Polygon) {
final Polygon p = (Polygon) g;
visitInteriorRing(p.getShell(), graph);
} else if (g instanceof Polygonal) {
final Polygonal polygonal = (Polygonal) g;
for (final Polygon polygon : polygonal.polygons()) {
visitInteriorRing(polygon.getShell(), graph);
}
}
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class OsmPbfRecordIterator method isPolygon.
public boolean isPolygon(final OsmWay way, final Geometry geometry) {
if (geometry instanceof LineString) {
final LineString line = (LineString) geometry;
if (line.isClosed()) {
boolean isPolygon = true;
if (!"yes".equals(way.getTag("area"))) {
if (way.containsKey("barrier")) {
isPolygon = false;
} else if (way.containsKey("highway")) {
isPolygon = false;
}
}
if (isPolygon) {
final Polygon polygon = line.getGeometryFactory().polygon(line);
way.setGeometryValue(polygon);
}
return isPolygon;
}
}
return false;
}
Aggregations