def test_combine(self): req1 = WMS111MapRequest(url=TESTSERVER_URL + '/service?map=foo', param={ 'layers': 'foo', 'transparent': 'true' }) wms1 = WMSClient(req1, http_client=self.http) req2 = WMS111MapRequest(url=TESTSERVER_URL + '/service?map=foo', param={ 'layers': 'bar', 'transparent': 'true' }) wms2 = WMSClient(req2, http_client=self.http) req = MapQuery((-200000, -200000, 200000, 200000), (512, 512), SRS(900913), 'png') combined = wms1.combined_client(wms2, req) eq_(combined.request_template.params.layers, ['foo', 'bar']) eq_(combined.request_template.url, TESTSERVER_URL + '/service?map=foo')
def setup(self): SystemTest.setup(self) self.common_cap_req = WMS111CapabilitiesRequest(url='/service?', param=dict(service='WMS', version='1.1.1')) self.common_map_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', bbox='-20037508,0.0,0.0,20037508', width='256', height='256', layers='wms_cache', srs='EPSG:900913', format='image/jpeg', styles='', request='GetMap')) self.common_fi_req = WMS111FeatureInfoRequest(url='/service?', param=dict(x='10', y='20', width='200', height='200', layers='wms_cache', format='image/png', query_layers='wms_cache', styles='', bbox='1000,400,2000,1400', srs='EPSG:900913'))
def setup(self): self.http_client = MockHTTPClient() self.req_template = WMS111MapRequest(url='http://localhost/service?', param={ 'format': 'image/png', 'layers': 'foo' }) self.client = WMSClient(self.req_template, http_client=self.http_client) self.source = WMSSource(self.client, supported_srs=[SRS(4326)], image_opts=ImageOptions(resampling='bilinear'))
def setup(self): SystemTest.setup(self) self.common_map_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', bbox='-180,0,0,80', width='200', height='200', layers='watermark', srs='EPSG:4326', format='image/png', styles='', request='GetMap'))
def setup(self): SystemTest.setup(self) self.common_map_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', bbox='9,50,10,51', width='200', height='200', layers='online', srs='EPSG:4326', format='image/png', styles='', request='GetMap', transparent=True))
def setup(self): SystemTest.setup(self) self.common_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1')) self.common_lg_req_111 = WMS111LegendGraphicRequest( url='/service?', param=dict(format='image/png', layer='wms_legend', sld_version='1.1.0')) self.common_lg_req_130 = WMS130LegendGraphicRequest( url='/service?', param=dict(format='image/png', layer='wms_legend', sld_version='1.1.0'))
def setup(self): SystemTest.setup(self) self.common_map_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', bbox='0,-90,180,90', width='250', height='250', layers='tilesource', srs='EPSG:4326', format='image/png', styles='', request='GetMap', transparent=True)) self.common_tile_req = '/tiles/tilesource/EPSG4326/1/1/0.png'
def setup(self): self.common_map_req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", bbox="-180,0,0,80", width="200", height="200", layers="wms_cache", srs="EPSG:4326", format="image/png", styles="", request="GetMap", ), )
def setup(self): self.common_req = WMS111MapRequest(url="/service?", param=dict(service="WMS", version="1.1.1")) self.common_lg_req_111 = WMS111LegendGraphicRequest( url="/service?", param=dict(format="image/png", layer="wms_legend", sld_version="1.1.0"), ) self.common_lg_req_130 = WMS130LegendGraphicRequest( url="/service?", param=dict(format="image/png", layer="wms_legend", sld_version="1.1.0"), )
def setup(self): SystemTest.setup(self) self.common_map_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', bbox='0,0,10,10', width='200', height='200', srs='EPSG:4326', format='image/png', styles='', request='GetMap')) self.common_wms_url = ( "/service?styles=&srs=EPSG%3A4326&version=1.1.1&" "bbox=0.0,0.0,10.0,10.0&service=WMS&format=image%2Fpng&request=GetMap" "&width=200&height=200")
def setup(self): SystemTest.setup(self) self.common_map_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', bbox='0,0,180,80', width='200', height='200', layers='mixed_mode', srs='EPSG:4326', format='image/png', styles='', request='GetMap', transparent='true')) self.expected_base_path = '/service?SERVICE=WMS&REQUEST=GetMap&HEIGHT=256' \ '&SRS=EPSG%3A900913&styles=&VERSION=1.1.1&WIDTH=512' \ '&BBOX=-20037508.3428,0.0,20037508.3428,20037508.3428'
def test_wms_transparent(self): req = WMS111MapRequest( url='/service?', param=dict( service='WMS', version='1.1.1', bbox='-180,0,0,80', width='200', height='200', layers='wms_cache_transparent', srs='EPSG:4326', format='image/png', styles='', request='GetMap', transparent='True' ) ) resp = self.app.get( req, extra_environ={'mapproxy.decorate_img': to_greyscale} ) data = BytesIO(resp.body) assert is_png(data) img = Image.open(data) eq_(img.mode, 'RGBA')
def setup(self): self.common_map_req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", bbox="9,50,10,51", width="200", height="200", layers="online", srs="EPSG:4326", format="image/png", styles="", request="GetMap", transparent=True, ), )
def test_similar_srs(self): # request in 3857 and source supports only 900913 # 3857 and 900913 are equal but the client requests must use 900913 self.req = WMS111MapRequest(url=TESTSERVER_URL + '/service?map=foo', param={'layers':'foo', 'transparent': 'true'}) self.wms = WMSClient(self.req, http_client=self.http) self.source = WMSSource(self.wms, supported_srs=[SRS(900913)], image_opts=ImageOptions(resampling='bilinear')) req = MapQuery((-200000, -200000, 200000, 200000), (512, 512), SRS(3857), 'png') self.source.get_map(req) eq_(len(self.http.requested), 1) assert_query_eq(self.http.requested[0], TESTSERVER_URL+'/service?map=foo&LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A900913' '&VERSION=1.1.1&WIDTH=512&STYLES=&transparent=true' '&BBOX=-200000,-200000,200000,200000')
def setup(self): self.common_map_req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", bbox="0,0,180,80", width="200", height="200", layers="mixed_mode", srs="EPSG:4326", format="image/png", styles="", request="GetMap", transparent="true", ), ) self.expected_base_path = "/service?SERVICE=WMS&REQUEST=GetMap&HEIGHT=256" "&SRS=EPSG%3A900913&styles=&VERSION=1.1.1&WIDTH=512" "&BBOX=-20037508.3428,0.0,20037508.3428,20037508.3428"
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_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 setup(self): self.common_map_req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", bbox="0,-90,180,90", width="250", height="250", layers="tilesource", srs="EPSG:4326", format="image/png", styles="", request="GetMap", transparent=True, ), ) self.common_tile_req = "/tiles/tilesource/EPSG4326/1/1/0.png"
def test_wms_bgcolor(self): req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1', bbox='-180,0,0,80', width='200', height='200', layers='wms_cache_transparent', srs='EPSG:4326', format='image/png', styles='', request='GetMap', bgcolor='0xff00a0')) resp = self.app.get( req, extra_environ={'mapproxy.decorate_img': to_greyscale}) data = StringIO(resp.body) assert is_png(data) img = Image.open(data) eq_(img.mode, 'RGB') eq_(sorted(img.getcolors())[-1][1], (94, 94, 94))
def test_transformed_request_transparent(self, mock_http_client): req = WMS111MapRequest(url=TESTSERVER_URL + '/service?map=foo', param={'layers':'foo', 'transparent': 'true'}) wms = WMSClient(req, http_client=mock_http_client) source = WMSSource(wms, supported_srs=SupportedSRS([SRS(4326)]), image_opts=ImageOptions(resampling='bilinear')) req = MapQuery((-200000, -200000, 200000, 200000), (512, 512), SRS(900913), 'png') resp = source.get_map(req) assert len(mock_http_client.requested) == 1 assert wms_query_eq(mock_http_client.requested[0], TESTSERVER_URL+'/service?map=foo&LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng' '&REQUEST=GetMap&HEIGHT=512&SRS=EPSG%3A4326' '&VERSION=1.1.1&WIDTH=512&STYLES=&transparent=true' '&BBOX=-1.79663056824,-1.7963362121,1.79663056824,1.7963362121') img = resp.as_image() assert img.mode in ('P', 'RGBA') img = img.convert('RGBA') assert img.getpixel((5, 5))[3] == 0
def setup(self): self.common_map_req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", bbox="0,0,10,10", width="200", height="200", srs="EPSG:4326", format="image/png", styles="", request="GetMap", exceptions="xml", ), ) self.common_wms_url = ( "/service?styles=&srs=EPSG%3A4326&version=1.1.1&" "bbox=0.0,0.0,10.0,10.0&service=WMS&format=image%2Fpng&request=GetMap" "&width=200&height=200")
def test_copy_with_request_params(self): # check that we allways have our internal axis order req1 = WMS130MapRequest(param=dict(bbox="10,0,20,40", crs='EPSG:4326')) eq_(req1.params.bbox, (0.0, 10.0, 40.0, 20.0)) req2 = WMS111MapRequest(param=dict(bbox="0,10,40,20", srs='EPSG:4326')) eq_(req2.params.bbox, (0.0, 10.0, 40.0, 20.0)) # 130 <- 111 req3 = req1.copy_with_request_params(req2) eq_(req3.params.bbox, (0.0, 10.0, 40.0, 20.0)) assert isinstance(req3, WMS130MapRequest) # 130 <- 130 req4 = req1.copy_with_request_params(req3) eq_(req4.params.bbox, (0.0, 10.0, 40.0, 20.0)) assert isinstance(req4, WMS130MapRequest) # 111 <- 130 req5 = req2.copy_with_request_params(req3) eq_(req5.params.bbox, (0.0, 10.0, 40.0, 20.0)) assert isinstance(req5, WMS111MapRequest)
def test_wms(self, app): req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", bbox="-180,0,0,80", width="200", height="200", layers="wms_cache", srs="EPSG:4326", format="image/png", styles="", request="GetMap", ), ) resp = app.get(req, extra_environ={"mapproxy.decorate_img": to_greyscale}) data = BytesIO(resp.body) assert is_png(data) img = Image.open(data) assert img.mode == "RGB"
def setup(self): self.common_cap_req = WMTS100CapabilitiesRequest( url="/service?", param=dict(service="WMTS", version="1.0.0", request="GetCapabilities"), ) self.common_map_req = WMS111MapRequest( url="/service?", param=dict( service="WMS", version="1.1.1", bbox="-180,0,0,80", width="100", height="100", layers="dop_l", srs="EPSG:4326", format="image/png", styles="", request="GetMap", ), )
def test_wms_args(self): req = WMS111MapRequest( url='/service?', param=dict( service='WMS', version='1.1.1', bbox='-180,0,0,80', width='200', height='200', layers='wms_cache,wms_cache_transparent', srs='EPSG:4326', format='image/png', styles='', request='GetMap', transparent='True' ) ) def callback(img_src, service, layers, environ, query_extent): assert isinstance(img_src, ImageSource) eq_('wms.map', service) eq_(len(layers), 2) assert 'wms_cache_transparent' in layers assert 'wms_cache' in layers assert isinstance(environ, dict) assert len(query_extent) == 2 assert len(query_extent[1]) == 4 eq_(query_extent[0], 'EPSG:4326') return img_src resp = self.app.get( req, extra_environ={'mapproxy.decorate_img': callback} )
def setup(self): self.common_req = WMS111MapRequest(url="/service?", param=dict(service="WMS", version="1.1.1"))
def setup(self): self.r = WMS111MapRequest(param=dict(layers='foo', WMTVER='1.0.0')) self.r.params = self.r.adapt_params_to_version()
def setup(self): SystemTest.setup(self) self.common_req = WMS111MapRequest(url='/service?', param=dict(service='WMS', version='1.1.1'))
def req_template(self): return WMS111MapRequest( url='http://%s:%d/service?' % TEST_SERVER_ADDRESS, param={'format': 'image/png', 'layers': 'foo'}, )
def source(self, mock_http_client): req = WMS111MapRequest(url=TESTSERVER_URL + '/service?map=foo', param={'layers':'foo'}) wms = WMSClient(req, http_client=mock_http_client) return WMSSource(wms, supported_srs=SupportedSRS([SRS(4326)]), image_opts=ImageOptions(resampling='bilinear'))