Beispiel #1
0
        public void TestWmtsRequestInParallel()
        {
            // arrange
            var resourceUrls      = CreateResourceUrls();
            var levelToIdentifier = new Dictionary <int, string> {
                [14] = "level-14"
            };
            var request  = new WmtsRequest(resourceUrls, levelToIdentifier);
            var urls     = new ConcurrentBag <Uri>(); // List is not thread save
            var tileInfo = new TileInfo {
                Index = new TileIndex(8938, 5680, 14)
            };

            // act
            var requests = new List <Func <Uri> >();

            for (var i = 0; i < 150; i++)
            {
                requests.Add(() => request.GetUri(tileInfo));
            }
            Parallel.ForEach(requests, r => urls.Add(r()));

            // assert
            var count = urls.Count(u => u.ToString() == "http://maps1.wien.gv.at/wmts/lb/farbe/google3857/level-14/5680/8938.jpeg");

            Assert.True(count == 50);
        }
Beispiel #2
0
        internal static IEnumerable <ResourceUrl> Reflect(WmtsRequest request)
        {
            var fi = typeof(WmtsRequest).GetField("_resourceUrls", BindingFlags.Instance | BindingFlags.NonPublic);

            if (fi == null)
            {
                throw new ArgumentException("Request does not have a private field '_resourceUrls'", "request");
            }
            return((IEnumerable <ResourceUrl>)fi.GetValue(request));
        }
Beispiel #3
0
        internal static Uri ReflectBaseUri(WmtsRequest request)
        {
            var fi = typeof(WmtsRequest).GetField("_baseUrl", BindingFlags.Instance | BindingFlags.NonPublic);

            if (fi == null)
            {
                throw new ArgumentException("Request does not have a private field '_baseUri'", "request");
            }

            return((Uri)fi.GetValue(request));
        }
Beispiel #4
0
        public void TestWmtsRequest()
        {
            // arrange
            var resourceUrls = CreateResourceUrls();
            var wmtsRequest  = new WmtsRequest(resourceUrls);

            // act
            var url1 = wmtsRequest.GetUri(new TileInfo {
                Index = new TileIndex(8938, 5680, "14")
            });
            var url2 = wmtsRequest.GetUri(new TileInfo {
                Index = new TileIndex(8938, 5680, "14")
            });

            // assert
            Assert.True(url1.ToString().Equals("http://maps1.wien.gv.at/wmts/lb/farbe/google3857/14/5680/8938.jpeg"));
            Assert.True(url2.ToString().Contains("maps2"));
        }
Beispiel #5
0
        public void TestWmtsRequest()
        {
            // arrange
            var resourceUrls      = CreateResourceUrls();
            var levelToIdentifier = new Dictionary <int, string> {
                [14] = "level-14"
            };
            var wmtsRequest = new WmtsRequest(resourceUrls, levelToIdentifier);

            // act
            var url1 = wmtsRequest.GetUri(new TileInfo {
                Index = new TileIndex(8938, 5680, 14)
            });
            var url2 = wmtsRequest.GetUri(new TileInfo {
                Index = new TileIndex(8938, 5680, 14)
            });

            // assert
            Assert.True(url1.ToString().Equals("http://maps1.wien.gv.at/wmts/lb/farbe/google3857/level-14/5680/8938.jpeg"));
            Assert.True(url2.ToString().Contains("maps2"));
        }