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)
class TestResolutionConditionalLayers(object): 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) def test_resolution_low(self): self.layer.get_map(MapQuery((0, 0, 10000, 10000), (100, 100), SRS(900913))) assert self.low.requested assert not self.high.requested def test_resolution_high(self): self.layer.get_map(MapQuery((0, 0, 100, 100), (100, 100), SRS(900913))) assert not self.low.requested assert self.high.requested def test_resolution_match(self): self.layer.get_map(MapQuery((0, 0, 10, 10), (100, 100), SRS(900913))) assert not self.low.requested assert self.high.requested def test_resolution_low_transform(self): self.layer.get_map(MapQuery((0, 0, 0.1, 0.1), (100, 100), SRS(4326))) assert self.low.requested assert not self.high.requested def test_resolution_high_transform(self): self.layer.get_map(MapQuery((0, 0, 0.005, 0.005), (100, 100), SRS(4326))) assert not self.low.requested assert self.high.requested
class TestResolutionConditionalLayers(object): 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) def test_resolution_low(self): self.layer.get_map( MapQuery((0, 0, 10000, 10000), (100, 100), SRS(900913))) assert self.low.requested assert not self.high.requested def test_resolution_high(self): self.layer.get_map(MapQuery((0, 0, 100, 100), (100, 100), SRS(900913))) assert not self.low.requested assert self.high.requested def test_resolution_match(self): self.layer.get_map(MapQuery((0, 0, 10, 10), (100, 100), SRS(900913))) assert not self.low.requested assert self.high.requested def test_resolution_low_transform(self): self.layer.get_map(MapQuery((0, 0, 0.1, 0.1), (100, 100), SRS(4326))) assert self.low.requested assert not self.high.requested def test_resolution_high_transform(self): self.layer.get_map( MapQuery((0, 0, 0.005, 0.005), (100, 100), SRS(4326))) assert not self.low.requested assert self.high.requested
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)
class TestNeastedConditionalLayers(object): 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) def test_resolution_high_900913(self): self.layer.get_map(MapQuery((0, 0, 100, 100), (100, 100), SRS(900913))) assert self.direct.requested def test_resolution_high_4326(self): self.layer.get_map( MapQuery((0, 0, 0.0001, 0.0001), (100, 100), SRS(4326))) assert self.direct.requested def test_resolution_low_4326(self): self.layer.get_map(MapQuery((0, 0, 10, 10), (100, 100), SRS(4326))) assert self.l4326.requested def test_resolution_low_projected(self): self.layer.get_map( MapQuery((0, 0, 10000, 10000), (100, 100), SRS(31467))) assert self.l900913.requested
class TestNeastedConditionalLayers(object): 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, ) def test_resolution_high_900913(self): self.layer.get_map(MapQuery((0, 0, 100, 100), (100, 100), SRS(900913))) assert self.direct.requested def test_resolution_high_4326(self): self.layer.get_map(MapQuery((0, 0, 0.0001, 0.0001), (100, 100), SRS(4326))) assert self.direct.requested def test_resolution_low_4326(self): self.layer.get_map(MapQuery((0, 0, 10, 10), (100, 100), SRS(4326))) assert self.l4326.requested def test_resolution_low_projected(self): self.layer.get_map(MapQuery((0, 0, 10000, 10000), (100, 100), SRS(31467))) assert self.l900913.requested
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 )
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)),