예제 #1
0
        private IList <IFeature> SplitNetworkEdge(IFeature edgeFeature,
                                                  IList <IGeometry> newGeometries)
        {
            IList <IFeature> cutResultFeatures;

            Assert.AreEqual(1, newGeometries.Count,
                            "Unexpected number of split geometries. Edge features require split point geometries.");

            IGeometry splitPoints = newGeometries[0];

            if (splitPoints.IsEmpty)
            {
                cutResultFeatures = new List <IFeature>(0);
            }
            else
            {
                NotifySplittingObservers(edgeFeature, new List <IFeature>(0));

                IList <IFeature> connectedEdges =
                    Assert.NotNull(_networkFeatureCutter)
                    .SplitNetworkEdge(edgeFeature, (IPointCollection)splitPoints);

                InsertedFeaturesByOriginal.Add(
                    new KeyValuePair <IFeature, IList <IFeature> >(
                        edgeFeature,
                        connectedEdges.Where(feature => feature != edgeFeature).ToList()));

                cutResultFeatures = connectedEdges;

                foreach (IFeature resultFeature in cutResultFeatures)
                {
                    ResultFeatures.Add(resultFeature);
                }
            }

            return(cutResultFeatures);
        }
예제 #2
0
        private IList <IFeature> StoreGeometries(
            [NotNull] ICollection <IGeometry> newGeometries,
            [NotNull] IFeature originalFeature,
            [NotNull] IGeometry geometryToStoreInOriginal,
            [CanBeNull] ITrackCancel trackCancel)
        {
            var storedFeatures = new List <IFeature>(newGeometries.Count + 1);

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

            // store the update
            IFeature stored = AssignGeometryToFeature(geometryToStoreInOriginal,
                                                      originalFeature,
                                                      false);

            if (stored != null)
            {
                storedFeatures.Add(stored);
            }

            // store other new geometries as inserts
            foreach (IGeometry modifyGeometry in
                     newGeometries.Where(polycurve => polycurve != geometryToStoreInOriginal))
            {
                if (trackCancel != null && !trackCancel.Continue())
                {
                    return(storedFeatures);
                }

                IFeature newFeature =
                    AssignGeometryToFeature(modifyGeometry, originalFeature, true);

                if (newFeature != null)
                {
                    storedFeatures.Add(newFeature);
                }
            }

            var inserts = new List <IFeature>(newGeometries.Count);

            foreach (IFeature storedFeature in storedFeatures)
            {
                ResultFeatures.Add(storedFeature);

                if (storedFeature != originalFeature)
                {
                    inserts.Add(storedFeature);
                }
            }

            NotifySplittingObservers(originalFeature, inserts);

            foreach (IFeature feature in storedFeatures)
            {
                feature.Store();
            }

            InsertedFeaturesByOriginal.Add(
                new KeyValuePair <IFeature, IList <IFeature> >(originalFeature, inserts));

            return(storedFeatures);
        }