Skip to content

Remove workaround for new datum types #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions pyproj/_crs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1317,14 +1317,14 @@ cdef class PrimeMeridian(_CRSParts):


_DATUM_TYPE_MAP = {
"GeodeticReferenceFrame": "Geodetic Reference Frame",
"DynamicGeodeticReferenceFrame": "Dynamic Geodetic Reference Frame",
"VerticalReferenceFrame": "Vertical Reference Frame",
"DynamicVerticalReferenceFrame": "Dynamic Vertical Reference Frame",
"DatumEnsemble": "Datum Ensemble",
"TemporalDatum": "Temporal Datum",
"EngineeringDatum": "Engineering Datum",
"ParametricDatum": "Parametric Datum",
PJ_TYPE_GEODETIC_REFERENCE_FRAME: "Geodetic Reference Frame",
PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME: "Dynamic Geodetic Reference Frame",
PJ_TYPE_VERTICAL_REFERENCE_FRAME: "Vertical Reference Frame",
PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME: "Dynamic Vertical Reference Frame",
PJ_TYPE_DATUM_ENSEMBLE: "Datum Ensemble",
PJ_TYPE_TEMPORAL_DATUM: "Temporal Datum",
PJ_TYPE_ENGINEERING_DATUM: "Engineering Datum",
PJ_TYPE_PARAMETRIC_DATUM: "Parametric Datum",
}

_PJ_DATUM_TYPE_MAP = {
Expand All @@ -1338,19 +1338,6 @@ _PJ_DATUM_TYPE_MAP = {
}


cdef _get_datum_type_name(PJ_CONTEXT* context, PJ* datum):
# workaround: https://github.com/OSGeo/PROJ/pull/2274
cdef const char* proj_json_string = proj_as_projjson(
context,
datum,
NULL,
)
if proj_json_string == NULL:
return None
json_dict = json.loads(cstrdecode(proj_json_string))
return _DATUM_TYPE_MAP.get(json_dict["type"])


cdef class Datum(_CRSParts):
"""
.. versionadded:: 2.2.0
Expand Down Expand Up @@ -1378,7 +1365,7 @@ cdef class Datum(_CRSParts):
datum.context = context
datum.projobj = datum_pj
datum._set_base_info()
datum.type_name = _get_datum_type_name(datum.context, datum.projobj)
datum.type_name = _DATUM_TYPE_MAP[proj_get_type(datum.projobj)]
return datum

@staticmethod
Expand Down Expand Up @@ -1458,7 +1445,7 @@ cdef class Datum(_CRSParts):
)
if (
datum_pj == NULL or
_get_datum_type_name(context, datum_pj) is None
proj_get_type(datum_pj) not in _DATUM_TYPE_MAP
):
proj_destroy(datum_pj)
proj_context_destroy(context)
Expand Down
3 changes: 3 additions & 0 deletions pyproj/proj.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ cdef extern from "proj.h":
PJ_TYPE_TRANSFORMATION
PJ_TYPE_CONCATENATED_OPERATION
PJ_TYPE_OTHER_COORDINATE_OPERATION
PJ_TYPE_TEMPORAL_DATUM
PJ_TYPE_ENGINEERING_DATUM
PJ_TYPE_PARAMETRIC_DATUM

PJ_TYPE proj_get_type(const PJ *obj)
const char* proj_get_name(const PJ *obj)
Expand Down