Search in sources :

Example 81 with LinearRing

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());
        }
    }
}
Also used : Punctual(com.revolsys.geometry.model.Punctual) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Polygonal(com.revolsys.geometry.model.Polygonal) Point(com.revolsys.geometry.model.Point) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon)

Example 82 with LinearRing

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);
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing)

Example 83 with LinearRing

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);
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing) Point(com.revolsys.geometry.model.Point)

Example 84 with LinearRing

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;
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing)

Example 85 with LinearRing

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);
    }
}
Also used : ArrayList(java.util.ArrayList) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing) BigDecimal(java.math.BigDecimal) Point(com.revolsys.geometry.model.Point)

Aggregations

LinearRing (com.revolsys.geometry.model.LinearRing)95 Polygon (com.revolsys.geometry.model.Polygon)53 Point (com.revolsys.geometry.model.Point)44 ArrayList (java.util.ArrayList)21 LineString (com.revolsys.geometry.model.LineString)19 Geometry (com.revolsys.geometry.model.Geometry)14 Polygonal (com.revolsys.geometry.model.Polygonal)11 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)9 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 Lineal (com.revolsys.geometry.model.Lineal)7 Punctual (com.revolsys.geometry.model.Punctual)6 List (java.util.List)4 NoSuchElementException (java.util.NoSuchElementException)4 IOException (java.io.IOException)3 MCPointInRing (com.revolsys.geometry.algorithm.MCPointInRing)2 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 Vertex (com.revolsys.geometry.model.vertex.Vertex)2 BigDecimal (java.math.BigDecimal)2 PointInRing (com.revolsys.geometry.algorithm.PointInRing)1 EdgeRing (com.revolsys.geometry.geomgraph.EdgeRing)1