public async void OnShowLocationRequested(uint viewerId, Point3D point3D)
        {
            MapView  thisView = MapView.Active;
            Envelope envelope = thisView?.Extent;

            if (envelope != null && point3D != null)
            {
                MapPoint point = await CoordSystemUtils.CycloramaToMapPointAsync(point3D.x, point3D.y, point3D.z);

                if (point != null)
                {
                    Camera camera = new Camera
                    {
                        X = point.X,
                        Y = point.Y,
                        Z = point.Z,
                        SpatialReference = point.SpatialReference
                    };

                    await QueuedTask.Run(() =>
                    {
                        thisView.PanTo(camera);
                    });
                }
            }
        }
Esempio n. 2
0
        public async void OnShowLocationRequested(uint viewerId, object point3D)
        {
            MapView  thisView = MapView.Active;
            Envelope envelope = thisView?.Extent;

            if (envelope != null && point3D != null)
            {
                // ToDo: Move to Cyclorama map position
                double   x = 0, y = 0, z = 0;
                MapPoint point = await CoordSystemUtils.CycloramaToMapPointAsync(x, y, z);

                if (point != null)
                {
                    Camera camera = new Camera
                    {
                        X = point.X,
                        Y = point.Y,
                        Z = point.Z,
                        SpatialReference = point.SpatialReference
                    };

                    await QueuedTask.Run(() =>
                    {
                        thisView.PanTo(camera);
                    });
                }
            }
        }
        public async Task UpdateObservationAsync(ApiObservation observation, Bitmap match)
        {
            string   imageId = observation.imageId;
            double   x       = observation.x;
            double   y       = observation.y;
            double   z       = observation.z;
            double   xDir    = observation.Dir_x;
            double   yDir    = observation.Dir_y;
            MapPoint point   = await CoordSystemUtils.CycloramaToMapPointAsync(x, y, z);

            if (_observations.ContainsKey(imageId))
            {
                _observations[imageId].Point   = point;
                _observations[imageId].ImageId = imageId;
                _observations[imageId].Match   = match;
                _observations[imageId].XDir    = xDir;
                _observations[imageId].YDir    = yDir;
                await _observations[imageId].RedrawObservationAsync();
            }
            else
            {
                MeasurementObservation measurementObservation = new MeasurementObservation(this, imageId, point, match, xDir, yDir);
                _observations.Add(imageId, measurementObservation);
                Add(measurementObservation);
                await measurementObservation.RedrawObservationAsync();
            }

            SetDetailPane();
        }
        private async Task MoveToLocationAsync(uint viewerId)
        {
            RecordingLocation location = _api?.GetRecordingLocation(viewerId);

            if (location != null)
            {
                MapPoint point = await CoordSystemUtils.CycloramaToMapPointAsync(location.X, location.Y, location.Z);

                MapView  thisView = MapView.Active;
                Envelope envelope = thisView?.Extent;

                if (point != null && envelope != null)
                {
                    const double percent = 10.0;
                    double       xBorder = (envelope.XMax - envelope.XMin) * percent / 100;
                    double       yBorder = (envelope.YMax - envelope.YMin) * percent / 100;
                    bool         inside  = point.X > envelope.XMin + xBorder && point.X <envelope.XMax - xBorder &&
                                                                                         point.Y> envelope.YMin + yBorder && point.Y < envelope.YMax - yBorder;

                    if (!inside)
                    {
                        Camera camera = new Camera
                        {
                            X = point.X,
                            Y = point.Y,
                            Z = point.Z,
                            SpatialReference = point.SpatialReference
                        };

                        await QueuedTask.Run(() =>
                        {
                            thisView.PanTo(camera);
                        });
                    }
                }
            }
        }
        public async Task UpdatePointAsync(ApiMeasurementPoint measurementPoint, int index)
        {
            if (!_updatePoint)
            {
                _updatePoint = true;
                Index        = index;

                ApiPoint = measurementPoint;
                double x = measurementPoint.x;
                double y = measurementPoint.y;
                double z = measurementPoint.z;
                Point = await CoordSystemUtils.CycloramaToMapPointAsync(x, y, z);

                LastPoint = LastPoint ?? Point;

                MapView  thisView = MapView.Active;
                Geometry geometry = await thisView.GetCurrentSketchAsync();

                if (geometry != null)
                {
                    var ptColl = await Measurement.ToPointCollectionAsync(geometry);

                    int nrPoints = Measurement.PointNr;

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

                            if (!IsSame(pointC))
                            {
                                await QueuedTask.Run(() =>
                                {
                                    MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Point.M,
                                                                                    geometry.SpatialReference);

                                    if (Measurement.IsPointMeasurement)
                                    {
                                        thisView.SetCurrentSketchAsync(point);
                                    }
                                    else
                                    {
                                        ptColl[_intId - 1] = point;

                                        if ((_intId == 1) && ((nrPoints + 1) == ptColl.Count))
                                        {
                                            ptColl[ptColl.Count - 1] = point;
                                        }

                                        if (Measurement.IsGeometryType(GeometryType.Polygon))
                                        {
                                            geometry = PolygonBuilder.CreatePolygon(ptColl, geometry.SpatialReference);
                                        }
                                        else if (Measurement.IsGeometryType(GeometryType.Polyline))
                                        {
                                            if (ptColl.Count == 1)
                                            {
                                                ptColl.Add(ptColl[0]);
                                            }

                                            geometry = PolylineBuilder.CreatePolyline(ptColl, geometry.SpatialReference);
                                        }

                                        thisView.SetCurrentSketchAsync(geometry);
                                    }
                                });
                            }
                        }
                        else
                        {
                            await QueuedTask.Run(() =>
                            {
                                MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Point.M,
                                                                                geometry.SpatialReference);
                                int nrPoints2 = ptColl.Count;

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

                                    if (geometry is Polygon)
                                    {
                                        ptColl.Add(point);
                                    }

                                    break;

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

                                default:
                                    if (_intId <= (nrPoints + 1))
                                    {
                                        if ((_intId - 1) != nrPoints2)
                                        {
                                            ptColl.Insert((_intId - 1), point);
                                        }
                                        else
                                        {
                                            ptColl.Add(point);
                                        }
                                    }

                                    break;
                                }

                                if (Measurement.IsGeometryType(GeometryType.Polygon))
                                {
                                    geometry = PolygonBuilder.CreatePolygon(ptColl, geometry.SpatialReference);
                                }
                                else if (Measurement.IsGeometryType(GeometryType.Polyline))
                                {
                                    if (ptColl.Count == 1)
                                    {
                                        ptColl.Add(ptColl[0]);
                                    }

                                    geometry = PolylineBuilder.CreatePolyline(ptColl, geometry.SpatialReference);
                                }
                                else if ((Measurement.IsPointMeasurement) && (ptColl.Count == 1))
                                {
                                    geometry = ptColl[0];
                                }

                                thisView.SetCurrentSketchAsync(geometry);
                            });
                        }
                    }
                    else
                    {
                        if (geometry is MapPoint)
                        {
                            await QueuedTask.Run(() =>
                            {
                                if (geometry.IsEmpty)
                                {
                                    if ((!double.IsNaN(Point.X)) && (!double.IsNaN(Point.Y)))
                                    {
                                        if (!_added)
                                        {
                                            _added         = true;
                                            MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Index);
                                            thisView.SetCurrentSketchAsync(point);
                                            _added = false;
                                        }
                                    }
                                }
                                else
                                {
                                    var pointC = geometry as MapPoint;

                                    if (!IsSame(pointC))
                                    {
                                        if ((!double.IsNaN(Point.X)) && (!double.IsNaN(Point.Y)))
                                        {
                                            MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Index);
                                            thisView.SetCurrentSketchAsync(point);
                                        }
                                    }
                                }
                            });
                        }
                    }
                }

                _updatePoint = false;
            }

            await RedrawPointAsync();
        }