Beispiel #1
0
        private async Task <bool> UpdateFeatures(List <Feature> selectedFeatures,
                                                 List <CutSubcurve> cutSubcurves,
                                                 CancelableProgressor progressor)
        {
            CancellationToken cancellationToken =
                progressor?.CancellationToken ?? new CancellationTokenSource().Token;

            ChangeAlongCurves newChangeAlongCurves;

            IList <Feature> targetFeatures = Assert.NotNull(_changeAlongCurves.TargetFeatures);

            List <ResultFeature> updatedFeatures = ChangeFeaturesAlong(
                selectedFeatures, targetFeatures, cutSubcurves, cancellationToken,
                out newChangeAlongCurves);

            _changeAlongCurves = newChangeAlongCurves;

            _feedback.Update(_changeAlongCurves);

            HashSet <long> editableClassHandles =
                MapUtils.GetLayers <BasicFeatureLayer>(MapView.Active, bfl => bfl.IsEditable)
                .Select(l => l.GetTable().Handle.ToInt64()).ToHashSet();

            // Updates:
            Dictionary <Feature, Geometry> resultFeatures =
                updatedFeatures
                .Where(f => GdbPersistenceUtils.CanChange(
                           f, editableClassHandles, RowChangeType.Update))
                .ToDictionary(r => r.Feature, r => r.NewGeometry);

            // Inserts (in case of cut), grouped by original feature:
            Dictionary <Feature, IList <Geometry> > insertsByOriginal =
                updatedFeatures
                .Where(f => GdbPersistenceUtils.CanChange(
                           f, editableClassHandles, RowChangeType.Insert))
                .GroupBy(f => f.Feature, f => f.NewGeometry)
                .ToDictionary(g => g.Key, g => (IList <Geometry>)g.ToList());

            // TODO
            //LogReshapeResults(result, selection.Count);

            var success = await GdbPersistenceUtils.SaveInOperationAsync(
                EditOperationDescription, resultFeatures, insertsByOriginal);

            return(success);
        }
Beispiel #2
0
 private static async Task <bool> SaveAsync(IDictionary <Feature, Geometry> resultFeatures)
 {
     return(await GdbPersistenceUtils.SaveInOperationAsync(
                "Advanced reshape", resultFeatures));
 }