Search in sources :

Example 56 with Polygon

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

the class KmlXmlWriter method writeGeometry.

public void writeGeometry(final Geometry geometry, final int axisCount) {
    if (geometry != null) {
        final int numGeometries = geometry.getGeometryCount();
        if (numGeometries > 1) {
            startTag(Kml22Constants.MULTI_GEOMETRY);
            for (int i = 0; i < numGeometries; i++) {
                writeGeometry(geometry.getGeometry(i), axisCount);
            }
            endTag();
        } else {
            final Geometry geoGraphicsGeom = geometry.convertGeometry(GeometryFactory.floating(Kml22Constants.COORDINATE_SYSTEM_ID, axisCount));
            if (geoGraphicsGeom instanceof Point) {
                final Point point = (Point) geoGraphicsGeom;
                writePoint(point);
            } else if (geoGraphicsGeom instanceof LinearRing) {
                final LinearRing line = (LinearRing) geoGraphicsGeom;
                writeLinearRing(line);
            } else if (geoGraphicsGeom instanceof LineString) {
                final LineString line = (LineString) geoGraphicsGeom;
                writeLineString(line);
            } else if (geoGraphicsGeom instanceof Polygon) {
                final Polygon polygon = (Polygon) geoGraphicsGeom;
                writePolygon(polygon);
            } else if (geoGraphicsGeom.isGeometryCollection()) {
                writeMultiGeometry(geoGraphicsGeom, axisCount);
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point)

Example 57 with Polygon

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

the class WktWriter method write.

private static void write(final Writer out, final Polygonal polygonal, final int axisCount) throws IOException {
    writeGeometryType(out, "MULTIPOLYGON", axisCount);
    if (polygonal.isEmpty()) {
        out.write(" EMPTY");
    } else {
        out.write("(");
        Polygon polygon = (Polygon) polygonal.getGeometry(0);
        writePolygon(out, polygon, axisCount);
        for (int i = 1; i < polygonal.getGeometryCount(); i++) {
            out.write(",");
            polygon = (Polygon) polygonal.getGeometry(i);
            writePolygon(out, polygon, axisCount);
        }
        out.write(")");
    }
}
Also used : Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point)

Example 58 with Polygon

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

the class PolygonEditorTest method testSetZ.

@Test
public void testSetZ() {
    final Polygon polygon = POLYGON;
    final PolygonEditor polygonEditor = polygon.newGeometryEditor(3);
    polygonEditor.setZ(1, 1, 10);
    final Polygon newPolygon = polygonEditor.newGeometry();
    Assert.assertNotSame(polygon, newPolygon);
    Assert.assertEquals(10.0, newPolygon.getZ(1, 1), 0.0);
}
Also used : PolygonEditor(com.revolsys.geometry.model.editor.PolygonEditor) Polygon(com.revolsys.geometry.model.Polygon) Test(org.junit.Test)

Example 59 with Polygon

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

the class PolygonEditorTest method testSetM.

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

Example 60 with Polygon

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

the class PolygonEditorTest method testSetY.

@Test
public void testSetY() {
    final Polygon polygon = POLYGON;
    final PolygonEditor polygonEditor = polygon.newGeometryEditor(3);
    polygonEditor.setY(1, 1, 10);
    final Polygon newPolygon = polygonEditor.newGeometry();
    Assert.assertNotSame(polygon, newPolygon);
    Assert.assertEquals(10.0, newPolygon.getY(1, 1), 0.0);
}
Also used : PolygonEditor(com.revolsys.geometry.model.editor.PolygonEditor) Polygon(com.revolsys.geometry.model.Polygon) Test(org.junit.Test)

Aggregations

Polygon (com.revolsys.geometry.model.Polygon)147 Point (com.revolsys.geometry.model.Point)66 LinearRing (com.revolsys.geometry.model.LinearRing)54 LineString (com.revolsys.geometry.model.LineString)39 Geometry (com.revolsys.geometry.model.Geometry)34 ArrayList (java.util.ArrayList)30 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)22 Polygonal (com.revolsys.geometry.model.Polygonal)17 BoundingBox (com.revolsys.geometry.model.BoundingBox)14 Punctual (com.revolsys.geometry.model.Punctual)12 Test (org.junit.Test)12 Lineal (com.revolsys.geometry.model.Lineal)11 BaseCloseable (com.revolsys.io.BaseCloseable)7 List (java.util.List)7 PolygonEditor (com.revolsys.geometry.model.editor.PolygonEditor)6 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)6 Vertex (com.revolsys.geometry.model.vertex.Vertex)6 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)3 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)3 Graphics2D (java.awt.Graphics2D)3