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'
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'
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"
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'
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"
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'
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)
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]
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}" ), )
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)
def test_template_converter_missing_vars(): URLTemplateConverter( '/wmts/{{Style}}/{{TileMatrixSet}}/{{TileCol}}.png').regexp()
def test_template_converter_dimensions(): converter = URLTemplateConverter( "/{Layer}/{Dim1}/{Dim2}/{TileMatrixSet}-{TileMatrix}-{TileCol}-{TileRow}/tile" ) assert converter.dimensions == ["Dim1", "Dim2"]
def test_template_converter_missing_vars(): with pytest.raises(InvalidWMTSTemplate): URLTemplateConverter( "/wmts/{Style}/{TileMatrixSet}/{TileCol}.png").regexp()
def test_template_converter_dimensions(): converter = URLTemplateConverter( '/{Layer}/{Dim1}/{Dim2}/{TileMatrixSet}-{TileMatrix}-{TileCol}-{TileRow}/tile' ) assert converter.dimensions == ['Dim1', 'Dim2']