public async Task GetTileChangeFormatAsync()
        {
            var db       = new MBT.Repository(MbtilesFilePath1);
            var original = db.ReadTile(0, 0, 0);

            {
                var r = await client.GetAsync("/xyz/world-mercator-hd/0/0/0.jpeg");

                Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
                var expected = Utils.ImageHelper.ConvertImageToFormat(original, MediaTypeNames.Image.Jpeg, 90);
                var actual   = await r.Content.ReadAsByteArrayAsync();

                Assert.AreEqual(MediaTypeNames.Image.Jpeg, r.Content.Headers.ContentType.MediaType);
                Assert.AreEqual(MediaTypeNames.Image.Jpeg, Utils.ImageHelper.GetImageMediaType(actual));
                Assert.AreEqual(expected, actual);
            }

            {
                var r = await client.GetAsync("/xyz/world-mercator-hd/0/0/0.webp");

                Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
                var expected = Utils.ImageHelper.ConvertImageToFormat(original, MediaTypeNames.Image.Webp, 90);
                var actual   = await r.Content.ReadAsByteArrayAsync();

                Assert.AreEqual(MediaTypeNames.Image.Webp, r.Content.Headers.ContentType.MediaType);
                Assert.AreEqual(MediaTypeNames.Image.Webp, Utils.ImageHelper.GetImageMediaType(actual));
                Assert.AreEqual(expected, actual);
            }
        }
        public async Task GetTileAsync()
        {
            {
                var r1 = await client.GetAsync("/xyz/world-mercator-hd/0/0/0.png");

                Assert.AreEqual(HttpStatusCode.OK, r1.StatusCode);
                Assert.AreEqual(MediaTypeNames.Image.Png, r1.Content.Headers.ContentType.MediaType);
                var expected1 = new MBT.Repository(MbtilesFilePath1).ReadTile(0, 0, 0);
                var actual1   = await r1.Content.ReadAsByteArrayAsync();

                Assert.AreEqual(expected1, actual1);
            }

            {
                var r2 = await client.GetAsync("/xyz/world-mercator-hd/?x=0&y=0&z=0");

                Assert.AreEqual(HttpStatusCode.OK, r2.StatusCode);
                Assert.AreEqual(MediaTypeNames.Image.Png, r2.Content.Headers.ContentType.MediaType);
                var expected2 = new MBT.Repository(MbtilesFilePath1).ReadTile(0, 0, 0);
                var actual2   = await r2.Content.ReadAsByteArrayAsync();

                Assert.AreEqual(expected2, actual2);
            }

            {
                var r3 = await client.GetAsync("/xyz/small-area/?x=0&y=255&z=8");

                Assert.AreEqual(HttpStatusCode.OK, r3.StatusCode);
                Assert.AreEqual(MediaTypeNames.Image.Jpeg, r3.Content.Headers.ContentType.MediaType);
                var expected3 = new MBT.Repository(MbtilesFilePath2).ReadTile(0, 0, 8);
                var actual3   = await r3.Content.ReadAsByteArrayAsync();

                Assert.AreEqual(expected3, actual3);
            }
        }
Esempio n. 3
0
        public async Task GetTile000KvpSyntaxChangeFormatAsync()
        {
            var db       = new MBT.Repository(MbtilesFilePath1);
            var original = db.ReadTile(0, 0, 0);

            {
                var expected = Utils.ImageHelper.ConvertImageToFormat(original, MediaTypeNames.Image.Jpeg, 90);
                var r        = await client.GetAsync("/wmts/?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=world-mercator-hd&STYLE=normal&FORMAT=image/jpeg&TILEMATRIXSET=EPSG:3857&TILEMATRIX=0&TILEROW=0&TILECOL=0");

                Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
                var actual = await r.Content.ReadAsByteArrayAsync();

                Assert.AreEqual(MediaTypeNames.Image.Jpeg, r.Content.Headers.ContentType.MediaType);
                Assert.AreEqual(MediaTypeNames.Image.Jpeg, Utils.ImageHelper.GetImageMediaType(actual));
                Assert.AreEqual(expected, actual);
            }

            {
                var expected = Utils.ImageHelper.ConvertImageToFormat(original, MediaTypeNames.Image.Webp, 90);
                var r        = await client.GetAsync("/wmts/?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=world-mercator-hd&STYLE=normal&FORMAT=image/webp&TILEMATRIXSET=EPSG:3857&TILEMATRIX=0&TILEROW=0&TILECOL=0");

                Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
                var actual = await r.Content.ReadAsByteArrayAsync();

                Assert.AreEqual(MediaTypeNames.Image.Webp, r.Content.Headers.ContentType.MediaType);
                Assert.AreEqual(MediaTypeNames.Image.Webp, Utils.ImageHelper.GetImageMediaType(actual));
                Assert.AreEqual(expected, actual);
            }
        }
        public async Task GetSmallAreaTmsTile800Async()
        {
            var db       = new MBT.Repository(MbtilesFilePath2);
            var expected = db.ReadTile(0, 0, 8);

            var r = await client.GetAsync("/tms/1.0.0/small-area/8/0/0.jpg");

            Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
            var actual = await r.Content.ReadAsByteArrayAsync();

            Assert.AreEqual(expected, actual);
        }
        public async Task GetWebMercatorTmsTile000Async()
        {
            var db       = new MBT.Repository(MbtilesFilePath1);
            var expected = db.ReadTile(0, 0, 0);

            var r = await client.GetAsync("/tms/1.0.0/world-mercator-hd/0/0/0.png");

            Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
            var actual = await r.Content.ReadAsByteArrayAsync();

            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        public async Task GetTile000KvpSyntaxAsync()
        {
            var db       = new MBT.Repository(MbtilesFilePath1);
            var expected = db.ReadTile(0, 0, 0);

            var r = await client.GetAsync("/wmts/?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=world-mercator-hd&STYLE=normal&FORMAT=image/png&TILEMATRIXSET=EPSG:3857&TILEMATRIX=0&TILEROW=0&TILECOL=0");

            Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
            var actual = await r.Content.ReadAsByteArrayAsync();

            Assert.AreEqual(expected, actual);
        }
Esempio n. 7
0
        public async Task GetTile000RestfulSyntaxAsync()
        {
            var db       = new MBT.Repository(MbtilesFilePath1);
            var expected = db.ReadTile(0, 0, 0);

            var r = await client.GetAsync("/wmts/tile/1.0.0/world-mercator-hd/normal/EPSG:3857/0/0/0.png");

            Assert.AreEqual(HttpStatusCode.OK, r.StatusCode);
            Assert.AreEqual(MediaTypeNames.Image.Png, r.Content.Headers.ContentType.MediaType);
            var actual = await r.Content.ReadAsByteArrayAsync();

            Assert.AreEqual(expected, actual);
        }