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);
}
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);
}
}
}
}
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);
}
}
}
}
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(')');
}
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());
}
Aggregations