Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            foreach (var knownTileSource in Enum.GetValues(typeof(KnownTileSource)).Cast<KnownTileSource>())
            {
                if (knownTileSource.ToString().ToLower().Contains("cloudmade")) continue; // Exclude CloudMade

                KnownTileSource source = knownTileSource;
                var radioButton = ToRadioButton(knownTileSource.ToString(), () => KnownTileSources.Create(source, "soep"));
                Layers.Children.Add(radioButton);
            }
            
            Layers.Children.Add(ToRadioButton("Google Map", () => 
                CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=m@130&hl=en&x={x}&y={y}&z={z}")));
            Layers.Children.Add(ToRadioButton("Google Terrain", () => 
                CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=t@125,r@130&hl=en&x={x}&y={y}&z={z}")));

            Layers.Children.Add(ToRadioButton("WMS called through tile schema", TileSourceForWmsSample.Create));

            Layers.Children.Add(ToRadioButton("Here Maps", () =>
                new HttpTileSource(new GlobalSphericalMercator(0, 18),
                    "https://{s}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?app_id=xWVIueSv6JL0aJ5xqTxb&app_code=djPZyynKsbTjIUDOBcHZ2g",
                    new[] { "1", "2", "3", "4" }, name: "Here Maps Source")));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new initialized instance of <see cref="WellKnownTileSourceLayerConfiguration"/>.
        /// </summary>
        /// <param name="knownTileSource">The built-in tile provider to be used.</param>
        /// <param name="tileSource">The tile source corresponding to <paramref name="knownTileSource"/>.</param>
        /// <exception cref="CannotCreateTileCacheException">Thrown when creating the file
        /// cache failed.</exception>
        private WellKnownTileSourceLayerConfiguration(KnownTileSource knownTileSource, ITileSource tileSource)
            : base(SuggestTileCachePath(tileSource, knownTileSource))
        {
            this.knownTileSource = knownTileSource;

            InitializeFromTileSource(tileSource);
        }
Ejemplo n.º 3
0
        public static OsmTileServerConfig Create(KnownTileSource knownTileSource, string apiKey)
        {
            switch (knownTileSource)
            {
            default:
                return(new OsmTileServerConfig("http://{0}.tile.openstreetmap.org/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18));

            case KnownTileSource.OpenCycleMap:
                return(new OsmTileServerConfig("http://123.57.79.15/Service/Traffic.ashx?zoom={1}&x={2}&y={3}", 3, new[] { "1", "2", "3" }, 0, 16));

            case KnownTileSource.OpenCycleMapTransport:
                return(new OsmTileServerConfig("http://{0}.tile2.opencyclemap.org/transport/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18));

            case KnownTileSource.CloudMadeWebStyle:
                return(new OsmTileServerConfigWithApiKey("http://{0}.tile.cloudmade.com/{4}/1/256/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18, apiKey));

            case KnownTileSource.CloudMadeFineLineStyle:
                return(new OsmTileServerConfigWithApiKey("http://{0}.tile.cloudmade.com/{4}/2/256/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18, apiKey));

            case KnownTileSource.CloudMadeNoNames:
                return(new OsmTileServerConfigWithApiKey("http://{0}.tile.cloudmade.com/{4}/1/256/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18, apiKey));

            case KnownTileSource.MapQuest:
                return(new OsmTileServerConfig("http://otile{0}.mqcdn.com/tiles/1.0.0/osm/{1}/{2}/{3}.png", 4, new[] { "1", "2", "3", "4" }, 0, 18));

            case KnownTileSource.MapQuestAerial:
                return(new OsmTileServerConfig("http://oatile{0}.mqcdn.com/naip/{1}/{2}/{3}.png", 4, new[] { "1", "2", "3", "4" }, 0, 11));
            }
        }
        private string GetApiKey(KnownTileSource kts)
        {
            string res;

            ApiKeys.TryGetValue(kts, out res);
            return(res);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a fully initialized instance of <see cref="WellKnownTileSourceLayerConfiguration"/>.
        /// </summary>
        /// <param name="wellKnownTileSource">The tile provider to be used.</param>
        /// <returns>The new <see cref="WellKnownTileSourceLayerConfiguration"/>.</returns>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="wellKnownTileSource"/>
        /// isn't a supported member.</exception>
        /// <exception cref="CannotCreateTileCacheException">Thrown when creating the file
        /// cache failed.</exception>
        public static WellKnownTileSourceLayerConfiguration CreateInitializedConfiguration(WellKnownTileSource wellKnownTileSource)
        {
            KnownTileSource knownTileSourceEquivalent = WellKnownTileSourceToKnownTileSource(wellKnownTileSource);

            ITileSource tileSource = TileSourceFactory.Instance.GetKnownTileSource(knownTileSourceEquivalent);

            return(new WellKnownTileSourceLayerConfiguration(knownTileSourceEquivalent, tileSource));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates an instance of <see cref="WellKnownTileSourceLayerConfiguration"/>.
        /// </summary>
        /// <param name="knownTileSource">The built-in tile provider to be used.</param>
        /// <param name="persistentCacheDirectoryPath">The directory path to the persistent tile cache.</param>
        /// <exception cref="ArgumentException">Thrown when <paramref name="persistentCacheDirectoryPath"/>
        /// is an invalid folder path.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="knownTileSource"/>
        /// isn't a supported member.</exception>
        /// <exception cref="CannotCreateTileCacheException">Thrown when creating the file
        /// cache failed.</exception>
        private WellKnownTileSourceLayerConfiguration(string persistentCacheDirectoryPath, KnownTileSource knownTileSource)
            : base(persistentCacheDirectoryPath)
        {
            this.knownTileSource = knownTileSource;

            ITileSource tileSource = TileSourceFactory.Instance.GetKnownTileSource(knownTileSource);

            InitializeFromTileSource(tileSource);
        }
Ejemplo n.º 7
0
        public ITileSource GetKnownTileSource(KnownTileSource knownTileSource)
        {
            if (wellKnownTileSource == null)
            {
                throw new NotSupportedException("use TestTileSourceFactory() to set the expected well known tile source");
            }

            return(wellKnownTileSource);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Static factory method for known tile services
        /// </summary>
        /// <param name="source">The source</param>
        /// <param name="apiKey">An (optional) API key</param>
        /// <param name="persistentCache">A place to permanently store tiles (file of database)</param>
        /// <param name="tileFetcher">Option to override the web request</param>
        /// <returns>The tile source</returns>
        public static HttpTileSource Create(KnownTileSource source = KnownTileSource.OpenCycleMap, string apiKey             = null,
                                            IPersistentCache <byte[]> persistentCache = null, Func <Uri, byte[]> tileFetcher = null)
        {
            switch (source)
            {
            case KnownTileSource.OpenCycleMap:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 17),
                                          "https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey={k}",
                                          new[] { "a", "b", "c" }, apiKey: apiKey, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.ThunderforestTransport:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 20),
                                          "https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey={k}",
                                          new[] { "a", "b", "c" }, apiKey: apiKey, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.ThunderforestOutdoors:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 20),
                                          "https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey={k}",
                                          new[] { "a", "b", "c" }, apiKey: apiKey, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.ThunderforestLandscape:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 20),
                                          "https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey={k}",
                                          new[] { "a", "b", "c" }, apiKey: apiKey, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.BingAerial:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft")));

            case KnownTileSource.BingHybrid:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft")));

            case KnownTileSource.BingRoads:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft")));

            default:
                throw new NotSupportedException("KnownTileSource not known");
            }
        }
Ejemplo n.º 9
0
 private void SetMainTileLayer(KnownTileSource tileSource)
 {
     var mapControl = GetMapControl();
     if (mapControl != null)
     {
         mapControl.Map.Layers.Clear();
         var mapLayer = new TileLayer(KnownTileSources.Create(tileSource)) { Name = "Map" };
         mapControl.Map.Layers.Add(mapLayer);
         mapControl.Refresh();
     }
 }
Ejemplo n.º 10
0
        private static SharpMap.Map InitializeMapBing(KnownTileSource mt)
        {
            var map = new SharpMap.Map();

            var tileLayer = new SharpMap.Layers.TileLayer(
                KnownTileSources.Create(mt), "TileLayer - Bing " + mt);

            map.BackgroundLayer.Add(tileLayer);
            map.ZoomToBox(tileLayer.Envelope);
            return(map);
        }
Ejemplo n.º 11
0
        private static string SuggestTileCachePath(ITileSource tileSource, KnownTileSource knownTileSource)
        {
            ITileSchema tileSchema = tileSource.Schema;
            string      host       = knownTileSource.ToString();
            string      format     = tileSchema.Format;

            foreach (char c in Path.GetInvalidFileNameChars())
            {
                host = host.Replace(c, '$');
            }

            return(Path.Combine(BruTileSettings.PersistentCacheDirectoryRoot, "WellKnown", host, format));
        }
Ejemplo n.º 12
0
        public static Map CreateMap(KnownTileSource source = KnownTileSource.BingAerial)
        {
            var map    = new Map();
            var apiKey = "Enter your api key here"; // Contact Microsoft about how to use this

            map.Layers.Add(new TileLayer(KnownTileSources.Create(source, apiKey),
                                         fetchStrategy: new FetchStrategy()) // FetchStrategy get tiles from higher levels in advance
            {
                Name = "Bing Aerial",
            });
            map.Home = n => n.NavigateTo(new Point(1059114.80157058, 5179580.75916194), map.Resolutions[14]);
            return(map);
        }
Ejemplo n.º 13
0
        public void ReplaceLayer(KnownTileSource tileSource)
        {
            if (activeLayer != null)
            {
                mapView.Map.Layers.Remove(activeLayer);
                activeLayer = null;
            }

            var api = "YOUR_API_HERE";

            activeLayer            = OpenStreetMap.CreateTileLayer();
            activeLayer.TileSource = KnownTileSources.Create(tileSource, api);
            mapView.Map.Layers.Add(activeLayer);
        }
Ejemplo n.º 14
0
        public static Map CreateMap(IPersistentCache <byte[]>?persistentCache, KnownTileSource source = KnownTileSource.BingAerial)
        {
            var map = new Map();

            var apiKey = "Enter your api key here"; // Contact Microsoft about how to use this

            map.Layers.Add(new TileLayer(KnownTileSources.Create(source, apiKey, persistentCache),
                                         dataFetchStrategy: new DataFetchStrategy()) // DataFetchStrategy prefetches tiles from higher levels
            {
                Name = "Bing Aerial",
            });
            map.Home      = n => n.NavigateTo(new MPoint(1059114.80157058, 5179580.75916194), map.Resolutions[14]);
            map.BackColor = Color.FromString("#000613");

            return(map);
        }
Ejemplo n.º 15
0
        public MainWindow()
        {
            InitializeComponent();

            foreach (var knownTileSource in Enum.GetValues(typeof(KnownTileSource)).Cast <KnownTileSource>())
            {
                if (knownTileSource.ToString().ToLower().Contains("cloudmade"))
                {
                    continue;                                                             // Exclude CloudMade
                }
                KnownTileSource source      = knownTileSource;
                var             radioButton = ToRadioButton(knownTileSource.ToString(), () => KnownTileSources.Create(source, "soep"));
                Layers.Children.Add(radioButton);
            }

            Layers.Children.Add(ToRadioButton("Google Map", () =>
                                              CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=m@130&hl=en&x={x}&y={y}&z={z}")));
            Layers.Children.Add(ToRadioButton("Google Terrain", () =>
                                              CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=t@125,r@130&hl=en&x={x}&y={y}&z={z}")));
        }
        public KnownTileLayerConfiguration(string fileCacheRoot, KnownTileSource tileSource, string apiKey) 
            : base(BruTileLayerPlugin.Settings.PermaCacheType, 
                   fileCacheRoot ?? Path.Combine(BruTileLayerPlugin.Settings.PermaCacheRoot , tileSource.ToString()))
        {
            _knownTileSource = tileSource;
            _apiKey = apiKey;
            /*
            if (tileServers == KnownTileServers.Custom)
                throw new NotSupportedException();
            */

            TileSource = KnownTileSources.Create(tileSource, apiKey);
            TileCache = CreateTileCache();
            LegendText = tileSource.ToString();

            _tileFetcher = new TileFetcher(ReflectionHelper.Reflect(TileSource),
                                           BruTileLayerPlugin.Settings.MemoryCacheMinimum,
                                           BruTileLayerPlugin.Settings.MemoryCacheMaximum,
                                           TileCache);
        }
        public KnownTileLayerConfiguration(string fileCacheRoot, KnownTileSource tileSource, string apiKey)
            : base(BruTileLayerPlugin.Settings.PermaCacheType,
                   fileCacheRoot ?? Path.Combine(BruTileLayerPlugin.Settings.PermaCacheRoot, tileSource.ToString()))
        {
            _knownTileSource = tileSource;
            _apiKey          = apiKey;

            /*
             * if (tileServers == KnownTileServers.Custom)
             *  throw new NotSupportedException();
             */

            TileSource = KnownTileSources.Create(tileSource, apiKey);
            TileCache  = CreateTileCache();
            LegendText = tileSource.ToString();

            _tileFetcher = new TileFetcher(ReflectionHelper.Reflect(TileSource),
                                           BruTileLayerPlugin.Settings.MemoryCacheMinimum,
                                           BruTileLayerPlugin.Settings.MemoryCacheMaximum,
                                           TileCache);
        }
Ejemplo n.º 18
0
 public static BruTileLayer CreateKnownLayer(KnownTileSource source, string apiKey)
 {
     var config = new KnownTileLayerConfiguration(null, source, apiKey);
     return new BruTileLayer(config);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Static factory method for known tile services
        /// </summary>
        /// <param name="source">The source</param>
        /// <param name="apiKey">An (optional) API key</param>
        /// <returns>The tile source</returns>
        public static ITileSource Create(KnownTileSource source = KnownTileSource.OpenStreetMap, string apiKey = null)
        {
            switch (source)
            {
            //case KnownTileSource.OpenStreetMap:
            //    return new HttpTileSource(new GlobalSphericalMercator(0, 18),
            //        "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
            //        new[] {"a", "b", "c"}, name: source.ToString());
            case KnownTileSource.OpenCycleMap:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 17),
                                          "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, name: source.ToString()));

            case KnownTileSource.OpenCycleMapTransport:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 20),
                                          "http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, name: source.ToString()));

            case KnownTileSource.CloudMadeWebStyle:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.cloudmade.com/{k}/1/256/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, apiKey, source.ToString()));

            case KnownTileSource.CloudMadeFineLineStyle:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.cloudmade.com/{k}/2/256/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, apiKey, source.ToString()));

            case KnownTileSource.CloudMadeNoNames:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.cloudmade.com/{k}/3/256/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, apiKey, source.ToString()));

            case KnownTileSource.MapQuest:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png",
                                          new[] { "1", "2", "3", "4" }, name: source.ToString()));

            case KnownTileSource.MapQuestAerial:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 11),
                                          "http://otile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png",
                                          new[] { "1", "2", "3", "4" }, name: source.ToString()));

            case KnownTileSource.MapQuestRoadsAndLabels:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png",
                                          new[] { "1", "2", "3", "4" }, name: source.ToString()));

            case KnownTileSource.BingAerial:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                                          new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString()));

            case KnownTileSource.BingHybrid:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                                          new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString()));

            case KnownTileSource.BingRoads:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString()));

            case KnownTileSource.BingAerialStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                                          new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString()));

            case KnownTileSource.BingHybridStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                                          new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString()));

            case KnownTileSource.BingRoadsStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString()));

            case KnownTileSource.StamenToner:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString()));

            case KnownTileSource.StamenTonerLite:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString()));

            case KnownTileSource.StamenWatercolor:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString()));

            case KnownTileSource.StamenTerrain:
                return(new HttpTileSource(new GlobalSphericalMercator(4)
                {
                    Extent = new Extent(-14871588.04, 2196494.41775, -5831227.94199995, 10033429.95725)
                },
                                          "http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString()));

            case KnownTileSource.EsriWorldTopo:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString()));

            case KnownTileSource.EsriWorldPhysical:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString()));

            case KnownTileSource.EsriWorldShadedRelief:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString()));

            case KnownTileSource.EsriWorldReferenceOverlay:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString()));

            case KnownTileSource.EsriWorldTransportation:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString()));

            case KnownTileSource.EsriWorldBoundariesAndPlaces:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString()));

            case KnownTileSource.EsriWorldDarkGrayBase:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 10),
                                          "http://server.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString()));

            default:
                throw new NotSupportedException("KnownTileSource not known");
            }
        }
 private string GetApiKey(KnownTileSource kts)
 {
     string res;
     ApiKeys.TryGetValue(kts, out res);
     return res;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Static factory method for known tile services
        /// </summary>
        /// <param name="source">The source</param>
        /// <param name="apiKey">An (optional) API key</param>
        /// <param name="persistentCache">A place to permanently store tiles (file of database)</param>
        /// <param name="tileFetcher">Option to override the web request</param>
        /// <returns>The tile source</returns>
        public static HttpTileSource Create(KnownTileSource source = KnownTileSource.OpenStreetMap, string apiKey            = null,
                                            IPersistentCache <byte[]> persistentCache = null, Func <Uri, byte[]> tileFetcher = null)
        {
            switch (source)
            {
            case KnownTileSource.OpenStreetMap:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 18),
                                          "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.OpenCycleMap:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 17),
                                          "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.OpenCycleMapTransport:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 20),
                                          "http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.BingAerial:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft")));

            case KnownTileSource.BingHybrid:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft")));

            case KnownTileSource.BingRoads:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft")));

            case KnownTileSource.BingAerialStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher));

            case KnownTileSource.BingHybridStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher));

            case KnownTileSource.BingRoadsStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(1),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher));

            case KnownTileSource.StamenToner:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.StamenTonerLite:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.StamenWatercolor:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution));

            case KnownTileSource.StamenTerrain:
                return
                    (new HttpTileSource(
                         new GlobalSphericalMercator(4)
                {
                    Extent = new Extent(-14871588.04, 2196494.41775, -5831227.94199995, 10033429.95725)
                },
                         "http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.png",
                         new[] { "a", "b", "c", "d" }, name: source.ToString(),
                         persistentCache: persistentCache, tileFetcher: tileFetcher,
                         attribution: OpenStreetMapAttribution));

            case KnownTileSource.EsriWorldTopo:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher));

            case KnownTileSource.EsriWorldPhysical:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 8),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher));

            case KnownTileSource.EsriWorldShadedRelief:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 13),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher));

            case KnownTileSource.EsriWorldReferenceOverlay:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 13),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher));

            case KnownTileSource.EsriWorldTransportation:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher));

            case KnownTileSource.EsriWorldBoundariesAndPlaces:
                return(new HttpTileSource(new GlobalSphericalMercator(),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher));

            case KnownTileSource.EsriWorldDarkGrayBase:
                return(new HttpTileSource(new GlobalSphericalMercator(0, 16),
                                          "https://server.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher));

            default:
                throw new NotSupportedException("KnownTileSource not known");
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates a layer displaying a known tile source
        /// </summary>
        /// <param name="source">The known tile source</param>
        /// <param name="apiKey">The api key</param>
        /// <returns>The layer</returns>
        public static BruTileLayer CreateKnownLayer(KnownTileSource source, string apiKey)
        {
            var config = new KnownTileLayerConfiguration(null, source, apiKey);

            return(new BruTileLayer(config));
        }
Ejemplo n.º 23
0
 public ITileSource GetKnownTileSource(KnownTileSource knownTileSource)
 {
     return(KnownTileSources.Create(knownTileSource, userAgent: "Riskeer"));
 }
Ejemplo n.º 24
0
 public OsmRequest(KnownTileSource renderer, string apiKey)
     : this(OsmTileServerConfig.Create(renderer, apiKey))
 {
 }
Ejemplo n.º 25
0
 public OsmRequest(KnownTileSource knownTileSources)
     : this(OsmTileServerConfig.Create(knownTileSources, null))
 {
 }
Ejemplo n.º 26
0
 public OsmRequest(KnownTileSource renderer, string apiKey)
     : this(OsmTileServerConfig.Create(renderer, apiKey))
 {
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Static factory method for known tile services
        /// </summary>
        /// <param name="source">The source</param>
        /// <param name="apiKey">An (optional) API key</param>
        /// <param name="persistentCache">A place to permanently store tiles (file of database)</param>
        /// <param name="tileFetcher">Option to override the web request</param>
        /// <param name="userAgent">The 'User-Agent' http header added to the tile request</param>
        /// <param name="minZoomLevel">The minimum zoom level</param>
        /// <param name="maxZoomLevel">The maximum zoom level</param>
        /// <returns>The tile source</returns>
        public static HttpTileSource Create(KnownTileSource source = KnownTileSource.OpenStreetMap, string apiKey            = null,
                                            IPersistentCache <byte[]> persistentCache = null, Func <Uri, byte[]> tileFetcher = null, string userAgent = null,
                                            int minZoomLevel = 0, int maxZoomLevel = 20)
        {
            switch (source)
            {
            case KnownTileSource.OpenStreetMap:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(18, maxZoomLevel)),
                                          "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
                                          name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution, userAgent: userAgent));

            case KnownTileSource.OpenCycleMap:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(17, maxZoomLevel)),
                                          "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution, userAgent: userAgent));

            case KnownTileSource.OpenCycleMapTransport:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(20, maxZoomLevel)),
                                          "http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution, userAgent: userAgent));

            case KnownTileSource.BingAerial:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(1, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://t{s}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft"), userAgent));

            case KnownTileSource.BingHybrid:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(1, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://t{s}.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft"), userAgent));

            case KnownTileSource.BingRoads:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(1, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://t{s}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, new Attribution("© Microsoft"), userAgent));

            case KnownTileSource.BingAerialStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(1, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, userAgent: userAgent));

            case KnownTileSource.BingHybridStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(1, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, userAgent: userAgent));

            case KnownTileSource.BingRoadsStaging:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(1, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "http://t{s}.staging.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                                          new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                                          persistentCache, tileFetcher, userAgent: userAgent));

            case KnownTileSource.StamenToner:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution, userAgent: userAgent));

            case KnownTileSource.StamenTonerLite:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution, userAgent: userAgent));

            case KnownTileSource.StamenWatercolor:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png",
                                          new[] { "a", "b", "c", "d" }, name: source.ToString(),
                                          persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: OpenStreetMapAttribution, userAgent: userAgent));

            case KnownTileSource.StamenTerrain:
                return
                    (new HttpTileSource(
                         new GlobalSphericalMercator(Math.Max(4, minZoomLevel), Math.Min(19, maxZoomLevel))
                {
                    Extent = new Extent(-14871588.04, 2196494.41775, -5831227.94199995, 10033429.95725)
                },
                         "http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.png",
                         new[] { "a", "b", "c", "d" }, name: source.ToString(),
                         persistentCache: persistentCache, tileFetcher: tileFetcher,
                         attribution: OpenStreetMapAttribution, userAgent: userAgent));

            case KnownTileSource.EsriWorldTopo:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher, userAgent: userAgent));

            case KnownTileSource.EsriWorldPhysical:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(8, maxZoomLevel)),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher, userAgent: userAgent));

            case KnownTileSource.EsriWorldShadedRelief:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(13, maxZoomLevel)),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher, userAgent: userAgent));

            case KnownTileSource.EsriWorldReferenceOverlay:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(13, maxZoomLevel)),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher, userAgent: userAgent));

            case KnownTileSource.EsriWorldTransportation:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher, userAgent: userAgent));

            case KnownTileSource.EsriWorldBoundariesAndPlaces:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher, userAgent: userAgent));

            case KnownTileSource.EsriWorldDarkGrayBase:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(16, maxZoomLevel)),
                                          "https://server.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher, userAgent: userAgent));

            case KnownTileSource.BKGTopPlusColor:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://sg.geodatenzentrum.de/wmts_topplus_open/tile/1.0.0/web/default/WEBMERCATOR/{z}/{y}/{x}.png",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: BKGAttribution, userAgent: userAgent));

            case KnownTileSource.BKGTopPlusGrey:
                return(new HttpTileSource(new GlobalSphericalMercator(Math.Max(0, minZoomLevel), Math.Min(19, maxZoomLevel)),
                                          "https://sg.geodatenzentrum.de/wmts_topplus_open/tile/1.0.0/web_grau/default/WEBMERCATOR/{z}/{y}/{x}.png",
                                          name: source.ToString(), persistentCache: persistentCache, tileFetcher: tileFetcher,
                                          attribution: BKGAttribution, userAgent: userAgent));

            default:
                throw new NotSupportedException("KnownTileSource not known");
            }
        }
Ejemplo n.º 28
0
 public OsmRequest(KnownTileSource knownTileSources)
     : this(OsmTileServerConfig.Create(knownTileSources, null))
 {
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Static factory method for known tile services
 /// </summary>
 /// <param name="source">The source</param>
 /// <param name="apiKey">An (optional) API key</param>
 /// <param name="persistentCache">A place to permanently store tiles (file of database)</param>
 /// <param name="tileFetcher">Option to override the web request</param>
 /// <returns>The tile source</returns>
 public static HttpTileSource Create(KnownTileSource source = KnownTileSource.OpenStreetMap, string apiKey = null,
     IPersistentCache<byte[]> persistentCache = null, Func<Uri, byte[]> tileFetcher = null)
 {
     switch (source)
     {
         case KnownTileSource.OpenStreetMap:
             return new HttpTileSource(new GlobalSphericalMercator(0, 18),
                 "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.OpenCycleMap:
             return new HttpTileSource(new GlobalSphericalMercator(0, 17),
                 "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.OpenCycleMapTransport:
             return new HttpTileSource(new GlobalSphericalMercator(0, 20),
                 "http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png",
                  new[] {"a", "b", "c"}, name: source.ToString(),
                  persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.CloudMadeWebStyle:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://{s}.tile.cloudmade.com/{k}/1/256/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c"}, apiKey, source.ToString(), persistentCache, tileFetcher);
         case KnownTileSource.CloudMadeFineLineStyle:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://{s}.tile.cloudmade.com/{k}/2/256/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c"}, apiKey, source.ToString(), persistentCache, tileFetcher);
         case KnownTileSource.CloudMadeNoNames:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://{s}.tile.cloudmade.com/{k}/3/256/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c"}, apiKey, source.ToString(), persistentCache, tileFetcher);
         case KnownTileSource.MapQuest:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png",
                 new[] {"1", "2", "3", "4"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.MapQuestAerial:
             return new HttpTileSource(new GlobalSphericalMercator(0, 11),
                 "http://otile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png",
                 new[] {"1", "2", "3", "4"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.MapQuestRoadsAndLabels:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png",
                 new[] {"1", "2", "3", "4"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.BingAerial:
             return new HttpTileSource(new GlobalSphericalMercator(1),
                 "http://t{s}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                 new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                 persistentCache, tileFetcher);
         case KnownTileSource.BingHybrid:
             return new HttpTileSource(new GlobalSphericalMercator(1),
                 "http://t{s}.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                 new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                 persistentCache, tileFetcher);
         case KnownTileSource.BingRoads:
             return new HttpTileSource(new GlobalSphericalMercator(1),
                 "http://t{s}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                 new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                 persistentCache, tileFetcher);
         case KnownTileSource.BingAerialStaging:
             return new HttpTileSource(new GlobalSphericalMercator(1),
                 "http://t{s}.staging.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=517&token={k}",
                 new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                 persistentCache, tileFetcher);
         case KnownTileSource.BingHybridStaging:
             return new HttpTileSource(new GlobalSphericalMercator(1),
                 "http://t{s}.staging.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=517&token={k}",
                 new [] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                 persistentCache, tileFetcher);
         case KnownTileSource.BingRoadsStaging:
             return new HttpTileSource(new GlobalSphericalMercator(1),
                 "http://t{s}.staging.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=517&token={k}",
                 new[] { "0", "1", "2", "3", "4", "5", "6", "7" }, apiKey, source.ToString(),
                 persistentCache, tileFetcher);
         case KnownTileSource.StamenToner:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c", "d"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.StamenTonerLite:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c", "d"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.StamenWatercolor:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png",
                 new[] {"a", "b", "c", "d"}, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.StamenTerrain:
             return new HttpTileSource(new GlobalSphericalMercator(4) { Extent = new Extent(-14871588.04,2196494.41775,-5831227.94199995,10033429.95725) },
                 "http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.png",
                 new[] { "a", "b", "c", "d" }, name: source.ToString(),
                 persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.EsriWorldTopo:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",
                 name: source.ToString(), persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.EsriWorldPhysical:
             return new HttpTileSource(new GlobalSphericalMercator(0, 8),
                 "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",
                 name: source.ToString(), persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.EsriWorldShadedRelief:
             return new HttpTileSource(new GlobalSphericalMercator(0, 13),
                 "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",
                 name: source.ToString(), persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.EsriWorldReferenceOverlay:
             return new HttpTileSource(new GlobalSphericalMercator(0, 13),
                 "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",
                 name: source.ToString(), persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.EsriWorldTransportation:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",
                 name: source.ToString(), persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.EsriWorldBoundariesAndPlaces:
             return new HttpTileSource(new GlobalSphericalMercator(),
                 "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",
                 name: source.ToString(), persistentCache:persistentCache, tileFetcher:tileFetcher);
         case KnownTileSource.EsriWorldDarkGrayBase:
             return new HttpTileSource(new GlobalSphericalMercator(0, 16),
                 "http://server.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",
                 name: source.ToString(), persistentCache:persistentCache, tileFetcher:tileFetcher);
         default:
             throw new NotSupportedException("KnownTileSource not known");
     }
 }
Ejemplo n.º 30
0
 public static OsmTileServerConfig Create(KnownTileSource knownTileSource, string apiKey)
 {
     switch (knownTileSource)
     {
         default:
             return new OsmTileServerConfig("http://{0}.tile.openstreetmap.org/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18);
         case KnownTileSource.OpenCycleMap:
             return new OsmTileServerConfig("http://{0}.tile.opencyclemap.org/cycle/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 16);
         case KnownTileSource.OpenCycleMapTransport:
             return new OsmTileServerConfig("http://{0}.tile2.opencyclemap.org/transport/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18);
         case KnownTileSource.CloudMadeWebStyle:
             return new OsmTileServerConfigWithApiKey("http://{0}.tile.cloudmade.com/{4}/1/256/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18, apiKey);
         case KnownTileSource.CloudMadeFineLineStyle:
             return new OsmTileServerConfigWithApiKey("http://{0}.tile.cloudmade.com/{4}/2/256/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18, apiKey);
         case KnownTileSource.CloudMadeNoNames:
             return new OsmTileServerConfigWithApiKey("http://{0}.tile.cloudmade.com/{4}/1/256/{1}/{2}/{3}.png", 3, new[] { "a", "b", "c" }, 0, 18, apiKey);
         case KnownTileSource.MapQuest:
             return new OsmTileServerConfig("http://otile{0}.mqcdn.com/tiles/1.0.0/osm/{1}/{2}/{3}.png", 4, new[] { "1", "2", "3", "4" }, 0, 18);
         case KnownTileSource.MapQuestAerial:
             return new OsmTileServerConfig("http://oatile{0}.mqcdn.com/naip/{1}/{2}/{3}.png", 4, new[] { "1", "2", "3", "4" }, 0, 11);
      }
 }