use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class GmlGeometryReader method readMultiPolygon.
private Polygonal readMultiPolygon(final GeometryFactory geometryFactory) throws XMLStreamException {
int axisCount = 2;
final GeometryFactory factory = getGeometryFactory(geometryFactory);
final List<Polygon> polygons = new ArrayList<>();
final int depth = this.in.getDepth();
while (this.in.skipToStartElements(depth, Gml.POLYGON)) {
final Polygon polygon = readPolygon(factory);
if (polygon != null) {
axisCount = Math.max(axisCount, polygon.getAxisCount());
polygons.add(polygon);
}
}
return factory.convertAxisCount(axisCount).polygonal(polygons);
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class GmlGeometryReader method readPolygon.
private Polygon readPolygon(final GeometryFactory geometryFactory) throws XMLStreamException {
int axisCount = 2;
final GeometryFactory factory = getGeometryFactory(geometryFactory);
final List<LinearRing> rings = new ArrayList<>();
final int depth = this.in.getDepth();
while (this.in.skipToStartElements(depth, Gml.OUTER_BOUNDARY_IS, Gml.INNER_BOUNDARY_IS)) {
final LinearRing ring = readLinearRing(factory);
if (ring != null) {
axisCount = Math.max(axisCount, ring.getAxisCount());
rings.add(ring);
}
}
final Polygon polygon = factory.convertAxisCount(axisCount).polygon(rings);
return polygon;
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class XmlGeometryFieldType method writeValueText.
@Override
protected void writeValueText(final XmlWriter out, final Object value) {
if (value instanceof Point) {
final Point point = (Point) value;
writePoint(out, point);
} else if (value instanceof LineString) {
final LineString line = (LineString) value;
writeLineString(out, line);
} else if (value instanceof Polygon) {
final Polygon polygon = (Polygon) value;
writePolygon(out, polygon);
} else if (value instanceof Lineal) {
final Lineal multiLine = (Lineal) value;
writeMultiLineString(out, multiLine);
}
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class ArcGisRestServerFeatureIterator method parseMultiPolygon.
public static Geometry parseMultiPolygon(final GeometryFactory geometryFactory, final MapEx properties) {
final List<Polygon> polygons = new ArrayList<>();
final List<LinearRing> rings = new ArrayList<>();
final List<List<List<Number>>> paths = properties.getValue("rings", Collections.emptyList());
for (final List<List<Number>> points : paths) {
final LinearRing ring = geometryFactory.linearRing(points);
if (ring.isClockwise()) {
if (!rings.isEmpty()) {
final Polygon polygon = geometryFactory.polygon(rings);
polygons.add(polygon);
}
rings.clear();
}
rings.add(ring);
}
if (!rings.isEmpty()) {
final Polygon polygon = geometryFactory.polygon(rings);
polygons.add(polygon);
}
return geometryFactory.geometry(polygons);
}
use of com.revolsys.geometry.model.Polygon 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);
}
}
}
}
Aggregations