use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class SnapTransformer method computeSizeBasedSnapTolerance.
public static double computeSizeBasedSnapTolerance(final Geometry g) {
final BoundingBox env = g.getBoundingBox();
final double minDimension = Math.min(env.getHeight(), env.getWidth());
final double snapTol = minDimension * SNAP_PRECISION_FACTOR;
return snapTol;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class OffsetCurveSetBuilder method isErodedCompletely.
/**
* The ringCoord is assumed to contain no repeated points.
* It may be degenerate (i.e. contain only 1, 2, or 3 points).
* In this case it has no area, and hence has a minimum diameter of 0.
*
* @param ringCoord
* @param offsetDistance
* @return
*/
private boolean isErodedCompletely(final LinearRing ring, final double bufferDistance) {
// degenerate ring has no area
if (ring.getVertexCount() < 4) {
return bufferDistance < 0;
}
// also optimizes erosion test for triangles
if (ring.getVertexCount() == 4) {
return isTriangleErodedCompletely(ring, bufferDistance);
}
// if envelope is narrower than twice the buffer distance, ring is eroded
final BoundingBox env = ring.getBoundingBox();
final double envMinDimension = Math.min(env.getHeight(), env.getWidth());
if (bufferDistance < 0.0 && 2 * Math.abs(bufferDistance) > envMinDimension) {
return true;
}
return false;
}
use of com.revolsys.geometry.model.BoundingBox 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.BoundingBox in project com.revolsys.open by revolsys.
the class DistanceWithLocation method computePointLine.
private boolean computePointLine(final Point point, final LineString line) {
final BoundingBox boundingBox = line.getBoundingBox();
if (this.minDistance == Double.MAX_VALUE || boundingBox.distance(point) <= this.minDistance) {
for (final Segment segment : line.segments()) {
final double distance = segment.distancePoint(point);
if (distance < this.minDistance) {
this.minDistance = distance;
final Point closestPoint = segment.closestPoint(point);
final int segmentIndex = segment.getSegmentIndex();
this.minDistanceLocation1 = new GeometryLocation(point, 0, point);
this.minDistanceLocation2 = new GeometryLocation(line, segmentIndex, closestPoint);
if (this.minDistance <= this.terminateDistance) {
return true;
}
}
}
}
return false;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ShapefileGeometryHandler method writeMCoordinatesRange.
public void writeMCoordinatesRange(final EndianOutput out, final Geometry geometry) {
final BoundingBox boundingBox = geometry.getBoundingBox();
final double minM = boundingBox.getMin(3);
final double maxM = boundingBox.getMax(3);
if (Double.isNaN(minM) || Double.isNaN(maxM)) {
out.writeLEDouble(0);
out.writeLEDouble(0);
} else {
out.writeLEDouble(minM);
out.writeLEDouble(maxM);
}
}
Aggregations