Exemplo n.º 1
0
        protected Map GetMap(IContextRequest request)
        {
            string type = request.GetParam("MAP_TYPE");

            if (String.IsNullOrEmpty(type))
            {
                throw new WmsParameterNotSpecifiedException("MAP_TYPE");
            }
            if (String.Equals(type, "DEF", StringComparison.InvariantCultureIgnoreCase))
            {
                return(ShapefileHelper.Default());
            }
            if (String.Equals(type, "SPH", StringComparison.InvariantCultureIgnoreCase))
            {
                return(ShapefileHelper.Spherical());
            }
            if (String.Equals(type, "SQL", StringComparison.InvariantCultureIgnoreCase))
            {
                return(DatabaseHelper.SqlServer());
            }
            if (String.Equals(type, "BRU", StringComparison.InvariantCultureIgnoreCase))
            {
                return(BruTileHelper.Osm());
            }
            string format = String.Format("unsupported map type: '{0}'", type);

            throw new NotSupportedException(format);
        }
        /// <summary>
        /// Sends GetCapabilities request to the specified URL.
        /// </summary>
        private void ConnectServer()
        {
            var server = SelectedServer;

            if (server == null)
            {
                return;
            }

            if (LoadCachedCapabilities(server))
            {
                return;
            }

            View.ShowHourglass();

            Task <Stream> .Factory.StartNew(() => BruTileHelper.GetWmsCapabilitiesStream(server.Url))
            .ContinueWith(ProcessWmsCapabilitiesResults, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemplo n.º 3
0
        public void Draw(esriDrawPhase drawPhase, IDisplay display, ITrackCancel trackCancel)
        {
            switch (drawPhase)
            {
            case esriDrawPhase.esriDPGeography:
                if (Valid)
                {
                    if (Visible)
                    {
                        try
                        {
                            var clipEnvelope = display.ClipEnvelope;

                            // when loading from a file the active map doesn't exist yet
                            // so just deal with it here.
                            if (_map == null)
                            {
                                var mxdoc = (IMxDocument)_application.Document;
                                _map = mxdoc.FocusMap;
                            }

                            Debug.WriteLine("Draw event");
                            var activeView = _map as IActiveView;
                            Logger.Debug("Layer name: " + Name);

                            if (activeView != null)
                            {
                                //_envelope = activeView.Extent;
                                _envelope = clipEnvelope;

                                Logger.Debug("Draw extent: xmin:" + _envelope.XMin +
                                             ", ymin:" + _envelope.YMin +
                                             ", xmax:" + _envelope.XMax +
                                             ", ymax:" + _envelope.YMax
                                             );
                                if (SpatialReference != null)
                                {
                                    Logger.Debug("Layer spatial reference: " + SpatialReference.FactoryCode);
                                }
                                if (_map.SpatialReference != null)
                                {
                                    Logger.Debug("Map spatial reference: " + _map.SpatialReference.FactoryCode);
                                }

                                var bruTileHelper = new BruTileHelper(_tileTimeOut);
                                //_displayFilter.Transparency = (short)(255 - ((_transparency * 255) / 100));
                                //if (display.Filter == null)
                                //{
                                //    display.Filter = _displayFilter;
                                //}
                                var fileCache = CacheDirectory.GetFileCache(_cacheDir, _config, _enumBruTileLayer);
                                bruTileHelper.Draw(_application.StatusBar.ProgressBar, activeView, fileCache, trackCancel, SpatialReference, ref _currentLevel, _tileSource, display);
                            }
                        }
                        catch (Exception ex)
                        {
                            var mbox = new ExceptionMessageBox(ex);
                            mbox.Show(null);
                        }
                    }  // isVisible
                }      // isValid
                break;

            case esriDrawPhase.esriDPAnnotation:
                break;
            }
        }