internal static com.epl.geometry.QuadTreeImpl BuildQuadTree(com.epl.geometry.MultiPointImpl multipointImpl, com.epl.geometry.Envelope2D extentOfInterest) { com.epl.geometry.QuadTreeImpl quad_tree_impl = new com.epl.geometry.QuadTreeImpl(extentOfInterest, 8); com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D(); bool resized_extent = false; com.epl.geometry.Envelope2D boundingbox = new com.epl.geometry.Envelope2D(); for (int i = 0; i < multipointImpl.GetPointCount(); i++) { multipointImpl.GetXY(i, pt); if (!extentOfInterest.Contains(pt)) { continue; } boundingbox.SetCoords(pt); int element_handle = quad_tree_impl.Insert(i, boundingbox); if (element_handle == -1) { if (resized_extent) { throw com.epl.geometry.GeometryException.GeometryInternalError(); } // resize extent resized_extent = true; com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D(); multipointImpl.CalculateEnvelope2D(extent, false); quad_tree_impl.Reset(extent, 8); i = -1; // resets the for-loop continue; } } return(quad_tree_impl); }
internal static com.epl.geometry.QuadTree BuildQuadTree_(com.epl.geometry.MultiPointImpl multipointImpl) { com.epl.geometry.Envelope2D extent = new com.epl.geometry.Envelope2D(); multipointImpl.QueryEnvelope2D(extent); com.epl.geometry.QuadTree quadTree = new com.epl.geometry.QuadTree(extent, 8); com.epl.geometry.Envelope2D boundingbox = new com.epl.geometry.Envelope2D(); com.epl.geometry.Point2D pt; for (int i = 0; i < multipointImpl.GetPointCount(); i++) { pt = multipointImpl.GetXY(i); boundingbox.SetCoords(pt.x, pt.y, pt.x, pt.y); quadTree.Insert(i, boundingbox, -1); } return(quadTree); }
private double BruteForceMultiPointMultiPoint_(com.epl.geometry.MultiPoint geometryA, com.epl.geometry.MultiPoint geometryB, bool geometriesAreDisjoint) { /* const */ /* const */ double minSqrDistance = com.epl.geometry.NumberUtils.DoubleMax(); com.epl.geometry.Point2D pointA = new com.epl.geometry.Point2D(); com.epl.geometry.Point2D pointB = new com.epl.geometry.Point2D(); double sqrDistance = minSqrDistance; /* const */ com.epl.geometry.MultiPointImpl multiPointImplA = (com.epl.geometry.MultiPointImpl)geometryA._getImpl(); /* const */ /* const */ com.epl.geometry.MultiPointImpl multiPointImplB = (com.epl.geometry.MultiPointImpl)geometryB._getImpl(); /* const */ int pointCountA = multiPointImplA.GetPointCount(); int pointCountB = multiPointImplB.GetPointCount(); for (int i = 0; i < pointCountA; i++) { multiPointImplA.GetXY(i, pointA); if (pointCountB > 1 && this.m_env2DgeometryB.SqrDistance(pointA) > minSqrDistance) { continue; } for (int j = 0; j < pointCountB; j++) { multiPointImplB.GetXY(j, pointB); sqrDistance = com.epl.geometry.Point2D.SqrDistance(pointA, pointB); if (sqrDistance < minSqrDistance) { if (sqrDistance == 0.0) { return(0.0); } minSqrDistance = sqrDistance; } } } return(System.Math.Sqrt(minSqrDistance)); }
private double BruteForceMultiPathMultiPoint_(com.epl.geometry.MultiPath geometryA, com.epl.geometry.MultiPoint geometryB, bool geometriesAreDisjoint) { /* const */ /* const */ com.epl.geometry.SegmentIterator segIterA = geometryA.QuerySegmentIterator(); com.epl.geometry.Envelope2D env2DSegmentA = new com.epl.geometry.Envelope2D(); double minSqrDistance = com.epl.geometry.NumberUtils.DoubleMax(); com.epl.geometry.Point2D inputPoint = new com.epl.geometry.Point2D(); double t = -1; double sqrDistance = minSqrDistance; /* const */ com.epl.geometry.MultiPointImpl multiPointImplB = (com.epl.geometry.MultiPointImpl)geometryB._getImpl(); int pointCountB = multiPointImplB.GetPointCount(); bool bDoPiPTest = !geometriesAreDisjoint && (geometryA.GetType() == com.epl.geometry.Geometry.Type.Polygon); while (segIterA.NextPath()) { while (segIterA.HasNextSegment()) { /* const */ com.epl.geometry.Segment segmentA = segIterA.NextSegment(); segmentA.QueryEnvelope2D(env2DSegmentA); // if multipointB has only 1 vertex then it is faster to not // test for // env2DSegmentA.distance(env2DgeometryB) if (pointCountB > 1 && env2DSegmentA.SqrDistance(this.m_env2DgeometryB) > minSqrDistance) { continue; } for (int i = 0; i < pointCountB; i++) { multiPointImplB.GetXY(i, inputPoint); if (bDoPiPTest) { // Test for polygon containment. This takes the // place of a more general intersection test at the // beginning of the operator if (com.epl.geometry.PolygonUtils.IsPointInPolygon2D((com.epl.geometry.Polygon)geometryA, inputPoint, 0) != com.epl.geometry.PolygonUtils.PiPResult.PiPOutside) { return(0.0); } } t = segmentA.GetClosestCoordinate(inputPoint, false); inputPoint.Sub(segmentA.GetCoord2D(t)); sqrDistance = inputPoint.SqrLength(); if (sqrDistance < minSqrDistance) { if (sqrDistance == 0.0) { return(0.0); } minSqrDistance = sqrDistance; } } // No need to do point-in-polygon anymore (if it is a // polygon vs polyline) bDoPiPTest = false; } } return(System.Math.Sqrt(minSqrDistance)); }
public override com.epl.geometry.Point2D GetXY(int index) { return(m_impl.GetXY(index)); }