Ejemplo n.º 1
0
 def test_out_of_extent(self):
     resp = self.app.get('http://localhost/service?SERVICE=WMS&REQUEST=GetMap'
         '&LAYERS=direct&STYLES='
         '&WIDTH=100&HEIGHT=100&FORMAT=image/png'
         '&BBOX=-10000,0,0,1000&SRS=EPSG:25832'
         '&VERSION=1.1.0&TRANSPARENT=TRUE')
     # empty/transparent response
     eq_(resp.content_type, 'image/png')
     assert is_png(resp.body)
     assert is_transparent(resp.body)
Ejemplo n.º 2
0
 def test_out_of_extent(self, app):
     resp = app.get("http://localhost/service?SERVICE=WMS&REQUEST=GetMap"
                    "&LAYERS=direct&STYLES="
                    "&WIDTH=100&HEIGHT=100&FORMAT=image/png"
                    "&BBOX=-10000,0,0,1000&SRS=EPSG:25832"
                    "&VERSION=1.1.0&TRANSPARENT=TRUE")
     # empty/transparent response
     assert resp.content_type == "image/png"
     assert is_png(resp.body)
     assert is_transparent(resp.body)
Ejemplo n.º 3
0
    def test_get_tile_limited_to_outside(self):
        def auth(service, layers, environ, **kw):
            eq_(environ['PATH_INFO'], '/wmts/layer3/GLOBAL_MERCATOR/2/0/0.jpeg')
            eq_(service, 'wmts')
            eq_(len(layers), 1)
            return {
                'authorized': 'partial',
                'limited_to': {
                    'geometry': [0, -89, 90, 89],
                    'srs': 'EPSG:4326',
                },
                'layers': {
                    'layer3': {'tile': True},
                }
            }

        resp = self.app.get('/wmts/layer3/GLOBAL_MERCATOR/2/0/0.jpeg', extra_environ={'mapproxy.authorize': auth})

        eq_(resp.content_type, 'image/png')
        is_transparent(resp.body)
Ejemplo n.º 4
0
 def test_out_of_extent(self):
     resp = self.app.get(
         'http://localhost/service?SERVICE=WMS&REQUEST=GetMap'
         '&LAYERS=direct&STYLES='
         '&WIDTH=100&HEIGHT=100&FORMAT=image/png'
         '&BBOX=-10000,0,0,1000&SRS=EPSG:25832'
         '&VERSION=1.1.0&TRANSPARENT=TRUE')
     # empty/transparent response
     eq_(resp.content_type, 'image/png')
     assert is_png(resp.body)
     assert is_transparent(resp.body)
Ejemplo n.º 5
0
    def test_get_tile_limited_to_outside(self):
        def auth(service, layers, environ, **kw):
            eq_(environ['PATH_INFO'], '/wmts/layer3/GLOBAL_MERCATOR/2/0/0.jpeg')
            eq_(service, 'wmts')
            eq_(len(layers), 1)
            return {
                'authorized': 'partial',
                'limited_to': {
                    'geometry': [0, -89, 90, 89],
                    'srs': 'EPSG:4326',
                },
                'layers': {
                    'layer3': {'tile': True},
                }
            }

        resp = self.app.get('/wmts/layer3/GLOBAL_MERCATOR/2/0/0.jpeg', extra_environ={'mapproxy.authorize': auth})

        eq_(resp.content_type, 'image/png')
        is_transparent(resp.body)
Ejemplo n.º 6
0
 def test_online(self):
     common_params = (r'?SERVICE=WMS&FORMAT=image%2Fpng'
                               '&REQUEST=GetMap&HEIGHT=200&SRS=EPSG%3A4326&styles='
                               '&VERSION=1.1.1&BBOX=9.0,50.0,10.0,51.0'
                               '&WIDTH=200&transparent=True')
     
     expected_req = [({'path': '/service_a' + common_params + '&layers=a_one'},
                      {'body': transp, 'headers': {'content-type': 'image/png'}}),
                     ]
                      
     with mock_httpd(('localhost', 42423), expected_req):
         self.common_map_req.params.layers = 'online'
         resp = self.app.get(self.common_map_req)
         assert 'Cache-Control' not in resp.headers
         eq_(resp.content_type, 'image/png')
         assert is_transparent(resp.body)
Ejemplo n.º 7
0
    def test_online(self):
        common_params = (r'?SERVICE=WMS&FORMAT=image%2Fpng'
                                  '&REQUEST=GetMap&HEIGHT=200&SRS=EPSG%3A4326&styles='
                                  '&VERSION=1.1.1&BBOX=9.0,50.0,10.0,51.0'
                                  '&WIDTH=200&transparent=True')

        expected_req = [({'path': '/service_a' + common_params + '&layers=a_one'},
                         {'body': transp, 'headers': {'content-type': 'image/png'}}),
                        ]

        with mock_httpd(('localhost', 42423), expected_req):
            self.common_map_req.params.layers = 'online'
            resp = self.app.get(self.common_map_req)
            assert 'Cache-Control' not in resp.headers
            eq_(resp.content_type, 'image/png')
            assert is_transparent(resp.body)
    def test_mixed_mode(self):
        with create_mixed_mode_img((512, 256)) as img:
            expected_req = ({'path': self.expected_base_path +
                                     '&layers=mixedsource' +
                                     '&format=image%2Fpng' +
                                     '&transparent=True'},
                            {'body': img.read(), 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req]):
                resp = self.app.get('/tms/1.0.0/mixed_mode/0/0/0.png')
                eq_(resp.content_type, 'image/png')
                assert is_transparent(resp.body)

                resp = self.app.get('/tms/1.0.0/mixed_mode/0/1/0.png')
                eq_(resp.content_type, 'image/jpeg')
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/000/000/000/000.mixed')
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/001/000/000/000.mixed')                   
Ejemplo n.º 9
0
 def test_get_map_mixed(self):
     # only res layer matches resolution range
     self.common_map_req.params['layers'] = 'res,scale'
     self.common_map_req.params['bbox'] = '0,0,100000,100000'
     self.common_map_req.params['srs'] = 'EPSG:900913'
     self.common_map_req.params.size = 100, 100
     self.created_tiles.append('res_cache_EPSG900913/08/000/000/128/000/000/128.jpeg')
     with tmp_image((200, 200), format='png') as img:
         expected_req = ({'path': r'/service?LAYERs=reslayer&SERVICE=WMS&FORMAT=image%2Fjpeg'
                                   '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A900913&styles='
                                   '&VERSION=1.1.1&BBOX=0.0,0.0,156543.033928,156543.033928'
                                   '&WIDTH=256'},
                         {'body': img.read(), 'headers': {'content-type': 'image/png'}})
         with mock_httpd(('localhost', 42423), [expected_req]):
             resp = self.app.get(self.common_map_req)
             assert is_png(resp.body)
             assert not is_transparent(resp.body)
Ejemplo n.º 10
0
    def test_mixed_mode(self):
        with create_mixed_mode_img((512, 256)) as img:
            expected_req = ({'path': self.expected_base_path +
                                     '&layers=mixedsource' +
                                     '&format=image%2Fpng' +
                                     '&transparent=True'},
                            {'body': img.read(), 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req], bbox_aware_query_comparator=True):
                resp = self.app.get(self.common_tile_req)
                eq_(resp.content_type, 'image/png')
                assert is_transparent(resp.body)
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/000/000/000/001.mixed')

                self.common_tile_req.params['tilecol'] = '1'
                resp = self.app.get(self.common_tile_req)
                eq_(resp.content_type, 'image/jpeg')
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/001/000/000/001.mixed')
Ejemplo n.º 11
0
    def test_mixed_mode(self):
        with create_mixed_mode_img((512, 256)) as img:
            expected_req = ({'path': self.expected_base_path +
                                     '&layers=mixedsource' +
                                     '&format=image%2Fpng' +
                                     '&transparent=True'},
                            {'body': img.read(), 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req], bbox_aware_query_comparator=True):
                resp = self.app.get('/tms/1.0.0/mixed_mode/0/0/0.png')
                eq_(resp.content_type, 'image/png')
                assert is_transparent(resp.body)

                resp = self.app.get('/tms/1.0.0/mixed_mode/0/1/0.png')

                eq_(resp.content_type, 'image/jpeg')
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/000/000/000/000.mixed')
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/001/000/000/000.mixed')
Ejemplo n.º 12
0
    def test_mixed_mode(self, app, cache_dir):
        req_format = "png"
        transparent = "True"
        with create_mixed_mode_img((512, 256)) as img:
            expected_req = (
                {
                    "path":
                    self.expected_base_path + "&layers=mixedsource" +
                    "&format=image%2F" + req_format + "&transparent=" +
                    transparent
                },
                {
                    "body": img.read(),
                    "headers": {
                        "content-type": "image/" + req_format
                    },
                },
            )
            with mock_httpd(("localhost", 42423), [expected_req],
                            bbox_aware_query_comparator=True):
                self.common_map_req.params["format"] = "image/" + req_format
                resp = app.get(self.common_map_req)

                assert resp.content_type == "image/" + req_format
                check_format(BytesIO(resp.body), req_format)
                # GetMap Request is fully within the opaque tile
                assert not is_transparent(resp.body)

        # check cache formats
        for f, format in [
            ["mixed_cache_EPSG900913/01/000/000/000/000/000/001.mixed", "png"],
            [
                "mixed_cache_EPSG900913/01/000/000/001/000/000/001.mixed",
                "jpeg"
            ],
        ]:
            assert cache_dir.join(f).check()
            check_format(cache_dir.join(f).read_binary(), format)
Ejemplo n.º 13
0
    def test_online(self, app):
        common_params = (r"?SERVICE=WMS&FORMAT=image%2Fpng"
                         "&REQUEST=GetMap&HEIGHT=200&SRS=EPSG%3A4326&styles="
                         "&VERSION=1.1.1&BBOX=9.0,50.0,10.0,51.0"
                         "&WIDTH=200&transparent=True")

        expected_req = [(
            {
                "path": "/service_a" + common_params + "&layers=a_one"
            },
            {
                "body": transp,
                "headers": {
                    "content-type": "image/png"
                }
            },
        )]

        with mock_httpd(("localhost", 42423), expected_req):
            self.common_map_req.params.layers = "online"
            resp = app.get(self.common_map_req)
            assert "Cache-Control" not in resp.headers
            assert resp.content_type == "image/png"
            assert is_transparent(resp.body)
Ejemplo n.º 14
0
    def test_mixed_mode(self):
        with create_mixed_mode_img((512, 256)) as img:
            expected_req = ({
                'path':
                self.expected_base_path + '&layers=mixedsource' +
                '&format=image%2Fpng' + '&transparent=True'
            }, {
                'body': img.read(),
                'headers': {
                    'content-type': 'image/png'
                }
            })
            with mock_httpd(('localhost', 42423), [expected_req]):
                resp = self.app.get(self.common_tile_req)
                eq_(resp.content_type, 'image/png')
                assert is_transparent(resp.body)
                self.created_tiles.append(
                    'mixed_cache_EPSG900913/01/000/000/000/000/000/001.mixed')

                self.common_tile_req.params['tilecol'] = '1'
                resp = self.app.get(self.common_tile_req)
                eq_(resp.content_type, 'image/jpeg')
                self.created_tiles.append(
                    'mixed_cache_EPSG900913/01/000/000/001/000/000/001.mixed')
Ejemplo n.º 15
0
    def test_mixed_mode(self):
        req_format = 'png'
        transparent = 'True'
        with create_mixed_mode_img((512, 256)) as img:
            expected_req = ({'path': self.expected_base_path +
                                     '&layers=mixedsource' +
                                     '&format=image%2F' + req_format +
                                     '&transparent=' + transparent},
                            {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}})
            with mock_httpd(('localhost', 42423), [expected_req]):
                self.common_map_req.params['format'] = 'image/'+req_format
                resp = self.app.get(self.common_map_req)
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/000/000/000/001.mixed')
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/001/000/000/001.mixed')

                eq_(resp.content_type, 'image/'+req_format)
                check_format(StringIO(resp.body), req_format)
                # GetMap Request is fully within the opaque tile
                assert not is_transparent(resp.body)

                # check cache formats
                cache_dir = base_config().cache.base_dir
                check_format(open(os.path.join(cache_dir, self.created_tiles[0]), 'rb'), 'png')
                check_format(open(os.path.join(cache_dir, self.created_tiles[1]), 'rb'), 'jpeg')
Ejemplo n.º 16
0
    def test_mixed_mode(self):
        req_format = 'png'
        transparent = 'True'
        with create_mixed_mode_img((512, 256)) as img:
            expected_req = ({'path': self.expected_base_path +
                                     '&layers=mixedsource' +
                                     '&format=image%2F' + req_format +
                                     '&transparent=' + transparent},
                            {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}})
            with mock_httpd(('localhost', 42423), [expected_req], bbox_aware_query_comparator=True):
                self.common_map_req.params['format'] = 'image/'+req_format
                resp = self.app.get(self.common_map_req)
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/000/000/000/001.mixed')
                self.created_tiles.append('mixed_cache_EPSG900913/01/000/000/001/000/000/001.mixed')

                eq_(resp.content_type, 'image/'+req_format)
                check_format(BytesIO(resp.body), req_format)
                # GetMap Request is fully within the opaque tile
                assert not is_transparent(resp.body)

                # check cache formats
                cache_dir = base_config().cache.base_dir
                check_format(open(os.path.join(cache_dir, self.created_tiles[0]), 'rb'), 'png')
                check_format(open(os.path.join(cache_dir, self.created_tiles[1]), 'rb'), 'jpeg')
Ejemplo n.º 17
0
 def test_get_map_above_res(self):
     # no layer rendered
     resp = self.app.get(self.common_map_req)
     assert is_png(resp.body)
     assert is_transparent(resp.body)
Ejemplo n.º 18
0
 def test_get_map_above_res(self):
     # no layer rendered
     resp = self.app.get(self.common_map_req)
     assert is_png(resp.body)
     assert is_transparent(resp.body)