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());
}
}
}
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(')');
}
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());
}
}
}
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);
}
}
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 <Polygon Text>.
*@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);
}
Aggregations