Exemplo n.º 1
0
        private static Overlaps SelectOverlaps(Overlaps overlaps, Geometry sketch)
        {
            if (overlaps == null)
            {
                return(new Overlaps());
            }

            int selectionTolerancePixels = 3;

            bool singlePick = ToolUtils.IsSingleClickSketch(sketch);

            if (singlePick)
            {
                sketch = ToolUtils.GetSinglePickSelectionArea(sketch, selectionTolerancePixels);
            }

            Overlaps result = overlaps.SelectNewOverlaps(
                o => o.GeometryType == GeometryType.Polyline &&
                IsOverlapSelected(sketch, o, singlePick));

            // in case of single pick the line has priority
            if (!result.HasOverlaps() || !singlePick)
            {
                result.AddGeometries(overlaps,
                                     g => g.GeometryType == GeometryType.Polygon &&
                                     IsOverlapSelected(sketch, g, singlePick));
            }

            return(result);
        }
Exemplo n.º 2
0
        private Overlaps SelectOverlaps(Overlaps overlaps, Geometry sketch)
        {
            if (overlaps == null)
            {
                return(new Overlaps());
            }

            sketch = ToolUtils.SketchToSearchGeometry(sketch, GetSelectionTolerancePixels(),
                                                      out bool singlePick);

            // in case of single pick the line has priority...
            Overlaps result = overlaps.SelectNewOverlaps(
                o => o.GeometryType == GeometryType.Polyline &&
                ToolUtils.IsSelected(sketch, o, singlePick));

            // ... over the polygon
            if (!result.HasOverlaps() || !singlePick)
            {
                result.AddGeometries(overlaps,
                                     g => g.GeometryType == GeometryType.Polygon &&
                                     ToolUtils.IsSelected(sketch, g, singlePick));
            }

            return(result);
        }
Exemplo n.º 3
0
        public static RemoveOverlapsResponse RemoveOverlaps(
            [NotNull] RemoveOverlapsRequest request,
            [CanBeNull] ITrackCancel trackCancel = null)
        {
            // Unpack request
            bool explodeMultiparts          = request.ExplodeMultipartResults;
            bool storeOverlapsAsNewFeatures = request.StoreOverlapsAsNewFeatures;

            GdbTableContainer container = ProtobufConversionUtils.CreateGdbTableContainer(
                request.ClassDefinitions, null, out _);

            IList <IFeature> selectedFeatureList =
                ProtobufConversionUtils.FromGdbObjectMsgList(
                    request.SourceFeatures, container);

            IList <IFeature> targetFeaturesForVertexInsertion =
                ProtobufConversionUtils.FromGdbObjectMsgList(
                    request.UpdatableTargetFeatures, container);

            Overlaps overlaps = new Overlaps();

            foreach (OverlapMsg overlapMsg in request.Overlaps)
            {
                GdbObjectReference gdbRef = new GdbObjectReference(
                    overlapMsg.OriginalFeatureRef.ClassHandle,
                    overlapMsg.OriginalFeatureRef.ObjectId);

                IFeatureClass fClass = (IFeatureClass)container.GetByClassId(gdbRef.ClassId);

                List <IGeometry> overlapGeometries =
                    ProtobufGeometryUtils.FromShapeMsgList <IGeometry>(
                        overlapMsg.Overlaps,
                        DatasetUtils.GetSpatialReference(fClass));

                overlaps.AddGeometries(gdbRef, overlapGeometries);
            }

            // Remove overlaps
            OverlapsRemover overlapsRemover = RemoveOverlaps(
                selectedFeatureList, overlaps, targetFeaturesForVertexInsertion, explodeMultiparts,
                storeOverlapsAsNewFeatures, trackCancel);

            // Pack response
            var result = overlapsRemover.Result;

            var response = new RemoveOverlapsResponse();

            PackResultGeometries(result.ResultsByFeature,
                                 response.ResultsByFeature);

            response.NonStorableMessages.AddRange(result.NonStorableMessages);

            if (result.TargetFeaturesToUpdate != null)
            {
                foreach (var keyValuePair in result.TargetFeaturesToUpdate)
                {
                    IFeature  feature     = keyValuePair.Key;
                    IGeometry newGeometry = keyValuePair.Value;

                    GdbObjectMsg targetFeatureMsg =
                        ProtobufGdbUtils.ToGdbObjectMsg(
                            feature, newGeometry, feature.Class.ObjectClassID);

                    response.TargetFeaturesToUpdate.Add(targetFeatureMsg);
                }
            }

            response.ResultHasMultiparts = result.ResultHasMultiparts;

            return(response);
        }