Example #1
0
class TestSRSConditionalLayers(object):
    def setup(self):
        self.l4326 = MockLayer()
        self.l900913 = MockLayer()
        self.l32632 = MockLayer()
        self.layer = SRSConditional(
            [
                (self.l4326, (SRS("EPSG:4326"),)),
                (self.l900913, (SRS("EPSG:900913"), SRS("EPSG:31467"))),
                (self.l32632, (SRSConditional.PROJECTED,)),
            ],
            GLOBAL_GEOGRAPHIC_EXTENT,
        )

    def test_srs_match(self):
        assert self.layer._select_layer(SRS(4326)) == self.l4326
        assert self.layer._select_layer(SRS(900913)) == self.l900913
        assert self.layer._select_layer(SRS(31467)) == self.l900913

    def test_srs_match_type(self):
        assert self.layer._select_layer(SRS(31466)) == self.l32632
        assert self.layer._select_layer(SRS(32633)) == self.l32632

    def test_no_match_first_type(self):
        assert self.layer._select_layer(SRS(4258)) == self.l4326
Example #2
0
 def setup(self):
     self.l4326 = MockLayer()
     self.l900913 = MockLayer()
     self.l32632 = MockLayer()
     self.layer = SRSConditional([
         (self.l4326, (SRS('EPSG:4326'), )),
         (self.l900913, (SRS('EPSG:900913'), SRS('EPSG:31467'))),
         (self.l32632, (SRSConditional.PROJECTED, )),
     ], GLOBAL_GEOGRAPHIC_EXTENT)
Example #3
0
 def setup(self):
     self.l4326 = MockLayer()
     self.l900913 = MockLayer()
     self.l32632 = MockLayer()
     self.layer = SRSConditional([
         (self.l4326, (SRS('EPSG:4326'),)), 
         (self.l900913, (SRS('EPSG:900913'), SRS('EPSG:31467'))),
         (self.l32632, (SRSConditional.PROJECTED,)),
     ], GLOBAL_GEOGRAPHIC_EXTENT)
Example #4
0
 def setup(self):
     self.direct = MockLayer()
     self.l900913 = MockLayer()
     self.l4326 = MockLayer()
     self.layer = ResolutionConditional(
         SRSConditional([(self.l900913, (SRS('EPSG:900913'), )),
                         (self.l4326, (SRS('EPSG:4326'), ))],
                        GLOBAL_GEOGRAPHIC_EXTENT), self.direct, 10,
         SRS(900913), GLOBAL_GEOGRAPHIC_EXTENT)
Example #5
0
class TestSRSConditionalLayers(object):
    def setup(self):
        self.l4326 = MockLayer()
        self.l900913 = MockLayer()
        self.l32632 = MockLayer()
        self.layer = SRSConditional([
            (self.l4326, (SRS('EPSG:4326'),)),
            (self.l900913, (SRS('EPSG:900913'), SRS('EPSG:31467'))),
            (self.l32632, (SRSConditional.PROJECTED,)),
        ], GLOBAL_GEOGRAPHIC_EXTENT)
    def test_srs_match(self):
        assert self.layer._select_layer(SRS(4326)) == self.l4326
        assert self.layer._select_layer(SRS(900913)) == self.l900913
        assert self.layer._select_layer(SRS(31467)) == self.l900913
    def test_srs_match_type(self):
        assert self.layer._select_layer(SRS(31466)) == self.l32632
        assert self.layer._select_layer(SRS(32633)) == self.l32632
    def test_no_match_first_type(self):
        assert self.layer._select_layer(SRS(4258)) == self.l4326
Example #6
0
def test_srs_conditional_layers():
    l4326 = MockLayer()
    l900913 = MockLayer()
    l32632 = MockLayer()
    layer = SRSConditional([
        (l4326, (SRS('EPSG:4326'), )),
        (l900913, (SRS('EPSG:900913'), SRS('EPSG:31467'))),
        (l32632, (SRSConditional.PROJECTED, )),
    ], GLOBAL_GEOGRAPHIC_EXTENT)

    # srs match
    assert layer._select_layer(SRS(4326)) == l4326
    assert layer._select_layer(SRS(900913)) == l900913
    assert layer._select_layer(SRS(31467)) == l900913
    # type match (projected)
    assert layer._select_layer(SRS(31466)) == l32632
    assert layer._select_layer(SRS(32633)) == l32632
    # fallback is first layer
    assert layer._select_layer(SRS(4258)) == l4326
Example #7
0
def test_srs_conditional_layers():
    l4326 = MockLayer()
    l3857 = MockLayer()
    l25832 = MockLayer()
    preferred = PreferredSrcSRS()
    preferred.add(SRS(31467), [SRS(25832), SRS(3857)])
    layer = SRSConditional([
        (l4326, SRS(4326)),
        (l3857, SRS(3857)),
        (l25832, SRS(25832)),
    ], GLOBAL_GEOGRAPHIC_EXTENT, preferred_srs=preferred,
    )

    # srs match
    assert layer._select_layer(SRS(4326)) == l4326
    assert layer._select_layer(SRS(3857)) == l3857
    assert layer._select_layer(SRS(25832)) == l25832
    # type match (projected)
    assert layer._select_layer(SRS(31466)) == l3857
    assert layer._select_layer(SRS(32633)) == l3857
    assert layer._select_layer(SRS(4258)) == l4326
    # preferred
    assert layer._select_layer(SRS(31467)) == l25832
Example #8
0
    assert layer._select_layer(SRS(31467)) == l25832

@pytest.mark.parametrize('case,map_query,is_direct,is_l3857,is_l4326', [
    ['high_3857', MapQuery((0, 0, 100, 100), (100, 100), SRS(900913)), True, False, False],
    ['high_4326', MapQuery((0, 0, 0.0001, 0.0001), (100, 100), SRS(4326)), True, False, False],
    ['low_4326', MapQuery((0, 0, 10, 10), (100, 100), SRS(4326)), False, False, True],
    ['low_3857', MapQuery((0, 0, 10000, 10000), (100, 100), SRS(31467)), False, True, False],
    ['low_projected', MapQuery((0, 0, 10000, 10000), (100, 100), SRS(31467)), False, True, False],
])
def test_neasted_conditional_layers(case, map_query, is_direct, is_l3857, is_l4326):
    direct = MockLayer()
    l3857 = MockLayer()
    l4326 = MockLayer()
    layer = ResolutionConditional(
        SRSConditional([
            (l3857, SRS('EPSG:3857')),
            (l4326, SRS('EPSG:4326'))
        ], GLOBAL_GEOGRAPHIC_EXTENT),
        direct, 10, SRS(3857), GLOBAL_GEOGRAPHIC_EXTENT
        )
    layer.get_map(map_query)
    assert bool(direct.requested) == is_direct
    assert bool(l3857.requested) == is_l3857
    assert bool(l4326.requested) == is_l4326


def is_blank(tiles):
    return all([t.source is None or isinstance(t.source, BlankImageSource) for t in tiles.tiles])

class TestTileManagerEmptySources(object):
    def test_upscale(self, mock_file_cache, tile_locker):
        grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
Example #9
0
    ],
    [
        'low_4326',
        MapQuery((0, 0, 10, 10), (100, 100), SRS(4326)), False, False, True
    ],
    [
        'low_3857',
        MapQuery((0, 0, 10000, 10000),
                 (100, 100), SRS(31467)), False, True, False
    ],
    [
        'low_projected',
        MapQuery((0, 0, 10000, 10000),
                 (100, 100), SRS(31467)), False, True, False
    ],
])
def test_neasted_conditional_layers(case, map_query, is_direct, is_l3857,
                                    is_l4326):
    direct = MockLayer()
    l3857 = MockLayer()
    l4326 = MockLayer()
    layer = ResolutionConditional(
        SRSConditional([(l3857, (SRS('EPSG:3857'), )),
                        (l4326, (SRS('EPSG:4326'), ))],
                       GLOBAL_GEOGRAPHIC_EXTENT), direct, 10, SRS(3857),
        GLOBAL_GEOGRAPHIC_EXTENT)
    layer.get_map(map_query)
    assert bool(direct.requested) == is_direct
    assert bool(l3857.requested) == is_l3857
    assert bool(l4326.requested) == is_l4326