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);
                    });
                }
            }
        }
        private async void OnDrawComplete(MapViewEventArgs args)
        {
            if (_api != null)
            {
                MapView          mapview = MapView.Active;
                Map              map     = mapview?.Map;
                SpatialReference spatRef = map?.SpatialReference;
                Unit             unit    = spatRef?.Unit;

                if (unit != null)
                {
                    string unitName = unit.Name;
                    string label    = _api.GetLengthUnitLabel();

                    if (label != unitName)
                    {
                        double           factor            = unit.ConversionFactor;
                        SpatialReference cyclSpatreference = await CoordSystemUtils.CycloramaSpatialReferenceAsync();

                        bool projected = cyclSpatreference.IsProjected;
                        Unit cyclUnit  = cyclSpatreference.Unit;

                        double cyclFactor = cyclUnit.ConversionFactor;
                        var    conversion = projected ? factor / cyclFactor : factor * cyclFactor;

                        _api.SetLengthUnitLabel(unitName);
                        _api.SetLengthUnitFactor(conversion);
                    }
                }
            }
        }
        private async void OnMapViewInitialized(MapViewEventArgs args)
        {
            CycloMediaLayer.ResetYears();
            LayersRemovedEvent.Subscribe(OnLayerRemoved);
            DrawCompleteEvent.Subscribe(OnDrawComplete);

            if (ContainsCycloMediaLayer(args.MapView))
            {
                await AddLayersAsync(args.MapView);
            }

            Settings settings = Settings.Instance;
            Login    login    = Login.Instance;

            settings.PropertyChanged += OnSettingsPropertyChanged;
            login.PropertyChanged    += OnLoginPropertyChanged;

            if (settings.CycloramaViewerCoordinateSystem != null)
            {
                await CoordSystemUtils.CheckInAreaCycloramaSpatialReferenceAsync();
            }

            if (!_agreement.Value)
            {
                PropertySheet.ShowDialog("streetSmartArcGISPro_optionsPropertySheet", "streetSmartArcGISPro_agreementPage");
            }
        }
        public async Task <MapPoint> AddHeightToMapPointAsync(MapPoint srcPoint)
        {
            return(await QueuedTask.Run(async() =>
            {
                MapView mapView = MapView.Active;
                Map map = mapView.Map;
                SpatialReference srcSpatialReference = map.SpatialReference;
                SpatialReference dstSpatialReference = await CoordSystemUtils.CycloramaSpatialReferenceAsync();

                ProjectionTransformation dstProjection = ProjectionTransformation.Create(srcSpatialReference,
                                                                                         dstSpatialReference);
                MapPoint dstPoint = GeometryEngine.Instance.ProjectEx(srcPoint, dstProjection) as MapPoint;

                if (dstPoint != null)
                {
                    double?height = await _cycloMediaGroupLayer.GetHeightAsync(dstPoint.X, dstPoint.Y);

                    if (height != null)
                    {
                        dstPoint = MapPointBuilder.CreateMapPoint(dstPoint.X, dstPoint.Y, ((double)height), dstSpatialReference);
                        ProjectionTransformation srcProjection = ProjectionTransformation.Create(dstSpatialReference,
                                                                                                 srcSpatialReference);
                        srcPoint = GeometryEngine.Instance.ProjectEx(dstPoint, srcProjection) as MapPoint;
                    }
                }

                return srcPoint;
            }));
        }
Exemplo n.º 5
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();
        }
        public void OnComponentReady()
        {
            string epsgCode = CoordSystemUtils.CheckCycloramaSpatialReference();

            if (_api != null)
            {
                _api.SetAPIKey(_apiKey.Value);
                _api.SetUserNamePassword(_login.Username, _login.Password);
                _api.SetSrsNameViewer(epsgCode);
                _api.SetSrsNameAddress(epsgCode);
                _api.SetAdressLanguageCode(_constants.AddressLanguageCode);

                if (!_configuration.UseDefaultBaseUrl)
                {
                    _api.SetServiceURL(_configuration.BaseUrlLocation, ServiceUrlType.URL_BASE);
                }
            }
        }
        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();
        }