Beispiel #1
0
 def setup(self):
     self.low = MockLayer()
     self.low.transparent = False  #TODO
     self.high = MockLayer()
     self.layer = ResolutionConditional(self.low, self.high, 10,
                                        SRS(900913),
                                        GLOBAL_GEOGRAPHIC_EXTENT)
Beispiel #2
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)
Beispiel #3
0
    def __init__(self):
        self.requested = []
    def get_map(self, query):
        self.requested.append((query.bbox, query.size, query.srs))

@pytest.mark.parametrize('case,map_query,low_requested', [
    ['low', MapQuery((0, 0, 10000, 10000), (100, 100), SRS(3857)), True],
    ['high', MapQuery((0, 0, 100, 100), (100, 100), SRS(3857)), False],
    ['match', MapQuery((0, 0, 10, 10), (100, 100), SRS(3857)), False],
    ['low_transform', MapQuery((0, 0, 0.1, 0.1), (100, 100), SRS(4326)), True],
    ['high_transform', MapQuery((0, 0, 0.005, 0.005), (100, 100), SRS(4326)), False],
])
def test_resolution_conditional_layers(case, map_query, low_requested):
    low = MockLayer()
    high = MockLayer()
    layer = ResolutionConditional(low, high, 10, SRS(3857),
        GLOBAL_GEOGRAPHIC_EXTENT)

    layer.get_map(map_query)
    assert bool(low.requested) == low_requested
    assert bool(high.requested) != low_requested


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)),