internal static com.epl.geometry.Geometry PointMinusPolyline_(com.epl.geometry.Point point, com.epl.geometry.Polyline polyline, double tolerance, com.epl.geometry.ProgressTracker progress_tracker) { com.epl.geometry.Point2D pt = point.GetXY(); com.epl.geometry.SegmentIterator seg_iter = polyline.QuerySegmentIterator(); double tolerance_cluster = tolerance * System.Math.Sqrt(2.0) * 1.00001; double tolerance_cluster_sq = tolerance_cluster * tolerance_cluster; com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D(); while (seg_iter.NextPath()) { while (seg_iter.HasNextSegment()) { com.epl.geometry.Segment segment = seg_iter.NextSegment(); segment.QueryEnvelope2D(env); env.Inflate(tolerance_cluster, tolerance_cluster); if (!env.Contains(pt)) { continue; } if (segment.IsIntersecting(pt, tolerance)) { return(point.CreateInstance()); } // check segment end points to the cluster tolerance com.epl.geometry.Point2D end_point = segment.GetStartXY(); if (com.epl.geometry.Point2D.SqrDistance(pt, end_point) <= tolerance_cluster_sq) { return(point.CreateInstance()); } end_point = segment.GetEndXY(); if (com.epl.geometry.Point2D.SqrDistance(pt, end_point) <= tolerance_cluster_sq) { return(point.CreateInstance()); } } } return(point); }