use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class MultiPolygonVertex method getY.
@Override
public double getY() {
final Polygon polygon = getPolygon();
final LinearRing ring = polygon.getRing(this.ringIndex);
if (ring == null) {
return java.lang.Double.NaN;
} else {
return ring.getY(this.vertexIndex);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PolygonVertex method getLineCoordinateRelative.
@Override
public double getLineCoordinateRelative(final int vertexOffset, final int axisIndex) {
if (isEmpty()) {
return java.lang.Double.NaN;
} else {
final int vertexIndex = getVertexIndex();
final LinearRing line = getRing();
return line.getCoordinate(vertexIndex + vertexOffset, axisIndex);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class OgrQueryIterator method toGeometry.
protected Geometry toGeometry(final org.gdal.ogr.Geometry ogrGeometry) {
if (ogrGeometry == null) {
return null;
} else {
final int geometryType = ogrGeometry.GetGeometryType();
final int axisCount = ogrGeometry.GetCoordinateDimension();
switch(geometryType) {
case 1:
case 0x80000000 + 1:
final double[] pointCoordinates = getCoordinates(ogrGeometry, axisCount);
return this.geometryFactory.point(pointCoordinates);
case 2:
case 0x80000000 + 2:
final double[] lineCoordinates = getCoordinates(ogrGeometry, axisCount);
return this.geometryFactory.lineString(axisCount, lineCoordinates);
case 3:
case 0x80000000 + 3:
final List<LineString> rings = new ArrayList<>();
for (int partIndex = 0; partIndex < ogrGeometry.GetGeometryCount(); partIndex++) {
final org.gdal.ogr.Geometry ogrRing = ogrGeometry.GetGeometryRef(partIndex);
final double[] ringCoordinates = getCoordinates(ogrRing, axisCount);
final LinearRing ring = this.geometryFactory.linearRing(axisCount, ringCoordinates);
rings.add(ring);
}
return this.geometryFactory.polygon(rings);
case 4:
case 0x80000000 + 4:
case 5:
case 0x80000000 + 5:
case 6:
case 0x80000000 + 6:
case 7:
case 0x80000000 + 7:
final List<Geometry> parts = new ArrayList<>();
for (int partIndex = 0; partIndex < ogrGeometry.GetGeometryCount(); partIndex++) {
final org.gdal.ogr.Geometry ogrPart = ogrGeometry.GetGeometryRef(partIndex);
final Geometry part = toGeometry(ogrPart);
parts.add(part);
}
return this.geometryFactory.geometry(parts);
case 101:
final double[] ringCoordinates = getCoordinates(ogrGeometry, axisCount);
return this.geometryFactory.linearRing(axisCount, ringCoordinates);
default:
return null;
}
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class ShapefileGeometryUtil method newPolygonGeometryFromParts.
public Geometry newPolygonGeometryFromParts(final GeometryFactory geometryFactory, final List<double[]> parts, final int axisCount) {
final List<Polygon> polygons = new ArrayList<>();
final List<LinearRing> currentParts = new ArrayList<>();
for (final double[] coordinates : parts) {
final LinearRing ring = geometryFactory.linearRing(axisCount, coordinates);
final boolean ringClockwise = ring.isClockwise();
if (ringClockwise) {
if (!currentParts.isEmpty()) {
final Polygon polygon = geometryFactory.polygon(currentParts);
polygons.add(polygon);
currentParts.clear();
}
}
currentParts.add(ring);
}
if (!currentParts.isEmpty()) {
final Polygon polygon = geometryFactory.polygon(currentParts);
polygons.add(polygon);
}
if (polygons.size() == 1) {
return polygons.get(0);
} else {
return geometryFactory.polygonal(polygons);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class EWktWriter method write.
public static void write(final Writer out, final Geometry geometry) {
if (geometry != null) {
if (geometry instanceof Point) {
final Point point = (Point) geometry;
write(out, point);
} else if (geometry instanceof Punctual) {
final Punctual punctual = (Punctual) geometry;
write(out, punctual);
} else if (geometry instanceof LinearRing) {
final LinearRing line = (LinearRing) geometry;
write(out, line);
} else if (geometry instanceof LineString) {
final LineString line = (LineString) geometry;
write(out, line);
} else if (geometry instanceof Lineal) {
final Lineal lineal = (Lineal) geometry;
write(out, lineal);
} else if (geometry instanceof Polygon) {
final Polygon polygon = (Polygon) geometry;
write(out, polygon);
} else if (geometry instanceof Polygonal) {
final Polygonal polygonal = (Polygonal) geometry;
write(out, polygonal);
} else if (geometry.isGeometryCollection()) {
writeGeometryCollection(out, geometry);
} else {
throw new IllegalArgumentException("Unknown geometry type" + geometry.getClass());
}
}
}
Aggregations