Example #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;
 }
Example #2
0
 /// <summary>
 /// Create tile layer for given tile source
 /// </summary>
 /// <param name="tileSource">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="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>
 /// <param name="fetchTileAsFeature">Fetch tile as feature</param>
 // ReSharper disable once UnusedParameter.Local // Is public and won't break this now
 public TileLayer(ITileSource tileSource, int minTiles = 200, int maxTiles = 300,
                  IDataFetchStrategy?dataFetchStrategy = null, IRenderFetchStrategy?renderFetchStrategy = null,
                  int minExtraTiles = -1, int maxExtraTiles = -1, Func <TileInfo, Task <IFeature?> >?fetchTileAsFeature = null)
 {
     _tileSource      = tileSource ?? throw new ArgumentException($"{tileSource} can not null");
     MemoryCache      = new MemoryCache <IFeature?>(minTiles, maxTiles);
     Style            = new RasterStyle();
     Attribution.Text = _tileSource.Attribution?.Text;
     Attribution.Url  = _tileSource.Attribution?.Url;
     _extent          = _tileSource.Schema?.Extent.ToMRect();
     dataFetchStrategy ??= new DataFetchStrategy(3);
     _renderFetchStrategy                  = renderFetchStrategy ?? new RenderFetchStrategy();
     _minExtraTiles                        = minExtraTiles;
     _maxExtraTiles                        = maxExtraTiles;
     _tileFetchDispatcher                  = new TileFetchDispatcher(MemoryCache, _tileSource.Schema, fetchTileAsFeature ?? ToFeatureAsync, dataFetchStrategy);
     _tileFetchDispatcher.DataChanged     += TileFetchDispatcherOnDataChanged;
     _tileFetchDispatcher.PropertyChanged += TileFetchDispatcherOnPropertyChanged;
 }
Example #3
0
 /// <summary>
 /// Create tile layer for given tile source
 /// </summary>
 /// <param name="tileSource">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="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>
 /// <param name="fetchTileAsFeature">Fetch tile as feature</param>
 // ReSharper disable once UnusedParameter.Local // Is public and won't break this now
 public TileLayer(ITileSource tileSource, int minTiles = 200, int maxTiles = 300,
                  IDataFetchStrategy?dataFetchStrategy = null, IRenderFetchStrategy?renderFetchStrategy = null,
                  int minExtraTiles = -1, int maxExtraTiles = -1, Func <TileInfo, IFeature?>?fetchTileAsFeature = null)
 {
     _tileSource = tileSource ?? throw new ArgumentException($"{tileSource} can not null");
     MemoryCache = new MemoryCache <IFeature?>(minTiles, maxTiles);
     Style       = new VectorStyle {
         Outline = { Color = Color.FromArgb(0, 0, 0, 0) }
     };                                                                            // initialize with transparent outline
     Attribution.Text = _tileSource.Attribution?.Text;
     Attribution.Url  = _tileSource.Attribution?.Url;
     _extent          = _tileSource.Schema?.Extent.ToMRect();
     dataFetchStrategy ??= new DataFetchStrategy(3);
     _renderFetchStrategy                  = renderFetchStrategy ?? new RenderFetchStrategy();
     _minExtraTiles                        = minExtraTiles;
     _maxExtraTiles                        = maxExtraTiles;
     _tileFetchDispatcher                  = new TileFetchDispatcher(MemoryCache, _tileSource.Schema, fetchTileAsFeature ?? ToFeature, dataFetchStrategy);
     _tileFetchDispatcher.DataChanged     += TileFetchDispatcherOnDataChanged;
     _tileFetchDispatcher.PropertyChanged += TileFetchDispatcherOnPropertyChanged;
 }