コード例 #1
0
def test_template_converter():
    regexp = URLTemplateConverter('/{Layer}/{Style}/{TileMatrixSet}-{TileMatrix}-{TileCol}-{TileRow}/tile').regexp()
    match = regexp.match('/test/bar/foo-EPSG4326-4-12-99/tile')
    assert match
    assert match.groupdict()['Layer'] == 'test'
    assert match.groupdict()['TileMatrixSet'] == 'foo-EPSG4326'
    assert match.groupdict()['TileMatrix'] == '4'
    assert match.groupdict()['TileCol'] == '12'
    assert match.groupdict()['TileRow'] == '99'
    assert match.groupdict()['Style'] == 'bar'
コード例 #2
0
def test_template_converter_deprecated_format():
    # old format that doesn't match the WMTS spec, now deprecated
    regexp = URLTemplateConverter('/{{Layer}}/{{Style}}/{{TileMatrixSet}}-{{TileMatrix}}-{{TileCol}}-{{TileRow}}/tile').regexp()
    match = regexp.match('/test/bar/foo-EPSG4326-4-12-99/tile')
    assert match
    assert match.groupdict()['Layer'] == 'test'
    assert match.groupdict()['TileMatrixSet'] == 'foo-EPSG4326'
    assert match.groupdict()['TileMatrix'] == '4'
    assert match.groupdict()['TileCol'] == '12'
    assert match.groupdict()['TileRow'] == '99'
    assert match.groupdict()['Style'] == 'bar'
コード例 #3
0
def test_template_converter():
    regexp = URLTemplateConverter(
        "/{Layer}/{Style}/{TileMatrixSet}-{TileMatrix}-{TileCol}-{TileRow}/tile"
    ).regexp()
    match = regexp.match("/wmts/test/bar/foo-EPSG4326-4-12-99/tile")
    assert match
    assert match.groupdict()["Layer"] == "test"
    assert match.groupdict()["TileMatrixSet"] == "foo-EPSG4326"
    assert match.groupdict()["TileMatrix"] == "4"
    assert match.groupdict()["TileCol"] == "12"
    assert match.groupdict()["TileRow"] == "99"
    assert match.groupdict()["Style"] == "bar"
コード例 #4
0
def test_template_converter():
    regexp = URLTemplateConverter(
        '/{{Layer}}/{{Style}}/{{TileMatrixSet}}-{{TileMatrix}}-{{TileCol}}-{{TileRow}}/tile'
    ).regexp()
    match = regexp.match('/test/bar/foo-EPSG4326-4-12-99/tile')
    assert match
    assert match.groupdict()['Layer'] == 'test'
    assert match.groupdict()['TileMatrixSet'] == 'foo-EPSG4326'
    assert match.groupdict()['TileMatrix'] == '4'
    assert match.groupdict()['TileCol'] == '12'
    assert match.groupdict()['TileRow'] == '99'
    assert match.groupdict()['Style'] == 'bar'
コード例 #5
0
def test_template_converter_deprecated_format():
    # old format that doesn't match the WMTS spec, now deprecated
    regexp = URLTemplateConverter(
        "/{{Layer}}/{{Style}}/{{TileMatrixSet}}-{{TileMatrix}}-{{TileCol}}-{{TileRow}}/tile"
    ).regexp()
    match = regexp.match("/wmts/test/bar/foo-EPSG4326-4-12-99/tile")
    assert match
    assert match.groupdict()["Layer"] == "test"
    assert match.groupdict()["TileMatrixSet"] == "foo-EPSG4326"
    assert match.groupdict()["TileMatrix"] == "4"
    assert match.groupdict()["TileCol"] == "12"
    assert match.groupdict()["TileRow"] == "99"
    assert match.groupdict()["Style"] == "bar"
コード例 #6
0
def test_template_converter_deprecated_format():
    # old format that doesn't match the WMTS spec, now deprecated
    regexp = URLTemplateConverter(
        '/{{Layer}}/{{Style}}/{{TileMatrixSet}}-{{TileMatrix}}-{{TileCol}}-{{TileRow}}/tile'
    ).regexp()
    match = regexp.match('/test/bar/foo-EPSG4326-4-12-99/tile')
    assert match
    assert match.groupdict()['Layer'] == 'test'
    assert match.groupdict()['TileMatrixSet'] == 'foo-EPSG4326'
    assert match.groupdict()['TileMatrix'] == '4'
    assert match.groupdict()['TileCol'] == '12'
    assert match.groupdict()['TileRow'] == '99'
    assert match.groupdict()['Style'] == 'bar'
コード例 #7
0
 def __init__(self, layers, md, max_tile_age=None, template=None):
     WMTSServer.__init__(self, layers, md)
     self.max_tile_age = max_tile_age
     self.template = template or self.default_template
     self.url_converter = URLTemplateConverter(self.template)
     self.request_parser = make_wmts_rest_request_parser(self.url_converter)
     self.capabilities_class = partial(RestfulCapabilities, url_converter=self.url_converter)
コード例 #8
0
def test_template_converter_unknown_var():
    try:
        regexp = URLTemplateConverter(
            '/{{Unknown}}/{{TileMatrixSet}}-{{TileMatrix}}-{{TileCol}}-{{TileRow}}/tile'
        ).regexp()
    except InvalidWMTSTemplate, ex:
        assert 'unknown variable Unknown in /{{Unknown}}/{{TileMatrixSet}}' in ex.args[
            0]
コード例 #9
0
 def parser(self):
     return make_wmts_rest_request_parser(
         URLTemplateConverter(
             "/{Layer}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.{Format}"
         ),
         FeatureInfoURLTemplateConverter(
             "/{Layer}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}/{I}/{J}.{InfoFormat}"
         ),
     )
コード例 #10
0
ファイル: wmts.py プロジェクト: yili9111/mapproxy
 def __init__(self, layers, md, max_tile_age=None, template=None, fi_template=None, info_formats={}):
     WMTSServer.__init__(self, layers, md)
     self.max_tile_age = max_tile_age
     self.template = template or self.default_template
     self.fi_template = fi_template or self.default_info_template
     self.info_formats = info_formats
     self.url_converter = URLTemplateConverter(self.template)
     self.fi_url_converter = FeatureInfoURLTemplateConverter(self.fi_template)
     self.request_parser = make_wmts_rest_request_parser(self.url_converter, self.fi_url_converter)
     self.capabilities_class = partial(RestfulCapabilities, url_converter=self.url_converter, fi_url_converter=self.fi_url_converter)
コード例 #11
0
def test_template_converter_missing_vars():
    URLTemplateConverter(
        '/wmts/{{Style}}/{{TileMatrixSet}}/{{TileCol}}.png').regexp()
コード例 #12
0
def test_template_converter_dimensions():
    converter = URLTemplateConverter(
        "/{Layer}/{Dim1}/{Dim2}/{TileMatrixSet}-{TileMatrix}-{TileCol}-{TileRow}/tile"
    )
    assert converter.dimensions == ["Dim1", "Dim2"]
コード例 #13
0
def test_template_converter_missing_vars():
    with pytest.raises(InvalidWMTSTemplate):
        URLTemplateConverter(
            "/wmts/{Style}/{TileMatrixSet}/{TileCol}.png").regexp()
コード例 #14
0
def test_template_converter_dimensions():
    converter = URLTemplateConverter(
        '/{Layer}/{Dim1}/{Dim2}/{TileMatrixSet}-{TileMatrix}-{TileCol}-{TileRow}/tile'
    )
    assert converter.dimensions == ['Dim1', 'Dim2']