Search in sources :

Example 1 with FacetSequence

use of com.revolsys.geometry.operation.distance.FacetSequence in project com.revolsys.open by revolsys.

the class MinimumClearance method compute.

private void compute() {
    if (!this.calculated) {
        this.calculated = true;
        this.minClearance = Double.MAX_VALUE;
        if (!this.geometry.isEmpty()) {
            final StrTree<FacetSequence> geomTree = FacetSequenceTreeBuilder.build(this.geometry);
            final Pair<FacetSequence, FacetSequence> nearest = geomTree.nearestNeighbour(new MinClearanceDistance(this.calculateLine));
            final MinClearanceDistance mcd = new MinClearanceDistance(this.calculateLine);
            this.minClearance = mcd.distance(nearest.getValue1(), nearest.getValue2());
            final GeometryFactory geometryFactory = this.geometry.getGeometryFactory();
            if (this.calculateLine) {
                this.minClearancePts = new Point[] { // 
                geometryFactory.point(mcd.getMinX1(), mcd.getMinY1()), geometryFactory.point(mcd.getMinX2(), mcd.getMinY2()) };
            }
        }
    }
}
Also used : FacetSequence(com.revolsys.geometry.operation.distance.FacetSequence) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 FacetSequence (com.revolsys.geometry.operation.distance.FacetSequence)1