Skip to content
Commits on Source (20)
......@@ -284,7 +284,9 @@
"avatar_url": "https://avatars3.githubusercontent.com/u/483428?v=4",
"profile": "https://github.com/cgohlke",
"contributions": [
"platform"
"platform",
"question",
"bug"
]
},
{
......
......@@ -24,6 +24,8 @@ http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
#### Environment Information
<!-- If you have pyproj>=2.4.0 -->
- Output from: `python -m pyproj -v`
<!-- If you have pyproj>=2.2.1 -->
- Output from: `python -c "import pyproj; pyproj.show_versions()"`
<!-- If you have pyproj<2.2.1 -->
......
......@@ -11,7 +11,7 @@ env:
global:
- PROJ_BASE_DIR=$HOME/proj_install
- CYTHON_COVERAGE=True
- PROJSOURCE=6.1.1
- PROJSOURCE=6.2.0
# Following generated with
- WHEELHOUSE_UPLOADER_USERNAME=travis-worker
# Following generated by
......@@ -26,20 +26,17 @@ matrix:
os: osx
env:
- PYTHON=3.6.8
- PROJSOURCE=6.1.1
- PROJSOURCE=6.2.0
- python: 3.5
env:
- PROJSOURCE=6.1.1
- PROJSOURCE=6.2.0
- python: 3.6
env:
- PROJSOURCE=6.1.0
- python: 3.6
env:
- PROJSOURCE=6.1.1
- PROJSOURCE=6.2.0
- python: 3.7
dist: xenial
env:
- PROJSOURCE=6.1.1
- PROJSOURCE=6.2.0
- DOC=true
- python: "nightly"
env:
......
# Preparing a pyproj release
Preparing a pyproj release is a two-phase process.
## Phase 1: Release Candidate
In this phase, we want to ensure all the builds work on all platforms and methods
of distribution for the next release.
### Add the rc postfix
The first step in this phase is to update the version number `__version__` in `__init__.py`
to the next release `<major>.<minor>.<patch>`. Then, add the `rc` style posfix following the [PEP-440](https://www.python.org/dev/peps/pep-0440/#pre-releases) conventions.
### Create a tag on the repository
The next step is to create a tag with the same name as the version just added. This can be done using the git command line or from https://github.com/pyproj4/pyproj/tags.
### Test the release builds
1. Create a draft PR at https://github.com/pyproj4/pyproj-wheels and verify tests pass.
2. Create a draft PR at https://github.com/conda-forge/pyproj-feedstock and verify tests pass.
3. Verify Windows wheels built properly.
4. Verify Debian builds were succesful.
5. Verify the docs build successfully.
## Phase 2: Make the release
After the candidate has proven itself, it will be promoted to a final release.
### Remove the rc postfix
Remove the `rc` postfix from the the version number `__version__` in `__init__.py`.
### Create a tag on the repository
The next step is to create a tag with the name `v<major>.<minor>.<patch>rel`. This can be done using the git command line or from https://github.com/pyproj4/pyproj/tags.
Next, go through the history and add release notes. Make sure to acknowledge contributions made by others in the release. A useful script for automating this task for code contributions is the [pandas announce script](https://github.com/pandas-dev/pandas/blob/bb6135880e5e453d7701764b9f2e4ad3356a68d7/doc/sphinxext/announce.py).
### The wheels
1. Update the PR at https://github.com/pyproj4/pyproj-wheels with the release tag, merge, and download wheels.
2. Retrieve Windows wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs.
### Create the release sdist
1. Make sure the directory is clean and checkout the release tag.
2. `python setup.py sdist`
### Upload to pypi
Upload the wheels and the sdist `tar.gz` for the release to pypi.
### Verify conda-forge build is correct
A PR for `pyproj` will be generated automatically after you push to pypi.
Verify all is correct on the PR at https://github.com/conda-forge/pyproj-feedstock.
### Update the docs
On the `gh-pages` branch, update the stable symlink to point to the next version.
......@@ -9,4 +9,5 @@ include pyproj/*.pxd
include pyproj/*.pxi
include test/sample.out
recursive-include docs *
prune docs/_build
prune pyproj/proj_dir
......@@ -36,7 +36,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<table>
<tr>
<td align="center"><a href="https://github.com/jswhit"><img src="https://avatars2.githubusercontent.com/u/579593?v=4" width="100px;" alt="Jeff Whitaker"/><br /><sub><b>Jeff Whitaker</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=jswhit" title="Documentation">📖</a> <a href="https://github.com/snowman2/pyproj/commits?author=jswhit" title="Tests">⚠️</a> <a href="https://github.com/snowman2/pyproj/commits?author=jswhit" title="Code">💻</a> <a href="#example-jswhit" title="Examples">💡</a> <a href="#ideas-jswhit" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review-jswhit" title="Reviewed Pull Requests">👀</a> <a href="#question-jswhit" title="Answering Questions">💬</a> <a href="#maintenance-jswhit" title="Maintenance">🚧</a> <a href="#infra-jswhit" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center"><a href="https://www.linkedin.com/in/alan-snow-55bb8726/"><img src="https://avatars3.githubusercontent.com/u/8699967?v=4" width="100px;" alt="Alan D. Snow"/><br /><sub><b>Alan D. Snow</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=snowman2" title="Documentation">📖</a> <a href="https://github.com/snowman2/pyproj/commits?author=snowman2" title="Tests">⚠️</a> <a href="https://github.com/snowman2/pyproj/commits?author=snowman2" title="Code">💻</a> <a href="#example-snowman2" title="Examples">💡</a> <a href="#maintenance-snowman2" title="Maintenance">🚧</a> <a href="#infra-snowman2" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#ideas-snowman2" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review-snowman2" title="Reviewed Pull Requests">👀</a> <a href="#question-snowman2" title="Answering Questions">💬</a></td>
<td align="center"><a href="https://github.com/snowman2"><img src="https://avatars3.githubusercontent.com/u/8699967?v=4" width="100px;" alt="Alan D. Snow"/><br /><sub><b>Alan D. Snow</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=snowman2" title="Documentation">📖</a> <a href="https://github.com/snowman2/pyproj/commits?author=snowman2" title="Tests">⚠️</a> <a href="https://github.com/snowman2/pyproj/commits?author=snowman2" title="Code">💻</a> <a href="#example-snowman2" title="Examples">💡</a> <a href="#maintenance-snowman2" title="Maintenance">🚧</a> <a href="#infra-snowman2" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#ideas-snowman2" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review-snowman2" title="Reviewed Pull Requests">👀</a> <a href="#question-snowman2" title="Answering Questions">💬</a></td>
<td align="center"><a href="https://github.com/micahcochran"><img src="https://avatars0.githubusercontent.com/u/7433104?v=4" width="100px;" alt="Micah Cochran"/><br /><sub><b>Micah Cochran</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=micahcochran" title="Documentation">📖</a> <a href="https://github.com/snowman2/pyproj/commits?author=micahcochran" title="Tests">⚠️</a> <a href="https://github.com/snowman2/pyproj/commits?author=micahcochran" title="Code">💻</a> <a href="#maintenance-micahcochran" title="Maintenance">🚧</a> <a href="#infra-micahcochran" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#review-micahcochran" title="Reviewed Pull Requests">👀</a> <a href="#question-micahcochran" title="Answering Questions">💬</a></td>
<td align="center"><a href="https://jorisvandenbossche.github.io/"><img src="https://avatars2.githubusercontent.com/u/1020496?v=4" width="100px;" alt="Joris Van den Bossche"/><br /><sub><b>Joris Van den Bossche</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=jorisvandenbossche" title="Documentation">📖</a> <a href="https://github.com/snowman2/pyproj/commits?author=jorisvandenbossche" title="Code">💻</a> <a href="#ideas-jorisvandenbossche" title="Ideas, Planning, & Feedback">🤔</a> <a href="#review-jorisvandenbossche" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/cjmayo"><img src="https://avatars1.githubusercontent.com/u/921089?v=4" width="100px;" alt="Chris Mayo"/><br /><sub><b>Chris Mayo</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=cjmayo" title="Tests">⚠️</a></td>
......@@ -64,10 +64,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center"><a href="http://lizards.opensuse.org/author/bmwiedemann/"><img src="https://avatars3.githubusercontent.com/u/637990?v=4" width="100px;" alt="Bernhard M. Wiedemann"/><br /><sub><b>Bernhard M. Wiedemann</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=bmwiedemann" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ReallyNiceGuy"><img src="https://avatars0.githubusercontent.com/u/6545730?v=4" width="100px;" alt="Marco Aurélio da Costa"/><br /><sub><b>Marco Aurélio da Costa</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=ReallyNiceGuy" title="Code">💻</a></td>
<td align="center"><a href="http://response.restoration.noaa.gov"><img src="https://avatars2.githubusercontent.com/u/916576?v=4" width="100px;" alt="Chris Barker"/><br /><sub><b>Chris Barker</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=ChrisBarker-NOAA" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ChrisBarker-NOAA"><img src="https://avatars2.githubusercontent.com/u/916576?v=4" width="100px;" alt="Christopher H. Barker"/><br /><sub><b>Christopher H. Barker</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=ChrisBarker-NOAA" title="Code">💻</a></td>
<td align="center"><a href="https://evers.dev/"><img src="https://avatars3.githubusercontent.com/u/13132571?v=4" width="100px;" alt="Kristian Evers"/><br /><sub><b>Kristian Evers</b></sub></a><br /><a href="#question-kbevers" title="Answering Questions">💬</a> <a href="#ideas-kbevers" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="http://www.spatialys.com/en/about/"><img src="https://avatars2.githubusercontent.com/u/1192433?v=4" width="100px;" alt="Even Rouault"/><br /><sub><b>Even Rouault</b></sub></a><br /><a href="#question-rouault" title="Answering Questions">💬</a></td>
<td align="center"><a href="https://github.com/cgohlke"><img src="https://avatars3.githubusercontent.com/u/483428?v=4" width="100px;" alt="Christoph Gohlke"/><br /><sub><b>Christoph Gohlke</b></sub></a><br /><a href="#platform-cgohlke" title="Packaging/porting to new platform">📦</a></td>
<td align="center"><a href="https://github.com/cgohlke"><img src="https://avatars3.githubusercontent.com/u/483428?v=4" width="100px;" alt="Christoph Gohlke"/><br /><sub><b>Christoph Gohlke</b></sub></a><br /><a href="#platform-cgohlke" title="Packaging/porting to new platform">📦</a> <a href="#question-cgohlke" title="Answering Questions">💬</a> <a href="https://github.com/snowman2/pyproj/issues?q=author%3Acgohlke" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/chrrrisw"><img src="https://avatars0.githubusercontent.com/u/5555320?v=4" width="100px;" alt="Chris Willoughby"/><br /><sub><b>Chris Willoughby</b></sub></a><br /><a href="https://github.com/snowman2/pyproj/commits?author=chrrrisw" title="Code">💻</a></td>
</tr>
</table>
......
......@@ -21,19 +21,19 @@ environment:
# PYTHON_ARCH: "64"
# VS_VERSION: Visual Studio 14
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
# PROJSOURCE: 6.1.0
# PROJSOURCE: 6.2.0
- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
VS_VERSION: Visual Studio 14
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PROJSOURCE: 6.1.1
PROJSOURCE: 6.2.0
# - PYTHON: "C:\\Python37-x64"
# PYTHON_VERSION: "3.7"
# PYTHON_ARCH: "64"
# VS_VERSION: Visual Studio 14
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
# PROJSOURCE: 6.1.1
# PROJSOURCE: 6.2.0
# - PYTHON: "C:\\Python36-x64"
# PYTHON_VERSION: "3.6"
# PYTHON_ARCH: "64"
......
#!/bin/bash
echo "Building PROJ.4 $1 version from source..."
if [[ $1 == "git" ]]; then
git clone https://github.com/OSGeo/proj.4.git proj-git
git clone https://github.com/OSGeo/proj.git proj-git
else
curl https://download.osgeo.org/proj/proj-$1.tar.gz > "proj-${1:0:5}.tar.gz"
tar zxf "proj-${1:0:5}.tar.gz"
......
python-pyproj (2.4.0+ds-1) unstable; urgency=medium
* New upstream release.
* Move from experimental to unstable.
-- Bas Couwenberg <sebastic@debian.org> Sat, 21 Sep 2019 06:27:00 +0200
python-pyproj (2.4~rc1+ds-1~exp1) experimental; urgency=medium
* New upstream release candidate.
* Drop patches, applied/fixed upstream.
-- Bas Couwenberg <sebastic@debian.org> Fri, 20 Sep 2019 14:50:23 +0200
python-pyproj (2.4~rc0+ds-1~exp1) experimental; urgency=medium
* New upstream release candidate.
* Update watch file for pre-releases.
* Add patch to use python3 interpreter for tests.
* Add patch to fix spelling errors.
* Use ${python3:Provides} substvar in Provides field.
-- Bas Couwenberg <sebastic@debian.org> Thu, 19 Sep 2019 07:25:56 +0200
python-pyproj (2.3.1+ds-1) unstable; urgency=medium
* Move from experimental to unstable.
......
......@@ -27,6 +27,7 @@ Depends: ${python3:Depends},
${shlibs:Depends},
${misc:Depends},
proj-data
Provides: ${python3:Provides}
Description: Python 3 interface to PROJ library
PROJ performs cartographic transformations between geographic (lat/lon)
and map projection (x/y) coordinates. It can also transform directly
......
......@@ -2,7 +2,7 @@ version=3
opts=\
dversionmangle=s/\+(debian|dfsg|ds|deb)\d*$//,\
uversionmangle=s/_/./g;s/rel$//;s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha|b|a)[\-\.]?\d*)$/$1~$2/,\
filenamemangle=s/(?:.*?)?v?(\d[\d\.]*)(?:rel)?\.(tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))/pyproj-$1.$2/,\
filenamemangle=s/(?:.*?\/archive\/)?(?:rel|v|pyproj)?[\-\_]?(\d\S+)(?:rel)?\.(tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))/pyproj-$1.$2/,\
repacksuffix=+ds \
https://github.com/pyproj4/pyproj/releases \
(?:.*?/archive/)*(?:rel|v|pyproj|)[\-\_]?(\d[\d\-\.]+[a-z]*)\.(?:tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
(?:.*?/archive/)*(?:rel|v|pyproj)?[\-\_]?(\d\S+)\.(?:tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
......@@ -47,7 +47,7 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """
__version__ = "2.3.1"
__version__ = "2.4.0"
__all__ = [
"Proj",
"Geod",
......@@ -64,11 +64,14 @@ __all__ = [
"get_units_map",
"show_versions",
]
import sys
from pyproj._datadir import PYPROJ_CONTEXT
import warnings
from pyproj import _datadir
from pyproj._list import ( # noqa: F401
get_angular_units_map,
get_authorities,
get_codes,
get_ellps_map,
get_prime_meridians_map,
get_proj_operations_map,
......@@ -76,31 +79,12 @@ from pyproj._list import ( # noqa: F401
)
from pyproj._show_versions import show_versions # noqa: F401
from pyproj.crs import CRS # noqa: F401
from pyproj.exceptions import ProjError # noqa: F401
from pyproj.exceptions import DataDirError, ProjError # noqa: F401
from pyproj.geod import Geod, geodesic_version_str, pj_ellps # noqa: F401
from pyproj.proj import Proj, pj_list, proj_version_str # noqa: F401
from pyproj.transformer import Transformer, itransform, transform # noqa: F401
PYPROJ_CONTEXT.set_search_paths()
def test(**kwargs):
"""run the examples in the docstrings using the doctest module"""
import doctest
import pyproj
verbose = kwargs.get("verbose")
failure_count, test_count = doctest.testmod(pyproj.proj, verbose=verbose)
failure_count_crs, test_count_crs = doctest.testmod(pyproj.crs, verbose=verbose)
failure_count_geod, test_count_geod = doctest.testmod(pyproj.geod, verbose=verbose)
failure_count_transform, test_count_transform = doctest.testmod(
pyproj.transformer, verbose=verbose
)
return (
failure_count + failure_count_crs + failure_count_geod + failure_count_transform
)
if __name__ == "__main__":
sys.exit(test(verbose=True))
try:
_datadir.pyproj_global_context_initialize()
except DataDirError as err:
warnings.warn(str(err))
"""
This is the main entry point for pyproj
e.g. python -m pyproj
"""
import argparse
from pyproj import __version__, _show_versions, proj_version_str
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
help="Show verbose debugging version information.",
action="store_true",
)
args = parser.parse_args()
if args.verbose:
_show_versions.show_versions()
else:
print("pyproj version: {} [PROJ version: {}]".format(__version__, proj_version_str))
parser.print_help()
include "proj.pxi"
cdef _get_concatenated_operations(PJ_CONTEXT*context, PJ*concatenated_operation)
cdef class Axis:
cdef readonly object name
cdef readonly object abbrev
......@@ -10,7 +14,7 @@ cdef class Axis:
cdef readonly object unit_code
@staticmethod
cdef create(PJ* projobj, int index)
cdef create(PJ_CONTEXT* context, PJ* projobj, int index)
cdef class AreaOfUse:
cdef readonly double west
......@@ -20,12 +24,15 @@ cdef class AreaOfUse:
cdef readonly object name
@staticmethod
cdef create(PJ* projobj)
cdef create(PJ_CONTEXT* context, PJ* projobj)
cdef class Base:
cdef PJ *projobj
cdef PJ_CONTEXT* context
cdef readonly object name
cdef readonly object _remarks
cdef readonly object _scope
cdef class Ellipsoid(Base):
......@@ -36,7 +43,7 @@ cdef class Ellipsoid(Base):
cdef readonly object ellipsoid_loaded
@staticmethod
cdef create(PJ* ellipsoid_pj)
cdef create(PJ_CONTEXT* context, PJ* ellipsoid_pj)
cdef class PrimeMeridian(Base):
cdef readonly double longitude
......@@ -44,7 +51,7 @@ cdef class PrimeMeridian(Base):
cdef readonly object unit_name
@staticmethod
cdef create(PJ* prime_meridian_pj)
cdef create(PJ_CONTEXT* context, PJ* prime_meridian_pj)
cdef class Datum(Base):
......@@ -52,14 +59,14 @@ cdef class Datum(Base):
cdef readonly object _prime_meridian
@staticmethod
cdef create(PJ* datum_pj)
cdef create(PJ_CONTEXT* context, PJ* datum_pj)
cdef class CoordinateSystem(Base):
cdef readonly object _axis_list
@staticmethod
cdef create(PJ* coordinate_system_pj)
cdef create(PJ_CONTEXT* context, PJ* coordinate_system_pj)
cdef class Param:
......@@ -74,7 +81,7 @@ cdef class Param:
cdef readonly object unit_category
@staticmethod
cdef create(PJ* projobj, int param_idx)
cdef create(PJ_CONTEXT* context, PJ* projobj, int param_idx)
cdef class Grid:
......@@ -87,7 +94,7 @@ cdef class Grid:
cdef readonly object available
@staticmethod
cdef create(PJ* projobj, int grid_idx)
cdef create(PJ_CONTEXT* context, PJ* projobj, int grid_idx)
cdef class CoordinateOperation(Base):
......@@ -101,9 +108,10 @@ cdef class CoordinateOperation(Base):
cdef readonly object is_instantiable
cdef readonly object has_ballpark_transformation
cdef readonly object _towgs84
cdef readonly object _operations
@staticmethod
cdef create(PJ* coordinate_operation_pj)
cdef create(PJ_CONTEXT* context, PJ* coordinate_operation_pj)
cdef class _CRS(Base):
......
This diff is collapsed.
include "proj.pxi"
cdef ContextManager PROJ_CONTEXT
cdef void pyproj_context_initialize(PJ_CONTEXT* context, bint free_context_on_error) except *
cdef class ContextManager:
cdef PJ_CONTEXT *context
\ No newline at end of file
cdef object _set_search_paths
\ No newline at end of file
......@@ -4,7 +4,8 @@ from libc.stdlib cimport malloc, free
from pyproj.compat import cstrencode, pystrdecode
from pyproj.datadir import get_data_dir
from pyproj.exceptions import ProjError
from pyproj.exceptions import ProjError, DataDirError
cdef void pyproj_log_function(void *user_data, int level, const char *error_msg):
"""
......@@ -13,40 +14,37 @@ cdef void pyproj_log_function(void *user_data, int level, const char *error_msg)
if level == PJ_LOG_ERROR:
ProjError.internal_proj_error = pystrdecode(error_msg)
cdef class ContextManager:
def __cinit__(self):
self.context = NULL
def __dealloc__(self):
if self.context != NULL:
proj_context_destroy(self.context)
self.context = NULL
def __init__(self):
self.context = proj_context_create()
self._set_search_paths = False
proj_context_use_proj4_init_rules(self.context, 1)
proj_log_func(self.context, NULL, pyproj_log_function)
def set_search_paths(self, reset=False):
cdef void set_context_data_dir(PJ_CONTEXT* context) except *:
"""
This method sets the search paths
based on pyproj.datadir.get_data_dir()
Setup the data directory for the context for pyproj
"""
if self._set_search_paths and not reset:
return
data_dir_list = get_data_dir().split(os.pathsep)
cdef char **c_data_dir = <char **>malloc(len(data_dir_list) * sizeof(char*))
try:
for iii in range(len(data_dir_list)):
b_data_dir = cstrencode(data_dir_list[iii])
c_data_dir[iii] = b_data_dir
proj_context_set_search_paths(NULL, len(data_dir_list), c_data_dir)
proj_context_set_search_paths(self.context, len(data_dir_list), c_data_dir)
proj_context_set_search_paths(context, len(data_dir_list), c_data_dir)
finally:
free(c_data_dir)
self._set_search_paths = True
cdef ContextManager PROJ_CONTEXT = ContextManager()
PYPROJ_CONTEXT = PROJ_CONTEXT
cdef void pyproj_context_initialize(PJ_CONTEXT* context, bint free_context_on_error) except *:
"""
Setup the context for pyproj
"""
proj_log_func(context, NULL, pyproj_log_function)
proj_context_use_proj4_init_rules(context, 1)
proj_context_set_autoclose_database(context, 1)
try:
set_context_data_dir(context)
except DataDirError:
if free_context_on_error and context != NULL:
proj_context_destroy(context)
raise
def pyproj_global_context_initialize():
proj_log_func(NULL, NULL, pyproj_log_function)
set_context_data_dir(NULL)
......@@ -6,18 +6,18 @@ cdef extern from "geodesic.h":
void geod_init(geod_geodesic* g, double a, double f)
void geod_direct(geod_geodesic* g,
double lat1, double lon1, double azi1, double s12,
double* plat2, double* plon2, double* pazi2)
double* plat2, double* plon2, double* pazi2) nogil
void geod_inverse(geod_geodesic* g,
double lat1, double lon1, double lat2, double lon2,
double* ps12, double* pazi1, double* pazi2)
double* ps12, double* pazi1, double* pazi2) nogil
void geod_lineinit(geod_geodesicline* l,
geod_geodesic* g,
double lat1, double lon1, double azi1, unsigned caps)
double lat1, double lon1, double azi1, unsigned caps) nogil
void geod_position(geod_geodesicline* l, double s12,
double* plat2, double* plon2, double* pazi2)
double* plat2, double* plon2, double* pazi2) nogil
void geod_polygonarea(geod_geodesic* g,
double lats[], double lons[], int n,
double* pA, double* pP)
double* pA, double* pP) nogil
cdef enum:
GEODESIC_VERSION_MAJOR
......
......@@ -66,6 +66,7 @@ cdef class Geod:
latsdata = <double *>latdata
azdata = <double *>azdat
distdata = <double *>distdat
with nogil:
for iii in range(ndim):
if not radians:
lon1 = lonsdata[iii]
......@@ -129,6 +130,7 @@ cdef class Geod:
latsdata = <double *>latdata
azdata = <double *>azdat
distdata = <double *>distdat
with nogil:
for iii in range(ndim):
if radians:
lon1 = _RAD2DG * lonsdata[iii]
......@@ -176,6 +178,7 @@ cdef class Geod:
# do inverse computation to set azimuths, distance.
# in proj 4.9.3 and later the next two steps can be replace by a call
# to geod_inverseline with del_s = line.s13/(npts+1)
with nogil:
geod_inverse(
&self._geod_geodesic,
lat1, lon1, lat2, lon2,
......@@ -242,7 +245,7 @@ cdef class Geod:
if ndim == 1:
lonsdata[0] = 0
return 0.0
with nogil:
for iii in range(ndim - 1):
if radians:
lon1 = _RAD2DG * lonsdata[iii]
......@@ -310,6 +313,7 @@ cdef class Geod:
lonsdata = <double *>londata
latsdata = <double *>latdata
with nogil:
if radians:
for iii in range(ndim):
lonsdata[iii] *= _RAD2DG
......
include "proj.pxi"
from collections import namedtuple
from enum import IntEnum
from pyproj.compat import pystrdecode
from pyproj.compat import cstrencode, pystrdecode
from pyproj.enums import PJType
from pyproj._datadir cimport pyproj_context_initialize
def get_proj_operations_map():
"""
......@@ -99,3 +101,102 @@ def get_angular_units_map():
)
iii += 1
return units_map
def get_authorities():
"""
.. versionadded:: 2.4.0
Returns
-------
list[str]: Authorities in PROJ database.
"""
cdef PJ_CONTEXT* context = proj_context_create()
pyproj_context_initialize(context, True)
cdef PROJ_STRING_LIST proj_auth_list = proj_get_authorities_from_database(context)
if proj_auth_list == NULL:
proj_context_destroy(context)
return []
cdef int iii = 0
try:
auth_list = []
while proj_auth_list[iii] != NULL:
auth_list.append(pystrdecode(proj_auth_list[iii]))
iii += 1
finally:
proj_context_destroy(context)
proj_string_list_destroy(proj_auth_list)
return auth_list
PJ_TYPE_MAP = {
PJType.UNKNOWN: PJ_TYPE_UNKNOWN,
PJType.ELLIPSOID: PJ_TYPE_ELLIPSOID,
PJType.PRIME_MERIDIAN: PJ_TYPE_PRIME_MERIDIAN,
PJType.GEODETIC_REFERENCE_FRAME: PJ_TYPE_GEODETIC_REFERENCE_FRAME,
PJType.DYNAMIC_GEODETIC_REFERENCE_FRAME: PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME,
PJType.VERTICAL_REFERENCE_FRAME: PJ_TYPE_VERTICAL_REFERENCE_FRAME,
PJType.DYNAMIC_VERTICAL_REFERENCE_FRAME: PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME,
PJType.DATUM_ENSEMBLE: PJ_TYPE_DATUM_ENSEMBLE,
PJType.CRS: PJ_TYPE_CRS,
PJType.GEODETIC_CRS: PJ_TYPE_GEODETIC_CRS,
PJType.GEOCENTRIC_CRS: PJ_TYPE_GEOCENTRIC_CRS,
PJType.GEOGRAPHIC_CRS: PJ_TYPE_GEOGRAPHIC_CRS,
PJType.GEOGRAPHIC_2D_CRS: PJ_TYPE_GEOGRAPHIC_2D_CRS,
PJType.GEOGRAPHIC_3D_CRS: PJ_TYPE_GEOGRAPHIC_3D_CRS,
PJType.VERTICAL_CRS: PJ_TYPE_VERTICAL_CRS,
PJType.PROJECTED_CRS: PJ_TYPE_PROJECTED_CRS,
PJType.COMPOUND_CRS: PJ_TYPE_COMPOUND_CRS,
PJType.TEMPORAL_CRS: PJ_TYPE_TEMPORAL_CRS,
PJType.ENGINEERING_CRS: PJ_TYPE_ENGINEERING_CRS,
PJType.BOUND_CRS: PJ_TYPE_BOUND_CRS,
PJType.OTHER_CRS: PJ_TYPE_OTHER_CRS,
PJType.CONVERSION: PJ_TYPE_CONVERSION,
PJType.TRANSFORMATION: PJ_TYPE_TRANSFORMATION,
PJType.CONCATENATED_OPERATION: PJ_TYPE_CONCATENATED_OPERATION,
PJType.OTHER_COORDINATE_OPERATION: PJ_TYPE_OTHER_COORDINATE_OPERATION,
}
def get_codes(auth_name, pj_type, allow_deprecated=False):
"""
.. versionadded:: 2.4.0
Parameters
----------
auth_name: str
The name of the authority.
pj_type: ~pyproj.enums.PJType
The type of object to get the authorities.
allow_deprecated: bool, optional
Allow a deprecated code in the return.
Returns
-------
list[str]: Codes associated with authorities in PROJ database.
"""
cdef PJ_CONTEXT* context = NULL
cdef PJ_TYPE cpj_type = PJ_TYPE_MAP[PJType.create(pj_type)]
cdef PROJ_STRING_LIST proj_code_list = NULL
try:
context = proj_context_create()
pyproj_context_initialize(context, False)
cpj_type = PJ_TYPE_MAP[PJType.create(pj_type)]
proj_code_list = proj_get_codes_from_database(
context,
cstrencode(auth_name),
cpj_type,
allow_deprecated,
)
finally:
proj_context_destroy(context)
if proj_code_list == NULL:
return []
cdef int iii = 0
try:
code_list = []
while proj_code_list[iii] != NULL:
code_list.append(pystrdecode(proj_code_list[iii]))
iii += 1
finally:
proj_string_list_destroy(proj_code_list)
return code_list