Пример #1
0
    def test_transformed_request_transparent(self):
        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(4326)],
                                image_opts=ImageOptions(resampling='bilinear'))

        req = MapQuery((-200000, -200000, 200000, 200000), (512, 512),
                       SRS(900913), 'png')
        resp = self.source.get_map(req)
        eq_(len(self.http.requested), 1)

        assert wms_query_eq(
            self.http.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')
        eq_(img.getpixel((5, 5))[3], 0)
Пример #2
0
 def test_get_map_transformed(self, source, mock_http_client):
     source.get_map(MapQuery(
        (556597, 4865942, 1669792, 7361866), (300, 150), SRS(900913)))
     assert wms_query_eq(mock_http_client.requested[0], "http://localhost/service?"
         "layers=foo&width=300&version=1.1.1"
         "&bbox=4.99999592195,39.9999980766,14.999996749,54.9999994175&service=WMS"
         "&format=image%2Fpng&styles=&srs=EPSG%3A4326&request=GetMap&height=450")
Пример #3
0
 def test_get_map_transformed(self):
     self.source.get_map(MapQuery(
        (556597, 4865942, 1669792, 7361866), (300, 150), SRS(900913)))
     assert wms_query_eq(self.http_client.requested[0], "http://localhost/service?"
         "layers=foo&width=300&version=1.1.1"
         "&bbox=4.99999592195,39.9999980766,14.999996749,54.9999994175&service=WMS"
         "&format=image%2Fpng&styles=&srs=EPSG%3A4326&request=GetMap&height=450")
Пример #4
0
    def test_transformed_request(self, source, mock_http_client):
        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='
                           '&BBOX=-1.79663056824,-1.7963362121,1.79663056824,1.7963362121')
        img = resp.as_image()
        assert img.mode in ('P', 'RGB')
Пример #5
0
    def test_transformed_request(self):
        req = MapQuery((-200000, -200000, 200000, 200000), (512, 512), SRS(900913), 'png')
        resp = self.source.get_map(req)
        eq_(len(self.http.requested), 1)

        assert wms_query_eq(self.http.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='
                           '&BBOX=-1.79663056824,-1.7963362121,1.79663056824,1.7963362121')
        img = resp.as_image()
        assert img.mode in ('P', 'RGB')
Пример #6
0
    def test_transform_fi_request(self):
        req = WMS111FeatureInfoRequest(url=TESTSERVER_URL + '/service?map=foo', param={'layers':'foo', 'srs': 'EPSG:25832'})
        http = MockHTTPClient()
        wms = WMSInfoClient(req, http_client=http)
        fi_req = InfoQuery((8, 50, 9, 51), (512, 512),
                           SRS(4326), (256, 256), 'text/plain')

        wms.get_info(fi_req)

        assert wms_query_eq(http.requested[0],
            TESTSERVER_URL+'/service?map=foo&LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
                           '&REQUEST=GetFeatureInfo&HEIGHT=512&SRS=EPSG%3A25832&info_format=text/plain'
                           '&query_layers=foo'
                           '&VERSION=1.1.1&WIDTH=512&STYLES=&x=259&y=255'
                           '&BBOX=428333.552496,5538630.70275,500000.0,5650300.78652')
Пример #7
0
    def test_transform_fi_request(self):
        req = WMS111FeatureInfoRequest(url=TESTSERVER_URL + '/service?map=foo', param={'layers':'foo', 'srs': 'EPSG:25832'})
        http = MockHTTPClient()
        wms = WMSInfoClient(req, http_client=http)
        fi_req = InfoQuery((8, 50, 9, 51), (512, 512),
                           SRS(4326), (128, 64), 'text/plain')

        wms.get_info(fi_req)

        assert wms_query_eq(http.requested[0],
            TESTSERVER_URL+'/service?map=foo&LAYERS=foo&SERVICE=WMS&FORMAT=image%2Fpng'
                           '&REQUEST=GetFeatureInfo&SRS=EPSG%3A25832&info_format=text/plain'
                           '&query_layers=foo'
                           '&VERSION=1.1.1&WIDTH=512&HEIGHT=797&STYLES=&x=135&y=101'
                           '&BBOX=428333.552496,5538630.70275,500000.0,5650300.78652'), http.requested[0]
Пример #8
0
    def test_transformed_request_transparent(self):
        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(4326)],
            image_opts=ImageOptions(resampling='bilinear'))

        req = MapQuery((-200000, -200000, 200000, 200000), (512, 512), SRS(900913), 'png')
        resp = self.source.get_map(req)
        eq_(len(self.http.requested), 1)

        assert wms_query_eq(self.http.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')
        eq_(img.getpixel((5, 5))[3], 0)