use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class Densifier method densify.
private static Polygonal densify(final Polygonal polygonal, final double distanceTolerance) {
final List<Polygon> polygons = new ArrayList<>();
for (final Polygon polygon : polygonal.getPolygons()) {
final Polygon newPolygon = densify(polygon, distanceTolerance);
polygons.add(newPolygon);
}
final GeometryFactory geometryFactory = polygonal.getGeometryFactory();
final Polygonal newMultiPolygon = geometryFactory.polygonal(polygons);
return (Polygonal) newMultiPolygon.buffer(0);
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class MultiPolygonVertex method next.
@Override
public Vertex next() {
final Polygonal polygonal = getPolygonal();
this.vertexIndex++;
while (this.partIndex < polygonal.getGeometryCount()) {
final Polygon polygon = polygonal.getPolygon(this.partIndex);
while (this.ringIndex < polygon.getRingCount()) {
final LinearRing ring = polygon.getRing(this.ringIndex);
if (this.vertexIndex < ring.getVertexCount()) {
return this;
} else {
this.ringIndex++;
this.vertexIndex = 0;
}
}
this.partIndex++;
this.ringIndex = 0;
this.vertexIndex = 0;
}
throw new NoSuchElementException();
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class BufferDistanceValidator method checkNegativeValid.
private void checkNegativeValid() {
// MD - could generalize this to handle GCs too
if (!(this.input instanceof Polygonal || this.input.isGeometryCollection())) {
return;
}
final Geometry inputCurve = getPolygonLines(this.input);
checkMinimumDistance(inputCurve, this.result, this.minValidDistance);
if (!this.isValid) {
return;
}
checkMaximumDistance(inputCurve, this.result, this.maxValidDistance);
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class SnapTransformer method snapToSelf.
/**
* Snaps the vertices in the component {@link LineString}s
* of the source geometry
* to the vertices of the same geometry.
* Allows optionally cleaning the result to ensure it is
* topologically valid
* (which fixes issues such as topology collapses in polygonal inputs).
*
*@param snapTolerance the snapping tolerance
*@param cleanResult whether the result should be made valid
* @return a new snapped Geometry
*/
public Geometry snapToSelf(final double snapTolerance, final boolean cleanResult) {
final Collection<Point> snapPoints = extractTargetCoordinates(this.srcGeom);
if (snapPoints.isEmpty()) {
return this.srcGeom;
} else {
final SnapTransformer snapTrans = new SnapTransformer(snapTolerance, snapPoints, true);
final Geometry snappedGeom = snapTrans.transform(this.srcGeom);
Geometry result = snappedGeom;
if (cleanResult && result instanceof Polygonal) {
// TODO: use better cleaning approach
result = snappedGeom.buffer(0);
}
return result;
}
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class TriangulationFunctions method delaunayTrianglesWithTolerance.
public static Polygonal delaunayTrianglesWithTolerance(final Geometry geom, final double tolerance) {
GeometryFactory geometryFactory = geom.getGeometryFactory();
geometryFactory = geometryFactory.convertScales(tolerance, tolerance, tolerance);
final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
builder.insertVertices(geom);
final Polygonal triangles = builder.getTrianglesPolygonal();
return triangles;
}
Aggregations