Search in sources :

Example 36 with LinearRing

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

the class GmlGeometryFieldType method polygon.

private void polygon(final XmlWriter out, final Polygon polygon, final boolean writeSrsName) {
    out.startTag(Gml.POLYGON);
    srsName(out, polygon, writeSrsName);
    if (!polygon.isEmpty()) {
        final LinearRing shell = polygon.getShell();
        out.startTag(Gml.OUTER_BOUNDARY_IS);
        linearRing(out, shell.toCounterClockwise(), false);
        out.endTag(Gml.OUTER_BOUNDARY_IS);
        for (final LinearRing hole : polygon.holes()) {
            out.startTag(Gml.INNER_BOUNDARY_IS);
            linearRing(out, hole.toClockwise(), false);
            out.endTag(Gml.INNER_BOUNDARY_IS);
        }
    }
    out.endTag(Gml.POLYGON);
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing)

Example 37 with LinearRing

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

the class KmlWriterUtil method writeGeometry.

// Assumes geometry is wgs84
public static void writeGeometry(final Writer out, final Geometry geometry, final int axisCount) throws IOException {
    if (geometry != null) {
        final int numGeometries = geometry.getGeometryCount();
        if (numGeometries > 1) {
            out.write("<MultiGeometry>\n");
            for (int i = 0; i < numGeometries; i++) {
                writeGeometry(out, geometry.getGeometry(i), axisCount);
            }
            out.write("</MultiGeometry>\n");
        } else {
            if (geometry instanceof Point) {
                final Point point = (Point) geometry;
                writePoint(out, point);
            } else if (geometry instanceof LinearRing) {
                final LinearRing line = (LinearRing) geometry;
                writeLinearRing(out, line);
            } else if (geometry instanceof LineString) {
                final LineString line = (LineString) geometry;
                writeLineString(out, line);
            } else if (geometry instanceof Polygon) {
                final Polygon polygon = (Polygon) geometry;
                writePolygon(out, polygon);
            } else if (geometry.isGeometryCollection()) {
                writeMultiGeometry(out, geometry, axisCount);
            }
        }
    }
}
Also used : 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 38 with LinearRing

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

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

the class EWktWriter method writePolygon.

private static void writePolygon(final Writer out, final Polygon polygon, final int axisCount) throws IOException {
    out.write('(');
    final LinearRing shell = polygon.getShell().toCounterClockwise();
    writeCoordinates(out, shell, axisCount);
    for (final LinearRing hole : polygon.holes()) {
        out.write(',');
        final LinearRing clockwiseHole = hole.toClockwise();
        writeCoordinates(out, clockwiseHole, axisCount);
    }
    out.write(')');
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing)

Example 40 with LinearRing

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

the class MiscellaneousTest method testLinearRingIsSimple.

/**
 * @todo Enable when #isSimple implemented
 */
// public void testLineStringIsSimple2() throws Exception {
// Geometry g = reader.read("LINESTRING(10 10, 20 10, 15 20, 15 0)");
// assertTrue(! g.isSimple());
// }
public void testLinearRingIsSimple() throws Exception {
    final LinearRing linearRing = this.geometryFactory.linearRing(2, 10.0, 10, 10, 20, 20, 20, 20, 15, 10, 10);
    assertTrue(linearRing.isSimple());
}
Also used : LinearRing(com.revolsys.geometry.model.LinearRing)

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