Example #1
0
 def test_same_source(self):
     layers = [
         WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'a'}, {}))),
         WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'b'}, {}))),
     ]
     combined = combined_layers(layers, self.q)
     eq_(len(combined), 1)
     eq_(combined[0].client.request_template.params.layers, ['a', 'b'])
Example #2
0
 def test_same_source(self):
     layers = [
         WMSSource(
             WMSClient(create_request({"url": "http://foo/", "layers": "a"}, {}))
         ),
         WMSSource(
             WMSClient(create_request({"url": "http://foo/", "layers": "b"}, {}))
         ),
     ]
     combined = combined_layers(layers, self.q)
     assert len(combined) == 1
     assert combined[0].client.request_template.params.layers == ["a", "b"]
Example #3
0
def create_wms_source(raster_source, app_state):
    url = raster_source.url
    username = raster_source.username
    password = raster_source.password

    http_client = create_http_client(username, password)

    coverage = coverage_from_geojson(raster_source.download_coverage)
    if coverage:
        # wrap to prevent partial tiles
        coverage = AlwaysContainsCoverage(coverage)

    request = create_request({'url': url, 'layers': raster_source.layer}, {}, version='1.1.1')

    image_opts = ImageOptions(resampling='bicubic',
        transparent=True)

    supported_srs = None
    if raster_source.srs != 'EPSG:3857':
        supported_srs = [SRS(raster_source.srs)]

    client = WMSClient(request, http_client=http_client)
    source = WMSSource(client, coverage=coverage,
        supported_srs=supported_srs, image_opts=image_opts,
    )

    # wrap to prevent partial tiles
    source.extent = AlwaysContainsMapExtent(source.extent)
    return source
Example #4
0
def create_wms_source(raster_source, app_state):
    url = raster_source.url
    username = raster_source.username
    password = raster_source.password

    http_client = create_http_client(username, password)

    coverage = coverage_from_geojson(raster_source.download_coverage)
    if coverage:
        # wrap to prevent partial tiles
        coverage = AlwaysContainsCoverage(coverage)

    request = create_request({
        'url': url,
        'layers': raster_source.layer
    }, {},
                             version='1.1.1')

    image_opts = ImageOptions(resampling='bicubic', transparent=True)

    supported_srs = None
    if raster_source.srs != 'EPSG:3857':
        supported_srs = [SRS(raster_source.srs)]

    client = WMSClient(request, http_client=http_client)
    source = WMSSource(
        client,
        coverage=coverage,
        supported_srs=supported_srs,
        image_opts=image_opts,
    )

    # wrap to prevent partial tiles
    source.extent = AlwaysContainsMapExtent(source.extent)
    return source
Example #5
0
 def test_same_source(self):
     layers = [
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://foo/',
                     'layers': 'a'
                 }, {}))),
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://foo/',
                     'layers': 'b'
                 }, {}))),
     ]
     combined = combined_layers(layers, self.q)
     eq_(len(combined), 1)
     eq_(combined[0].client.request_template.params.layers, ['a', 'b'])
Example #6
0
    def test_mixed_params(self):
        layers = [
            WMSSource(
                WMSClient(create_request({"url": "http://foo/", "layers": "a"}, {}))
            ),
            WMSSource(
                WMSClient(create_request({"url": "http://foo/", "layers": "b"}, {}))
            ),
            WMSSource(
                WMSClient(create_request({"url": "http://foo/", "layers": "c"}, {}))
            ),
            WMSSource(
                WMSClient(create_request({"url": "http://foo/", "layers": "d"}, {}))
            ),
            WMSSource(
                WMSClient(create_request({"url": "http://foo/", "layers": "e"}, {}))
            ),
            WMSSource(
                WMSClient(create_request({"url": "http://foo/", "layers": "f"}, {}))
            ),
        ]

        layers[0].supported_srs = ["EPSG:4326"]
        layers[1].supported_srs = ["EPSG:4326"]

        layers[2].supported_formats = ["image/png"]
        layers[3].supported_formats = ["image/png"]

        combined = combined_layers(layers, self.q)
        assert len(combined) == 3
        assert combined[0].client.request_template.params.layers == ["a", "b"]
        assert combined[1].client.request_template.params.layers == ["c", "d"]
        assert combined[2].client.request_template.params.layers == ["e", "f"]
Example #7
0
 def test_mixed_hosts(self):
     layers = [
         WMSSource(
             WMSClient(create_request({"url": "http://foo/", "layers": "a"}, {}))
         ),
         WMSSource(
             WMSClient(create_request({"url": "http://foo/", "layers": "b"}, {}))
         ),
         WMSSource(
             WMSClient(create_request({"url": "http://bar/", "layers": "c"}, {}))
         ),
         WMSSource(
             WMSClient(create_request({"url": "http://bar/", "layers": "d"}, {}))
         ),
         WMSSource(
             WMSClient(create_request({"url": "http://foo/", "layers": "e"}, {}))
         ),
         WMSSource(
             WMSClient(create_request({"url": "http://foo/", "layers": "f"}, {}))
         ),
     ]
     combined = combined_layers(layers, self.q)
     assert len(combined) == 3
     assert combined[0].client.request_template.params.layers == ["a", "b"]
     assert combined[1].client.request_template.params.layers == ["c", "d"]
     assert combined[2].client.request_template.params.layers == ["e", "f"]
Example #8
0
    def test_mixed_params(self):
        layers = [
            WMSSource(
                WMSClient(
                    create_request({
                        'url': 'http://foo/',
                        'layers': 'a'
                    }, {}))),
            WMSSource(
                WMSClient(
                    create_request({
                        'url': 'http://foo/',
                        'layers': 'b'
                    }, {}))),
            WMSSource(
                WMSClient(
                    create_request({
                        'url': 'http://foo/',
                        'layers': 'c'
                    }, {}))),
            WMSSource(
                WMSClient(
                    create_request({
                        'url': 'http://foo/',
                        'layers': 'd'
                    }, {}))),
            WMSSource(
                WMSClient(
                    create_request({
                        'url': 'http://foo/',
                        'layers': 'e'
                    }, {}))),
            WMSSource(
                WMSClient(
                    create_request({
                        'url': 'http://foo/',
                        'layers': 'f'
                    }, {}))),
        ]

        layers[0].supported_srs = ["EPSG:4326"]
        layers[1].supported_srs = ["EPSG:4326"]

        layers[2].supported_formats = ["image/png"]
        layers[3].supported_formats = ["image/png"]

        combined = combined_layers(layers, self.q)
        eq_(len(combined), 3)
        eq_(combined[0].client.request_template.params.layers, ['a', 'b'])
        eq_(combined[1].client.request_template.params.layers, ['c', 'd'])
        eq_(combined[2].client.request_template.params.layers, ['e', 'f'])
Example #9
0
 def test_mixed_hosts(self):
     layers = [
         WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'a'}, {}))),
         WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'b'}, {}))),
         WMSSource(WMSClient(create_request({'url': 'http://bar/', 'layers': 'c'}, {}))),
         WMSSource(WMSClient(create_request({'url': 'http://bar/', 'layers': 'd'}, {}))),
         WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'e'}, {}))),
         WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'f'}, {}))),
     ]
     combined = combined_layers(layers, self.q)
     eq_(len(combined), 3)
     eq_(combined[0].client.request_template.params.layers, ['a', 'b'])
     eq_(combined[1].client.request_template.params.layers, ['c', 'd'])
     eq_(combined[2].client.request_template.params.layers, ['e', 'f'])
Example #10
0
 def test_mixed_hosts(self):
     layers = [
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://foo/',
                     'layers': 'a'
                 }, {}))),
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://foo/',
                     'layers': 'b'
                 }, {}))),
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://bar/',
                     'layers': 'c'
                 }, {}))),
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://bar/',
                     'layers': 'd'
                 }, {}))),
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://foo/',
                     'layers': 'e'
                 }, {}))),
         WMSSource(
             WMSClient(
                 create_request({
                     'url': 'http://foo/',
                     'layers': 'f'
                 }, {}))),
     ]
     combined = combined_layers(layers, self.q)
     eq_(len(combined), 3)
     eq_(combined[0].client.request_template.params.layers, ['a', 'b'])
     eq_(combined[1].client.request_template.params.layers, ['c', 'd'])
     eq_(combined[2].client.request_template.params.layers, ['e', 'f'])
Example #11
0
    def test_mixed_params(self):
        layers = [
            WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'a'}, {}))),
            WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'b'}, {}))),
            WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'c'}, {}))),
            WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'd'}, {}))),
            WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'e'}, {}))),
            WMSSource(WMSClient(create_request({'url': 'http://foo/', 'layers': 'f'}, {}))),
        ]

        layers[0].supported_srs = ["EPSG:4326"]
        layers[1].supported_srs = ["EPSG:4326"]

        layers[2].supported_formats = ["image/png"]
        layers[3].supported_formats = ["image/png"]

        combined = combined_layers(layers, self.q)
        eq_(len(combined), 3)
        eq_(combined[0].client.request_template.params.layers, ['a', 'b'])
        eq_(combined[1].client.request_template.params.layers, ['c', 'd'])
        eq_(combined[2].client.request_template.params.layers, ['e', 'f'])