コード例 #1
0
        private Task ModifyLayerSelection(SelectionCombinationMethod method)
        {
            Task t = QueuedTask.Run(() =>
            {
                System.Diagnostics.Debug.WriteLine("Mod Layer Selection");
                if (MapView.Active == null || SelectedLayer == null || UicSelection == null)
                {
                    return;
                }

                //if (!ValidateExpresion(false))
                //    return;
                string wc = string.Format("FacilityID = \"{0}\"", UicSelection);
                System.Diagnostics.Debug.WriteLine(wc);
                SelectedLayer.Select(new QueryFilter()
                {
                    WhereClause = wc
                }, method);
                MapView.Active.ZoomToSelected();
            });

            this.UpdateModel(UicSelection);
            this.showPaneTest("esri_editing_AttributesDockPane");
            return(t);
        }
コード例 #2
0
ファイル: Selector.cs プロジェクト: esride-jts/ProSuite
        public static void SelectLayersFeaturesByOids(
            KeyValuePair <BasicFeatureLayer, List <long> > featuresOfLayer,
            SelectionCombinationMethod method)
        {
            if (!featuresOfLayer.Value.Any())
            {
                return;
            }

            if (method == SelectionCombinationMethod.New)
            {
                //since SelectionCombinationMethod.New is only applied to
                //the current layer but selections of other layers remain,
                //we manually need to clear all selections first.
                SelectionUtils.ClearSelection(MapView.Active.Map);
            }

            {
                var qf = new QueryFilter
                {
                    ObjectIDs = featuresOfLayer.Value
                };
                featuresOfLayer.Key.Select(qf, method);
            }
        }
コード例 #3
0
ファイル: Selector.cs プロジェクト: esride-jts/ProSuite
        public static void SelectLayersFeaturesByOids(
            [CanBeNull] Dictionary <BasicFeatureLayer, List <long> > featuresPerLayer,
            SelectionCombinationMethod method)
        {
            if (featuresPerLayer == null)
            {
                return;
            }

            if (method == SelectionCombinationMethod.New)
            {
                //since SelectionCombinationMethod.New is only applied to
                //the current layer but selections of other layers remain,
                //we manually need to clear all selections first.
                SelectionUtils.ClearSelection(MapView.Active.Map);
            }

            foreach (KeyValuePair <BasicFeatureLayer, List <long> > kvp in featuresPerLayer)
            {
                var qf = new QueryFilter
                {
                    ObjectIDs = kvp.Value
                };
                kvp.Key.Select(qf, method);
            }
        }
コード例 #4
0
ファイル: SelectionUtils.cs プロジェクト: sungaoyong/ProSuite
        /// <summary>
        /// Selects the requested features from the specified layer and immediately disposes
        /// the selection to avoid selection and immediate de-selection (for selection method XOR)
        /// because it is called in 2 threads.
        /// </summary>
        /// <param name="featureLayer"></param>
        /// <param name="combinationMethod"></param>
        /// <param name="objectIds"></param>
        public static void SelectFeatures([NotNull] BasicFeatureLayer featureLayer,
                                          SelectionCombinationMethod combinationMethod,
                                          [NotNull] IReadOnlyList <long> objectIds)
        {
            var queryFilter = new QueryFilter
            {
                ObjectIDs = objectIds
            };

            using (Selection selection = featureLayer.Select(queryFilter, combinationMethod))
            {
                if (_msg.IsVerboseDebugEnabled)
                {
                    _msg.VerboseDebug(
                        $"Selected OIDs {StringUtils.Concatenate(selection.GetObjectIDs(), ", ")} " +
                        $"from {featureLayer.Name}");
                }
            }
        }
        private Task ModifyLayerSelection(SelectionCombinationMethod method)
        {
            return(QueuedTask.Run(() =>
            {
                if (MapView.Active == null || SelectedLayer == null || WhereClause == null)
                {
                    return;
                }

                if (!ValidateExpresion(false))
                {
                    return;
                }

                SelectedLayer.Select(new QueryFilter()
                {
                    WhereClause = WhereClause
                }, method);
            }));
        }
    private Task ModifyLayerSelection(SelectionCombinationMethod method)
    {
      return QueuedTask.Run(() =>
      {
        if (MapView.Active == null || SelectedLayer == null || WhereClause == null)
          return;

        if (!ValidateExpresion(false))
          return;

        SelectedLayer.Select(new QueryFilter() { WhereClause = WhereClause }, method);
      });
    }
コード例 #7
0
        private async Task <bool> OnSelectionSketchComplete(Geometry sketchGeometry,
                                                            CancelableProgressor progressor)
        {
            // TODO: Add Utils method to KeyboardUtils to do it in the WPF way
            SelectionCombinationMethod selectionMethod =
                KeyboardUtils.IsModifierPressed(Keys.Shift)
                                        ? SelectionCombinationMethod.XOR
                                        : SelectionCombinationMethod.New;

            Geometry selectionGeometry;
            var      pickerWindowLocation = new Point(0, 0);

            Dictionary <BasicFeatureLayer, List <long> > candidatesOfManyLayers =
                await QueuedTaskUtils.Run(() =>
            {
                DisposeOverlays();

                selectionGeometry    = GetSelectionGeometry(sketchGeometry);
                pickerWindowLocation =
                    MapView.Active.MapToScreen(selectionGeometry.Extent.Center);

                // find all features spatially related with selectionGeometry
                return(FindFeaturesOfAllLayers(selectionGeometry));
            });

            if (!candidatesOfManyLayers.Any())
            {
                //no candidate (user clicked into empty space): clear selection
                await QueuedTask.Run(() =>
                {
                    SelectionUtils.ClearSelection(ActiveMapView.Map);
                });

                return(false);
            }

            if (SketchingMoveType == SketchingMoveType.Click)
            {
                //note if necessary add a virtual core method here for overriding

                if (GetSelectionSketchMode() == SelectionMode.Original
                    )             //alt was pressed: select all xy
                {
                    await QueuedTask.Run(() =>
                    {
                        Selector.SelectLayersFeaturesByOids(
                            candidatesOfManyLayers, selectionMethod);
                    });
                }

                // select a single feature using feature reduction and picker
                else
                {
                    IEnumerable <KeyValuePair <BasicFeatureLayer, List <long> > > candidatesOfLayers =
                        await QueuedTask.Run(
                            () => GeometryReducer.GetReducedset(candidatesOfManyLayers));

                    // show picker if more than one candidate
                    if (GeometryReducer.ContainsManyFeatures(candidatesOfManyLayers))
                    {
                        List <IPickableItem> pickables = new List <IPickableItem>();
                        foreach (var layerCandidates in candidatesOfLayers)
                        {
                            pickables.AddRange(
                                await QueuedTask.Run(
                                    () => PickerUI.Picker.CreatePickableFeatureItems(
                                        layerCandidates)));
                        }

                        var picker = new PickerUI.Picker(pickables, pickerWindowLocation);

                        var item = await picker.PickSingle() as PickableFeatureItem;

                        if (item != null)
                        {
                            var kvp = new KeyValuePair <BasicFeatureLayer, List <long> >(
                                item.Layer, new List <long> {
                                item.Oid
                            });

                            await QueuedTask.Run(() =>
                            {
                                Selector.SelectLayersFeaturesByOids(
                                    kvp, selectionMethod);
                            });
                        }
                    }
                    else
                    {
                        await QueuedTask.Run(() =>
                        {
                            Selector.SelectLayersFeaturesByOids(
                                candidatesOfLayers.First(), selectionMethod);
                        });
                    }
                }
            }

            if (SketchingMoveType == SketchingMoveType.Drag)
            {
                //CTRL was pressed: picker shows FC's to select from
                if (GetSelectionSketchMode() == SelectionMode.UserSelect)
                {
                    List <IPickableItem> pickingCandidates = await QueuedTask.Run(() =>
                    {
                        List <FeatureClassInfo> featureClassInfos =
                            Selector.GetSelectableFeatureclassInfos();

                        return(PickableItemAdapter.Get(featureClassInfos));
                    });

                    var picker = new PickerUI.Picker(pickingCandidates, pickerWindowLocation);

                    var item = await picker.PickSingle() as PickableFeatureClassItem;

                    if (item != null)
                    {
                        await QueuedTask.Run(() =>
                        {
                            item.BelongingFeatureLayers.ForEach(layer =>
                            {
                                List <long> oids = candidatesOfManyLayers[layer];
                                QueryFilter qf   = new QueryFilter {
                                    ObjectIDs = oids
                                };
                                layer.Select(qf, selectionMethod);
                            });
                        });
                    }
                }

                //no modifier pressed: select all in envelope
                else
                {
                    await QueuedTask.Run(() =>
                    {
                        Selector.SelectLayersFeaturesByOids(
                            candidatesOfManyLayers, selectionMethod);
                    });
                }
            }

            MapView activeMapView = MapView.Active;

            await QueuedTask.Run(() =>
                                 ProcessSelection(
                                     SelectionUtils.GetSelectedFeatures(activeMapView),
                                     progressor));

            return(true);
        }