Skip to content

Commit

Permalink
Use proj_context_errno_string in PROJ 8+ due to deprecation (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 authored Dec 20, 2020
1 parent 48dba99 commit ba00b01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Change Log

3.0.1
-----
* Use `proj_context_errno_string` in PROJ 8+ due to deprecation (issue #760)

3.0.0
-----
Expand Down
14 changes: 11 additions & 3 deletions pyproj/_transformer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ from pyproj.exceptions import ProjError
proj_version_str = f"{PROJ_VERSION_MAJOR}.{PROJ_VERSION_MINOR}.{PROJ_VERSION_PATCH}"


cdef pyproj_errno_string(PJ_CONTEXT* ctx, int err):
# https://github.com/pyproj4/pyproj/issues/760
IF CTE_PROJ_VERSION_MAJOR >= 8:
return pystrdecode(proj_context_errno_string(ctx, err))
ELSE:
return pystrdecode(proj_errno_string(err))


_PJ_DIRECTION_MAP = {
TransformDirection.FORWARD: PJ_FWD,
TransformDirection.INVERSE: PJ_INV,
Expand Down Expand Up @@ -503,7 +511,7 @@ cdef class _Transformer(Base):
if errcheck and errno:
with gil:
raise ProjError(
f"transform error: {pystrdecode(proj_errno_string(errno))}"
f"transform error: {pyproj_errno_string(self.context, errno)}"
)
elif errcheck:
with gil:
Expand Down Expand Up @@ -601,7 +609,7 @@ cdef class _Transformer(Base):
if errcheck and errno:
with gil:
raise ProjError(
f"itransform error: {pystrdecode(proj_errno_string(errno))}"
f"itransform error: {pyproj_errno_string(self.context, errno)}"
)
elif errcheck:
with gil:
Expand Down Expand Up @@ -701,7 +709,7 @@ cdef class _Transformer(Base):
if errcheck and errno:
with gil:
raise ProjError(
f"proj error: {pystrdecode(proj_errno_string(errno))}"
f"proj error: {pyproj_errno_string(self.context, errno)}"
)

if errno or invalid_coord:
Expand Down
3 changes: 2 additions & 1 deletion pyproj/proj.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

IF CTE_PROJ_VERSION_MAJOR >= 8:
cdef extern from "proj.h":
const char * proj_context_errno_string(PJ_CONTEXT* ctx, int err)
ctypedef enum PJ_CATEGORY:
PJ_CATEGORY_ELLIPSOID
PJ_CATEGORY_PRIME_MERIDIAN
Expand All @@ -11,6 +12,7 @@ IF CTE_PROJ_VERSION_MAJOR >= 8:
PJ_CATEGORY_DATUM_ENSEMBLE
ELSE:
cdef extern from "proj.h":
const char * proj_errno_string(int err)
ctypedef enum PJ_CATEGORY:
PJ_CATEGORY_ELLIPSOID
PJ_CATEGORY_PRIME_MERIDIAN
Expand Down Expand Up @@ -51,7 +53,6 @@ cdef extern from "proj.h":

int proj_errno (const PJ *P) nogil
int proj_context_errno (PJ_CONTEXT *ctx)
const char * proj_errno_string (int err)
int proj_errno_reset (const PJ *P) nogil
PJ *proj_create (PJ_CONTEXT *ctx, const char *definition)
PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ* obj)
Expand Down

0 comments on commit ba00b01

Please sign in to comment.