Exemple #1
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!
        }
Exemple #2
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));
        }
Exemple #3
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));
        }