Ejemplo n.º 1
0
 /// <summary>
 /// Create tile layer for given tile source
 /// </summary>
 /// <param name="source">Tile source to use for this layer</param>
 /// <param name="minTiles">Minimum number of tiles to cache</param>
 /// <param name="maxTiles">Maximum number of tiles to cache</param>
 /// <param name="maxRetries">Unused</param>
 /// <param name="dataFetchStrategy">Strategy to get list of tiles for given extent</param>
 /// <param name="renderFetchStrategy"></param>
 /// <param name="minExtraTiles">Number of minimum extra tiles for memory cache</param>
 /// <param name="maxExtraTiles">Number of maximum extra tiles for memory cache</param>
 // ReSharper disable once UnusedParameter.Local // Is public and won't break this now
 public TileLayer(ITileSource source = null, int minTiles = 200, int maxTiles = 300,
                  IDataFetchStrategy dataFetchStrategy = null, IRenderFetchStrategy renderFetchStrategy = null,
                  int minExtraTiles = -1, int maxExtraTiles = -1, Func <TileInfo, Feature> fetchTileAsFeature = null)
 {
     MemoryCache = new MemoryCache <Feature>(minTiles, maxTiles);
     Style       = new VectorStyle {
         Outline = { Color = Color.FromArgb(0, 0, 0, 0) }
     };                                                                            // initialize with transparent outline
     _tileSource = source;
     if (_tileSource != null)
     {
         if (Attribution == null)
         {
             Attribution = new Hyperlink();
         }
         Attribution.Text = _tileSource.Attribution?.Text;
         Attribution.Url  = _tileSource.Attribution?.Url;
     }
     _envelope                             = _tileSource?.Schema?.Extent.ToBoundingBox();
     dataFetchStrategy                     = dataFetchStrategy ?? new DataFetchStrategy(3);
     _renderFetchStrategy                  = renderFetchStrategy ?? new RenderFetchStrategy();
     _minExtraTiles                        = minExtraTiles;
     _maxExtraTiles                        = maxExtraTiles;
     _tileFetchDispatcher                  = new TileFetchDispatcher(MemoryCache, source.Schema, fetchTileAsFeature ?? ToFeature, dataFetchStrategy);
     _tileFetchDispatcher.DataChanged     += TileFetchDispatcherOnDataChanged;
     _tileFetchDispatcher.PropertyChanged += TileFetchDispatcherOnPropertyChanged;
 }
Ejemplo n.º 2
0
 public TileFetchDispatcher(
     ITileCache <Feature> tileCache,
     ITileSchema tileSchema,
     Func <TileInfo, Feature> fetchTileAsFeature,
     IDataFetchStrategy dataFetchStrategy = null)
 {
     _tileCache          = tileCache;
     _tileSchema         = tileSchema;
     _fetchTileAsFeature = fetchTileAsFeature;
     _dataFetchStrategy  = dataFetchStrategy ?? new MinimalDataFetchStrategy();
     _fetchMachine       = new FetchMachine(this);
 }