use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class PolygonVertex method getCoordinate.
@Override
public double getCoordinate(final int axisIndex) {
final Polygon polygon = getPolygon();
final LinearRing ring = polygon.getRing(this.ringIndex);
if (ring == null) {
return java.lang.Double.NaN;
} else {
return ring.getCoordinate(this.vertexIndex, axisIndex);
}
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class Buffer method buffer.
private static Geometry buffer(final Noder noder, final GeometryFactory precisionModel, final Geometry geometry, final double distance, final BufferParameters parameters) {
final GeometryFactory geometryFactory = geometry.getGeometryFactory();
final OffsetCurveSetBuilder curveSetBuilder = new OffsetCurveSetBuilder(geometry, distance, precisionModel, parameters);
final List<NodedSegmentString> curves = curveSetBuilder.getCurves();
if (curves.size() == 0) {
return geometryFactory.polygon();
} else {
final EdgeList edgeList = new EdgeList();
computeNodedEdges(noder, edgeList, curves);
final PlanarGraph graph = new PlanarGraph(new OverlayNodeFactory());
final List<Edge> edges = edgeList.getEdges();
graph.addEdges(edges);
final List<BufferSubgraph> subgraphList = newSubgraphs(graph);
final PolygonBuilder polyBuilder = new PolygonBuilder(geometryFactory);
buildSubgraphs(subgraphList, polyBuilder);
final List<Polygon> polygons = polyBuilder.getPolygons();
if (polygons.size() == 0) {
return geometryFactory.polygon();
} else {
final Geometry resultGeom = geometryFactory.buildGeometry(polygons);
return resultGeom;
}
}
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class DistanceWithPoints method computeContainmentDistance.
private boolean computeContainmentDistance(final List<Point> locations, final List<Polygon> polygons) {
for (final Point point : locations) {
final double x = point.getX();
final double y = point.getY();
for (final Polygon polygon : polygons) {
if (computeContainmentDistance(polygon, x, y)) {
return true;
}
}
}
return false;
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class BufferDistanceValidator method getPolygonLines.
private Geometry getPolygonLines(final Geometry geometry) {
final List<LineString> lines = new ArrayList<>();
for (final Polygon polygon : geometry.getGeometries(Polygon.class)) {
lines.addAll(polygon.getRings());
}
final GeometryFactory geometryFactory = geometry.getGeometryFactory();
return geometryFactory.geometry(lines);
}
use of com.revolsys.geometry.model.Polygon in project com.revolsys.open by revolsys.
the class DistanceToPointFinder method computeDistance.
public static void computeDistance(final Geometry geometry, final Point pt, final PointPairDistance ptDist) {
if (geometry instanceof LineString) {
computeDistance(geometry, pt, ptDist);
} else if (geometry instanceof Polygon) {
computeDistance(geometry, pt, ptDist);
} else if (geometry.isGeometryCollection()) {
for (int i = 0; i < geometry.getGeometryCount(); i++) {
final Geometry g = geometry.getGeometry(i);
computeDistance(g, pt, ptDist);
}
} else {
// assume geom is Point
ptDist.setMinimum(geometry.getPoint(), pt);
}
}
Aggregations