Search in sources :

Example 41 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class ValidClosedRingTest method testGoodLinearRing.

public void testGoodLinearRing() {
    final LinearRing ring = (LinearRing) fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)");
    checkIsValid(ring, true);
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing)

Example 42 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class GeometryFactoryTest method assertCreateGeometryCollection.

public static void assertCreateGeometryCollection(final Geometry geometry, final LineString... pointsList) {
    if (geometry.isGeometryCollection()) {
        if (geometry.getGeometryCount() == 1) {
            final Geometry part = geometry.getGeometry(0);
            final Class<? extends Geometry> geometryClass = geometry.getClass();
            final Geometry copy2 = GEOMETRY_FACTORY.geometry(geometryClass, part);
            Assert.assertEquals("Geometry class", geometryClass, copy2.getClass());
            Assert.assertEquals("Geometry", geometry, copy2);
        // assertCoordinatesListEqual(copy2, pointsList);
        }
    } else if (!(geometry instanceof LinearRing)) {
        final Geometry[] geometries = { geometry };
        final Geometry collection = GEOMETRY_FACTORY.geometry(geometries);
        final Geometry copy = collection.getGeometry(0);
        final Class<? extends Geometry> geometryClass = geometry.getClass();
        Assert.assertEquals("Geometry class", geometryClass, copy.getClass());
        Assert.assertEquals("Geometry", geometry, copy);
        // assertCoordinatesListEqual(collection, pointsList);
        final Geometry copy2 = GEOMETRY_FACTORY.geometry(geometryClass, collection);
        Assert.assertEquals("Geometry class", geometryClass, copy2.getClass());
        Assert.assertEquals("Geometry", geometry, copy2);
    // assertCoordinatesListEqual(copy2, pointsList);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 43 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class GeometryFactoryTest method testCreateGeometry.

private static void testCreateGeometry() {
    final LineString pointPoints = new LineStringDouble(2, 0.0, 0);
    final LineString point2Points = new LineStringDouble(2, 20.0, 20);
    final LineString ringPoints = new LineStringDouble(2, 0.0, 0, 0, 100, 100, 100, 100, 0, 0, 0);
    final LineString ring2Points = new LineStringDouble(2, 20.0, 20, 20, 80, 80, 80, 80, 20, 20, 20);
    final LineString ring3Points = new LineStringDouble(2, 120.0, 120, 120, 180, 180, 180, 180, 120, 120, 120);
    final Point point = GEOMETRY_FACTORY.point(2, 0.0, 0);
    assertCopyGeometry(point, pointPoints);
    final LineString line = GEOMETRY_FACTORY.lineString(ringPoints);
    assertCopyGeometry(line, ringPoints);
    final LinearRing linearRing = GEOMETRY_FACTORY.linearRing(ringPoints);
    assertCopyGeometry(linearRing, ringPoints);
    final Polygon polygon = GEOMETRY_FACTORY.polygon(ringPoints);
    assertCopyGeometry(polygon, ringPoints);
    final Polygon polygon2 = GEOMETRY_FACTORY.polygon(ringPoints, ring2Points);
    assertCopyGeometry(polygon2, ringPoints, ring2Points);
    final Punctual multiPoint = GEOMETRY_FACTORY.punctual(pointPoints);
    assertCopyGeometry(multiPoint, pointPoints);
    final Punctual multiPoint2 = GEOMETRY_FACTORY.punctual(pointPoints, point2Points);
    assertCopyGeometry(multiPoint2, pointPoints, point2Points);
    final Lineal multiLineString = GEOMETRY_FACTORY.lineal(ringPoints);
    assertCopyGeometry(multiLineString, ringPoints);
    final Lineal multiLineString2 = GEOMETRY_FACTORY.lineal(ringPoints, ring2Points);
    assertCopyGeometry(multiLineString2, ringPoints, ring2Points);
    final Polygonal multiPolygon = GEOMETRY_FACTORY.polygonal(ringPoints);
    assertCopyGeometry(multiPolygon, ringPoints);
    final Polygonal multiPolygon2 = GEOMETRY_FACTORY.polygonal(ringPoints, ring3Points);
    assertCopyGeometry(multiPolygon2, ringPoints, ring3Points);
}
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) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Example 44 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class PostgreSQLGeometryWrapper method parsePolygon.

private Polygon parsePolygon(final GeometryFactory geometryFactory, final ValueGetter 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 45 with LinearRing

use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.

the class OracleSdoGeometryJdbcFieldDefinition method addRingComplex.

private int addRingComplex(final List<LinearRing> rings, final int axisCount, final BigDecimal[] elemInfo, final int type, final BigDecimal[] coordinatesArray, int elemInfoOffset, final int offset, final long interpretation) {
    if (interpretation > 0) {
        int length = 0;
        for (int part = 0; part < interpretation; part++) {
            elemInfoOffset += 3;
            if (elemInfoOffset + 3 < elemInfo.length) {
                final long nextOffset = elemInfo[elemInfoOffset + 3].longValue();
                length = (int) (nextOffset - offset);
            } else {
                final int coordinateCount = coordinatesArray.length;
                length = coordinateCount + 1 - offset;
            }
        }
        final double[] coordinates = Numbers.toDoubleArray(coordinatesArray, offset - 1, length);
        final LinearRing ring = this.geometryFactory.linearRing(axisCount, coordinates);
        rings.add(ring);
    } else {
        throw new IllegalArgumentException("Unsupported geometry type " + type + " interpretation " + interpretation);
    }
    return elemInfoOffset + 3;
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing) 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