use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class TestPerfDistanceGeomSet method newCircleRandomLocation.
Geometry newCircleRandomLocation(final int nPts) {
final SineStarFactory gsf = new SineStarFactory();
gsf.setCentre(randomLocation());
gsf.setSize(GEOM_SIZE);
gsf.setNumPoints(nPts);
final Polygon g = gsf.newCircle();
return g;
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class DelaunayTest method testBoundary.
@Test
public void testBoundary() throws ParseException {
// final Point point = this.geometryFactory.point(0, 0, 0);
// testBoundaryDo(point);
final LineString line = this.geometryFactory.lineString(3, 2, 0.0, 0, 0, 10, 10, 0);
testBoundaryDo(line);
final Polygon polygon = //
this.geometryFactory.polygon(//
3, //
0, //
10, //
2, //
10, //
10, //
3, //
10, //
0, //
4, //
0.0, //
0, //
1, //
0, //
10, //
2);
testBoundaryDo(polygon);
}
use of com.revolsys.geometry.model.Polygon 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.Polygon in project com.revolsys.open by revolsys.
the class GeometryStyleRenderer method renderGeometry.
public static final void renderGeometry(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;
renderPolygon(viewport, graphics, polygon, style);
}
}
}
}
}
}
use of com.revolsys.geometry.model.Polygon 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);
}
}
}
}
}
}
}
Aggregations