use of com.revolsys.geometry.model.Geometry 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.Geometry 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);
}
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class Polygonizer method addLineString.
public void addLineString(LineString lineString) {
if (lineString instanceof LinearRing) {
lineString = ((LinearRing) lineString).newLineStringEmpty();
}
// unioning the linestring with the point makes any self intersections
// explicit.
final Geometry geometry = lineString.newValidGeometry();
// Add result to polygonizer
add(geometry);
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class OverlayOp method labelIncompleteNode.
/**
* Label an isolated node with its relationship to the target geometry.
*/
private void labelIncompleteNode(final Node node, final int targetIndex) {
final Geometry geometry = this.arg[targetIndex].getGeometry();
final double x = node.getX();
final double y = node.getY();
final Location location = this.ptLocator.locate(geometry, x, y);
final Label label = node.getLabel();
label.setLocation(targetIndex, location);
}
use of com.revolsys.geometry.model.Geometry 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;
}
}
Aggregations