use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PostgreSQLGeometryWrapper method writeGeometry.
private static void writeGeometry(final PrintWriter out, final Geometry geometry, final int axisCount) {
if (geometry != null) {
if (geometry instanceof Point) {
final Point point = (Point) geometry;
writePoint(out, point, axisCount);
} else if (geometry instanceof Punctual) {
final Punctual punctual = (Punctual) geometry;
writeMultiPoint(out, punctual, axisCount);
} else if (geometry instanceof LinearRing) {
final LinearRing line = (LinearRing) geometry;
writeLinearRing(out, line, axisCount);
} else if (geometry instanceof LineString) {
final LineString line = (LineString) geometry;
writeLineString(out, line, axisCount);
} else if (geometry instanceof Lineal) {
final Lineal lineal = (Lineal) geometry;
writeMultiLineString(out, lineal, axisCount);
} else if (geometry instanceof Polygon) {
final Polygon polygon = (Polygon) geometry;
writePolygon(out, polygon, axisCount);
} else if (geometry instanceof Polygonal) {
final Polygonal polygonal = (Polygonal) geometry;
writeMultiPolygon(out, polygonal, axisCount);
} else if (geometry.isGeometryCollection()) {
writeGeometryCollection(out, geometry, axisCount);
} else {
throw new IllegalArgumentException("Unknown geometry type" + geometry.getClass());
}
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PostgreSQLGeometryWrapper method writeLinearRing.
private static void writeLinearRing(final PrintWriter out, final Geometry geometry, final int axisCount) {
final LinearRing line = getGeometry(geometry, LinearRing.class);
writeLinearRing(out, line, axisCount);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class GeoPackageGeometryJdbcFieldDefinition method parsePolygon.
private Polygon parsePolygon(final GeometryFactory geometryFactory, final ByteBuffer data, final boolean hasZ, final boolean hasM) {
final int count = data.getInt();
final LinearRing[] rings = new LinearRing[count];
for (int i = 0; i < count; ++i) {
rings[i] = parseLinearRing(geometryFactory, data, hasZ, hasM);
}
return geometryFactory.polygon(rings);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class OracleSdoGeometryJdbcFieldDefinition method toSdoAddPolygon.
private int toSdoAddPolygon(int offset, final int[] elemInfo, int elemIndex, final int axisCount, final double[] coordinates, final Polygon polygon) {
final LinearRing shell = polygon.getShell();
offset = toSodAddPolygonRing(offset, elemInfo, elemIndex, 1003, axisCount, coordinates, ClockDirection.COUNTER_CLOCKWISE, shell);
for (final LinearRing hole : polygon.holes()) {
elemIndex += 3;
offset = toSodAddPolygonRing(offset, elemInfo, elemIndex, 2003, axisCount, coordinates, ClockDirection.CLOCKWISE, hole);
}
return offset;
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class OracleSdoGeometryJdbcFieldDefinition method toPolygonal.
private Polygonal toPolygonal(final ResultSet resultSet, final int columnIndex, final int axisCount) throws SQLException {
final List<Polygon> polygons = new ArrayList<>();
final BigDecimal[] elemInfo = JdbcUtils.getBigDecimalArray(resultSet, columnIndex + 4);
final BigDecimal[] coordinatesArray = JdbcUtils.getBigDecimalArray(resultSet, columnIndex + 5);
List<LinearRing> rings = Collections.emptyList();
for (int elemInfoOffset = 0; elemInfoOffset < elemInfo.length; ) {
final int offset = elemInfo[elemInfoOffset].intValue();
final int type = (int) elemInfo[elemInfoOffset + 1].longValue();
final long interpretation = elemInfo[elemInfoOffset + 2].longValue();
switch(type) {
case 1003:
if (!rings.isEmpty()) {
final Polygon polygon = this.geometryFactory.polygon(rings);
polygons.add(polygon);
}
rings = new ArrayList<>();
elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
break;
case 1005:
if (!rings.isEmpty()) {
final Polygon polygon = this.geometryFactory.polygon(rings);
polygons.add(polygon);
}
rings = new ArrayList<>();
elemInfoOffset = addRingComplex(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
break;
case 2003:
elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
break;
case 2005:
elemInfoOffset = addRingComplex(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
break;
default:
throw new IllegalArgumentException("Unsupported geometry type " + type);
}
}
if (!rings.isEmpty()) {
final Polygon polygon = this.geometryFactory.polygon(rings);
polygons.add(polygon);
}
if (polygons.size() == 1) {
return polygons.get(0);
} else {
return this.geometryFactory.polygonal(polygons);
}
}
Aggregations