Search in sources :

Example 76 with LinearRing

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

the class EWktWriter method write.

private static void write(final Writer out, final Geometry geometry, final int axisCount) throws IOException {
    if (geometry != null) {
        if (geometry instanceof Point) {
            final Point point = (Point) geometry;
            write(out, point, axisCount);
        } else if (geometry instanceof Punctual) {
            final Punctual punctual = (Punctual) geometry;
            write(out, punctual, axisCount);
        } else if (geometry instanceof LinearRing) {
            final LinearRing line = (LinearRing) geometry;
            write(out, line, axisCount);
        } else if (geometry instanceof LineString) {
            final LineString line = (LineString) geometry;
            write(out, line, axisCount);
        } else if (geometry instanceof Lineal) {
            final Lineal lineal = (Lineal) geometry;
            write(out, lineal, axisCount);
        } else if (geometry instanceof Polygon) {
            final Polygon polygon = (Polygon) geometry;
            write(out, polygon, axisCount);
        } else if (geometry instanceof Polygonal) {
            final Polygonal polygonal = (Polygonal) geometry;
            write(out, polygonal, axisCount);
        } else if (geometry.isGeometryCollection()) {
            writeGeometryCollection(out, geometry, axisCount);
        } 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)

Example 77 with LinearRing

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

the class WktWriter method writePolygon.

private static void writePolygon(final Writer out, final Polygon polygon, final int axisCount) throws IOException {
    out.write('(');
    LinearRing shell = polygon.getShell();
    shell = shell.toCounterClockwise();
    final LineString coordinates = shell;
    writeCoordinates(out, coordinates, axisCount);
    for (int i = 0; i < polygon.getHoleCount(); i++) {
        out.write(',');
        LinearRing hole = polygon.getHole(i);
        hole = hole.toClockwise();
        writeCoordinates(out, hole, axisCount);
    }
    out.write(')');
}
Also used : LineString(com.revolsys.geometry.model.LineString) LinearRing(com.revolsys.geometry.model.LinearRing) Point(com.revolsys.geometry.model.Point)

Example 78 with LinearRing

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

the class WktWriter 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)

Example 79 with LinearRing

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

the class WktWriter method write.

public static void write(final Writer out, final Geometry geometry, final int axisCount) {
    try {
        if (geometry != null) {
            if (geometry instanceof Point) {
                final Point point = (Point) geometry;
                write(out, point, axisCount);
            } else if (geometry instanceof Punctual) {
                final Punctual punctual = (Punctual) geometry;
                write(out, punctual, axisCount);
            } else if (geometry instanceof LinearRing) {
                final LinearRing line = (LinearRing) geometry;
                write(out, line, axisCount);
            } else if (geometry instanceof LineString) {
                final LineString line = (LineString) geometry;
                write(out, line, axisCount);
            } else if (geometry instanceof Lineal) {
                final Lineal lineal = (Lineal) geometry;
                write(out, lineal, axisCount);
            } else if (geometry instanceof Polygon) {
                final Polygon polygon = (Polygon) geometry;
                write(out, polygon, axisCount);
            } else if (geometry instanceof Polygonal) {
                final Polygonal polygonal = (Polygonal) geometry;
                write(out, polygonal, axisCount);
            } else if (geometry.isGeometryCollection()) {
                writeGeometryCollection(out, geometry, axisCount);
            } else {
                throw new IllegalArgumentException("Unknown geometry type" + geometry.getClass());
            }
        }
    } catch (final IOException e) {
        throw Exceptions.wrap(e);
    }
}
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) IOException(java.io.IOException) LinearRing(com.revolsys.geometry.model.LinearRing) Polygon(com.revolsys.geometry.model.Polygon)

Example 80 with LinearRing

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

the class WKTReader method readPolygonText.

/**
 *  Creates a <code>Polygon</code> using the next token in the stream.
 *
 *@param  tokenizer        tokenizer over a stream of text in Well-known Text
 *      format. The next tokens must form a &lt;Polygon Text&gt;.
 *@return                  a <code>Polygon</code> specified by the next token
 *      in the stream
 *@throws  ParseException  if the coordinates used to create the <code>Polygon</code>
 *      shell and holes do not form closed linestrings, or if an unexpected
 *      token was encountered.
 *@throws  IOException     if an I/O error occurs
 */
private Polygon readPolygonText() throws IOException, ParseException {
    String nextToken = getNextEmptyOrOpener();
    if (nextToken.equals(EMPTY)) {
        return this.geometryFactory.polygon();
    }
    final List<LinearRing> rings = new ArrayList<>();
    final LinearRing shell = readLinearRingText();
    rings.add(shell);
    nextToken = getNextCloserOrComma();
    while (nextToken.equals(COMMA)) {
        final LinearRing hole = readLinearRingText();
        rings.add(hole);
        nextToken = getNextCloserOrComma();
    }
    return this.geometryFactory.polygon(rings);
}
Also used : ArrayList(java.util.ArrayList) LineString(com.revolsys.geometry.model.LineString) 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