Search in sources :

Example 11 with Polygonal

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

the class GeoJsonRecordWriter method geometry.

private void geometry(final Geometry geometry) {
    this.out.startObject();
    if (geometry instanceof Point) {
        final Point point = (Point) geometry;
        point(point);
    } else if (geometry instanceof LineString) {
        final LineString line = (LineString) geometry;
        line(line);
    } else if (geometry instanceof Polygon) {
        final Polygon polygon = (Polygon) geometry;
        polygon(polygon);
    } else if (geometry instanceof Punctual) {
        final Punctual punctual = (Punctual) geometry;
        multiPoint(punctual);
    } else if (geometry instanceof Lineal) {
        final Lineal lineal = (Lineal) geometry;
        multiLineString(lineal);
    } else if (geometry instanceof Polygonal) {
        final Polygonal polygonal = (Polygonal) geometry;
        multiPolygon(polygonal);
    } else if (geometry.isGeometryCollection()) {
        geometryCollection(geometry);
    }
    this.out.endObject();
}
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) Polygon(com.revolsys.geometry.model.Polygon)

Example 12 with Polygonal

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

the class MultiPolygonEditorTest method testSetM.

@Test
public void testSetM() {
    final PolygonalEditor editor = POLYGONAL.newGeometryEditor(4);
    editor.setM(1, 1, 1, 10);
    final Polygonal newGeometry = editor.newGeometry();
    Assert.assertNotSame(POLYGONAL, newGeometry);
    Assert.assertEquals(10.0, newGeometry.getM(1, 1, 1), 0.0);
}
Also used : PolygonalEditor(com.revolsys.geometry.model.editor.PolygonalEditor) Polygonal(com.revolsys.geometry.model.Polygonal) Test(org.junit.Test)

Example 13 with Polygonal

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

the class MultiPolygonEditorTest method testSetCoordinates.

@Test
public void testSetCoordinates() {
    for (int i = 0; i < 4; i++) {
        final PolygonalEditor editor = POLYGONAL.newGeometryEditor(4);
        final double newValue = POLYGONAL.getCoordinate(1, 1, 1, i);
        editor.setCoordinate(1, 1, 1, i, newValue);
        final Polygonal newGeometry = editor.newGeometry();
        Assert.assertNotSame(POLYGONAL, newGeometry);
        Assert.assertEquals(newValue, newGeometry.getCoordinate(1, 1, 1, i), 0.0);
    }
}
Also used : PolygonalEditor(com.revolsys.geometry.model.editor.PolygonalEditor) Polygonal(com.revolsys.geometry.model.Polygonal) Test(org.junit.Test)

Example 14 with Polygonal

use of com.revolsys.geometry.model.Polygonal 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 15 with Polygonal

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

the class MultiPolygonSegment method hasNext.

@Override
public boolean hasNext() {
    final Polygonal polygonal = this.polygonal;
    if (polygonal.isEmpty()) {
        return false;
    } else {
        int partIndex = this.partIndex;
        int ringIndex = this.ringIndex;
        int segmentIndex = this.segmentIndex + 1;
        while (partIndex < polygonal.getGeometryCount()) {
            final Polygon polygon = getPolygon();
            while (ringIndex < polygon.getRingCount()) {
                final LinearRing ring = polygon.getRing(ringIndex);
                if (segmentIndex < ring.getSegmentCount()) {
                    return true;
                } else {
                    ringIndex++;
                    segmentIndex = 0;
                }
            }
            partIndex++;
            ringIndex = 0;
            segmentIndex = 0;
        }
        return false;
    }
}
Also used : Polygonal(com.revolsys.geometry.model.Polygonal) Polygon(com.revolsys.geometry.model.Polygon) LinearRing(com.revolsys.geometry.model.LinearRing)

Aggregations

Polygonal (com.revolsys.geometry.model.Polygonal)41 Polygon (com.revolsys.geometry.model.Polygon)17 LinearRing (com.revolsys.geometry.model.LinearRing)12 Point (com.revolsys.geometry.model.Point)12 LineString (com.revolsys.geometry.model.LineString)9 Lineal (com.revolsys.geometry.model.Lineal)9 Punctual (com.revolsys.geometry.model.Punctual)9 Geometry (com.revolsys.geometry.model.Geometry)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 PolygonalEditor (com.revolsys.geometry.model.editor.PolygonalEditor)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 PathName (com.revolsys.io.PathName)2 Record (com.revolsys.record.Record)2 NoSuchElementException (java.util.NoSuchElementException)2 LocateFailureException (com.revolsys.elevation.tin.quadedge.LocateFailureException)1 QuadEdgeConformingDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeConformingDelaunayTinBuilder)1 IndexedPointInAreaLocator (com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator)1