Exemplo n.º 1
0
        private static IPolyline BufferTargetLine([NotNull] IPolyline targetLine,
                                                  [NotNull] TargetBufferOptions options,
                                                  [CanBeNull] IEnvelope envelopeScope,
                                                  [CanBeNull]
                                                  NotificationCollection bufferNotifications,
                                                  [CanBeNull] ITrackCancel trackCancel)
        {
            Assert.ArgumentNotNull(targetLine, nameof(targetLine));
            Assert.ArgumentCondition(!targetLine.IsEmpty,
                                     "BufferTargetLine: Target line is empty.");

            IPolyline result = null;

            IPolygon targetBuffer;

            if (AdjustUtils.TryBuffer(targetLine,
                                      options.BufferDistance,
                                      options.LogInfoPointThreshold,
                                      "Buffering target geometry...",
                                      bufferNotifications, out targetBuffer))
            {
                Assert.NotNull(targetBuffer, "targetBuffer");

                if (trackCancel != null && !trackCancel.Continue())
                {
                    return(targetLine);
                }

                if (options.EnforceMinimumBufferSegmentLength)
                {
                    // TODO: removing short segments is slow if many adjacent segments
                    //		 need to be removed.
                    if (trackCancel != null && !trackCancel.Continue())
                    {
                        return(targetLine);
                    }

                    if (((IPointCollection)targetLine).PointCount > options.LogInfoPointThreshold)
                    {
                        _msg.Info("Removing short segments from buffer...");
                    }

                    EnforceMinimumSegmentLength(targetBuffer,
                                                options.BufferMinimumSegmentLength,
                                                envelopeScope);
                }

                result = GeometryFactory.CreatePolyline(targetBuffer);

                Marshal.ReleaseComObject(targetBuffer);
            }

            return(result);
        }
Exemplo n.º 2
0
        public SubcurveFilter PrepareFilter(
            [NotNull] IList <IPolyline> preprocessedSourceLines,
            [NotNull] IList <IGeometry> targetGeometries,
            bool useMinimalTolerance,
            [NotNull] ReshapeCurveFilterOptions filterOptions)
        {
            _useMinimalTolerance = useMinimalTolerance;
            _filterOptions       = filterOptions;

            ReleaseFilterObjects();

            if (filterOptions.OnlyInVisibleExtent)
            {
                Assert.NotNull(_extentProvider);
                _currentlyVisibleExtents = new List <IEnvelope>();

                // add the lens window extents
                _currentlyVisibleExtents.AddRange(
                    _extentProvider.GetVisibleLensWindowExtents());

                // plus the main map window
                _currentlyVisibleExtents.Add(_extentProvider.GetCurrentExtent());
            }

            if (filterOptions.ExcludeOutsideTolerance)
            {
                // NOTE: Buffer lines / outlines -> otherwise we miss lines for individual reshapes
                //		 and clip on extent (pre-process) before buffering to improve performance

                var sourceOutline =
                    (IPolyline)GeometryUtils.UnionGeometries(preprocessedSourceLines);

                const int logInfoPointCountThreshold = 10000;
                var       bufferNotifications        = new NotificationCollection();

                if (AdjustUtils.TryBuffer(sourceOutline,
                                          filterOptions.ExcludeTolerance,
                                          logInfoPointCountThreshold,
                                          "Calculating reshape line tolerance buffer...",
                                          bufferNotifications,
                                          out _mustBeWithinSourceBuffer))
                {
                    ExclusionOutsideSourceBufferLine =
                        GeometryFactory.CreatePolyline(
                            Assert.NotNull(_mustBeWithinSourceBuffer));
                }
                else
                {
                    _msg.WarnFormat(
                        "Unable to calculate reshape line tolerance buffer: {0}",
                        bufferNotifications.Concatenate(". "));
                }

                Marshal.ReleaseComObject(sourceOutline);
            }

            if (filterOptions.ExcludeResultingInOverlaps)
            {
                _targetUnionPoly = ReshapeUtils.CreateUnionPolygon(
                    targetGeometries, _useMinimalTolerance);
            }

            return(this);
        }