|
1 | 1 | """Tests of the transform submodule""" |
2 | 2 |
|
3 | 3 | import math |
4 | | - |
5 | 4 | import pytest |
6 | | - |
7 | 5 | from fiona import transform |
8 | 6 |
|
9 | 7 |
|
|
48 | 46 | def test_transform_geom_with_z(geom): |
49 | 47 | """Transforming a geom with Z succeeds""" |
50 | 48 | g2 = transform.transform_geom("epsg:4326", "epsg:3857", geom, precision=3) |
| 49 | + |
| 50 | + |
| 51 | +@pytest.mark.parametrize("crs", ["epsg:4326", |
| 52 | + "EPSG:4326", |
| 53 | + "WGS84", |
| 54 | + {'init': 'epsg:4326'}, |
| 55 | + {'proj': 'longlat', 'datum': 'WGS84', 'no_defs': True}, |
| 56 | + "OGC:CRS84"]) |
| 57 | +def test_axis_ordering(crs): |
| 58 | + """ Test if transform uses traditional_axis_mapping """ |
| 59 | + |
| 60 | + expected = (-8427998.647958742, 4587905.27136252) |
| 61 | + t1 = transform.transform(crs, "epsg:3857", [-75.71], [38.06]) |
| 62 | + assert (t1[0][0], t1[1][0]) == pytest.approx(expected) |
| 63 | + geom = {"type": "Point", "coordinates": [-75.71, 38.06]} |
| 64 | + g1 = transform.transform_geom(crs, "epsg:3857", geom, precision=3) |
| 65 | + assert g1["coordinates"] == pytest.approx(expected) |
| 66 | + |
| 67 | + rev_expected = (-75.71, 38.06) |
| 68 | + t2 = transform.transform("epsg:3857", crs, [-8427998.647958742], [4587905.27136252]) |
| 69 | + assert (t2[0][0], t2[1][0]) == pytest.approx(rev_expected) |
| 70 | + geom = {"type": "Point", "coordinates": [-8427998.647958742, 4587905.27136252]} |
| 71 | + g2 = transform.transform_geom("epsg:3857", crs, geom, precision=3) |
| 72 | + assert g2["coordinates"] == pytest.approx(rev_expected) |
0 commit comments