Beispiel #1
0
        private static IEnumerable <SegmentIntersection> IntersectLineWithLinestringXY(
            [NotNull] Line3D line1, int line1Index,
            [NotNull] IEnumerable <KeyValuePair <int, Line3D> > linestring2Segments,
            double tolerance)
        {
            // Tolerance rules:
            // If there is an accurate intersection along the segment's interior but the source start AND end are
            // within the tolerance, the source line is used

            // If there is no accurate intersection:
            // The line1 start or the line1 end could be within distance of the other line -> add source point
            // the other line's start or end could be within distance of this line -> add target point
            // if at least 2 start/end points are within distance: create Line3D result from source line

            // TODO: Test for 0-length lines

            foreach (KeyValuePair <int, Line3D> path2Segment in
                     linestring2Segments.OrderBy(kvp => kvp.Key))
            {
                int    targetIdx = path2Segment.Key;
                Line3D otherLine = path2Segment.Value;

                // With the speculative optimization for continued linear intersections
                // providing a known target end intersection factor has no extra benefit.
                SegmentIntersection intersection =
                    SegmentIntersection.CalculateIntersectionXY(
                        line1Index, targetIdx, line1, otherLine, tolerance);

                if (intersection.HasIntersection)
                {
                    yield return(intersection);
                }
            }
        }
Beispiel #2
0
        public static bool SourceInteriorIntersectsXY([NotNull] Line3D line1,
                                                      [NotNull] Line3D line2,
                                                      double tolerance)
        {
            SegmentIntersection segmentIntersection =
                SegmentIntersection.CalculateIntersectionXY(
                    0, 0, line1, line2, tolerance);

            return(segmentIntersection.HasSourceInteriorIntersection);
        }