示例#1
0
 def test_to_bbox_dict_from_sequence_mismatch(self):
     with pytest.raises(ValueError,
                        match="Expected sequence with 4 items, but got 3."):
         to_bbox_dict([1, 2, 3])
     with pytest.raises(ValueError,
                        match="Expected sequence with 4 items, but got 5."):
         to_bbox_dict([1, 2, 3, 4, 5])
示例#2
0
 def test_to_bbox_dict_from_dict(self):
     assert to_bbox_dict({
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4
     }) == {
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4
     }
     assert to_bbox_dict({
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4,
         "crs": "EPSG:4326"
     }) == {
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4,
         "crs": "EPSG:4326"
     }
     assert to_bbox_dict({
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4
     },
                         crs="EPSG:4326") == {
                             "west": 1,
                             "south": 2,
                             "east": 3,
                             "north": 4,
                             "crs": "EPSG:4326",
                         }
     assert to_bbox_dict({
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4,
         "crs": "EPSG:4326",
         "color": "red",
         "other": "garbage",
     }) == {
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4,
         "crs": "EPSG:4326"
     }
示例#3
0
 def test_to_bbox_dict_from_geometry(self):
     geometry = shapely.geometry.Polygon([(4, 2), (7, 4), (5, 8), (3, 3),
                                          (4, 2)])
     assert to_bbox_dict(geometry) == {
         "west": 3,
         "south": 2,
         "east": 7,
         "north": 8
     }
示例#4
0
 def test_to_bbox_dict_from_sequence(self):
     assert to_bbox_dict([1, 2, 3, 4]) == {
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4
     }
     assert to_bbox_dict((1, 2, 3, 4)) == {
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4
     }
     assert to_bbox_dict([1, 2, 3, 4], crs="EPSG:4326") == {
         "west": 1,
         "south": 2,
         "east": 3,
         "north": 4,
         "crs": "EPSG:4326",
     }
示例#5
0
 def test_to_bbox_dict_from_dict_missing_field(self):
     with pytest.raises(ValueError, match="but only found {'east'}"):
         to_bbox_dict({"east": 3})