def test_mesh(self): # low map scale -> more meshes # print(SRS(4326).transform_bbox_to(SRS(3857), (5, 50, 10, 55))) meshes = transform_meshes( src_size=(1000, 2000), src_bbox=(556597, 6446275, 1113194, 7361866), src_srs=SRS(3857), dst_size=(1000, 1000), dst_bbox=(5, 50, 10, 55), dst_srs=SRS(4326), ) assert len(meshes) == 16 # large map scale -> one meshes # print(SRS(4326).transform_bbox_to(SRS(3857), (5, 50, 5.1, 50.1))) meshes = transform_meshes( src_size=(1000, 2000), src_bbox=( 556597.4539663672, 6446275.841017158, 567729.4030456939, 6463612.124257667, ), src_srs=SRS(3857), dst_size=(1000, 1000), dst_bbox=(5, 50, 5.1, 50.1), dst_srs=SRS(4326), ) assert len(meshes) == 1 # quad stretches whole image plus 1 pixel assert meshes[0][0] == (0, 0, 1000, 1000) for e, a in zip(meshes[0][1], [0.0, 0.0, 0.0, 2000.0, 1000.0, 2000.0, 1000.0, 0.0]): assert e == pytest.approx(a)
def test_mesh(self): # low map scale -> more meshes # print(SRS(4326).transform_bbox_to(SRS(3857), (5, 50, 10, 55))) meshes = transform_meshes( src_size=(1000, 2000), src_bbox=(556597, 6446275, 1113194, 7361866), src_srs=SRS(3857), dst_size=(1000, 1000), dst_bbox=(5, 50, 10, 55), dst_srs=SRS(4326), ) eq_(len(meshes), 16) # large map scale -> one meshes # print(SRS(4326).transform_bbox_to(SRS(3857), (5, 50, 5.1, 50.1))) meshes = transform_meshes( src_size=(1000, 2000), src_bbox=(556597.4539663672, 6446275.841017158, 567729.4030456939, 6463612.124257667), src_srs=SRS(3857), dst_size=(1000, 1000), dst_bbox=(5, 50, 5.1, 50.1), dst_srs=SRS(4326), ) eq_(len(meshes), 1) # quad stretches whole image plus 1 pixel eq_(meshes[0][0], (0, 0, 1000, 1000)) for e, a in zip(meshes[0][1], [0.0, 0.0, 0.0, 2000.0, 1000.0, 2000.0, 1000.0, 0.0]): assert_almost_equal(e, a)
def test_mesh_utm(self): meshes = transform_meshes( src_size=(1335, 1531), src_bbox=(3.65, 39.84, 17.00, 55.15), src_srs=SRS(4326), dst_size=(853, 1683), dst_bbox=(158512, 4428236, 1012321, 6111268), dst_srs=SRS(25832), ) assert len(meshes) == 40
def test_mesh_utm(self): meshes = transform_meshes( src_size=(1335, 1531), src_bbox=(3.65, 39.84, 17.00, 55.15), src_srs=SRS(4326), dst_size=(853, 1683), dst_bbox=(158512, 4428236, 1012321, 6111268), dst_srs=SRS(25832), ) eq_(len(meshes), 40)
def test_mesh_none(self): meshes = transform_meshes( src_size=(1000, 1500), src_bbox=(0, 0, 10, 15), src_srs=SRS(4326), dst_size=(1000, 1500), dst_bbox=(0, 0, 10, 15), dst_srs=SRS(4326), ) eq_(meshes, [((0, 0, 1000, 1500), [0.0, 0.0, 0.0, 1500.0, 1000.0, 1500.0, 1000.0, 0.0])]) eq_(len(meshes), 1)
def test_mesh_none(self): meshes = transform_meshes( src_size=(1000, 1500), src_bbox=(0, 0, 10, 15), src_srs=SRS(4326), dst_size=(1000, 1500), dst_bbox=(0, 0, 10, 15), dst_srs=SRS(4326), ) assert meshes == [ ((0, 0, 1000, 1500), [0.0, 0.0, 0.0, 1500.0, 1000.0, 1500.0, 1000.0, 0.0]) ] assert len(meshes) == 1