Search in sources :

Example 71 with LinearRing

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

Example 72 with LinearRing

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

Example 73 with LinearRing

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

Example 74 with LinearRing

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

Example 75 with LinearRing

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());
        }
    }
}
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)

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