public ITileSource CreateTileSource()
        {
            var request = (HttpWebRequest)WebRequest.Create(_url);

            request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14";
            var response   = (HttpWebResponse)request.GetResponse();
            var stream     = response.GetResponseStream();
            var tileSource = TileMapParser.CreateTileSource(stream);
            var s          = new SphericalMercatorInvertedWorldSchema();

            // now remove all resolutions that are not in the Tilesource.
            // For example Strava level 18 we must not draw.
            var l = new List <String>();

            foreach (var res in s.Resolutions)
            {
                var r = tileSource.Schema.Resolutions.ContainsKey(res.Key);
                if (!r)
                {
                    l.Add(res.Key);
                }
            }
            foreach (var p in l)
            {
                s.Resolutions.Remove(p);
            }

            return(new TileSource(tileSource.Provider, s));
        }
Example #2
0
        public void TestSphericalMercatorInvertedWorldSchema()
        {
            string message;
            var    s1    = new SphericalMercatorInvertedWorldSchema();
            var    s2    = SandD(s1);
            var    equal = EqualTileSchemas(s1, s2, out message);

            Assert.IsTrue(equal, message);
        }
 public GeodanWorldWmsTileSource()
 {
     var schema = new SphericalMercatorInvertedWorldSchema();
     schema.Srs = "EPSG:900913";
     const string url = "http://geoserver.nl/world/mapserv.cgi?map=world/world.map&VERSION=1.1.1";
     var request = new WmscRequest(new Uri(url), schema,
       new List<string>(new [] { "world" }), new List<string>(), new Dictionary<string, string>());
     Provider = new WebTileProvider(request);
     Schema = new SphericalMercatorInvertedWorldSchema();
 }
Example #4
0
        public GeodanWorldWmsTileSource()
        {
            var schema = new SphericalMercatorInvertedWorldSchema();

            schema.Srs = "EPSG:900913";
            const string url     = "http://geoserver.nl/world/mapserv.cgi?map=world/world.map&VERSION=1.1.1";
            var          request = new WmscRequest(new Uri(url), schema,
                                                   new List <string>(new [] { "world" }), new List <string>(), new Dictionary <string, string>());

            Provider = new WebTileProvider(request);
            Schema   = new SphericalMercatorInvertedWorldSchema();
        }
Example #5
0
        private void button7_Click(object sender, EventArgs e)
        {
            ITileSchema schema = new SphericalMercatorInvertedWorldSchema();

            ILayer[]           layers   = CreateLayers();
            SharpMapTileSource source   = new SharpMapTileSource(schema, layers);
            TileAsyncLayer     osmLayer = new TileAsyncLayer(source, "TileLayer - SharpMap");

            this.mapBox1.Map.BackgroundLayer.Clear();
            this.mapBox1.Map.BackgroundLayer.Add(osmLayer);
            this.mapBox1.Refresh();
        }
Example #6
0
 public GoogleTileSource(GoogleRequest request, IPersistentCache <byte[]> persistentCache = null)
 {
     _tileSchema = new SphericalMercatorInvertedWorldSchema();
     _provider   = new HttpTileProvider(request, persistentCache,
                                        // The Google requests needs to fake the UserAgent en Referer.
                                        uri =>
     {
         var httpWebRequest       = (HttpWebRequest)WebRequest.Create(uri);
         httpWebRequest.UserAgent = UserAgent;
         httpWebRequest.Referer   = Referer;
         return(RequestHelper.FetchImage(httpWebRequest));
     });
 }
Example #7
0
 public OsmTileSource()
 {
     Schema   = new SphericalMercatorInvertedWorldSchema();
     Provider = new WebTileProvider(new TmsRequest(new Uri("http://b.tile.openstreetmap.org"), "png"));
 }
Example #8
0
 public GoogleTileSource(GoogleRequest request, ITileCache <byte[]> fileCache)
 {
     _tileSchema   = new SphericalMercatorInvertedWorldSchema();
     _tileProvider = new WebTileProvider(request, fileCache, UserAgent, Referer, true);
 }
Example #9
0
 private void button7_Click(object sender, EventArgs e)
 {
     ITileSchema schema = new SphericalMercatorInvertedWorldSchema();
     ILayer[] layers = CreateLayers();
     SharpMapTileSource source = new SharpMapTileSource(schema, layers);
     TileAsyncLayer osmLayer = new TileAsyncLayer(source, "TileLayer - SharpMap");
     this.mapBox1.Map.BackgroundLayer.Clear();
     this.mapBox1.Map.BackgroundLayer.Add(osmLayer);
     this.mapBox1.Refresh();
 }