public VectorLayerList()
        {
            _updateHeight  = false;
            _currentToolId = string.Empty;
            GlobeSpotter moduleGlobeSpotter = GlobeSpotter.Current;

            _measurementList      = moduleGlobeSpotter.MeasurementList;
            _cycloMediaGroupLayer = moduleGlobeSpotter.CycloMediaGroupLayer;
            EditTool = EditTools.NoEditTool;
        }
Beispiel #2
0
        protected override async void OnClick()
        {
            OnUpdate();
            GlobeSpotter globeSpotter = GlobeSpotter.Current;

            if (IsChecked)
            {
                await globeSpotter.RemoveLayerAsync(LayerName);
            }
            else
            {
                await globeSpotter.AddLayersAsync(LayerName);
            }
        }
Beispiel #3
0
        public void Dispose()
        {
            _disposeInnerLine?.Dispose();
            _disposeOuterLine?.Dispose();
            Viewer = null;
            GlobeSpotter globeSpotter = GlobeSpotter.Current;
            ViewerList   viewerList   = globeSpotter.ViewerList;

            // event listeners
            MapViewCameraChangedEvent.Unsubscribe(OnMapViewCameraChanged);
            viewerList.ViewerAdded            -= OnViewerAdded;
            viewerList.ViewerRemoved          -= OnViewerRemoved;
            viewerList.ViewerMoved            -= OnViewerMoved;
            _measurementPoint.PropertyChanged -= OnPropertyMeasurementPointChanged;
            PropertyChanged -= OnPropertyMeasurementObservationChanged;
        }
        public VectorLayer(FeatureLayer layer, VectorLayerList vectorLayerList)
        {
            _vectorLayerList         = vectorLayerList;
            Layer                    = layer;
            _settings                = Settings.Instance;
            _storedLayerList         = StoredLayerList.Instance;
            _isVisibleInGlobespotter = _storedLayerList.Get(Layer?.Name ?? string.Empty);
            LayerId                  = null;
            _selection               = null;
            _updateMeasurements      = false;

            GlobeSpotter globeSpotter = GlobeSpotter.Current;

            _viewerList      = globeSpotter.ViewerList;
            _measurementList = globeSpotter.MeasurementList;
            _ci = CultureInfo.InvariantCulture;
        }
Beispiel #5
0
        public MeasurementObservation(MeasurementPoint measurementPoint, string imageId, MapPoint observationPoint, Bitmap match, double xDir, double yDir)
        {
            XDir = xDir;
            YDir = yDir;
            _measurementPoint = measurementPoint;
            ImageId           = imageId;
            Point             = observationPoint;
            Match             = match;
            GlobeSpotter globeSpotter = GlobeSpotter.Current;
            ViewerList   viewerList   = globeSpotter.ViewerList;

            Viewer = viewerList.Get(imageId);

            // event listeners
            _measurementPoint.PropertyChanged += OnPropertyMeasurementPointChanged;
            PropertyChanged += OnPropertyMeasurementObservationChanged;
            MapViewCameraChangedEvent.Subscribe(OnMapViewCameraChanged);
            viewerList.ViewerAdded   += OnViewerAdded;
            viewerList.ViewerRemoved += OnViewerRemoved;
            viewerList.ViewerMoved   += OnViewerMoved;
        }
        protected override async void OnUpdate()
        {
            MapView mapView = MapView.Active;
            IReadOnlyList <Layer> layers = mapView?.GetSelectedLayers();

            if (layers?.Count == 1)
            {
                Layer        layer        = layers[0];
                GlobeSpotter globeSpotter = GlobeSpotter.Current;

                CycloMediaGroupLayer groupLayer = globeSpotter.CycloMediaGroupLayer;
                _cycloMediaLayer = groupLayer?.GetLayer(layer);

                VectorLayerList vectorLayerList = await globeSpotter.GetVectorLayerListAsync();

                _vectorLayer = vectorLayerList.GetLayer(layer);

                if (_cycloMediaLayer != null)
                {
                    IsChecked = _cycloMediaLayer.IsVisibleInGlobespotter;
                    Enabled   = _cycloMediaLayer.IsVisible;
                }
                else if (_vectorLayer != null)
                {
                    IsChecked = _vectorLayer.IsVisibleInGlobespotter;
                    Enabled   = _vectorLayer.IsVisible;
                }
                else
                {
                    IsChecked = false;
                    Enabled   = false;
                }
            }
            else
            {
                Enabled = false;
            }

            base.OnUpdate();
        }
        private async Task AddLayerAsync(Layer layer)
        {
            FeatureLayer         featureLayer    = layer as FeatureLayer;
            GlobeSpotter         globeSpotter    = GlobeSpotter.Current;
            CycloMediaGroupLayer cycloGrouplayer = globeSpotter?.CycloMediaGroupLayer;

            if ((featureLayer != null) && (cycloGrouplayer != null) && (!cycloGrouplayer.IsKnownName(featureLayer.Name)))
            {
                if (!this.Aggregate(false, (current, vecLayer) => (vecLayer.Layer == layer) || current))
                {
                    var  vectorLayer = new VectorLayer(featureLayer, this);
                    bool initialized = await vectorLayer.InitializeEventsAsync();

                    if (initialized)
                    {
                        Add(vectorLayer);
                        vectorLayer.PropertyChanged += OnVectorLayerPropertyChanged;
                        LayerAdded?.Invoke(vectorLayer);
                    }
                }
            }
        }
Beispiel #8
0
        protected RecentRecordingLayer()
        {
            IsChecked = false;
            GlobeSpotter         globeSpotter = GlobeSpotter.Current;
            CycloMediaGroupLayer groupLayer   = globeSpotter.CycloMediaGroupLayer;

            if (groupLayer != null)
            {
                foreach (var layer in groupLayer)
                {
                    if (layer.IsRemoved)
                    {
                        IsChecked = layer.Name != LayerName && IsChecked;
                    }
                    else
                    {
                        IsChecked = layer.Name == LayerName || IsChecked;
                    }
                }

                groupLayer.PropertyChanged += OnLayerPropertyChanged;
            }
        }
/*
 *  protected async override void OnUpdate()
 *  {
 *    Cursor nowCursor = Cursor;
 *    Cursor = _containsFeatures ? Cursors.Arrow : _thisCursor;
 *
 *    if (nowCursor != Cursor)
 *    {
 *      await FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool");
 *      await FrameworkApplication.SetCurrentToolAsync("globeSpotterArcGISPro_openImageTool");
 *    }
 *
 *    base.OnUpdate();
 *  }
 *
 *  protected override async void OnToolMouseMove(MapViewMouseEventArgs e)
 *  {
 *    await QueuedTask.Run(() =>
 *    {
 *      var constants = ConstantsRecordingLayer.Instance;
 *      double size = constants.SizeLayer;
 *      double halfSize = size / 2;
 *      MapView activeView = MapView.Active;
 *
 *      WinPoint clientPoint = e.ClientPoint;
 *      WinPoint pointScreen = activeView.ClientToScreen(clientPoint);
 *      double x = pointScreen.X;
 *      double y = pointScreen.Y;
 *      WinPoint minPoint = new WinPoint(x - halfSize, y - halfSize);
 *      WinPoint maxPoint = new WinPoint(x + halfSize, y + halfSize);
 *      MapPoint minPoint1 = activeView.ScreenToMap(minPoint);
 *      MapPoint maxPoint1 = activeView.ScreenToMap(maxPoint);
 *      Envelope envelope = EnvelopeBuilder.CreateEnvelope(minPoint1, maxPoint1, minPoint1.SpatialReference);
 *      var features = MapView.Active?.GetFeatures(envelope);
 *      _containsFeatures = (features != null) && (features.Count >= 1);
 *    });
 *
 *    base.OnToolMouseMove(e);
 *  }
 */
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            return(QueuedTask.Run(() =>
            {
                MapPoint point = geometry as MapPoint;
                MapView activeView = MapView.Active;

                if (point != null && activeView != null)
                {
                    var constants = ConstantsRecordingLayer.Instance;
                    double size = constants.SizeLayer;
                    double halfSize = size / 2;

                    SpatialReference pointSpatialReference = point.SpatialReference;
                    var pointScreen = activeView.MapToScreen(point);
                    double x = pointScreen.X;
                    double y = pointScreen.Y;
                    WinPoint pointScreenMin = new WinPoint(x - halfSize, y - halfSize);
                    WinPoint pointScreenMax = new WinPoint(x + halfSize, y + halfSize);
                    var pointMapMin = activeView.ScreenToMap(pointScreenMin);
                    var pointMapMax = activeView.ScreenToMap(pointScreenMax);

                    Envelope envelope = EnvelopeBuilder.CreateEnvelope(pointMapMin, pointMapMax, pointSpatialReference);
                    var features = activeView.GetFeatures(envelope);

                    GlobeSpotter globeSpotter = GlobeSpotter.Current;
                    CycloMediaGroupLayer groupLayer = globeSpotter?.CycloMediaGroupLayer;

                    if (features != null && groupLayer != null)
                    {
                        _nearest = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);

                        if (_nearest)
                        {
                            Settings settings = Settings.Instance;
                            MySpatialReference cycloCoordSystem = settings.CycloramaViewerCoordinateSystem;

                            if (cycloCoordSystem != null)
                            {
                                SpatialReference cycloSpatialReference = cycloCoordSystem.ArcGisSpatialReference ??
                                                                         cycloCoordSystem.CreateArcGisSpatialReferenceAsync().Result;

                                if (pointSpatialReference.Wkid != cycloSpatialReference.Wkid)
                                {
                                    ProjectionTransformation projection = ProjectionTransformation.Create(pointSpatialReference,
                                                                                                          cycloSpatialReference);
                                    point = GeometryEngine.Instance.ProjectEx(point, projection) as MapPoint;
                                }

                                if (point != null)
                                {
                                    CultureInfo ci = CultureInfo.InvariantCulture;
                                    _location = string.Format(ci, "{0},{1}", point.X, point.Y);

                                    if (!globeSpotter.InsideScale())
                                    {
                                        double minimumScale = ConstantsRecordingLayer.Instance.MinimumScale;
                                        double scale = minimumScale / 2;
                                        Camera camera = new Camera(point.X, point.Y, scale, 0.0);
                                        MapView.Active?.ZoomTo(camera);
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (var feature in features)
                            {
                                Layer layer = feature.Key;
                                CycloMediaLayer cycloMediaLayer = groupLayer.GetLayer(layer);

                                if (cycloMediaLayer != null)
                                {
                                    foreach (long uid in feature.Value)
                                    {
                                        Recording recording = cycloMediaLayer.GetRecordingAsync(uid).Result;

                                        if (recording.IsAuthorized == null || (bool)recording.IsAuthorized)
                                        {
                                            _location = recording.ImageId;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return true;
            }));
        }
        private async Task RedrawConeAsync()
        {
            await QueuedTask.Run(() =>
            {
                GlobeSpotter globeSpotter = GlobeSpotter.Current;

                if ((globeSpotter.InsideScale()) && (!_mapPoint.IsEmpty) && (Color != null))
                {
                    var thisColor                       = (SystCol)Color;
                    MapView thisView                    = MapView.Active;
                    Map map                             = thisView.Map;
                    SpatialReference mapSpat            = map.SpatialReference;
                    SpatialReference mapPointSpat       = _mapPoint.SpatialReference;
                    ProjectionTransformation projection = ProjectionTransformation.Create(mapPointSpat, mapSpat);
                    _mapPoint                           = GeometryEngine.Instance.ProjectEx(_mapPoint, projection) as MapPoint;

                    WinPoint point = thisView.MapToScreen(_mapPoint);
                    double angleh  = (_hFov *Math.PI) / 360;
                    double angle   = (((270 + _angle) % 360) * Math.PI) / 180;
                    double angle1  = angle - angleh;
                    double angle2  = angle + angleh;
                    double x       = point.X;
                    double y       = point.Y;
                    double size    = Size / 2;

                    WinPoint screenPoint1 = new WinPoint((x + (size * Math.Cos(angle1))), (y + (size * Math.Sin(angle1))));
                    WinPoint screenPoint2 = new WinPoint((x + (size * Math.Cos(angle2))), (y + (size * Math.Sin(angle2))));
                    MapPoint point1       = thisView.ScreenToMap(screenPoint1);
                    MapPoint point2       = thisView.ScreenToMap(screenPoint2);

                    IList <MapPoint> polygonPointList = new List <MapPoint>();
                    polygonPointList.Add(_mapPoint);
                    polygonPointList.Add(point1);
                    polygonPointList.Add(point2);
                    polygonPointList.Add(_mapPoint);
                    Polygon polygon = PolygonBuilder.CreatePolygon(polygonPointList);

                    Color colorPolygon             = SystCol.FromArgb(_blinking ? BlinkAlpha : NormalAlpha, thisColor);
                    CIMColor cimColorPolygon       = ColorFactory.Instance.CreateColor(colorPolygon);
                    CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.DefaultPolygonSymbol;
                    polygonSymbol.SetColor(cimColorPolygon);
                    polygonSymbol.SetOutlineColor(null);
                    CIMSymbolReference polygonSymbolReference = polygonSymbol.MakeSymbolReference();
                    IDisposable disposePolygon = thisView.AddOverlay(polygon, polygonSymbolReference);

                    IList <MapPoint> linePointList = new List <MapPoint>();
                    linePointList.Add(point1);
                    linePointList.Add(_mapPoint);
                    linePointList.Add(point2);
                    Polyline polyline = PolylineBuilder.CreatePolyline(linePointList);

                    Color colorLine             = _active ? SystCol.Yellow : SystCol.Gray;
                    CIMColor cimColorLine       = ColorFactory.Instance.CreateColor(colorLine);
                    CIMLineSymbol cimLineSymbol = SymbolFactory.Instance.DefaultLineSymbol;
                    cimLineSymbol.SetColor(cimColorLine);
                    cimLineSymbol.SetSize(_blinking ? BorderSizeBlinking : BorderSize);
                    CIMSymbolReference lineSymbolReference = cimLineSymbol.MakeSymbolReference();
                    IDisposable disposePolyLine            = thisView.AddOverlay(polyline, lineSymbolReference);

                    _disposePolygon?.Dispose();
                    _disposePolygon = disposePolygon;
                    _disposePolyLine?.Dispose();
                    _disposePolyLine = disposePolyLine;

                    if (_blinking)
                    {
                        var blinkEvent         = new AutoResetEvent(true);
                        var blinkTimerCallBack = new TimerCallback(ResetBlinking);
                        _blinkTimer            = new Timer(blinkTimerCallBack, blinkEvent, BlinkTime, -1);
                    }
                }
                else
                {
                    _disposePolygon?.Dispose();
                    _disposePolyLine?.Dispose();
                }
            });
        }