コード例 #1
0
ファイル: BruTileLayer.cs プロジェクト: jeason0813/ArcBruTile
        // used by WMTS
        public BruTileLayer(IApplication application, ITileSource tileSource)
        {
            LayerWeight       = 110;
            Cached            = true;
            _enumBruTileLayer = EnumBruTileLayer.WMTS;
            _application      = application;

            var mxdoc = (IMxDocument)_application.Document;

            _map         = mxdoc.FocusMap;
            _cacheDir    = CacheSettings.GetCacheFolder();
            _tileTimeOut = ConfigurationHelper.GetTileTimeOut();

            var spatialReferences = new SpatialReferences();

            _tileSource           = tileSource;
            _schema               = _tileSource.Schema;
            _dataSpatialReference = spatialReferences.GetSpatialReference(_schema.Srs);
            _envelope             = GetDefaultEnvelope();

            if (_map.SpatialReference == null)
            {
                // zet dan de spatial ref...
                _map.SpatialReference = _dataSpatialReference;
            }

            // If there is only one layer in the TOC zoom to this layer...
            if (_map.LayerCount == 0)
            {
                _envelope.Project(_map.SpatialReference);
                ((IActiveView)_map).Extent = _envelope;
            }

            _displayFilter = new TransparencyDisplayFilterClass();
        }
コード例 #2
0
ファイル: BruTileLayer.cs プロジェクト: zhzhy86/TrafficSpider
        private void InitializeLayer()
        {
            var mxdoc = (IMxDocument)_application.Document;

            _map         = mxdoc.FocusMap;
            _cacheDir    = CacheSettings.GetCacheFolder();
            _tileTimeOut = ConfigurationHelper.GetTileTimeOut();

            var spatialReferences = new SpatialReferences();

            _tileSource           = _config.CreateTileSource();
            _schema               = _tileSource.Schema;
            _dataSpatialReference = spatialReferences.GetSpatialReference(_schema.Srs);
            _envelope             = GetDefaultEnvelope();

            if (_map.SpatialReference == null)
            {
                // zet dan de spatial ref...
                _map.SpatialReference = _dataSpatialReference;
            }

            // If there is only one layer in the TOC zoom to this layer...
            if (_map.LayerCount == 0)
            {
                //envelope.Expand(-0.1, -0.1, true);
                _envelope.Project(_map.SpatialReference);
                ((IActiveView)_map).Extent = _envelope;
            }

            _displayFilter = new TransparencyDisplayFilterClass();
        }
コード例 #3
0
ファイル: Projector.cs プロジェクト: andrepraska/andre
        public static IEnvelope ProjectEnvelope(IEnvelope envelope, string srs)
        {
            var spatialReferences    = new SpatialReferences();
            var dataSpatialReference = spatialReferences.GetSpatialReference(srs);

            envelope.Project(dataSpatialReference);
            return(envelope);
        }
コード例 #4
0
        public BruTileCustomLayer(IApplication application, TileSource tileSource, FileCache fileCache)
        {
            _tileSource = tileSource;
            _fileCache = fileCache;
            _simplefilefetcher = new SimpleFileFetcher(tileSource, fileCache);
            var spatialReferences = new SpatialReferences();
            _dataSpatialReference = spatialReferences.GetSpatialReference(_tileSource.Schema.Srs);

            if (SpatialReference.FactoryCode == 0)
            {
                // zet dan de spatial ref...
                m_spatialRef = _dataSpatialReference;
            }
            var mxdoc = (IMxDocument)application.Document;
            _map = mxdoc.FocusMap;
            var envelope = GetDefaultEnvelope();

            // If there is only one layer in the TOC zoom to this layer...
            if (_map.LayerCount == 0)
            {
                ((IActiveView)_map).Extent = envelope;
            }
        }
コード例 #5
0
ファイル: BruTileHelper.cs プロジェクト: ariwori/PcArcBruTile
        public void Draw(IStepProgressor stepProgressor,
                         IActiveView activeView,
                         FileCache fileCache,
                         ITrackCancel trackCancel,
                         ISpatialReference layerSpatialReference,
                         ref string currentLevel, ITileSource tileSource, IDisplay display)
        {
            _tileSource            = tileSource;
            _trackCancel           = trackCancel;
            _layerSpatialReference = layerSpatialReference;
            _currentLevel          = currentLevel;
            _fileCache             = fileCache;
            _tileProvider          = (WebTileProvider)tileSource.Provider;
            var spatialReferences = new SpatialReferences();

            _dataSpatialReference = spatialReferences.GetSpatialReference(tileSource.Schema.Srs);

            //var fetcher = new FileFetcher<Image>(osmTileSource, fileCache);

            _display = display;

            if (!activeView.Extent.IsEmpty)
            {
                _tiles       = GetTiles(activeView);
                currentLevel = _currentLevel;
                Logger.Debug("Number of tiles to draw: " + _tiles.Count);

                if (_tiles.ToList().Count > 0)
                {
                    stepProgressor.MinRange = 0;
                    stepProgressor.MaxRange = _tiles.ToList().Count;
                    stepProgressor.Show();

                    var downloadFinished = new ManualResetEvent(false);

                    // this is a hack, otherwise we get error message...
                    // "WaitAll for multiple handles on a STA thread is not supported. (mscorlib)"
                    // so lets start a thread first...
                    var t = new Thread(DownloadTiles);
                    t.Start(downloadFinished);

                    // wait till finished
                    downloadFinished.WaitOne();

                    // 3. Now draw all tiles...

                    //if (layerSpatialReference != null && _dataSpatialReference != null)
                    //{
                    //    _needReproject = (layerSpatialReference.FactoryCode != _dataSpatialReference.FactoryCode);
                    //}
                    //Logger.Debug("Need reproject tile: " + _needReproject.ToString());

                    //foreach (var tile in _tiles)
                    //{
                    //    stepProgressor.Step();

                    //    /*                        if (IsBeAdded(tile))
                    //                                continue;
                    //                            _showTiles.Add(tile);*/

                    //    /*                        if (tile != null)
                    //                            {
                    //                                var name = _fileCache.GetFileName(tile.Index);

                    //                                if (!File.Exists(name)) continue;
                    //                                DrawRaster(name);
                    //                            }*/
                    //}

                    //stepProgressor.Hide();
                }
                else
                {
                    Logger.Debug("No tiles to retrieve or draw");
                }

                Logger.Debug("End drawing tiles: " + _tiles.ToList().Count);
            }
        }
コード例 #6
0
ファイル: BruTileLayer.cs プロジェクト: Jiangwm/PcArcBruTile
        private void InitializeLayer()
        {
            var mxdoc = (IMxDocument)_application.Document;
            _map = mxdoc.FocusMap;
            _cacheDir = CacheSettings.GetCacheFolder();
            _tileTimeOut = ConfigurationHelper.GetTileTimeOut();

            var spatialReferences = new SpatialReferences();

            _tileSource=_config.CreateTileSource();
            _schema = _tileSource.Schema;
            _dataSpatialReference = spatialReferences.GetSpatialReference(_schema.Srs);
            _envelope = GetDefaultEnvelope();

            if (_map.SpatialReference == null)
            {
                // zet dan de spatial ref...
                _map.SpatialReference = _dataSpatialReference;
            }

            // If there is only one layer in the TOC zoom to this layer...
            if (_map.LayerCount == 0)
            {
                //envelope.Expand(-0.1, -0.1, true);
                _envelope.Project(_map.SpatialReference);
                ((IActiveView)_map).Extent = _envelope;
            }

            _displayFilter = new TransparencyDisplayFilterClass();
        }
コード例 #7
0
        public void Draw(IStepProgressor stepProgressor,
                         IActiveView activeView,
                         FileCache fileCache,
                         ITrackCancel trackCancel,
                         ISpatialReference layerSpatialReference,
                         ref string currentLevel, ITileSource tileSource, IDisplay display)
        {
            _tileSource = tileSource;
            _trackCancel = trackCancel;
            _layerSpatialReference = layerSpatialReference;
            _currentLevel = currentLevel;
            _fileCache = fileCache;
            _tileProvider = (WebTileProvider)tileSource.Provider;
            var spatialReferences = new SpatialReferences();
            _dataSpatialReference = spatialReferences.GetSpatialReference(tileSource.Schema.Srs);

            //var fetcher = new FileFetcher<Image>(osmTileSource, fileCache);

            _display = display;

            if (!activeView.Extent.IsEmpty)
            {
                _tiles = GetTiles(activeView);
                currentLevel = _currentLevel;
                Logger.Debug("Number of tiles to draw: " + _tiles.Count);

                if (_tiles.ToList().Count > 0)
                {

                    stepProgressor.MinRange = 0;
                    stepProgressor.MaxRange = _tiles.ToList().Count;
                    stepProgressor.Show();

                    var downloadFinished = new ManualResetEvent(false);

                    // this is a hack, otherwise we get error message...
                    // "WaitAll for multiple handles on a STA thread is not supported. (mscorlib)"
                    // so lets start a thread first...
                    var t = new Thread(DownloadTiles);
                    t.Start(downloadFinished);

                    // wait till finished
                    downloadFinished.WaitOne();

                    // 3. Now draw all tiles...

                    //if (layerSpatialReference != null && _dataSpatialReference != null)
                    //{
                    //    _needReproject = (layerSpatialReference.FactoryCode != _dataSpatialReference.FactoryCode);
                    //}
                    //Logger.Debug("Need reproject tile: " + _needReproject.ToString());

                    //foreach (var tile in _tiles)
                    //{
                    //    stepProgressor.Step();

                    //    /*                        if (IsBeAdded(tile))
                    //                                continue;
                    //                            _showTiles.Add(tile);*/

                    //    /*                        if (tile != null)
                    //                            {
                    //                                var name = _fileCache.GetFileName(tile.Index);

                    //                                if (!File.Exists(name)) continue;
                    //                                DrawRaster(name);
                    //                            }*/
                    //}

                    //stepProgressor.Hide();
                }
                else
                {
                    Logger.Debug("No tiles to retrieve or draw");
                }

                Logger.Debug("End drawing tiles: " + _tiles.ToList().Count);
            }
        }