Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_transformer__operations():
transformer = Transformer.from_crs(28356, 7856)
assert [op.name for op in transformer.operations] == [
"Inverse of Map Grid of Australia zone 56",
"GDA94 to GDA2020 (1)",
"Map Grid of Australia zone 56",
]
def test_transformer__operations_missing():
assert Transformer.from_crs(7789, 8401).operations == ()
def test_to_wkt():
transformer = Transformer.from_crs(4326, 3857)
assert transformer.to_wkt().startswith(
'CONVERSION["Popular Visualisation Pseudo-Mercator"'
)
def test_transform_direction__string_lowercase():
forward_transformer = Transformer.from_crs(4326, 3857)
inverse_transformer = Transformer.from_crs(3857, 4326)
assert inverse_transformer.transform(
-33, 24, direction="inverse"
) == forward_transformer.transform(-33, 24, direction="forward")
ident_transformer = Transformer.from_crs(4326, 3857)
ident_transformer.transform(-33, 24, direction="ident") == (-33, 24)
def test_repr():
assert repr(Transformer.from_crs(7789, 8401)) == (
"\n"
"Description: ITRF2014 to ETRF2014 (1)\n"
"Area of Use:\n"
"- name: Europe - ETRS89\n"
"- bounds: (-16.1, 32.88, 40.18, 84.17)"
)
assert repr(Transformer.from_crs(4326, 3857)) == (
"\n"
"Description: Popular Visualisation Pseudo-Mercator\n"
"Area of Use:\n"
"- name: World\n"
"- bounds: (-180.0, -90.0, 180.0, 90.0)"
)
assert repr(Transformer.from_crs(4326, 26917)) == (
def _reproject(geo, from_proj, to_proj):
if from_proj != to_proj:
from_proj = get_proj(from_proj)
to_proj = get_proj(to_proj)
tfm = pyproj.Transformer.from_crs(from_proj, to_proj, always_xy=True)
return ops.transform(tfm.transform, geo)
return geo
def _reproject(self, geometry, from_proj=None, to_proj=None):
if from_proj is None:
from_proj = self._default_proj
if to_proj is None:
to_proj = self.proj if self.proj is not None else "EPSG:4326"
tfm = pyproj.Transformer.from_crs(get_proj(from_proj), get_proj(to_proj), always_xy=True)
return ops.transform(tfm.transform, geometry)