use of com.revolsys.geometry.model.GeometryFactory 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.GeometryFactory in project com.revolsys.open by revolsys.
the class SnapTransformer method computeOverlaySnapTolerance.
/**
* Estimates the snap tolerance for a Geometry, taking into account its precision model.
*
* @param g a Geometry
* @return the estimated snap tolerance
*/
public static double computeOverlaySnapTolerance(final Geometry g) {
double snapTolerance = computeSizeBasedSnapTolerance(g);
/**
* Overlay is carried out in the precision model
* of the two inputs.
* If this precision model is of type FIXED, then the snap tolerance
* must reflect the precision grid size.
* Specifically, the snap tolerance should be at least
* the distance from a corner of a precision grid cell
* to the centre point of the cell.
*/
final GeometryFactory geometryFactory = g.getGeometryFactory();
if (!geometryFactory.isFloating()) {
final double fixedSnapTol = 1 / geometryFactory.getScaleXY() * 2 / 1.415;
if (fixedSnapTol > snapTolerance) {
snapTolerance = fixedSnapTol;
}
}
return snapTolerance;
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class OffsetSegmentString method addPoint.
public void addPoint(double x, double y) {
final GeometryFactory geometryFactory = getGeometryFactory();
x = geometryFactory.makeXyPrecise(x);
y = geometryFactory.makeXyPrecise(y);
if (!isRedundant(x, y)) {
appendVertex(x, y);
}
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class BufferResultValidator method checkEnvelope.
private void checkEnvelope() {
if (this.distance < 0.0) {
return;
}
double padding = this.distance * MAX_ENV_DIFF_FRAC;
if (padding == 0.0) {
padding = 0.001;
}
final BoundingBox expectedEnv = this.input.getBoundingBox().expand(this.distance);
final BoundingBox bufEnv = this.result.getBoundingBox().expand(padding);
if (!bufEnv.covers(expectedEnv)) {
this.isValid = false;
this.errorMsg = "Buffer envelope is incorrect";
final GeometryFactory r = this.input.getGeometryFactory();
this.errorIndicator = bufEnv.toGeometry();
}
report("Envelope");
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class GeometryGraphOperation method getScale.
private static double getScale(final Geometry g0, final Geometry g1) {
double scale;
final GeometryFactory geometryFactory1 = g0.getGeometryFactory();
final double scale0 = geometryFactory1.getScaleXY();
final GeometryFactory geometryFactory2 = g1.getGeometryFactory();
final double scale1 = geometryFactory2.getScaleXY();
final int sigDigits = geometryFactory1.getMaximumSignificantDigits();
final int otherSigDigits = geometryFactory2.getMaximumSignificantDigits();
// use the most precise model for the result
if (Integer.compare(sigDigits, otherSigDigits) >= 0) {
scale = scale0;
} else {
scale = scale1;
}
return scale;
}
Aggregations