Esempio n. 1
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());
        }
Esempio n. 2
0
        /// <summary>
        /// Removes the overlap between the source and the target from the source.
        /// - Vertical targets are not supported.
        /// - Counter-clockwise oriented (interior) rings are supported. The counter-clockwise
        ///   rings have their 'interior' on the outside, i.e. their overlap 'removed' on the
        ///   outside, if the target is also counter-clockwise (i.e. inner rings are unioned).
        /// - If the target is equal to the source in XY, the result is one empty Linestring.
        /// - If the target is disjoint or completely within the source, an empty list is returned.
        /// </summary>
        /// <returns></returns>
        public IList <Linestring> RemoveOverlapXY()
        {
            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 - positive rings cancel each other out:
                Linestring resultRing =
                    IsExterior(_sourceRing) && IsExterior(_target)
                                                ? Linestring.CreateEmpty()
                                                : _sourceRing.Clone();

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

            return(_target.ClockwiseOriented.Value
                                       ? GetLeftSideRings()
                                       : GetRightSideRings());
        }