Example #1
0
        private static List <Linestring> RemoveContainedExistingIslands <T>(
            [NotNull] T fromPolygon,
            [NotNull] Linestring cookieCutter,
            double tolerance) where T : MultiLinestring
        {
            List <Linestring> existingInnerRings = fromPolygon
                                                   .GetLinestrings()
                                                   .Where(l => l.ClockwiseOriented == false)
                                                   .ToList();

            Assert.NotNull(cookieCutter.ClockwiseOriented);

            var containedExistingIslands = new List <Linestring>();

            foreach (Linestring existingInnerRing in existingInnerRings)
            {
                bool?islandWithinCookie = GeomRelationUtils.AreaContainsXY(
                    cookieCutter, existingInnerRing.StartPoint, tolerance, true);

                // TODO: handle the case where the inner ring touches cutter in StartPoint
                if (islandWithinCookie == true)
                {
                    containedExistingIslands.Add(existingInnerRing);
                    fromPolygon.RemoveLinestring(existingInnerRing);
                }
            }

            return(containedExistingIslands);
        }
Example #2
0
        protected static Linestring GetTargetSubcurve(
            [NotNull] Linestring target,
            [NotNull] IntersectionPoint3D fromIntersection,
            [NotNull] IntersectionPoint3D toIntersection,
            bool forward)
        {
            double fromDistanceAlongAsRatio;
            int    fromIndex = fromIntersection.GetLocalTargetIntersectionSegmentIdx(
                target, out fromDistanceAlongAsRatio);

            double toDistanceAlongAsRatio;
            int    toIndex = toIntersection.GetLocalTargetIntersectionSegmentIdx(
                target, out toDistanceAlongAsRatio);

            if (!forward &&
                fromIntersection.VirtualTargetVertex > toIntersection.VirtualTargetVertex)
            {
            }

            Linestring subcurve = target.GetSubcurve(
                fromIndex, fromDistanceAlongAsRatio,
                toIndex, toDistanceAlongAsRatio,
                false, !forward);

            // Replace the start / end with the actual intersection (correct source Z, exactly matching previous subcurve end)
            subcurve.ReplacePoint(0, fromIntersection.Point);
            subcurve.ReplacePoint(subcurve.SegmentCount, toIntersection.Point);

            return(subcurve);
        }
Example #3
0
        protected Linestring GetSourceSubcurve(
            [NotNull] IntersectionPoint3D fromIntersection,
            [NotNull] IntersectionPoint3D toIntersection)
        {
            Assert.ArgumentCondition(
                fromIntersection.SourcePartIndex == toIntersection.SourcePartIndex,
                "Cannot jump between source parts");

            Linestring source = GetSourcePart(fromIntersection.SourcePartIndex);

            double fromDistanceAlongAsRatio;
            int    fromIndex = fromIntersection.GetLocalSourceIntersectionSegmentIdx(
                source, out fromDistanceAlongAsRatio);

            double toDistanceAlongAsRatio;
            int    toIndex = toIntersection.GetLocalSourceIntersectionSegmentIdx(
                source, out toDistanceAlongAsRatio);

            Linestring subcurve = source.GetSubcurve(
                fromIndex, fromDistanceAlongAsRatio,
                toIndex, toDistanceAlongAsRatio,
                false);

            return(subcurve);
        }
        protected override IntersectionPoint3D FollowUntilNextIntersection(
            IntersectionPoint3D previousIntersection,
            bool continueOnSource,
            int partIndex,
            bool continueForward,
            out Linestring subcurve)
        {
            IntersectionPoint3D nextIntersection;

            if (continueOnSource)
            {
                nextIntersection = GetNextIntersectionAlongSource(previousIntersection);

                subcurve = GetSourceSubcurve(previousIntersection, nextIntersection);
            }
            else
            {
                // TODO: Handle verticals?
                nextIntersection =
                    GetNextIntersectionAlongTarget(previousIntersection, continueForward);

                Linestring targetPart = Target.GetPart(previousIntersection.TargetPartIndex);

                subcurve = GetTargetSubcurve(targetPart, previousIntersection,
                                             nextIntersection, continueForward);
            }

            return(nextIntersection);
        }
Example #5
0
 public IntersectionPath3D(
     [NotNull] Linestring segments,
     RingPlaneTopology ringPlaneTopology)
 {
     Segments          = segments;
     RingPlaneTopology = ringPlaneTopology;
 }
Example #6
0
        /// <summary>
        /// Determines whether the specified closed polycurve contains (including the boundary) the
        /// specified test geometry. This method ignores the orientation.
        /// </summary>
        /// <param name="closedPolycurve"></param>
        /// <param name="targetSegments"></param>
        /// <param name="tolerance"></param>
        /// <param name="knownIntersections"></param>
        /// <returns></returns>
        public static bool PolycurveContainsXY(
            [NotNull] ISegmentList closedPolycurve,
            [NotNull] Linestring targetSegments,
            double tolerance,
            IEnumerable <SegmentIntersection> knownIntersections = null)
        {
            if (AreBoundsDisjoint(closedPolycurve, targetSegments, tolerance))
            {
                return(false);
            }

            if (knownIntersections == null)
            {
                knownIntersections =
                    SegmentIntersectionUtils.GetSegmentIntersectionsXY(
                        closedPolycurve, targetSegments, tolerance);
            }

            // TODO: GeomUtils.IEnumerable<IntersectionPoint3D> GetIntersectionPointsWithDeviation() for better performance
            var intersectionPoints =
                GeomTopoOpUtils.GetIntersectionPoints(closedPolycurve, targetSegments, tolerance,
                                                      knownIntersections, false);

            Pnt3D nonIntersectingTargetPnt =
                GetNonIntersectingTargetPoint(targetSegments, intersectionPoints);

            IEnumerable <Pnt3D> checkPoints = nonIntersectingTargetPnt != null
                                                                 ? new[] { nonIntersectingTargetPnt }
                                                                 : targetSegments.GetPoints();

            return(checkPoints.All(p => PolycurveContainsXY(closedPolycurve, p, tolerance)));

            // The check points are assumed not to be on the boundary!
        }
Example #7
0
        /// <summary>
        /// Calculates the overlap between the source and the target. If the target is disjoint or within
        /// the source, an empty list is returned.
        /// </summary>
        /// <returns></returns>
        public IList <Linestring> IntersectXY()
        {
            Assert.True(_sourceRing.ClockwiseOriented == true,
                        "The source is not oriented clockwise or it is vertical.");
            Assert.True(_target.IsClosed, "The target is not a closed linestring.");

            Assert.NotNull(_target.ClockwiseOriented, "The target is vertical");

            if (SourceEqualsTargetXY())
            {
                // Target equals source in XY - return source if both are positive:
                Linestring resultRing =
                    IsExterior(_sourceRing) && IsExterior(_target)
                                                ? _sourceRing.Clone()
                                                : Linestring.CreateEmpty();

                return(new List <Linestring> {
                    resultRing
                });
            }

            return(_target.ClockwiseOriented.Value
                                       ? GetRightSideRings()
                                       : GetLeftSideRings());
        }
Example #8
0
        /// <summary>
        /// Determines whether the test point is completely contained (true) or
        /// on the boundary of the specified ring (i.e. intersecting the linestring).
        /// </summary>
        /// <param name="closedRing">The containing ring.</param>
        /// <param name="testPoint">The test point.</param>
        /// <param name="tolerance">The tolerance.</param>
        /// <param name="disregardingOrientation">Whether the orientation should be disregarded.
        /// If false, a point inside the ring is considered outside if the ring orientation is
        /// counter-clockwise.</param>
        /// <returns>Null, if the point is on the boundary, true if the point is inside the ring.</returns>
        public static bool?AreaContainsXY([NotNull] Linestring closedRing,
                                          [NotNull] Pnt3D testPoint,
                                          double tolerance,
                                          bool disregardingOrientation = false)
        {
            Assert.ArgumentCondition(closedRing.IsClosed, "Ring must be closed");

            if (AreBoundsDisjoint(closedRing, testPoint.X, testPoint.Y, tolerance))
            {
                return(disregardingOrientation ? false : closedRing.ClockwiseOriented == false);
            }

            // Test boundary:
            if (LinesContainXY(closedRing, testPoint, tolerance))
            {
                return(null);
            }

            bool result = HasRayOddCrossingNumber(closedRing, testPoint, tolerance);

            if (disregardingOrientation)
            {
                return(result);
            }

            if (closedRing.ClockwiseOriented == false)
            {
                result = !result;
            }

            return(result);
        }
Example #9
0
        public static bool TouchesXY([NotNull] Linestring ring1,
                                     [NotNull] IEnumerable <Linestring> interiorRings,
                                     double tolerance,
                                     out bool disjoint)
        {
            disjoint = false;

            bool polyTouchesAnyInnerRing = false;

            foreach (Linestring interiorRing in interiorRings)
            {
                // NOTE: disjoint with interor ring means the outer ring is inside:
                bool ring1WithinInterior;
                if (TouchesXY(ring1, interiorRing, tolerance,
                              out ring1WithinInterior))
                {
                    polyTouchesAnyInnerRing = true;
                }
                else if (ring1WithinInterior)
                {
                    // assuming interior rings do not intersect each other: ring1 within inner ring -> disjoint
                    disjoint = true;
                }
            }

            return(polyTouchesAnyInnerRing);
        }
Example #10
0
        private static Pnt3D GetNonIntersectingTargetPoint(
            Linestring targetRing,
            IEnumerable <IntersectionPoint3D> intersectionPoints)
        {
            foreach (IntersectionPoint3D intersectionPoint in intersectionPoints)
            {
                if (intersectionPoint.Type == IntersectionPointType.LinearIntersectionIntermediate)
                {
                    continue;
                }

                if (intersectionPoint.Type == IntersectionPointType.LinearIntersectionStart &&
                    MathUtils.AreEqual(intersectionPoint.VirtualSourceVertex, 0))
                {
                    // Do not use the first point, there might be no proper deviation
                    // because it is actually an intermediate intersection point in a closed ring.
                    continue;
                }

                Pnt3D nonIntersectingTargetPnt =
                    intersectionPoint.GetNonIntersectingTargetPoint(targetRing, 0.5);

                return(nonIntersectingTargetPnt);
            }

            return(null);
        }
Example #11
0
        private static Linestring CreateWithBoundaryLoop(Linestring containingSourceRing,
                                                         Linestring touchingInteriorRing,
                                                         IntersectionPoint3D touchIntersection,
                                                         double tolerance)
        {
            double sourceTouchPointRatio;
            int    sourceTouchSegmentIdx =
                touchIntersection.GetLocalSourceIntersectionSegmentIdx(
                    containingSourceRing, out sourceTouchPointRatio);
            List <Linestring> subcurves = new List <Linestring>();

            subcurves.Add(containingSourceRing.GetSubcurve(
                              0, 0, sourceTouchSegmentIdx, sourceTouchPointRatio,
                              false));

            double targetTouchPointRatio;
            int    targetTouchSegmentIdx =
                touchIntersection.GetLocalTargetIntersectionSegmentIdx(
                    touchingInteriorRing, out targetTouchPointRatio);

            subcurves.Add(touchingInteriorRing.GetSubcurve(
                              targetTouchSegmentIdx, targetTouchPointRatio, false,
                              true));

            subcurves.Add(containingSourceRing.GetSubcurve(
                              sourceTouchSegmentIdx, sourceTouchPointRatio,
                              containingSourceRing.SegmentCount - 1, 1, false));

            Linestring withBoundaryLoop =
                GeomTopoOpUtils.MergeConnectedLinestrings(subcurves, null, tolerance);

            return(withBoundaryLoop);
        }
Example #12
0
        private static int GetLocalIntersectionSegmentIdx([NotNull] Linestring forSegments,
                                                          double virtualVertexIndex,
                                                          out double distanceAlongAsRatio)
        {
            Assert.ArgumentNotNull(forSegments, nameof(forSegments));
            Assert.ArgumentNotNaN(virtualVertexIndex, nameof(virtualVertexIndex));

            var localSegmentIdx = (int)Math.Truncate(virtualVertexIndex);

            distanceAlongAsRatio = virtualVertexIndex - localSegmentIdx;

            if (forSegments.IsLastPointInPart(localSegmentIdx) && distanceAlongAsRatio >= 0)
            {
                // out of segment bounds:
                if (forSegments.IsClosed)
                {
                    localSegmentIdx = 0;
                }
                else
                {
                    // last segment, end point:
                    localSegmentIdx      -= 1;
                    distanceAlongAsRatio += 1;
                }
            }

            return(localSegmentIdx);
        }
Example #13
0
 public IntersectionRun(IntersectionPoint3D nextIntersection,
                        Linestring subcurve,
                        Pnt3D includedRingStartPoint)
 {
     _includedRingStartPoint = includedRingStartPoint;
     NextIntersection        = nextIntersection;
     Subcurve = subcurve;
 }
Example #14
0
        public void AddLinestring(Linestring linestring)
        {
            Linestrings.Add(linestring);

            UpdateBounds(linestring);

            UpdateSpatialIndex(linestring, Linestrings.Count - 1);

            CacheStartIndexes();
        }
Example #15
0
        public void InsertLinestring(int index, Linestring linestring)
        {
            Linestrings.Insert(index, linestring);

            UpdateBounds(linestring);

            SpatialIndex = null;

            CacheStartIndexes();
        }
Example #16
0
        public RingOperator([NotNull] Linestring sourceRing,
                            [NotNull] Linestring target,
                            double tolerance)
            : this(new SingleRingNavigator(sourceRing, target, tolerance))
        {
            Assert.ArgumentCondition(sourceRing.IsClosed, "Source ring must be closed.");

            _sourceRing = sourceRing;
            _target     = target;
        }
Example #17
0
        public bool IsOnTheRightSide([NotNull] ISegmentList source,
                                     [NotNull] Pnt3D testPoint,
                                     bool disregardOrientation = false)
        {
            Assert.True(source.IsClosed, "Source must be closed ring(s)");

            Linestring sourceRing = source.GetPart(SourcePartIndex);

            double sourceRatio;
            int    sourceSegmentIdx =
                GetLocalSourceIntersectionSegmentIdx(sourceRing, out sourceRatio);

            Line3D sourceSegment = sourceRing[sourceSegmentIdx];

            if (sourceRatio > 0 && sourceRatio < 1)
            {
                // The intersection is on the source segment's interior
                return(sourceSegment.IsLeftXY(testPoint) < 0);
            }

            Line3D previousSegment, nextSegment;

            // Intersection at source vertex 0 or 1 -> get the 2 adjacent segments
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (sourceRatio == 0)
            {
                previousSegment =
                    sourceRing.PreviousSegmentInRing(sourceSegmentIdx, true);

                nextSegment = SegmentIntersection.IsSourceZeroLength2D
                                                      ? sourceRing.NextSegmentInRing(sourceSegmentIdx, true)
                                                      : sourceSegment;
            }
            else             // sourceRatio == 1
            {
                previousSegment = SegmentIntersection.IsSourceZeroLength2D
                                                          ? sourceRing.PreviousSegmentInRing(
                    sourceSegmentIdx, true)
                                                          : sourceSegment;
                nextSegment = sourceRing.NextSegmentInRing(sourceSegmentIdx, true);
            }

            bool result = GeomTopoOpUtils.IsOnTheRightSide(previousSegment.StartPoint, Point,
                                                           nextSegment.EndPoint, testPoint);

            if (!disregardOrientation && sourceRing.ClockwiseOriented == false)
            {
                result = !result;
            }

            return(result);
        }
        protected override IntersectionPoint3D FollowUntilNextIntersection(
            IntersectionPoint3D previousIntersection,
            bool continueOnSource,
            int partIndex,
            bool continueForward,
            out Linestring subcurve)
        {
            IntersectionPoint3D nextIntersection;

            if (continueOnSource)
            {
                nextIntersection = GetNextIntersectionAlongSource(previousIntersection);

                subcurve = GetSourceSubcurve(previousIntersection, nextIntersection);
            }
            else
            {
                int previousTargetIdx = IntersectionOrders[previousIntersection].Value;

                // If there are vertical rings, there can be 2 intersections at the exact same target distance
                int otherDirectionIdx = GetNextAlongTargetIdx(
                    previousTargetIdx, !continueForward,
                    IntersectionsAlongTarget);

                double epsilon = MathUtils.GetDoubleSignificanceEpsilon(
                    previousIntersection.Point.X,
                    previousIntersection.Point.Y);

                int nextAlongTargetIdx;
                if (MathUtils.AreEqual(
                        IntersectionsAlongTarget[otherDirectionIdx].VirtualTargetVertex,
                        IntersectionsAlongTarget[previousTargetIdx].VirtualTargetVertex,
                        epsilon))
                {
                    // vertical ring, 2 intersections at same XY location
                    nextAlongTargetIdx = otherDirectionIdx;
                }
                else
                {
                    nextAlongTargetIdx = GetNextAlongTargetIdx(
                        previousTargetIdx, continueForward,
                        IntersectionsAlongTarget);
                }

                nextIntersection = IntersectionsAlongTarget[nextAlongTargetIdx];

                subcurve = GetTargetSubcurve(_target, previousIntersection,
                                             nextIntersection, continueForward);
            }

            return(nextIntersection);
        }
Example #19
0
        public Pnt3D GetNonIntersectingSourcePoint([NotNull] Linestring sourceRing,
                                                   double distanceFromIntersectionAsRatio)
        {
            Assert.NotNull(SegmentIntersection);

            double factor;

            var searchForward = true;

            if (Type == IntersectionPointType.LinearIntersectionStart)
            {
                searchForward = false;
                factor        = SegmentIntersection.GetLinearIntersectionStartFactor(true);
            }
            else if (Type == IntersectionPointType.LinearIntersectionEnd)
            {
                factor = SegmentIntersection.GetLinearIntersectionEndFactor(true);
            }
            else
            {
                factor = SegmentIntersection.GetIntersectionPointFactorAlongSource();
            }

            Line3D segment = sourceRing[SegmentIntersection.SourceIndex];

            if (searchForward)
            {
                factor += distanceFromIntersectionAsRatio;
            }
            else
            {
                factor -= distanceFromIntersectionAsRatio;
            }

            if (factor >= 1)
            {
                segment =
                    sourceRing[
                        sourceRing.NextIndexInRing(SegmentIntersection.SourceIndex)];
                factor -= 1;
            }
            else if (factor < 0)
            {
                segment =
                    sourceRing[
                        sourceRing.PreviousIndexInRing(SegmentIntersection.SourceIndex)];
                factor += 1;
            }

            return(segment.GetPointAlong(factor, true));
        }
Example #20
0
        /// <summary>
        /// Determines whether any of the rings in rings1 interior-intersects the other ring.
        /// If available, the spatial index of the other ring is used.
        /// </summary>
        /// <param name="rings1"></param>
        /// <param name="otherRing"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public static bool InteriorIntersectXY([NotNull] IEnumerable <Linestring> rings1,
                                               [NotNull] Linestring otherRing,
                                               double tolerance)
        {
            foreach (Linestring ring1 in rings1)
            {
                if (InteriorIntersectXY(ring1, otherRing, tolerance))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #21
0
        private IList <Tuple <Linestring, Linestring> > GetEqualBoundaryRingPairs()
        {
            var boundaryIntersectingRings = new List <Tuple <Linestring, Linestring> >(0);

            // W.r.t. AreaContainsXY returning null: if the start point is on the boundary there
            // are duplicate rings (otherwise they would be 'intesected' and we would not get here.

            for (int j = 0; j < _subcurveNavigator.Source.PartCount; j++)
            {
                var sourceIntersections = _subcurveNavigator
                                          .IntersectionPoints.Where(ip => ip.SourcePartIndex == j)
                                          .ToList();

                if (sourceIntersections.Count != 2)
                {
                    continue;
                }

                if (sourceIntersections[0].TargetPartIndex !=
                    sourceIntersections[1].TargetPartIndex)
                {
                    continue;
                }

                if (sourceIntersections[0].Type != IntersectionPointType.LinearIntersectionStart ||
                    sourceIntersections[1].Type != IntersectionPointType.LinearIntersectionEnd)
                {
                    continue;
                }

                if (!sourceIntersections[0].Point.EqualsXY(
                        sourceIntersections[1].Point,
                        _subcurveNavigator.Tolerance))
                {
                    continue;
                }

                // If there are exactly 2 intersection points both linear start/end in the same point:
                // The ring is covered by the respective target index
                Linestring sourceRing =
                    _subcurveNavigator.Source.GetPart(sourceIntersections[0].SourcePartIndex);
                Linestring targetRing =
                    _subcurveNavigator.Target.GetPart(sourceIntersections[0].TargetPartIndex);

                boundaryIntersectingRings.Add(
                    new Tuple <Linestring, Linestring>(sourceRing, targetRing));
            }

            return(boundaryIntersectingRings);
        }
Example #22
0
        /// <summary>
        /// Determines whether the source ring is contained within the target.
        /// </summary>
        /// <param name="sourceRing"></param>
        /// <param name="targetRing"></param>
        /// <param name="intersectionPoints"></param>
        /// <param name="tolerance"></param>
        /// <param name="disregardRingOrientation"></param>
        /// <returns></returns>
        public static bool?WithinAreaXY(
            [NotNull] Linestring sourceRing,
            [NotNull] Linestring targetRing,
            [NotNull] IEnumerable <IntersectionPoint3D> intersectionPoints,
            double tolerance, bool disregardRingOrientation)
        {
            Pnt3D nonIntersectingSourcePnt =
                GetNonIntersectingSourcePoint(sourceRing, intersectionPoints);

            IEnumerable <Pnt3D> checkPoints = nonIntersectingSourcePnt != null
                                                                 ? new[] { nonIntersectingSourcePnt }
                                                                 : sourceRing.GetPoints();

            return(Contains(targetRing, checkPoints, tolerance, disregardRingOrientation));
        }
        private static IEnumerable <Linestring> GetUnused(ISegmentList linestrings,
                                                          HashSet <int> usedIndexes)
        {
            for (int i = 0; i < linestrings.PartCount; i++)
            {
                if (usedIndexes.Contains(i))
                {
                    continue;
                }

                Linestring cutLine = linestrings.GetPart(i);

                yield return(cutLine);
            }
        }
Example #24
0
        public bool RemoveLinestring(Linestring linestring)
        {
            bool result = Linestrings.Remove(linestring);

            foreach (Linestring l in Linestrings)
            {
                UpdateBounds(l);
            }

            SpatialIndex = null;

            CacheStartIndexes();

            return(result);
        }
Example #25
0
        private bool TryCutCookie <T>(Linestring cutRing, T origPolygon, out T updatedOriginal,
                                      out RingGroup innerResult,
                                      bool allowEmptyResults = false) where T : MultiLinestring
        {
            updatedOriginal = null;

            if (TryCutCookie(origPolygon, cutRing, _subcurveNavigator.Tolerance, out innerResult,
                             allowEmptyResults))
            {
                updatedOriginal = origPolygon;
                return(true);
            }

            return(false);
        }
Example #26
0
        /// <summary>
        /// Determines whether the source ring contains the target.
        /// </summary>
        /// <param name="sourceRing"></param>
        /// <param name="target"></param>
        /// <param name="intersectionPoints"></param>
        /// <param name="tolerance"></param>
        /// <param name="disregardRingOrientation"></param>
        /// <returns></returns>
        public static bool?AreaContainsXY(
            [NotNull] Linestring sourceRing,
            [NotNull] Linestring target,
            [NotNull] IEnumerable <IntersectionPoint3D> intersectionPoints,
            double tolerance, bool disregardRingOrientation)
        {
            Pnt3D nonIntersectingTargetPnt =
                GetNonIntersectingTargetPoint(target, intersectionPoints);

            // Check if ring1 contains ring2 (or its check points):
            IEnumerable <Pnt3D> checkPoints = nonIntersectingTargetPnt != null
                                                                 ? new[] { nonIntersectingTargetPnt }
                                                                 : target.GetPoints();

            return(Contains(sourceRing, checkPoints, tolerance, disregardRingOrientation));
        }
Example #27
0
        private void UpdateSpatialIndex([NotNull] Linestring additionalLinestring,
                                        int partIndex)
        {
            if (SpatialIndex == null)
            {
                return;
            }

            for (int i = 0; i < additionalLinestring.SegmentCount; i++)
            {
                Line3D line = additionalLinestring[i];

                SpatialIndex.Add(new SegmentIndex(partIndex, i),
                                 line.XMin, line.YMin, line.XMax, line.YMax);
            }
        }
Example #28
0
        public bool?TargetDeviatesToLeftOfSourceRing([NotNull] Linestring sourceRing,
                                                     [NotNull] Linestring targetRing)
        {
            if (TargetDeviatesToLeftOfSource != null)
            {
                return(TargetDeviatesToLeftOfSource);
            }

            Pnt3D nonIntersectingTargetPnt =
                Assert.NotNull(GetNonIntersectingTargetPoint(targetRing, 0.5));

            TargetDeviatesToLeftOfSource =
                !IsOnTheRightSide(sourceRing, nonIntersectingTargetPnt, true);

            return(TargetDeviatesToLeftOfSource);
        }
Example #29
0
        private static int AssignInteriorRing([NotNull] Linestring interiorRing,
                                              IEnumerable <RingGroup> resultPolys,
                                              double tolerance)
        {
            int assignmentCount = 0;

            foreach (RingGroup resultPoly in resultPolys)
            {
                if (GeomRelationUtils.PolycurveContainsXY(
                        resultPoly.ExteriorRing, interiorRing.StartPoint, tolerance))
                {
                    resultPoly.AddInteriorRing(interiorRing);
                    assignmentCount++;
                }
            }

            return(assignmentCount);
        }
Example #30
0
        private bool TryCutCookie <T>(Linestring cutRing,
                                      IList <T> origPolygons,
                                      out T updatedOriginal,
                                      out RingGroup innerResult) where T : MultiLinestring
        {
            updatedOriginal = null;
            innerResult     = null;

            foreach (T origPolygon in origPolygons.ToList())
            {
                if (TryCutCookie(cutRing, origPolygon, out updatedOriginal, out innerResult))
                {
                    return(true);
                }
            }

            return(false);
        }