use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class OracleSdoGeometryJdbcFieldDefinition method toPolygon.
private Polygon toPolygon(final ResultSet resultSet, final int columnIndex, final int axisCount) throws SQLException {
final BigDecimal[] elemInfo = JdbcUtils.getBigDecimalArray(resultSet, columnIndex + 4);
final BigDecimal[] coordinatesArray = JdbcUtils.getBigDecimalArray(resultSet, columnIndex + 5);
final List<LinearRing> rings = new ArrayList<>();
int numInteriorRings = 0;
for (int elemInfoOffset = 0; elemInfoOffset < elemInfo.length; ) {
final int offset = elemInfo[elemInfoOffset].intValue();
final int type = (int) elemInfo[elemInfoOffset + 1].longValue();
final long interpretation = elemInfo[elemInfoOffset + 2].longValue();
switch(type) {
case 1003:
if (rings.isEmpty()) {
elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
} else {
throw new IllegalArgumentException("Cannot have two exterior rings on a geometry");
}
break;
case 1005:
if (rings.isEmpty()) {
elemInfoOffset = addRingComplex(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
} else {
throw new IllegalArgumentException("Cannot have two exterior rings on a geometry");
}
break;
case 2003:
if (numInteriorRings == rings.size()) {
throw new IllegalArgumentException("Too many interior rings");
} else {
numInteriorRings++;
elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
}
break;
case 2005:
if (numInteriorRings == rings.size()) {
throw new IllegalArgumentException("Too many interior rings");
} else {
numInteriorRings++;
elemInfoOffset = addRingSimple(rings, axisCount, elemInfo, type, coordinatesArray, elemInfoOffset, offset, interpretation);
}
break;
default:
throw new IllegalArgumentException("Unsupported geometry type " + type);
}
}
final Polygon polygon = this.geometryFactory.polygon(rings);
return polygon;
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class GeometryStyleRenderer method renderGeometryOutline.
public static final void renderGeometryOutline(final Viewport2D viewport, final Graphics2D graphics, final Geometry geometry, final GeometryStyle style) {
if (geometry != null) {
final BoundingBox viewExtent = viewport.getBoundingBox();
if (!viewExtent.isEmpty()) {
final GeometryFactory viewGeometryFactory = viewport.getGeometryFactory2dFloating();
for (int i = 0; i < geometry.getGeometryCount(); i++) {
final Geometry part = geometry.getGeometry(i);
final BoundingBox partExtent = part.getBoundingBox();
if (partExtent.intersects(viewExtent)) {
final Geometry convertedPart = part.convertGeometry(viewGeometryFactory);
if (convertedPart instanceof Point) {
final Point point = (Point) convertedPart;
MarkerStyleRenderer.renderMarker(viewport, graphics, point, style, 0);
} else if (convertedPart instanceof LineString) {
final LineString lineString = (LineString) convertedPart;
renderLineString(viewport, graphics, lineString, style);
} else if (convertedPart instanceof Polygon) {
final Polygon polygon = (Polygon) convertedPart;
for (final LinearRing ring : polygon.rings()) {
renderLineString(viewport, graphics, ring, style);
}
}
}
}
}
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PdfViewport method drawGeometry.
@Override
public void drawGeometry(final Geometry geometry, final GeometryStyle style) {
try {
this.contentStream.saveGraphicsState();
setGeometryStyle(style);
this.contentStream.setNonStrokingColor(style.getPolygonFill());
this.contentStream.setStrokingColor(style.getLineColor());
for (Geometry part : geometry.geometries()) {
part = part.convertGeometry(getGeometryFactory());
if (part instanceof LineString) {
final LineString line = (LineString) part;
drawLine(line);
this.contentStream.stroke();
} else if (part instanceof Polygon) {
final Polygon polygon = (Polygon) part;
int i = 0;
for (final LinearRing ring : polygon.rings()) {
if (i == 0) {
if (ring.isClockwise()) {
drawLineReverse(ring);
} else {
drawLine(ring);
}
} else {
if (ring.isCounterClockwise()) {
drawLineReverse(ring);
} else {
drawLine(ring);
}
}
this.contentStream.closeSubPath();
i++;
}
this.contentStream.fill(PathIterator.WIND_NON_ZERO);
for (final LinearRing ring : polygon.rings()) {
drawLine(ring);
this.contentStream.stroke();
}
}
}
} catch (final IOException e) {
} finally {
try {
this.contentStream.restoreGraphicsState();
} catch (final IOException e) {
}
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class DistanceToPoint method computeDistance.
public static void computeDistance(final Polygon poly, final Point point, final PointPairDistance pointDistance) {
final double x = point.getX();
final double y = point.getY();
for (final LinearRing ring : poly.rings()) {
computeDistance(ring, x, y, pointDistance);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PreparedPolygon method prepareRings.
private static LinearRing[] prepareRings(final Polygon polygon) {
final LinearRing[] rings = new LinearRing[polygon.getRingCount()];
for (int i = 0; i < rings.length; i++) {
final LinearRing ring = polygon.getRing(i);
rings[i] = ring.prepare();
}
return rings;
}
Aggregations