Skip to content

Commit

Permalink
DEP: Minimum PROJ version 8.0 (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Oct 7, 2021
1 parent e8e4099 commit 5c68a10
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 159 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
- os: ubuntu-latest
python-version: 3.8
python-implementation: python
proj-version: 7.2
proj-version: 8.0
- os: ubuntu-latest
python-version: 3.8
python-implementation: python
proj-version: 8.0
proj-version: 8.1
- os: ubuntu-latest
python-version: '*'
python-implementation: pypy
Expand Down
10 changes: 1 addition & 9 deletions docs/build_crs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ PROJ string::

.. code-block:: python
from packaging import version
from pyproj.crs import BoundCRS, Ellipsoid, GeographicCRS, ProjectedCRS
from pyproj.crs.coordinate_operation import (
TransverseMercatorConversion,
Expand All @@ -124,12 +122,6 @@ PROJ string::
from pyproj.crs.datum import CustomDatum
import pyproj
if version.parse(pyproj.__proj_version__) >= version.parse("8.0")
# https://github.com/OSGeo/PROJ/pull/2536
HAYFORD_ELLIPSOID_NAME = "International 1924 (Hayford 1909, 1910)"
else:
HAYFORD_ELLIPSOID_NAME = "International 1909 (Hayford)"
proj_crs = ProjectedCRS(
conversion=TransverseMercatorConversion(
latitude_natural_origin=0,
Expand All @@ -139,7 +131,7 @@ PROJ string::
scale_factor_natural_origin=0.9996,
),
geodetic_crs=GeographicCRS(
datum=CustomDatum(ellipsoid=HAYFORD_ELLIPSOID_NAME)
datum=CustomDatum(ellipsoid="International 1924 (Hayford 1909, 1910)")
),
)
bound_crs = BoundCRS(
Expand Down
1 change: 1 addition & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Change Log
Latest
-------
- DEP: Minimum supported Python version 3.8 (issue #930)
- DEP: Minimum PROJ version 8.0 (issue #940)
- BUG: Prepend "Derived" to CRS type name if CRS is derived (issue #932)
- BUG: Improved handling of inf values in :attr:`pyproj.transformer.Transformer.transform_bounds` (pull #961)
- ENH: Add support for transforming bounds at the poles in :attr:`pyproj.transformer.Transformer.transform_bounds` (pull #962)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Python interface to `PROJ <https://proj.org/>`_ (cartographic projections and c

GitHub Repository: https://github.com/pyproj4/pyproj

.. note:: Minimum supported PROJ version is 7.2.0
.. note:: Minimum supported PROJ version is 8.0

.. note:: Minimum supported Python version is 3.8

Expand Down
1 change: 1 addition & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pyproj PROJ
2.4-2.6 6.2-7
3.0.0 7.2
3.0.1+ 7.2+
3.3.0+ 8.0+
============ ============

Setup PROJ
Expand Down
22 changes: 4 additions & 18 deletions pyproj/_transformer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ proj_version_str = f"{PROJ_VERSION_MAJOR}.{PROJ_VERSION_MINOR}.{PROJ_VERSION_PAT
_AUTH_CODE_RE = re.compile(r"(?P<authority>\w+)\:(?P<code>\w+)")


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


cdef dict _PJ_DIRECTION_MAP = {
TransformDirection.FORWARD: PJ_FWD,
TransformDirection.INVERSE: PJ_INV,
Expand Down Expand Up @@ -272,20 +264,14 @@ cdef PJ* proj_create_crs_to_crs(
options[2] = NULL
options[3] = NULL
if authority is not None:
if PROJ_VERSION_MAJOR < 8:
warnings.warn("authority requires PROJ 8+")
b_authority = cstrencode(f"AUTHORITY={authority}")
options[options_index] = b_authority
options_index += 1
if accuracy is not None:
if PROJ_VERSION_MAJOR < 8:
warnings.warn("accuracy requires PROJ 8+")
b_accuracy = cstrencode(f"ACCURACY={accuracy}")
options[options_index] = b_accuracy
options_index += 1
if allow_ballpark is not None:
if PROJ_VERSION_MAJOR < 8:
warnings.warn("allow_ballpark requires PROJ 8+")
if not allow_ballpark:
options[options_index] = b"ALLOW_BALLPARK=NO"

Expand Down Expand Up @@ -1099,7 +1085,7 @@ cdef class _Transformer(Base):
if errcheck and errno:
with gil:
raise ProjError(
f"transform error: {pyproj_errno_string(self.context, errno)}"
f"transform error: {proj_context_errno_string(self.context, errno)}"
)
elif errcheck:
with gil:
Expand Down Expand Up @@ -1194,7 +1180,7 @@ cdef class _Transformer(Base):
if errcheck and errno:
with gil:
raise ProjError(
f"itransform error: {pyproj_errno_string(self.context, errno)}"
f"itransform error: {proj_context_errno_string(self.context, errno)}"
)
elif errcheck:
with gil:
Expand Down Expand Up @@ -1278,7 +1264,7 @@ cdef class _Transformer(Base):
with gil:
raise ProjError(
"transform bounds error: "
f"{pyproj_errno_string(self.context, errno)}"
f"{proj_context_errno_string(self.context, errno)}"
)
else:
with gil:
Expand Down Expand Up @@ -1379,7 +1365,7 @@ cdef class _Transformer(Base):
if errcheck and errno:
with gil:
raise ProjError(
f"proj error: {pyproj_errno_string(self.context, errno)}"
f"proj error: {proj_context_errno_string(self.context, errno)}"
)

if errno or invalid_coord:
Expand Down
4 changes: 2 additions & 2 deletions pyproj/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def set_ca_bundle_path(ca_bundle_path: Union[Path, str, bool, None] = None) -> N
.. versionadded:: 3.0.0
Sets the path to the CA Bundle used by the `curl`
built into PROJ when PROJ network is enabled..
built into PROJ when PROJ network is enabled.
Environment variables that can be used with PROJ 7.2+:
Environment variables:
- PROJ_CURL_CA_BUNDLE
- CURL_CA_BUNDLE
Expand Down
33 changes: 8 additions & 25 deletions pyproj/proj.pxi
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
# PROJ API Definition

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
PJ_CATEGORY_DATUM
PJ_CATEGORY_CRS
PJ_CATEGORY_COORDINATE_OPERATION
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
PJ_CATEGORY_DATUM
PJ_CATEGORY_CRS
PJ_CATEGORY_COORDINATE_OPERATION
cdef int PJ_CATEGORY_DATUM_ENSEMBLE = PJ_CATEGORY_DATUM


cdef extern from "proj.h":
cdef int PROJ_VERSION_MAJOR
cdef int PROJ_VERSION_MINOR
Expand All @@ -34,8 +12,6 @@ cdef extern from "proj.h":
const char* const *options)
void proj_context_set_ca_bundle_path(PJ_CONTEXT *ctx, const char *path);

# projCtx has been replaced by PJ_CONTEXT *.
# projPJ has been replaced by PJ *
ctypedef struct PJ
ctypedef struct PJ_CONTEXT
PJ_CONTEXT *proj_context_create ()
Expand All @@ -52,7 +28,7 @@ cdef extern from "proj.h":
void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf)

int proj_errno (const PJ *P) nogil
int proj_context_errno (PJ_CONTEXT *ctx)
const char * proj_context_errno_string(PJ_CONTEXT* ctx, 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 Expand Up @@ -424,6 +400,13 @@ cdef extern from "proj.h":
PJ *proj_concatoperation_get_step(PJ_CONTEXT *ctx,
const PJ *concatoperation,
int i_step)
ctypedef enum PJ_CATEGORY:
PJ_CATEGORY_ELLIPSOID
PJ_CATEGORY_PRIME_MERIDIAN
PJ_CATEGORY_DATUM
PJ_CATEGORY_CRS
PJ_CATEGORY_COORDINATE_OPERATION
PJ_CATEGORY_DATUM_ENSEMBLE
PJ *proj_create_from_database(PJ_CONTEXT *ctx,
const char *auth_name,
const char *code,
Expand Down
5 changes: 2 additions & 3 deletions pyproj/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,13 @@ def from_crs(
to “any”, then coordinate operations from any authority will be
searched. If authority is a non-empty string different from "any",
then coordinate operations will be searched only in that authority
namespace (e.g. EPSG). Requires PROJ 8+.
namespace (e.g. EPSG).
accuracy: float, optional
The minimum desired accuracy (in metres) of the candidate
coordinate operations. Requires PROJ 8+.
coordinate operations.
allow_ballpark: bool, optional
Set to False to disallow the use of Ballpark transformation
in the candidate coordinate operations. Default is to allow.
Requires PROJ 8+.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pkg_resources import parse_version
from setuptools import Extension, setup

PROJ_MIN_VERSION = parse_version("7.2.0")
PROJ_MIN_VERSION = parse_version("8.0.0")
CURRENT_FILE_PATH = Path(__file__).absolute().parent
BASE_INTERNAL_PROJ_DIR = Path("proj_dir")
INTERNAL_PROJ_DIR = CURRENT_FILE_PATH / "pyproj" / BASE_INTERNAL_PROJ_DIR
Expand Down
13 changes: 0 additions & 13 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@

_NETWORK_ENABLED = pyproj.network.is_network_enabled()
PROJ_LOOSE_VERSION = version.parse(pyproj.__proj_version__)
PROJ_GTE_8 = PROJ_LOOSE_VERSION >= version.parse("8.0")
PROJ_GTE_81 = PROJ_LOOSE_VERSION >= version.parse("8.1")
PROJ_GTE_82 = PROJ_LOOSE_VERSION >= version.parse("8.2")
RGF93toWSG84 = "RGF93 v1 to WGS 84 (1)" if PROJ_GTE_82 else "RGF93 to WGS 84 (1)"

if PROJ_GTE_8:
# https://github.com/OSGeo/PROJ/pull/2536
HAYFORD_ELLIPSOID_NAME = "International 1924 (Hayford 1909, 1910)"
else:
HAYFORD_ELLIPSOID_NAME = "International 1909 (Hayford)"


def unset_data_dir():
pyproj.datadir._USER_PROJ_DATA = None
Expand Down Expand Up @@ -86,12 +79,6 @@ def grids_available(*grid_names, check_network=True, check_all=False):
return any(available)


def get_wgs84_datum_name():
if PROJ_GTE_8:
return "World Geodetic System 1984 ensemble"
return "World Geodetic System 1984"


def assert_can_pickle(raw_obj, tmp_path):
file_path = tmp_path / "temporary.pickle"
with open(file_path, "wb") as f:
Expand Down

0 comments on commit 5c68a10

Please sign in to comment.