From 7b5cb5cc91d7a2fd84907b6ae65c93cedd7a0a1e Mon Sep 17 00:00:00 2001 From: Javier Jimenez Shaw Date: Fri, 5 Apr 2024 14:29:19 +0200 Subject: [PATCH] convert from str to PJType --- pyproj/database.pyx | 3 +++ test/test_database.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/pyproj/database.pyx b/pyproj/database.pyx index 3af1a80e6..f8c0bd07f 100644 --- a/pyproj/database.pyx +++ b/pyproj/database.pyx @@ -514,6 +514,9 @@ def query_geodetic_crs_from_datum( list[CRS] """ + if pj_type is not None and not isinstance(pj_type, PJType): + pj_type = PJType.create(pj_type) + cdef const char* c_crs_type = NULL if pj_type is None: pass diff --git a/test/test_database.py b/test/test_database.py index cc47e7678..3f00f5df0 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -272,6 +272,10 @@ def test_get_database_metadata__invalid(): def test_query_geodetic_crs_from_datum(): + crss = query_geodetic_crs_from_datum("EPSG", "EPSG", "1116", "GEOCENTRIC_CRS") + assert len(crss) == 1 + assert crss[0].to_authority()[1] == "6317" + crss = query_geodetic_crs_from_datum("EPSG", "EPSG", "1116", PJType.GEOCENTRIC_CRS) assert len(crss) == 1 assert crss[0].to_authority()[1] == "6317" @@ -304,6 +308,9 @@ def test_query_geodetic_crs_from_datum_invalid(): with pytest.raises(ValueError): query_geodetic_crs_from_datum("EPSG", "EPSG", "1116", PJType.PROJECTED_CRS) + with pytest.raises(ValueError): + query_geodetic_crs_from_datum("EPSG", "EPSG", "1116", "invalid string") + with pytest.raises(TypeError): query_geodetic_crs_from_datum("EPSG", "EPSG", None)