Search in sources :

Example 16 with BoundingBox

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;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 17 with BoundingBox

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;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 18 with BoundingBox

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");
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 19 with BoundingBox

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;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment) Point(com.revolsys.geometry.model.Point)

Example 20 with BoundingBox

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);
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox)

Aggregations

BoundingBox (com.revolsys.geometry.model.BoundingBox)307 Point (com.revolsys.geometry.model.Point)83 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)76 ArrayList (java.util.ArrayList)45 Geometry (com.revolsys.geometry.model.Geometry)41 LineString (com.revolsys.geometry.model.LineString)26 List (java.util.List)26 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)19 Polygon (com.revolsys.geometry.model.Polygon)14 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)14 Project (com.revolsys.swing.map.layer.Project)14 CreateListVisitor (com.revolsys.visitor.CreateListVisitor)12 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)11 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)11 Edge (com.revolsys.geometry.graph.Edge)10 HashMap (java.util.HashMap)10 Record (com.revolsys.record.Record)9 Graphics2D (java.awt.Graphics2D)9 MapEx (com.revolsys.collection.map.MapEx)8 LinearRing (com.revolsys.geometry.model.LinearRing)8