예제 #1
0
        protected Settings()
        {
            _settings = FileSettings.Instance;

            _recordingLayerCoordinateSystem  = _settings.RecordingLayerCoordinateSystem;
            _cycloramaViewerCoordinateSystem = _settings.CycloramaViewerCoordinateSystem;

            _ctrlClickHashTag            = _settings.CtrlClickHashTag;
            _ctrlClickDelta              = _settings.CtrlClickDelta;
            _showDetailImages            = _settings.ShowDetailImages;
            _enableSmartClickMeasurement = _settings.EnableSmartClickMeasurement;
        }
        /// <summary>
        /// asynchronous function to request or this spatial reference exists in the current area
        /// </summary>
        public async Task <bool> ExistsInAreaAsync()
        {
            await QueuedTask.Run(() =>
            {
                if (ArcGisSpatialReference == null)
                {
                    CreateSpatialReference();
                }

                if (ArcGisSpatialReference != null)
                {
                    MapView activeView = MapView.Active;
                    Envelope envelope  = null;

                    if (activeView == null)
                    {
                        FileSettings settings             = FileSettings.Instance;
                        SpatialReference spatialReference = settings.CycloramaViewerCoordinateSystem;

                        if (spatialReference != null)
                        {
                            if (spatialReference.ArcGisSpatialReference == null)
                            {
                                spatialReference.CreateSpatialReference();
                            }

                            if (spatialReference.ArcGisSpatialReference != null)
                            {
                                Bounds bounds     = spatialReference.NativeBounds;
                                var minCoordinate = new Coordinate2D(bounds.MinX, bounds.MinY);
                                var maxCoordinate = new Coordinate2D(bounds.MaxX, bounds.MaxY);
                                envelope          = EnvelopeBuilder.CreateEnvelope(minCoordinate, maxCoordinate,
                                                                                   spatialReference.ArcGisSpatialReference);
                            }
                        }
                    }
                    else
                    {
                        envelope = activeView.Extent;
                    }

                    if (envelope != null)
                    {
                        ArcGISSpatialReference spatEnv = envelope.SpatialReference;
                        int spatEnvFactoryCode         = spatEnv?.Wkid ?? 0;

                        if (spatEnv != null && spatEnvFactoryCode != ArcGisSpatialReference.Wkid)
                        {
                            try
                            {
                                ProjectionTransformation projection = ProjectionTransformation.Create(envelope.SpatialReference,
                                                                                                      ArcGisSpatialReference);

                                if (!(GeometryEngine.Instance.ProjectEx(envelope, projection) is Envelope copyEnvelope) || copyEnvelope.IsEmpty)
                                {
                                    ArcGisSpatialReference = null;
                                }
                                else
                                {
                                    if (NativeBounds != null)
                                    {
                                        double xMin = NativeBounds.MinX;
                                        double yMin = NativeBounds.MinY;
                                        double xMax = NativeBounds.MaxX;
                                        double yMax = NativeBounds.MaxY;

                                        if (copyEnvelope.XMin < xMin || copyEnvelope.XMax > xMax || copyEnvelope.YMin < yMin ||
                                            copyEnvelope.YMax > yMax)
                                        {
                                            ArcGisSpatialReference = null;
                                        }
                                    }
                                }
                            }
                            catch (ArgumentException)
                            {
                                ArcGisSpatialReference = null;
                            }
                        }