Exemple #1
0
        public void Prepare(IEnumerable <IFeature> sourceFeatures,
                            IList <IFeature> targetFeatures,
                            IEnvelope processingExtent,
                            bool useMinimalTolerance,
                            ReshapeCurveFilterOptions filterOptions)
        {
            ClipExtent          = processingExtent;
            UseMinimumTolerance = useMinimalTolerance;

            IList <IGeometry> sourceGeometries =
                GdbObjectUtils.GetGeometries(sourceFeatures);

            // Consider remembering the pre-processed sources. But clipping is really fast.
            List <IPolyline> preprocessedSource =
                sourceGeometries
                .Select(
                    g => ChangeGeometryAlongUtils.GetPreprocessedGeometryForExtent(
                        g, processingExtent))
                .ToList();

            var targetGeometries = GdbObjectUtils.GetGeometries(targetFeatures);

            SubcurveFilter.PrepareFilter(
                preprocessedSource, targetGeometries, useMinimalTolerance, filterOptions);

            foreach (IGeometry sourceGeometry in sourceGeometries)
            {
                Marshal.ReleaseComObject(sourceGeometry);
            }

            foreach (IGeometry targetGeometry in targetGeometries)
            {
                Marshal.ReleaseComObject(targetGeometry);
            }
        }
Exemple #2
0
        private bool CalculateReshapeSubcurves(
            [NotNull] IPolyline preprocessedSourcePolyline,
            [NotNull] IPolyline targetPolyline,
            [NotNull] IGeometryCollection differences,
            [NotNull] IPointCollection intersectionPoints,
            [NotNull] ICollection <CutSubcurve> resultList,
            [CanBeNull] ITrackCancel trackCancel)
        {
            var canReshape = false;

            foreach (
                CutSubcurve subcurve in
                CalculateReshapeSubcurves(preprocessedSourcePolyline, differences,
                                          intersectionPoints, targetPolyline))
            {
                if (trackCancel != null && !trackCancel.Continue())
                {
                    return(canReshape);
                }

                if (subcurve.CanReshape)
                {
                    canReshape = true;
                }

                subcurve.IsFiltered = SubcurveFilter != null &&
                                      SubcurveFilter.IsExcluded(subcurve);

                resultList.Add(subcurve);
            }

            return(canReshape);
        }
Exemple #3
0
        /// <summary>
        /// Calculates the DifferenceLines and adds the subcurves to the provided result list.
        /// </summary>
        /// <param name="sourceGeometry"></param>
        /// <param name="targetPolyline"></param>
        /// <param name="resultList">All resulting subcurves including the ones that cannot be used to reshape</param>
        /// <param name="trackCancel"></param>
        /// <returns></returns>
        public ReshapeAlongCurveUsability CalculateSubcurves(
            IGeometry sourceGeometry,
            IPolyline targetPolyline,
            IList <CutSubcurve> resultList,
            ITrackCancel trackCancel)
        {
            Assert.ArgumentNotNull(sourceGeometry);
            Assert.ArgumentNotNull(targetPolyline);
            Assert.ArgumentNotNull(resultList);

            Stopwatch watch = _msg.DebugStartTiming();

            IPolyline preprocessedSourcePolyline =
                ChangeGeometryAlongUtils.GetPreprocessedGeometryForExtent(
                    sourceGeometry, ClipExtent);

            if (preprocessedSourcePolyline.IsEmpty)
            {
                _msg.WarnFormat("Source feature is outside the processing extent.");
                return(ReshapeAlongCurveUsability.NoSource);
            }

            IPointCollection    intersectionPoints;
            IGeometryCollection differences = CalculateDifferences(
                preprocessedSourcePolyline,
                targetPolyline,
                trackCancel,
                out intersectionPoints);

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

            if (differences == null)
            {
                return(ReshapeAlongCurveUsability.AlreadyCongruent);
            }

            SubcurveFilter?.PrepareForSource(sourceGeometry);

            bool canReshape = CalculateReshapeSubcurves(
                preprocessedSourcePolyline, targetPolyline, differences,
                intersectionPoints, resultList, trackCancel);

            JoinNonForkingSubcurves(resultList);

            Marshal.ReleaseComObject(preprocessedSourcePolyline);
            Marshal.ReleaseComObject(differences);

            _msg.DebugStopTiming(
                watch, "RecalculateReshapableSubcurves: Total number of curves: {0}.",
                resultList.Count);

            if (canReshape)
            {
                return(ReshapeAlongCurveUsability.CanReshape);
            }

            return(resultList.Count == 0
                                       ? ReshapeAlongCurveUsability.NoReshapeCurves
                                       : ReshapeAlongCurveUsability.InsufficientOrAmbiguousReshapeCurves);
        }