Exemplo n.º 1
0
        private static void ExpectResult(ReshapeInfo reshapeInfo,
                                         RingReshapeSideOfLine reshapeSide, double area,
                                         int ringCount, int exteriorRingCount)
        {
            Assert.AreEqual(reshapeSide, reshapeInfo.RingReshapeSide);

            Assert.AreEqual(Math.Round(area, 2),
                            Math.Round(((IArea)reshapeInfo.GeometryToReshape).Area, 2),
                            "Wrong result area.");

            Assert.AreEqual(ringCount,
                            ((IGeometryCollection)reshapeInfo.GeometryToReshape).GeometryCount,
                            "Wrong number of rings in result.");
            Assert.AreEqual(exteriorRingCount,
                            ((IPolygon)reshapeInfo.GeometryToReshape).ExteriorRingCount,
                            "Wrong number of exterior rings in result.");
        }
Exemplo n.º 2
0
        private static IPath GetChangedSegments(ReshapeInfo reshapeInfo,
                                                RingReshapeSideOfLine proposedSide)
        {
            IPath replacedSegments;

            if (reshapeInfo.ReplacedSegments == null)
            {
                var   ringToReshape  = (IRing)reshapeInfo.GetGeometryPartToReshape();
                IPath cutReshapePath = Assert.NotNull(reshapeInfo.CutReshapePath).Path;

                replacedSegments = SegmentReplacementUtils.GetSegmentsToReplace(
                    ringToReshape, cutReshapePath.FromPoint, cutReshapePath.ToPoint,
                    proposedSide);
            }
            else
            {
                replacedSegments = reshapeInfo.ReplacedSegments;
            }

            return(replacedSegments);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Determines whether the proposed reshape side and result is allowed regarding other
        /// criteria than the geometric situation. These could be determined by the current reshape
        /// options, such as allowed target overlaps or updates to the geometry outside the visible
        /// extent.
        /// This method is called after the default reshape side has been determined
        /// and the ReshapeSide property of the reshape info is set. It takes precedence over the
        /// boolean parameter useNonDefaultReshapeSide available in the reshape methods.
        /// </summary>
        /// <param name="reshapeInfo"></param>
        /// <param name="proposedSide"></param>
        /// <param name="notifications"></param>
        /// <returns></returns>
        public bool IsReshapeSideAllowed([NotNull] ReshapeInfo reshapeInfo,
                                         RingReshapeSideOfLine proposedSide,
                                         [CanBeNull] NotificationCollection notifications)
        {
            if (proposedSide == RingReshapeSideOfLine.Undefined)
            {
                // Special case, such as zig-zag
                return(true);
            }

            if (_allowedExtents != null &&
                !ChangesVisibleInAnyExtent(_allowedExtents, GetChangedSegments(
                                               reshapeInfo,
                                               proposedSide)))
            {
                NotificationUtils.Add(notifications,
                                      "Reshape side was swapped because otherwise the geometry would change outside the allowed (visible) extents. This is prevented by the option Exclude reshapes that are not completely within main map extent'.");

                return(false);
            }

            if (_targetUnionPoly != null)
            {
                IPolygon proposedResult =
                    proposedSide == RingReshapeSideOfLine.Left
                                                ? reshapeInfo.LeftReshapePolygon
                                                : reshapeInfo.RightReshapePolygon;

                if (ReshapeUtils.ResultsInOverlapWithTarget(reshapeInfo, proposedResult,
                                                            _targetUnionPoly))
                {
                    NotificationUtils.Add(notifications,
                                          "Reshape side was swapped because otherwise the result would overlap a target. This is prevented by the option 'Exclude reshape lines that result in overlaps with target features'.");
                    return(false);
                }
            }

            return(true);
        }