|
2 | 2 |
|
3 | 3 |
|
4 | 4 | def test_geom_should_compare_with_coords():
|
5 |
| - assert (((35, 10), (45, 45), (15, 40), (10, 20), (35, 10)), ((20, 30), (35, 35), (30, 20), (20, 30))) == Polygon((((35, 10), (45, 45), (15, 40), (10, 20), (35, 10)), ((20, 30), (35, 35), (30, 20), (20, 30)))) # noqa |
| 5 | + assert ( |
| 6 | + ((35, 10), (45, 45), (15, 40), (10, 20), (35, 10)), |
| 7 | + ((20, 30), (35, 35), (30, 20), (20, 30)), |
| 8 | + ) == Polygon( |
| 9 | + ( |
| 10 | + ((35, 10), (45, 45), (15, 40), (10, 20), (35, 10)), |
| 11 | + ((20, 30), (35, 35), (30, 20), (20, 30)), |
| 12 | + ) |
| 13 | + ) # noqa |
6 | 14 |
|
7 | 15 |
|
8 | 16 | def test_polygon_geojson():
|
9 | 17 | poly = Polygon((((1, 2), (3, 4), (5, 6), (1, 2)),))
|
10 |
| - assert poly.geojson == {"type": "Polygon", |
11 |
| - "coordinates": (((1, 2), (3, 4), (5, 6), (1, 2)),)} |
| 18 | + assert poly.geojson == { |
| 19 | + "type": "Polygon", |
| 20 | + "coordinates": (((1, 2), (3, 4), (5, 6), (1, 2)),), |
| 21 | + } |
12 | 22 |
|
13 | 23 |
|
14 | 24 | def test_polygon_wkt():
|
15 | 25 | poly = Polygon((((1, 2), (3, 4), (5, 6), (1, 2)),))
|
16 | 26 | wkt = poly.wkt
|
17 |
| - wkt = wkt.replace('.0','') |
18 |
| - wkt = wkt.replace(', ',',') |
19 |
| - assert wkt == 'POLYGON((1 2,3 4,5 6,1 2))' |
| 27 | + wkt = wkt.replace(".0", "") |
| 28 | + wkt = wkt.replace(", ", ",") |
| 29 | + assert wkt == "POLYGON((1 2,3 4,5 6,1 2))" |
| 30 | + |
| 31 | + |
| 32 | +def test_polygon_is_hashable(): |
| 33 | + p1 = Polygon((((1, 2), (3, 4), (5, 6), (1, 2)),)) |
| 34 | + p2 = Polygon((((1, 2), (3, 4), (5, 6), (1, 2)),)) |
| 35 | + p3 = Polygon((((1, 2), (3, 4), (6, 7), (1, 2)),)) |
| 36 | + assert {p1, p2, p3} == {p1, p3} |
| 37 | + p1 = Polygon((((1, 2), (3, 4), (5, 6), (1, 2)),), srid=4326) |
| 38 | + p2 = Polygon((((1, 2), (3, 4), (5, 6), (1, 2)),), srid=3857) |
| 39 | + assert len({p1, p2}) == 2 |
0 commit comments