use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PolygonEditor method getCurrentGeometry.
@Override
public Geometry getCurrentGeometry() {
final GeometryFactory geometryFactory = getGeometryFactory();
if (isEmpty()) {
return geometryFactory.polygon();
}
final List<LinearRing> rings = new ArrayList<>();
final List<Geometry> geometries = new ArrayList<>();
boolean shell = true;
for (final LinearRingEditor editor : this.editors) {
final Geometry ringGeometry = editor.getCurrentGeometry();
if (ringGeometry instanceof LinearRing) {
final LinearRing ring = (LinearRing) ringGeometry;
if (shell || !rings.isEmpty()) {
rings.add(ring);
} else {
geometries.add(ringGeometry);
}
} else {
geometries.add(ringGeometry);
}
shell = false;
}
if (!rings.isEmpty()) {
final Polygon polygon = geometryFactory.polygon(rings);
if (geometries.isEmpty()) {
return polygon;
} else {
geometries.add(polygon);
}
}
return geometryFactory.geometry(geometries);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class MultiPolygonVertex method next.
@Override
public Vertex next() {
final Polygonal polygonal = getPolygonal();
this.vertexIndex++;
while (this.partIndex < polygonal.getGeometryCount()) {
final Polygon polygon = polygonal.getPolygon(this.partIndex);
while (this.ringIndex < polygon.getRingCount()) {
final LinearRing ring = polygon.getRing(this.ringIndex);
if (this.vertexIndex < ring.getVertexCount()) {
return this;
} else {
this.ringIndex++;
this.vertexIndex = 0;
}
}
this.partIndex++;
this.ringIndex = 0;
this.vertexIndex = 0;
}
throw new NoSuchElementException();
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class MultiPolygonVertex 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);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class MultiPolygonVertex method getX.
@Override
public double getX() {
final Polygon polygon = getPolygon();
final LinearRing ring = polygon.getRing(this.ringIndex);
if (ring == null) {
return java.lang.Double.NaN;
} else {
return ring.getX(this.vertexIndex);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PolygonVertex method hasNext.
@Override
public boolean hasNext() {
if (getGeometry().isEmpty()) {
return false;
} else {
final Polygon polygon = getPolygon();
int ringIndex = this.ringIndex;
int vertexIndex = this.vertexIndex;
while (ringIndex < polygon.getRingCount()) {
final LinearRing ring = polygon.getRing(ringIndex);
if (vertexIndex + 1 < ring.getVertexCount()) {
return true;
} else {
ringIndex++;
vertexIndex = 0;
}
}
return false;
}
}
Aggregations