def test_seed_refresh_remove_before_from_file(self): # tile already there but too old, will be refreshed and removed t000 = self.make_tile((0, 0, 0), timestamp=time.time() - (60*60*25)) with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&VERSION=1.1.1&bbox=-180.0,-90.0,180.0,90.0' '&width=256&height=128&srs=EPSG:4326'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): # touch the seed_conf file and refresh everything timestamp = time.time() - 60 os.utime(self.seed_conf_file, (timestamp, timestamp)) with local_base_config(self.mapproxy_conf.base_config): seed_conf = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf) tasks = seed_conf.seeds(['refresh_from_file']) seed(tasks, dry_run=False) assert os.path.exists(t000) assert os.path.getmtime(t000) - 5 < time.time() < os.path.getmtime(t000) + 5 # now touch the seed_conf again and remove everything os.utime(self.seed_conf_file, None) with local_base_config(self.mapproxy_conf.base_config): seed_conf = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf) cleanup_tasks = seed_conf.cleanups(['remove_from_file']) cleanup(cleanup_tasks, verbose=False, dry_run=False)
def test_combined_mixed_fwd_req_params(self): # not merged to one request because fwd_req_params are different common_params = (r'/service_a?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') with tmp_image((200, 200), format='png') as img: img = img.read() expected_req = [({'path': common_params + '&layers=a_one&TIME=20041012'}, {'body': img, 'headers': {'content-type': 'image/png'}}), ({'path': common_params + '&layers=a_two&TIME=20041012&VENDOR=foo'}, {'body': img, 'headers': {'content-type': 'image/png'}}), ({'path': common_params + '&layers=a_four'}, {'body': img, 'headers': {'content-type': 'image/png'}}), ] with mock_httpd(('localhost', 42423), expected_req): self.common_map_req.params.layers = 'layer_fwdparams1,single' self.common_map_req.params['time'] = '20041012' self.common_map_req.params['vendor'] = 'foo' self.common_map_req.params.transparent = True resp = self.app.get(self.common_map_req) resp.content_type = 'image/png' data = BytesIO(resp.body) assert is_png(data)
def test_get_tile_intersection_tms(self): with tmp_image((256, 256), format='jpeg') as img: expected_req = ({'path': r'/tms/1.0.0/foo/1/1/1.jpeg'}, {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/tms_cache/0/1/1.jpeg') eq_(resp.content_type, 'image/jpeg') self.created_tiles.append('tms_cache_EPSG900913/01/000/000/001/000/000/001.jpeg')
def test_get_tile_without_caching(self): with tmp_image((256, 256), format='png') as img: expected_req = ({'path': r'/tile.png'}, {'body': img.read(), 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/tiles/0/0/0.png') eq_(resp.content_type, 'image/png') is_png(resp.body) assert not os.path.exists(test_config['cache_dir']) with tmp_image((256, 256), format='png') as img: expected_req = ({'path': r'/tile.png'}, {'body': img.read(), 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/tiles/0/0/0.png') eq_(resp.content_type, 'image/png') is_png(resp.body)
def tile_server(tile_coords): with tmp_image((256, 256), format='jpeg') as img: img = img.read() expected_reqs = [] for tile in tile_coords: expected_reqs.append( ({'path': r'/tiles/%d/%d/%d.png' % (tile[2], tile[0], tile[1])}, {'body': img, 'headers': {'content-type': 'image/png'}})) with mock_httpd(('localhost', 42423), expected_reqs, unordered=True): yield
def check_get_cached(self, layer, source, tms_format, cache_format, req_format): self.created_tiles.append((layer+'_EPSG900913/01/000/000/001/000/000/001.'+cache_format, cache_format)) with tmp_image((256, 256), format=req_format) as img: expected_req = ({'path': self.expected_base_path + '&layers=' + source + '&format=image%2F' + req_format}, {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}}) with mock_httpd(('localhost', 42423), [expected_req], bbox_aware_query_comparator=True): resp = self.app.get('/tms/1.0.0/%s/0/1/1.%s' % (layer, tms_format)) eq_(resp.content_type, 'image/'+tms_format)
def test_get_tile_with_watermark_cache(self): with tmp_image((256, 256), format='png', color=(0, 0, 0)) as img: expected_req = ({'path': r'/tiles/01/000/000/000/000/000/000.png'}, {'body': img.read(), 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/watermark_cache/0/0/0.png') eq_(resp.content_type, 'image/png') img = Image.open(BytesIO(resp.body)) colors = img.getcolors() assert len(colors) >= 2 eq_(sorted(colors)[-1][1], (0, 0, 0))
def test_get_tile(self): with tmp_image((256, 256), format='jpeg') as img: expected_req = ({'path': r'/service?LAYERs=bar&SERVICE=WMS&FORMAT=image%2Fjpeg' '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A25832&styles=' '&VERSION=1.1.1&BBOX=283803.311362,5609091.90862,319018.942566,5644307.53982' '&WIDTH=256'}, {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/wms_cache/utm32n/4/2/2.jpeg') eq_(resp.content_type, 'image/jpeg') self.created_tiles.append('wms_cache/utm32n/04/000/000/002/000/000/002.jpeg')
def test_get_tile_intersections(self): with tmp_image((256, 256), format='jpeg') as img: expected_req = ({'path': r'/service?LAYERs=foo,bar&SERVICE=WMS&FORMAT=image%2Fjpeg' '&REQUEST=GetMap&HEIGHT=25&SRS=EPSG%3A900913&styles=' '&VERSION=1.1.1&BBOX=1113194.90793,1689200.13961,3339584.7238,3632749.14338' '&WIDTH=28'}, {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/wms_cache/0/1/1.jpeg') eq_(resp.content_type, 'image/jpeg') self.created_tiles.append('wms_cache_EPSG900913/01/000/000/001/000/000/001.jpeg')
def test_get_tile(self): with tmp_image((256, 256), format='jpeg') as img: expected_req = ({'path': r'/service?LAYERs=foo,bar&SERVICE=WMS&FORMAT=image%2Fjpeg' '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A900913&styles=' '&VERSION=1.1.1&BBOX=-20037508.3428,-20037508.3428,0.0,0.0' '&WIDTH=256'}, {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/kml/wms_cache/1/0/0.jpeg') eq_(resp.content_type, 'image/jpeg') self.created_tiles.append('wms_cache_EPSG900913/01/000/000/000/000/000/000.jpeg')
def test_seed(self): with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&VERSION=1.1.1&bbox=-180.0,-90.0,180.0,90.0' '&width=256&height=128&srs=EPSG:4326'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): seed_conf = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf) tasks, cleanup_tasks = seed_conf.seeds(['one']), seed_conf.cleanups() seed(tasks, dry_run=False) cleanup(cleanup_tasks, verbose=False, dry_run=False)
def check_get_direct(self, layer, source, wms_format, req_format): with tmp_image((256, 256), format=req_format) as img: expected_req = ({'path': self.expected_direct_base_path + '&layers=' + source + '&format=image%2F' + req_format}, {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}}) with mock_httpd(('localhost', 42423), [expected_req], bbox_aware_query_comparator=True): self.common_direct_map_req.params['layers'] = layer self.common_direct_map_req.params['format'] = 'image/'+wms_format resp = self.app.get(self.common_direct_map_req) eq_(resp.content_type, 'image/'+wms_format) check_format(BytesIO(resp.body), wms_format)
def test_02_get_legendgraphic_layer_static_url(self): self.common_lg_req_111.params['layer'] = 'wms_layer_static_url' with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req1 = ({'path': r'/staticlegend_layer.png'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req1]): resp = self.app.get(self.common_lg_req_111) eq_(resp.content_type, 'image/png') data = StringIO(resp.body) assert is_png(data) assert Image.open(data).size == (256,256)
def test_get_map(self): with tmp_image((512, 512)) as img: expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles=' '&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512'}, {'body': img.read(), 'headers': {'content-type': 'image/png'}}) with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]): q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326)) result = self.source.get_map(q) assert isinstance(result, ImageSource) eq_(result.size, (512, 512)) assert is_png(result.as_buffer(seekable=True)) eq_(result.as_image().size, (512, 512))
def check_get_cached(self, layer, source, wms_format, cache_format, req_format): self.created_tiles.append((layer+'_EPSG900913/01/000/000/001/000/000/001.'+cache_format, cache_format)) with tmp_image((256, 256), format=req_format) as img: expected_req = ({'path': self.expected_base_path + '&layers=' + source + '&format=image%2F' + req_format}, {'body': img.read(), 'headers': {'content-type': 'image/'+req_format}}) with mock_httpd(('localhost', 42423), [expected_req]): self.common_map_req.params['layers'] = layer self.common_map_req.params['format'] = 'image/'+wms_format resp = self.app.get(self.common_map_req) eq_(resp.content_type, 'image/'+wms_format) check_format(StringIO(resp.body), wms_format)
def test_get_tile_through_cache(self): # request tile from tms_transf, # should get tile from tms_source via tms_cache_in/out expected_reqs = [] with tmp_image((256, 256), format='jpeg') as img: for tile in [(8, 11, 4), (8, 10, 4)]: expected_reqs.append( ({'path': r'/tiles/%02d/000/000/%03d/000/000/%03d.png' % (tile[2], tile[0], tile[1])}, {'body': img.read(), 'headers': {'content-type': 'image/png'}})) with mock_httpd(('localhost', 42423), expected_reqs, unordered=True): resp = self.app.get('/tms/1.0.0/tms_transf/EPSG25832/0/0/0.png') eq_(resp.content_type, 'image/png') self.created_tiles.append('tms_cache_out_EPSG25832/00/000/000/000/000/000/000.png')
def test_transparent_watermark_tile(self): with tmp_image((256, 256), format='png', color=(0, 0, 0, 0), mode='RGBA') as img: expected_req = ({'path': r'/service?LAYERs=blank&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A4326&styles=' '&VERSION=1.1.1&BBOX=-180.0,-90.0,0.0,90.0' '&WIDTH=256'}, {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/watermark_transp/EPSG4326/0/0/0.png') eq_(resp.content_type, 'image/png') img = Image.open(BytesIO(resp.body)) colors = img.getcolors() assert len(colors) >= 2 eq_(sorted(colors)[-1][1], (0, 0, 0, 0))
def test_get_map_non_image_content_type(self): with tmp_image((512, 512)) as img: expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles=' '&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512'}, {'body': img.read(), 'headers': {'content-type': 'text/plain'}}) with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]): q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326)) try: self.source.get_map(q) except SourceError, e: assert 'no image returned' in e.args[0] else: assert False, 'no SourceError raised'
def test_get_map_intersection(self): self.created_tiles.append('wms_cache_EPSG4326/03/000/000/004/000/000/002.jpeg') with tmp_image((256, 256), format='jpeg') as img: expected_req = ({'path': r'/service?LAYERs=foo,bar&SERVICE=WMS&FORMAT=image%2Fjpeg' '&REQUEST=GetMap&HEIGHT=91&SRS=EPSG%3A4326&styles=' '&VERSION=1.1.1&BBOX=10,15,30,31' '&WIDTH=114'}, {'body': img.read(), 'headers': {'content-type': 'image/jpeg'}}) with mock_httpd(('localhost', 42423), [expected_req]): self.common_map_req.params.bbox = 0, 0, 40, 40 self.common_map_req.params.transparent = True resp = self.app.get(self.common_map_req) eq_(resp.content_type, 'image/png') data = StringIO(resp.body) assert is_png(data) eq_(Image.open(data).mode, 'RGBA')
def test_get_tile_with_watermark_cache(self): with tmp_image((256, 256), format='png', color=(0, 0, 0)) as img: expected_req = ({ 'path': r'/tiles/01/000/000/000/000/000/000.png' }, { 'body': img.read(), 'headers': { 'content-type': 'image/png' } }) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/watermark_cache/0/0/0.png') eq_(resp.content_type, 'image/png') img = Image.open(BytesIO(resp.body)) colors = img.getcolors() assert len(colors) >= 2 eq_(sorted(colors)[-1][1], (0, 0, 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)
def test_get_legendgraphic_111(self): self.common_lg_req_111.params['scale'] = '5.0' with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req1 = ({'path': r'/service?LAYER=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetLegendGraphic&SCALE=5.0&' '&VERSION=1.1.1&SLD_VERSION=1.1.0'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) expected_req2 = ({'path': r'/service?LAYER=bar&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetLegendGraphic&SCALE=5.0&' '&VERSION=1.1.1&SLD_VERSION=1.1.0'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req1, expected_req2]): resp = self.app.get(self.common_lg_req_111) eq_(resp.content_type, 'image/png') data = StringIO(resp.body) assert is_png(data) assert Image.open(data).size == (256,512)
def test_get_tile_combined_cache(self): # request from cache with two cache sources where only one # is compatible (supports tiled_only) expected_reqs = [] with tmp_image((256, 256), format='jpeg') as img: img = img.read() for tile in [ r'/tiles/04/000/000/008/000/000/011.png', r'/tiles/04/000/000/008/000/000/010.png', r'/tiles/utm/00/000/000/000/000/000/000.png', ]: expected_reqs.append( ({'path': tile}, {'body': img, 'headers': {'content-type': 'image/png'}})) with mock_httpd(('localhost', 42423), expected_reqs, unordered=True): resp = self.app.get('/tms/1.0.0/combined/EPSG25832/0/0/0.png') eq_(resp.content_type, 'image/png')
def test_get_tile_from_cache_with_tile_source(self, app, cache_dir): with tmp_image((256, 256), format="jpeg") as img: expected_req = ( { "path": r"/tiles/01/000/000/000/000/000/001.png" }, { "body": img.read(), "headers": { "content-type": "image/png" } }, ) with mock_httpd(("localhost", 42423), [expected_req]): resp = app.get("/tms/1.0.0/tms_cache/0/0/1.png") assert resp.content_type == "image/png" assert cache_dir.join( "tms_cache_EPSG900913/01/000/000/000/000/000/001.png").check()
def test_clipped_bgcolor(self): with tmp_image((256, 256), format='png', color=(255, 0, 0)) as img: expected_req = ({'path': r'/service?LAYERs=bar&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=100&SRS=EPSG%3A25832&styles=' '&VERSION=1.1.1&BBOX=0.0,3500000.0,100.0,3500100.0' '&WIDTH=50'}, {'body': img.read(), 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('http://localhost/service?SERVICE=WMS&REQUEST=GetMap' '&LAYERS=direct&STYLES=' '&WIDTH=100&HEIGHT=100&FORMAT=image/png' '&BBOX=-100,3500000,100,3500100&SRS=EPSG:25832' '&VERSION=1.1.0&TRANSPARENT=FALSE&BGCOLOR=0x00ff00') eq_(resp.content_type, 'image/png') assert is_png(resp.body) assert_colors_equal(img_from_buf(resp.body).convert('RGBA'), [(50 * 100, [255, 0, 0, 255]), (50 * 100, [0, 255, 0, 255])])
def test_02_get_legendgraphic_layer_static_url(self): self.common_lg_req_111.params['layer'] = 'wms_layer_static_url' with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req1 = ({ 'path': r'/staticlegend_layer.png' }, { 'body': img_data, 'headers': { 'content-type': 'image/png' } }) with mock_httpd(('localhost', 42423), [expected_req1]): resp = self.app.get(self.common_lg_req_111) eq_(resp.content_type, 'image/png') data = StringIO(resp.body) assert is_png(data) assert Image.open(data).size == (256, 256)
def test_get_map_non_image_content_type(self): with tmp_image((512, 512)) as img: expected_req = ( { "path": r"/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng" "&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles=" "&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512" }, {"body": img.read(), "headers": {"content-type": "text/plain"}}, ) with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]): q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326)) try: self.source.get_map(q) except SourceError as e: assert "no image returned" in e.args[0] else: assert False, "no SourceError raised"
def test_get_legendgraphic_111(self): self.common_lg_req_111.params['scale'] = '5.0' with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req1 = ({'path': r'/service?LAYER=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetLegendGraphic&SCALE=5.0&' '&VERSION=1.1.1&SLD_VERSION=1.1.0'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) expected_req2 = ({'path': r'/service?LAYER=bar&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetLegendGraphic&SCALE=5.0&' '&VERSION=1.1.1&SLD_VERSION=1.1.0'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req1, expected_req2]): resp = self.app.get(self.common_lg_req_111) eq_(resp.content_type, 'image/png') data = BytesIO(resp.body) assert is_png(data) assert Image.open(data).size == (256,512)
def test_get_map_through_cache(self, app): map_req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", width="100", height="100", bbox="432890.564641,5872387.45834,466833.867667,5928359.08814", layers="tms_transf", srs="EPSG:25832", format="image/png", styles="", request="GetMap", ), ) expected_reqs = [] with tmp_image((256, 256), format="jpeg") as img: img = img.read() # tms_cache_out has meta_size of [2, 2] but we need larger extent for transformation for tile in [ (132, 172, 8), (133, 172, 8), (134, 172, 8), (132, 173, 8), (133, 173, 8), (134, 173, 8), (132, 174, 8), (133, 174, 8), (134, 174, 8), ]: expected_reqs.append( ( { "path": r"/tiles/%02d/000/000/%03d/000/000/%03d.png" % (tile[2], tile[0], tile[1]) }, {"body": img, "headers": {"content-type": "image/png"}}, ) ) with mock_httpd(("localhost", 42423), expected_reqs, unordered=True): resp = app.get(map_req) assert resp.content_type == "image/png"
def test_get_tile_intersections(self): with tmp_image((256, 256), format='jpeg') as img: expected_req = ({ 'path': r'/service?LAYERs=foo,bar&SERVICE=WMS&FORMAT=image%2Fjpeg' '&REQUEST=GetMap&HEIGHT=24&SRS=EPSG%3A900913&styles=' '&VERSION=1.1.1&BBOX=1113194.90793,1689200.13961,3339584.7238,3632749.14338' '&WIDTH=28' }, { 'body': img.read(), 'headers': { 'content-type': 'image/jgeg' } }) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/wms_cache/0/1/1.jpeg') eq_(resp.content_type, 'image/jpeg') self.created_tiles.append( 'wms_cache_EPSG900913/01/000/000/001/000/000/001.jpeg')
def check_get_direct(self, layer, source, wms_format, req_format): with tmp_image((256, 256), format=req_format) as img: expected_req = ({ 'path': self.expected_direct_base_path + '&layers=' + source + '&format=image%2F' + req_format }, { 'body': img.read(), 'headers': { 'content-type': 'image/' + req_format } }) with mock_httpd(('localhost', 42423), [expected_req]): self.common_direct_map_req.params['layers'] = layer self.common_direct_map_req.params[ 'format'] = 'image/' + wms_format resp = self.app.get(self.common_direct_map_req) eq_(resp.content_type, 'image/' + wms_format) check_format(StringIO(resp.body), wms_format)
def test_combined_no_fwd_req_params(self): # merged to one request because no vendor param is set with tmp_image((200, 200), format='png') as img: img = img.read() expected_req = [({'path': '/service_a?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' '&layers=a_one,a_two,a_four'}, {'body': img, 'headers': {'content-type': 'image/png'}}), ] with mock_httpd(('localhost', 42423), expected_req): self.common_map_req.params.layers = 'layer_fwdparams1,single' self.common_map_req.params.transparent = True resp = self.app.get(self.common_map_req) resp.content_type = 'image/png' data = StringIO(resp.body) assert is_png(data)
def test_get_tile(self): with tmp_image((256, 256), format='jpeg') as img: expected_req = ({ 'path': r'/service?LAYERs=foo,bar&SERVICE=WMS&FORMAT=image%2Fjpeg' '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A900913&styles=' '&VERSION=1.1.1&BBOX=-20037508.3428,-20037508.3428,0.0,0.0' '&WIDTH=256' }, { 'body': img.read(), 'headers': { 'content-type': 'image/jgeg' } }) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/kml/wms_cache/1/0/0.jpeg') eq_(resp.content_type, 'image/jpeg') self.created_tiles.append( 'wms_cache_EPSG900913/01/000/000/000/000/000/000.jpeg')
def test_combined_layers(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') with tmp_image((200, 200), format='png') as img: img = img.read() expected_req = [ ({ 'path': '/service_a' + common_params + '&layers=a_one' }, { 'body': img, 'headers': { 'content-type': 'image/png' } }), ({ 'path': '/service_b' + common_params + '&layers=b_one' }, { 'body': img, 'headers': { 'content-type': 'image/png' } }), ({ 'path': '/service_a' + common_params + '&layers=a_two,a_three,a_four' }, { 'body': img, 'headers': { 'content-type': 'image/png' } }), ] with mock_httpd(('localhost', 42423), expected_req): self.common_map_req.params.layers = 'uncombinable,single' resp = self.app.get(self.common_map_req) eq_(resp.content_type, 'image/png') data = BytesIO(resp.body) assert is_png(data)
def test_get_tile(self): with tmp_image((256, 256), format='jpeg') as img: expected_req = ({ 'path': r'/service?LAYERs=bar&SERVICE=WMS&FORMAT=image%2Fjpeg' '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A25832&styles=' '&VERSION=1.1.1&BBOX=283803.311362,5609091.90862,319018.942566,5644307.53982' '&WIDTH=256' }, { 'body': img.read(), 'headers': { 'content-type': 'image/jpeg' } }) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/wms_cache/utm32n/4/2/2.jpeg') eq_(resp.content_type, 'image/jpeg') self.created_tiles.append( 'wms_cache/utm32n/04/000/000/002/000/000/002.jpeg')
def test_get_tile_intersection_tms(self, app, cache_dir): with tmp_image((256, 256), format="jpeg") as img: expected_req = ( { "path": r"/tms/1.0.0/foo/1/1/1.jpeg" }, { "body": img.read(), "headers": { "content-type": "image/jpeg" } }, ) with mock_httpd(("localhost", 42423), [expected_req], bbox_aware_query_comparator=True): resp = app.get("/tms/1.0.0/tms_cache/0/1/1.jpeg") assert resp.content_type == "image/jpeg" cache_dir.join( "tms_cache_EPSG900913/01/000/000/001/000/000/001.jpeg").check()
def test_get_map_through_cache(self): map_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', width='100', height='100', bbox='432890.564641,5872387.45834,466833.867667,5928359.08814', layers='tms_transf', srs='EPSG:25832', format='image/png', styles='', request='GetMap')) expected_reqs = [] with tmp_image((256, 256), format='jpeg') as img: img = img.read() # tms_cache_out has meta_size of [2, 2] but we need larger extent for transformation for tile in [(132, 172, 8), (133, 172, 8), (134, 172, 8), (132, 173, 8), (133, 173, 8), (134, 173, 8), (132, 174, 8), (133, 174, 8), (134, 174, 8)]: expected_reqs.append( ({'path': r'/tiles/%02d/000/000/%03d/000/000/%03d.png' % (tile[2], tile[0], tile[1])}, {'body': img, 'headers': {'content-type': 'image/png'}})) with mock_httpd(('localhost', 42423), expected_reqs, unordered=True): resp = self.app.get(map_req) eq_(resp.content_type, 'image/png')
def test_combined_mixed_transp_color(self, app): # not merged to one request because only one layer has transparent_color 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") with tmp_image((200, 200), color=(255, 0, 0), format="png") as img: img = img.read() expected_req = [ ( { "path": "/service_a" + common_params + "&layers=a_four" }, { "body": img, "headers": { "content-type": "image/png" } }, ), ( { "path": "/service_a" + common_params + "&layers=a_iopts_one" }, { "body": img, "headers": { "content-type": "image/png" } }, ), ] with mock_httpd(("localhost", 42423), expected_req): self.common_map_req.params.layers = "single,layer_image_opts1" self.common_map_req.params.transparent = True resp = app.get(self.common_map_req) resp.content_type = "image/png" data = BytesIO(resp.body) assert is_png(data)
def test_get_tile_without_caching(self, app, cache_dir): for _ in range(2): with tmp_image((256, 256), format="png") as img: expected_req = ( { "path": r"/tile.png" }, { "body": img.read(), "headers": { "content-type": "image/png" } }, ) with mock_httpd(("localhost", 42423), [expected_req]): resp = app.get("/tms/1.0.0/tiles/0/0/0.png") assert resp.content_type == "image/png" is_png(resp.body) assert not cache_dir.check()
def test_combined(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') with tmp_image((200, 200), format='png') as img: img = img.read() expected_req = [({'path': '/service_a' + common_params + '&layers=a_one,a_two,a_three,a_four'}, {'body': img, 'headers': {'content-type': 'image/png'}}), ({'path': '/service_b' + common_params + '&layers=b_one'}, {'body': img, 'headers': {'content-type': 'image/png'}}) ] with mock_httpd(('localhost', 42423), expected_req): self.common_map_req.params.layers = 'combinable' resp = self.app.get(self.common_map_req) eq_(resp.content_type, 'image/png') data = BytesIO(resp.body) assert is_png(data)
def test_get_map(self): with tmp_image((512, 512)) as img: expected_req = ({ 'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles=' '&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512' }, { 'body': img.read(), 'headers': { 'content-type': 'image/png' } }) with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]): q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326)) result = self.source.get_map(q) assert isinstance(result, ImageSource) eq_(result.size, (512, 512)) assert is_png(result.as_buffer(seekable=True)) eq_(result.as_image().size, (512, 512))
def check_get_cached(self, layer, source, tms_format, cache_format, req_format): self.created_tiles.append( (layer + '_EPSG900913/01/000/000/001/000/000/001.' + cache_format, cache_format)) with tmp_image((256, 256), format=req_format) as img: expected_req = ({ 'path': self.expected_base_path + '&layers=' + source + '&format=image%2F' + req_format }, { 'body': img.read(), 'headers': { 'content-type': 'image/' + req_format } }) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/%s/0/1/1.%s' % (layer, tms_format)) eq_(resp.content_type, 'image/' + tms_format)
def test_get_tile_with_watermark_cache(self, app): with tmp_image((256, 256), format="png", color=(0, 0, 0)) as img: expected_req = ( { "path": r"/tiles/01/000/000/000/000/000/000.png" }, { "body": img.read(), "headers": { "content-type": "image/png" } }, ) with mock_httpd(("localhost", 42423), [expected_req]): resp = app.get("/tms/1.0.0/watermark_cache/0/0/0.png") assert resp.content_type == "image/png" img = Image.open(BytesIO(resp.body)) colors = img.getcolors() assert len(colors) >= 2 assert sorted(colors)[-1][1] == (0, 0, 0)
def test_refresh_tile_1s(self, app, cache_dir): with tmp_image((256, 256), format="jpeg") as img: expected_req = ( { "path": r"/service?LAYERs=bar&SERVICE=WMS&FORMAT=image%2Fjpeg" "&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A900913&styles=" "&VERSION=1.1.1&BBOX=-20037508.3428,-20037508.3428,0.0,0.0" "&WIDTH=256" }, { "body": img.read(), "headers": { "content-type": "image/jpeg" } }, ) with mock_httpd(("localhost", 42423), [expected_req], bbox_aware_query_comparator=True): resp = app.get("/tiles/wms_cache/1/0/0.jpeg") assert resp.content_type == "image/jpeg" file_path = cache_dir.join( "wms_cache_EPSG900913/01/000/000/000/000/000/000.jpeg") assert file_path.check() t1 = file_path.mtime() # file_path.remove() # assert not file_path.check() resp = app.get("/tiles/wms_cache/1/0/0.jpeg") assert resp.content_type == "image/jpeg" assert file_path.check() t2 = file_path.mtime() # tile is expired after 1 sec, so it will be fetched again from mock server time.sleep(1.2) with mock_httpd(("localhost", 42423), [expected_req], bbox_aware_query_comparator=True): resp = app.get("/tiles/wms_cache/1/0/0.jpeg") assert resp.content_type == "image/jpeg" assert file_path.check() t3 = file_path.mtime() assert t2 == t1 assert t3 > t2
def test_combined(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") with tmp_image((200, 200), format="png") as img: img = img.read() expected_req = [ ( { "path": "/service_a" + common_params + "&layers=a_one,a_two,a_three,a_four" }, { "body": img, "headers": { "content-type": "image/png" } }, ), ( { "path": "/service_b" + common_params + "&layers=b_one" }, { "body": img, "headers": { "content-type": "image/png" } }, ), ] with mock_httpd(("localhost", 42423), expected_req): self.common_map_req.params.layers = "combinable" resp = app.get(self.common_map_req) assert resp.content_type == "image/png" data = BytesIO(resp.body) assert is_png(data)
def test_get_tile_combined_cache(self, app): # request from cache with two cache sources where only one # is compatible (supports tiled_only) expected_reqs = [] with tmp_image((256, 256), format="jpeg") as img: img = img.read() for tile in [ r"/tiles/04/000/000/008/000/000/011.png", r"/tiles/04/000/000/008/000/000/010.png", r"/tiles/utm/00/000/000/000/000/000/000.png", ]: expected_reqs.append( ( {"path": tile}, {"body": img, "headers": {"content-type": "image/png"}}, ) ) with mock_httpd(("localhost", 42423), expected_reqs, unordered=True): resp = app.get("/tms/1.0.0/combined/EPSG25832/0/0/0.png") assert resp.content_type == "image/png"
def test_seed(self): with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req = ({ 'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&VERSION=1.1.1&bbox=-180.0,-90.0,180.0,90.0' '&width=256&height=128&srs=EPSG:4326' }, { 'body': img_data, 'headers': { 'content-type': 'image/png' } }) with mock_httpd(('localhost', 42423), [expected_req]): seed_conf = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf) tasks, cleanup_tasks = seed_conf.seeds( ['one']), seed_conf.cleanups() seed(tasks, dry_run=False) cleanup(cleanup_tasks, verbose=False, dry_run=False)
def test_clipped(self): with tmp_image((256, 256), format='png', color=(255, 0, 0)) as img: expected_req = ({'path': r'/service?LAYERs=bar&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=100&SRS=EPSG%3A25832&styles=' '&VERSION=1.1.1&BBOX=0.0,3500000.0,150.0,3500100.0' '&WIDTH=75'}, {'body': img.read(), 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('http://localhost/service?SERVICE=WMS&REQUEST=GetMap' '&LAYERS=direct&STYLES=' '&WIDTH=100&HEIGHT=100&FORMAT=image/png' '&BBOX=-50,3500000,150,3500100&SRS=EPSG:25832' '&VERSION=1.1.0&TRANSPARENT=TRUE') eq_(resp.content_type, 'image/png') assert is_png(resp.body) colors = sorted(img_from_buf(resp.body).convert('RGBA').getcolors()) # quarter is clipped, check if it's transparent eq_(colors[0][0], (25 * 100)) eq_(colors[0][1][3], 0) eq_(colors[1], (75 * 100, (255, 0, 0, 255)))
def test_02_get_legendgraphic_layer_static_url(self, app): self.common_lg_req_111.params["layer"] = "wms_layer_static_url" with tmp_image((256, 256), format="png") as img: img_data = img.read() expected_req1 = ( { "path": r"/staticlegend_layer.png" }, { "body": img_data, "headers": { "content-type": "image/png" } }, ) with mock_httpd(("localhost", 42423), [expected_req1]): resp = app.get(self.common_lg_req_111) assert resp.content_type == "image/png" data = BytesIO(resp.body) assert is_png(data) assert Image.open(data).size == (256, 256)
def test_watermark_tile(self): with tmp_image((256, 256), format='png', color=(0, 0, 0)) as img: expected_req = ({ 'path': r'/service?LAYERs=blank&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A4326&styles=' '&VERSION=1.1.1&BBOX=-180.0,-90.0,0.0,90.0' '&WIDTH=256' }, { 'body': img.read(), 'headers': { 'content-type': 'image/jpeg' } }) with mock_httpd(('localhost', 42423), [expected_req]): resp = self.app.get('/tms/1.0.0/watermark/EPSG4326/0/0/0.png') eq_(resp.content_type, 'image/png') img = Image.open(StringIO(resp.body)) colors = img.getcolors() assert len(colors) >= 2 eq_(sorted(colors)[-1][1], (0, 0, 0))
def test_get_map_non_image_content_type(self): with tmp_image((512, 512)) as img: expected_req = ({ 'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326&styles=' '&VERSION=1.1.1&BBOX=0.0,10.0,10.0,20.0&WIDTH=512' }, { 'body': img.read(), 'headers': { 'content-type': 'text/plain' } }) with mock_httpd(TEST_SERVER_ADDRESS, [expected_req]): q = MapQuery((0.0, 10.0, 10.0, 20.0), (512, 512), SRS(4326)) try: self.source.get_map(q) except SourceError as e: assert 'no image returned' in e.args[0] else: assert False, 'no SourceError raised'
def test_refresh_tile_mtime(self, app, cache_dir): with tmp_image((256, 256), format="jpeg") as img: expected_req = ( { "path": r"/service?LAYERs=bar&SERVICE=WMS&FORMAT=image%2Fjpeg" "&REQUEST=GetMap&HEIGHT=256&SRS=EPSG%3A900913&styles=" "&VERSION=1.1.1&BBOX=-20037508.3428,-20037508.3428,0.0,0.0" "&WIDTH=256" }, { "body": img.read(), "headers": { "content-type": "image/jpeg" } }, ) with mock_httpd(("localhost", 42423), [expected_req], bbox_aware_query_comparator=True): resp = app.get("/tiles/wms_cache_isotime/1/0/0.jpeg") assert resp.content_type == "image/jpeg" file_path = cache_dir.join( "wms_cache_isotime_EPSG900913/01/000/000/000/000/000/000.jpeg" ) assert file_path.check() timestamp = timestamp_from_isodate("2009-02-15T23:31:30") file_path.setmtime(timestamp + 1.2) t1 = file_path.mtime() resp = app.get("/tiles/wms_cache_isotime/1/0/0.jpeg") assert resp.content_type == "image/jpeg" t2 = file_path.mtime() file_path.setmtime(timestamp - 1.2) with mock_httpd(("localhost", 42423), [expected_req], bbox_aware_query_comparator=True): resp = app.get("/tiles/wms_cache_isotime/1/0/0.jpeg") assert resp.content_type == "image/jpeg" assert file_path.check() t3 = file_path.mtime() assert t2 == t1 assert t3 > t2
def test_seed_skip_uncached(self): with tmp_image((256, 256), format='png') as img: img_data = img.read() with local_base_config(self.mapproxy_conf.base_config): expected_req = ({ 'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&VERSION=1.1.1&bbox=-180.0,-90.0,180.0,90.0' '&width=256&height=128&srs=EPSG:4326' }, { 'body': img_data, 'headers': { 'content-type': 'image/png' } }) seed_conf = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf) tasks, cleanup_tasks = seed_conf.seeds( ['one']), seed_conf.cleanups() # tile not in cache => skipped by seeder seed(tasks, dry_run=False, skip_uncached=True) assert not self.tile_exists((0, 0, 0)) with mock_httpd(('localhost', 42423), [expected_req]): # force tile generation in cache (via skip_uncached=False) seed(tasks, dry_run=False, skip_uncached=False) assert self.tile_exists((0, 0, 0)) # no refresh since tile is not older than 1 day (cf. config seed.yaml) seed(tasks, dry_run=False, skip_uncached=True) # create stale tile (older than 1 day) self.make_tile((0, 0, 0), timestamp=time.time() - (60 * 60 * 25)) with mock_httpd(('localhost', 42423), [expected_req]): # check that old tile in cache is refreshed seed(tasks, dry_run=False, skip_uncached=True) assert self.tile_exists((0, 0, 0)) cleanup(cleanup_tasks, verbose=False, dry_run=False)
def test_reseed_remove_before(self): # tile already there but too old t000 = self.make_tile((0, 0, 0), timestamp=time.time() - (60*60*25)) # old tile outside the seed view (should be removed) t001 = self.make_tile((0, 0, 1), timestamp=time.time() - (60*60*25)) assert os.path.exists(t000) assert os.path.exists(t001) with tmp_image((256, 256), format='png') as img: img_data = img.read() expected_req = ({'path': r'/service?LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&VERSION=1.1.1&bbox=-180.0,-90.0,180.0,90.0' '&width=256&height=128&srs=EPSG:4326'}, {'body': img_data, 'headers': {'content-type': 'image/png'}}) with mock_httpd(('localhost', 42423), [expected_req]): seed_conf = load_seed_tasks_conf(self.seed_conf_file, self.mapproxy_conf) tasks, cleanup_tasks = seed_conf.seeds(), seed_conf.cleanups() seed(tasks, dry_run=False) cleanup(cleanup_tasks, verbose=False, dry_run=False) assert os.path.exists(t000) assert os.path.getmtime(t000) - 5 < time.time() < os.path.getmtime(t000) + 5 assert not os.path.exists(t001)
def test_combined_mixed_transp_color(self): # not merged to one request because only one layer has transparent_color 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') with tmp_image((200, 200), color=(255, 0, 0), format='png') as img: img = img.read() expected_req = [({'path': '/service_a' + common_params + '&layers=a_four'}, {'body': img, 'headers': {'content-type': 'image/png'}}), ({'path': '/service_a' + common_params + '&layers=a_iopts_one'}, {'body': img, 'headers': {'content-type': 'image/png'}}), ] with mock_httpd(('localhost', 42423), expected_req): self.common_map_req.params.layers = 'single,layer_image_opts1' self.common_map_req.params.transparent = True resp = self.app.get(self.common_map_req) resp.content_type = 'image/png' data = BytesIO(resp.body) assert is_png(data)
def test_get_legendgraphic_111(self, app): self.common_lg_req_111.params["scale"] = "5.0" with tmp_image((256, 256), format="png") as img: img_data = img.read() expected_req1 = ( { "path": r"/service?LAYER=foo&SERVICE=WMS&FORMAT=image%2Fpng" "&REQUEST=GetLegendGraphic&SCALE=5.0&" "&VERSION=1.1.1&SLD_VERSION=1.1.0" }, { "body": img_data, "headers": { "content-type": "image/png" } }, ) expected_req2 = ( { "path": r"/service?LAYER=bar&SERVICE=WMS&FORMAT=image%2Fpng" "&REQUEST=GetLegendGraphic&SCALE=5.0&" "&VERSION=1.1.1&SLD_VERSION=1.1.0" }, { "body": img_data, "headers": { "content-type": "image/png" } }, ) with mock_httpd(("localhost", 42423), [expected_req1, expected_req2]): resp = app.get(self.common_lg_req_111) assert resp.content_type == "image/png" data = BytesIO(resp.body) assert is_png(data) assert Image.open(data).size == (256, 512)
def test_get_tile_through_cache(self, app, cache_dir): # request tile from tms_transf, # should get tile from tms_source via tms_cache_in/out expected_reqs = [] with tmp_image((256, 256), format="jpeg") as img: for tile in [(8, 11, 4), (8, 10, 4)]: expected_reqs.append( ( { "path": r"/tiles/%02d/000/000/%03d/000/000/%03d.png" % (tile[2], tile[0], tile[1]) }, {"body": img.read(), "headers": {"content-type": "image/png"}}, ) ) with mock_httpd(("localhost", 42423), expected_reqs, unordered=True): resp = app.get("/tms/1.0.0/tms_transf/EPSG25832/0/0/0.png") assert resp.content_type == "image/png" assert cache_dir.join( "tms_cache_out_EPSG25832/00/000/000/000/000/000/000.png" ).check()