public void UpdatePoint(int pointId, PointMeasurementData measurementData, int index)
        {
            if (!ContainsKey(pointId))
            {
                AddPoint(pointId);
            }

            if (ContainsKey(pointId))
            {
                MeasurementPoint measurementPoint = this[pointId];
                measurementPoint.UpdatePoint(measurementData, index);
            }
        }
Пример #2
0
        public async Task MeasurementPointUpdatedAsync(int entityId, int pointId)
        {
            if (GlobeSpotterConfiguration.MeasurePermissions)
            {
                _screenPointAdded = !_mapPointAdded;

                PointMeasurementData measurementData  = Api.GetMeasurementPointData(entityId, pointId);
                ApiMeasurementPoint  measurementPoint = measurementData.measurementPoint;
                Measurement          measurement      = Get(entityId);

                if (measurement != null)
                {
                    int index = (int)Api?.GetMeasurementPointIndex(entityId, pointId);
                    await measurement.UpdatePointAsync(pointId, measurementPoint, index);
                }

                _screenPointAdded = false;
            }
        }
Пример #3
0
        public void UpdatePoint(PointMeasurementData measurementData, int index)
        {
            _index = index;
            bool notCreated = NotCreated;
            MeasurementPointS measurementPoint = measurementData.measurementPoint;
            double            x = measurementPoint.x;
            double            y = measurementPoint.y;
            double            z = measurementPoint.z;

            _point = ArcUtils.GsToMapPoint(x, y, z);

            IActiveView            activeView = ArcUtils.ActiveView;
            var                    display    = activeView.ScreenDisplay;
            IDisplayTransformation dispTrans  = display.DisplayTransformation;
            double                 size       = dispTrans.FromPoints(PointSize);
            double                 xmin       = x - size;
            double                 xmax       = x + size;
            double                 ymin       = y - size;
            double                 ymax       = y + size;

            _oldEnvelope = _envelope;

            foreach (var observation in _observations)
            {
                double[] obs = observation.Value;

                if (obs.Length >= 2)
                {
                    double xdir = (_point.X - obs[0]) / 2;
                    double ydir = (_point.Y - obs[1]) / 2;
                    xmin = Math.Min(xmin, _point.X + xdir);
                    ymin = Math.Min(ymin, _point.Y + ydir);
                    xmax = Math.Max(xmax, obs[0]);
                    ymax = Math.Max(ymax, obs[1]);
                }
            }

            _envelope = new EnvelopeClass {
                XMin = xmin, XMax = xmax, YMin = ymin, YMax = ymax
            };
            var avEvents = ArcUtils.ActiveViewEvents;

            if (avEvents != null)
            {
                if (!notCreated)
                {
                    avEvents.AfterDraw -= AvEventsAfterDraw;
                }

                avEvents.AfterDraw += AvEventsAfterDraw;
            }

            IEditor3 editor = ArcUtils.Editor;
            var      sketch = editor as IEditSketch3;

            if ((sketch != null) && (_measurement != null))
            {
                IGeometry geometry = sketch.Geometry;
                int       nrPoints;
                var       ptColl = _measurement.ToPointCollection(geometry, out nrPoints);

                if ((ptColl != null) && _measurement.IsSketch)
                {
                    if (_intId <= nrPoints)
                    {
                        IPoint pointC = ptColl.Point[_intId - 1];

                        if (!IsSame(pointC))
                        {
                            ISketchOperation2 sketchOp = new SketchOperationClass();
                            sketchOp.Start(editor);
                            IPoint point = new PointClass {
                                X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                            };

                            if (_measurement.IsPointMeasurement)
                            {
                                sketch.Geometry = point;
                            }
                            else
                            {
                                ptColl.UpdatePoint((_intId - 1), point);

                                if ((_intId == 1) && ((nrPoints + 1) == ptColl.PointCount))
                                {
                                    ptColl.UpdatePoint((ptColl.PointCount - 1), point);
                                }

                                sketch.Geometry = ptColl as IGeometry;
                            }

                            geometry = sketch.Geometry;

                            if (geometry != null)
                            {
                                sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                            }
                        }
                    }
                    else
                    {
                        ISketchOperation2 sketchOp = new SketchOperationClass();
                        sketchOp.Start(editor);
                        IPoint point = new PointClass {
                            X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                        };
                        int nrPoints2 = ptColl.PointCount;

                        switch (nrPoints2)
                        {
                        case 0:
                            ptColl.AddPoint(point);

                            if (geometry is IPolygon4)
                            {
                                ptColl.AddPoint(point);
                            }
                            break;

                        case 1:
                            ptColl.AddPoint(point);
                            break;

                        default:
                            if (_intId <= (nrPoints + 1))
                            {
                                object point1 = ((_intId - 1) == nrPoints2) ? Type.Missing : (_intId - 1);
                                object point2 = Type.Missing;
                                ptColl.AddPoint(point, ref point1, ref point2);
                            }

                            break;
                        }

                        sketch.Geometry = ptColl as IGeometry;
                        geometry        = sketch.Geometry;

                        if (geometry != null)
                        {
                            sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                        }
                    }
                }
                else
                {
                    if (geometry is IPoint)
                    {
                        if (geometry.IsEmpty)
                        {
                            if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y)))
                            {
                                if (!_added)
                                {
                                    IApplication application = ArcMap.Application;
                                    ICommandItem tool        = application.CurrentTool;
                                    ICommand     command     = tool.Command;

                                    if (!(command is IEditTool))
                                    {
                                        _added = true;
                                        var    editorZ = editor as IEditorZ;
                                        double zOffset = 0.0;

                                        if (editorZ != null)
                                        {
                                            zOffset         = editorZ.ZOffset;
                                            editorZ.ZOffset = _point.Z;
                                        }

                                        ISketchOperation2 sketchOp = new SketchOperationClass();
                                        sketchOp.Start(editor);
                                        IPoint point = new PointClass {
                                            X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                                        };
                                        sketch.Geometry = point;
                                        geometry        = sketch.Geometry;
                                        sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                                        sketch.FinishSketch();

                                        if (editorZ != null)
                                        {
                                            editorZ.ZOffset = zOffset;
                                        }

                                        _added = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            var pointC = geometry as IPoint;

                            if (!IsSame(pointC))
                            {
                                if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y)))
                                {
                                    ISketchOperation2 sketchOp = new SketchOperationClass();
                                    sketchOp.Start(editor);
                                    IPoint point = new PointClass {
                                        X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                                    };
                                    sketch.Geometry = point;
                                    geometry        = sketch.Geometry;
                                    sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                                }
                            }
                        }
                    }
                }
            }

            Update();
        }
        public ApiMeasurementPoint GetApiPoint(int pointId)
        {
            PointMeasurementData measurementData = _api.GetMeasurementPointData(EntityId, pointId);

            return(measurementData.measurementPoint);
        }