Codebase list python-pyproj / f17a1c3
New upstream version 2.6.0+ds Bas Couwenberg 4 years ago
27 changed file(s) with 293 addition(s) and 231 deletion(s). Raw diff Collapse all Expand all
1818 hooks:
1919 - id: blacken-docs
2020 args: [--skip-errors]
21 - repo: https://gitlab.com/pycqa/flake8
22 rev: 3.7.7
23 hooks:
24 - id: flake8
25 additional_dependencies: [flake8-comprehensions>=3.1.0]
26 args: [--max-line-length, '88', --ignore, "E225,W503,C408"]
27 - id: flake8
28 name: flake8-pyx
29 files: \.(pyx|pxd)$
30 types:
31 - file
32 args: [--append-config=flake8/cython.cfg]
0 Contact: Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov
0 Copyright (c) 2006-2018, Jeffrey Whitaker.
1 Copyright (c) 2019-2020, Open source contributors.
12
2 copyright (c) 2013 by Jeffrey Whitaker.
3 Permission is hereby granted, free of charge, to any person obtaining a copy of
4 this software and associated documentation files (the "Software"), to deal in
5 the Software without restriction, including without limitation the rights to use,
6 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7 Software, and to permit persons to whom the Software is furnished to do so,
8 subject to the following conditions:
39
4 Permission to use, copy, modify, and distribute this software
5 and its documentation for any purpose and without fee is hereby
6 granted, provided that the above copyright notice appear in all
7 copies and that both the copyright notice and this permission
8 notice appear in supporting documentation. THE AUTHOR DISCLAIMS
9 ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
10 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
11 SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
12 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
10 The above copyright notice and this permission notice shall be included in all
11 copies or substantial portions of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
16 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6161
6262 lint: ## check style with flake8
6363 flake8 --max-line-length 88 setup.py pyproj/ test/ docs/
64 flake8 --append-config=flake8/cython.cfg pyproj/
6465
6566 check-type:
6667 mypy pyproj
0 [flake8]
1 filename = *.pyx,*.pxd
2 max-line-length=88
3 select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
0 # -*- coding: utf-8 -*-
10 """
2 Cython wrapper to provide python interfaces to
3 PROJ (https://proj.org) functions.
4
5 Performs cartographic transformations and geodetic computations.
6
7 The Proj class can convert from geographic (longitude,latitude)
8 to native map projection (x,y) coordinates and vice versa, or
9 from one map projection coordinate system directly to another.
10 The module variable pj_list is a dictionary containing all the
11 available projections and their descriptions.
12
13 The Geod class can perform forward and inverse geodetic, or
14 Great Circle, computations. The forward computation involves
15 determining latitude, longitude and back azimuth of a terminus
16 point given the latitude and longitude of an initial point, plus
17 azimuth and distance. The inverse computation involves
18 determining the forward and back azimuths and distance given the
19 latitudes and longitudes of an initial and terminus point.
20
21 Input coordinates can be given as python arrays, lists/tuples,
22 scalars or numpy/Numeric/numarray arrays. Optimized for objects
23 that support the Python buffer protocol (regular python and
24 numpy array objects).
1 Python interface to PROJ (https://proj.org),
2 cartographic projections and coordinate transformations library.
253
264 Download: http://python.org/pypi/pyproj
275
286 Requirements: Python 3.5+.
297
30 Example scripts are in 'test' subdirectory of source distribution.
31 The 'test()' function will run the examples in the docstrings.
8 Contact: Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov>
329
33 Contact: Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov
10 Copyright (c) 2006-2018, Jeffrey Whitaker.
11 Copyright (c) 2019-2020, Open source contributors.
3412
35 copyright (c) 2006 by Jeffrey Whitaker.
13 Permission is hereby granted, free of charge, to any person obtaining a copy of
14 this software and associated documentation files (the "Software"), to deal in
15 the Software without restriction, including without limitation the rights to use,
16 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
17 Software, and to permit persons to whom the Software is furnished to do so,
18 subject to the following conditions:
3619
37 Permission to use, copy, modify, and distribute this software
38 and its documentation for any purpose and without fee is hereby
39 granted, provided that the above copyright notice appear in all
40 copies and that both the copyright notice and this permission
41 notice appear in supporting documentation. THE AUTHOR DISCLAIMS
42 ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
43 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
44 SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
45 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
46 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
47 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
48 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """
49 __version__ = "2.6.0rc0"
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 """
30 __version__ = "2.6.0"
5031 __all__ = [
5132 "Proj",
5233 "Geod",
529529 return self._is_exact_same(other)
530530
531531
532
533532 cdef class _CRSParts(Base):
534533 @classmethod
535534 def from_user_input(cls, user_input):
717716 -------
718717 CoordinateSystem
719718 """
720 return CoordinateSystem.from_json_dict(_load_proj_json(coordinate_system_json_str))
719 return CoordinateSystem.from_json_dict(
720 _load_proj_json(coordinate_system_json_str)
721 )
721722
722723
723724 cdef class Ellipsoid(_CRSParts):
970971 CRSError.clear()
971972 return Ellipsoid.create(context, ellipsoid_pj)
972973
973
974974 @staticmethod
975975 def from_name(
976976 ellipsoid_name,
12681268 return PrimeMeridian.create(context, prime_meridian_pj)
12691269
12701270
1271
12721271 _DATUM_TYPE_MAP = {
12731272 PJ_TYPE_GEODETIC_REFERENCE_FRAME: "Geodetic Reference Frame",
12741273 PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME: "Dynamic Geodetic Reference Frame",
12791278
12801279 _PJ_DATUM_TYPE_MAP = {
12811280 DatumType.GEODETIC_REFERENCE_FRAME: PJ_TYPE_GEODETIC_REFERENCE_FRAME,
1282 DatumType.DYNAMIC_GEODETIC_REFERENCE_FRAME: PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME,
1281 DatumType.DYNAMIC_GEODETIC_REFERENCE_FRAME:
1282 PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME,
12831283 DatumType.VERTICAL_REFERENCE_FRAME: PJ_TYPE_VERTICAL_REFERENCE_FRAME,
1284 DatumType.DYNAMIC_VERTICAL_REFERENCE_FRAME: PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME,
1284 DatumType.DYNAMIC_VERTICAL_REFERENCE_FRAME:
1285 PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME,
12851286 DatumType.DATUM_ENSEMBLE: PJ_TYPE_DATUM_ENSEMBLE,
12861287 }
12871288
17311732
17321733 def __repr__(self):
17331734 return ("Param(name={name}, auth_name={auth_name}, code={code}, "
1734 "value={value}, unit_name={unit_name}, unit_auth_name={unit_auth_name}, "
1735 "unit_code={unit_code}, unit_category={unit_category})").format(
1735 "value={value}, unit_name={unit_name}, "
1736 "unit_auth_name={unit_auth_name}, unit_code={unit_code}, "
1737 "unit_category={unit_category})").format(
17361738 name=self.name,
17371739 auth_name=self.auth_name,
17381740 code=self.code,
17421744 unit_code=self.unit_code,
17431745 unit_category=self.unit_category,
17441746 )
1745
17461747
17471748
17481749 cdef class Grid:
18141815 return self.full_name
18151816
18161817 def __repr__(self):
1817 return ("Grid(short_name={short_name}, full_name={full_name}, package_name={package_name}, "
1818 "url={url}, direct_download={direct_download}, open_license={open_license}, "
1818 return ("Grid(short_name={short_name}, full_name={full_name}, "
1819 "package_name={package_name}, url={url}, "
1820 "direct_download={direct_download}, open_license={open_license}, "
18191821 "available={available})").format(
18201822 short_name=self.short_name,
18211823 full_name=self.full_name,
18391841 CoordinateOperationType.CONVERSION: PJ_TYPE_CONVERSION,
18401842 CoordinateOperationType.TRANSFORMATION: PJ_TYPE_TRANSFORMATION,
18411843 CoordinateOperationType.CONCATENATED_OPERATION: PJ_TYPE_CONCATENATED_OPERATION,
1842 CoordinateOperationType.OTHER_COORDINATE_OPERATION: PJ_TYPE_OTHER_COORDINATE_OPERATION,
1844 CoordinateOperationType.OTHER_COORDINATE_OPERATION:
1845 PJ_TYPE_OTHER_COORDINATE_OPERATION,
18431846 }
18441847
18451848 cdef class CoordinateOperation(_CRSParts):
18831886
18841887 def __init__(self):
18851888 raise RuntimeError(
1886 "CoordinateOperation can only be initialized like 'CoordinateOperation.from_*()'."
1889 "CoordinateOperation can only be initialized like "
1890 "CoordinateOperation.from_*()'."
18871891 )
18881892
18891893 @staticmethod
25882592 try:
25892593 self._sub_crs_list.append(_CRS(_to_wkt(self.context, projobj)))
25902594 finally:
2591 proj_destroy(projobj) # deallocate temp proj
2595 proj_destroy(projobj) # deallocate temp proj
25922596 iii += 1
25932597 projobj = proj_crs_get_sub_crs(
25942598 self.context,
26192623 try:
26202624 self._geodetic_crs = _CRS(_to_wkt(self.context, projobj))
26212625 finally:
2622 proj_destroy(projobj) # deallocate temp proj
2626 proj_destroy(projobj) # deallocate temp proj
26232627 return self._geodetic_crs
26242628
26252629 def to_proj4(self, version=ProjVersion.PROJ_4):
26282632
26292633 .. warning:: You will likely lose important projection
26302634 information when converting to a PROJ string from
2631 another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
2635 another format. See:
2636 https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems # noqa: E501
26322637
26332638 Parameters
26342639 ----------
27412746 user_auth_name = b_auth_name
27422747
27432748 try:
2744 proj_list = proj_identify(
2749 proj_list = proj_identify(
27452750 self.context,
27462751 self.projobj,
27472752 user_auth_name,
27582763 CRSError.clear()
27592764
27602765 # check to make sure that the projection found is valid
2761 if proj_list == NULL or num_proj_objects <= 0 or out_confidence < min_confidence:
2766 if (
2767 proj_list == NULL
2768 or num_proj_objects <= 0
2769 or out_confidence < min_confidence
2770 ):
27622771 if proj_list != NULL:
27632772 proj_list_destroy(proj_list)
27642773 return None
00 include "proj.pxi"
11
2 cdef void pyproj_context_initialize(PJ_CONTEXT* context, bint free_context_on_error) except *
2 cdef void pyproj_context_initialize(
3 PJ_CONTEXT* context,
4 bint free_context_on_error) except *
35
46 cdef class ContextManager:
57 cdef PJ_CONTEXT *context
2929 free(c_data_dir)
3030
3131
32 cdef void pyproj_context_initialize(PJ_CONTEXT* context, bint free_context_on_error) except *:
32 cdef void pyproj_context_initialize(
33 PJ_CONTEXT* context,
34 bint free_context_on_error,
35 ) except *:
3336 """
3437 Setup the context for pyproj
3538 """
4043 set_context_data_dir(context)
4144 except DataDirError:
4245 if free_context_on_error and context != NULL:
43 proj_context_destroy(context)
46 proj_context_destroy(context)
4447 raise
4548
4649
00 cdef extern from "geodesic.h":
1 struct geod_geodesic:
1 struct geod_geodesic:
22 pass
3 struct geod_geodesicline:
3 struct geod_geodesicline:
44 pass
5 void geod_init(geod_geodesic* g, double a, double f)
6 void geod_direct(geod_geodesic* g,
7 double lat1, double lon1, double azi1, double s12,
8 double* plat2, double* plon2, double* pazi2) nogil
9 void geod_inverse(geod_geodesic* g,
10 double lat1, double lon1, double lat2, double lon2,
11 double* ps12, double* pazi1, double* pazi2) nogil
12 void geod_lineinit(geod_geodesicline* l,
13 geod_geodesic* g,
14 double lat1, double lon1, double azi1, unsigned caps) nogil
15 void geod_position(geod_geodesicline* l, double s12,
16 double* plat2, double* plon2, double* pazi2) nogil
17 void geod_polygonarea(geod_geodesic* g,
18 double lats[], double lons[], int n,
19 double* pA, double* pP) nogil
5 void geod_init(geod_geodesic* g, double a, double f)
6 void geod_direct(
7 geod_geodesic* g,
8 double lat1,
9 double lon1,
10 double azi1,
11 double s12,
12 double* plat2,
13 double* plon2,
14 double* pazi2) nogil
15 void geod_inverse(
16 geod_geodesic* g,
17 double lat1,
18 double lon1,
19 double lat2,
20 double lon2,
21 double* ps12,
22 double* pazi1,
23 double* pazi2) nogil
24 void geod_lineinit(
25 geod_geodesicline* l,
26 geod_geodesic* g,
27 double lat1,
28 double lon1,
29 double azi1,
30 unsigned caps) nogil
31 void geod_position(
32 geod_geodesicline* l,
33 double s12,
34 double* plat2,
35 double* plon2,
36 double* pazi2) nogil
37 void geod_polygonarea(
38 geod_geodesic* g,
39 double lats[],
40 double lons[],
41 int n,
42 double* pA,
43 double* pP) nogil
2044
21 cdef enum:
22 GEODESIC_VERSION_MAJOR
23 GEODESIC_VERSION_MINOR
24 GEODESIC_VERSION_PATCH
45 cdef enum:
46 GEODESIC_VERSION_MAJOR
47 GEODESIC_VERSION_MINOR
48 GEODESIC_VERSION_PATCH
2549
2650
2751 cdef class Geod:
2525
2626 def __reduce__(self):
2727 """special method that allows pyproj.Geod instance to be pickled"""
28 return self.__class__,(self.initstring,)
29
30 @cython.boundscheck(False)
31 @cython.wraparound(False)
32 def _fwd(self, object lons, object lats, object az, object dist, bint radians=False):
28 return self.__class__, (self.initstring,)
29
30 @cython.boundscheck(False)
31 @cython.wraparound(False)
32 def _fwd(
33 self,
34 object lons,
35 object lats,
36 object az,
37 object dist,
38 bint radians=False,
39 ):
3340 """
3441 forward transformation - determine longitude, latitude and back azimuth
3542 of a terminus point given an initial point longitude and latitude, plus
5966 lat1 = _RAD2DG * latbuff.data[iii]
6067 az1 = _RAD2DG * azbuff.data[iii]
6168 s12 = distbuff.data[iii]
62 geod_direct(&self._geod_geodesic, lat1, lon1, az1, s12,\
63 &plat2, &plon2, &pazi2)
69 geod_direct(
70 &self._geod_geodesic,
71 lat1,
72 lon1,
73 az1,
74 s12,
75 &plat2,
76 &plon2,
77 &pazi2,
78 )
6479 # back azimuth needs to be flipped 180 degrees
6580 # to match what PROJ geod utility produces.
6681 if pazi2 > 0:
7893
7994 @cython.boundscheck(False)
8095 @cython.wraparound(False)
81 def _inv(self, object lons1, object lats1, object lons2, object lats2, bint radians=False):
96 def _inv(
97 self,
98 object lons1,
99 object lats1,
100 object lons2,
101 object lats2,
102 bint radians=False,
103 ):
82104 """
83105 inverse transformation - return forward and back azimuths, plus distance
84106 between an initial and terminus lat/lon pair.
129151
130152 @cython.boundscheck(False)
131153 @cython.wraparound(False)
132 def _npts(self, double lon1, double lat1, double lon2, double lat2, int npts, bint radians=False):
154 def _npts(
155 self,
156 double lon1,
157 double lat1,
158 double lon2,
159 double lat2,
160 int npts,
161 bint radians=False,
162 ):
133163 """
134164 given initial and terminus lat/lon, find npts intermediate points.
135165 """
136166 cdef Py_ssize_t iii
137 cdef double del_s,ps12,pazi1,pazi2,s12,plon2,plat2
167 cdef double del_s
168 cdef double ps12
169 cdef double pazi1
170 cdef double pazi2
171 cdef double s12
172 cdef double plon2
173 cdef double plat2
138174 cdef geod_geodesicline line
175
139176 if radians:
140177 lon1 = _RAD2DG * lon1
141178 lat1 = _RAD2DG * lat1
277314 )
278315 return (polygon_area, polygon_perimeter)
279316
280
281317 def __repr__(self):
282318 return "{classname}({init!r})".format(
283319 classname=self.__class__.__name__,
55 from pyproj.compat import cstrencode, pystrdecode
66 from pyproj.enums import PJType
77 from pyproj._datadir cimport pyproj_context_initialize
8
89
910 def get_proj_operations_map():
1011 """
162163 PJType.OTHER_COORDINATE_OPERATION: PJ_TYPE_OTHER_COORDINATE_OPERATION,
163164 }
164165
166
165167 def get_codes(auth_name, pj_type, allow_deprecated=False):
166168 """
167169 .. versionadded:: 2.4.0
1717 )
1818
1919
20 Factors = namedtuple("Factors",
20 Factors = namedtuple(
21 "Factors",
2122 [
2223 "meridional_scale",
2324 "parallel_scale",
3132 "dx_dphi",
3233 "dy_dlam",
3334 "dy_dphi",
34 ]
35 ],
3536 )
3637 Factors.__doc__ = """
3738 .. versionadded:: 2.6.0
3839
3940 These are the scaling and angular distortion factors.
4041
41 See `PJ_FACTORS documentation <https://proj.org/development/reference/datatypes.html?highlight=pj_factors#c.PJ_FACTORS>`__
42 See `PJ_FACTORS documentation <https://proj.org/development/reference/datatypes.html?highlight=pj_factors#c.PJ_FACTORS>`__ # noqa
4243
4344 Parameters
4445 ----------
106107 def _fwd(self, object lons, object lats, bint errcheck=False):
107108 """
108109 forward transformation - lons,lats to x,y (done in place).
109 if errcheck=True, an exception is raised if the forward transformation is invalid.
110 if errcheck=False and the forward transformation is invalid, no exception is
111 raised and 'inf' is returned.
110 if errcheck=True, an exception is raised if the forward
111 transformation is invalid. if errcheck=False and the forward
112 transformation is invalid, no exception is raised and 'inf' is returned.
112113 """
113114 cdef PyBuffWriteManager lonbuff = PyBuffWriteManager(lons)
114115 cdef PyBuffWriteManager latbuff = PyBuffWriteManager(lats)
126127 proj_errno_reset(self.projobj)
127128 for iii in range(latbuff.len):
128129 # if inputs are nan's, return big number.
129 if lonbuff.data[iii] != lonbuff.data[iii] or latbuff.data[iii] != latbuff.data[iii]:
130 if (
131 lonbuff.data[iii] != lonbuff.data[iii]
132 or latbuff.data[iii] != latbuff.data[iii]
133 ):
130134 lonbuff.data[iii] = HUGE_VAL
131135 latbuff.data[iii] = HUGE_VAL
132136 if errcheck:
168172 latbuff.data[iii] = projxyout.xy.y
169173 ProjError.clear()
170174
171
172175 @cython.boundscheck(False)
173176 @cython.wraparound(False)
174177 def _inv(self, object xx, object yy, bint errcheck=False):
175178 """
176179 inverse transformation - x,y to lons,lats (done in place).
177 if errcheck=True, an exception is raised if the inverse transformation is invalid.
178 if errcheck=False and the inverse transformation is invalid, no exception is
180 if errcheck=True, an exception is raised if the inverse
181 transformation is invalid. if errcheck=False and the
182 inverse transformation is invalid, no exception is
179183 raised and 'inf' is returned.
180184 """
181185 if not self.has_inverse:
198202 proj_errno_reset(self.projobj)
199203 for iii in range(xbuff.len):
200204 # if inputs are nan's, return big number.
201 if xbuff.data[iii] != xbuff.data[iii] or ybuff.data[iii] != ybuff.data[iii]:
205 if (
206 xbuff.data[iii] != xbuff.data[iii]
207 or ybuff.data[iii] != ybuff.data[iii]
208 ):
202209 xbuff.data[iii] = HUGE_VAL
203210 ybuff.data[iii] = HUGE_VAL
204211 if errcheck:
268275 dx_dphi = copy.copy(longitude)
269276 dy_dlam = copy.copy(longitude)
270277 dy_dphi = copy.copy(longitude)
271 cdef PyBuffWriteManager meridional_scale_buff = PyBuffWriteManager(meridional_scale)
272 cdef PyBuffWriteManager parallel_scale_buff = PyBuffWriteManager(parallel_scale)
278 cdef PyBuffWriteManager meridional_scale_buff = PyBuffWriteManager(
279 meridional_scale)
280 cdef PyBuffWriteManager parallel_scale_buff = PyBuffWriteManager(
281 parallel_scale)
273282 cdef PyBuffWriteManager areal_scale_buff = PyBuffWriteManager(areal_scale)
274 cdef PyBuffWriteManager angular_distortion_buff = PyBuffWriteManager(angular_distortion)
275 cdef PyBuffWriteManager meridian_parallel_angle_buff = PyBuffWriteManager(meridian_parallel_angle)
276 cdef PyBuffWriteManager meridian_convergence_buff = PyBuffWriteManager(meridian_convergence)
277 cdef PyBuffWriteManager tissot_semimajor_buff = PyBuffWriteManager(tissot_semimajor)
278 cdef PyBuffWriteManager tissot_semiminor_buff = PyBuffWriteManager(tissot_semiminor)
283 cdef PyBuffWriteManager angular_distortion_buff = PyBuffWriteManager(
284 angular_distortion)
285 cdef PyBuffWriteManager meridian_parallel_angle_buff = PyBuffWriteManager(
286 meridian_parallel_angle)
287 cdef PyBuffWriteManager meridian_convergence_buff = PyBuffWriteManager(
288 meridian_convergence)
289 cdef PyBuffWriteManager tissot_semimajor_buff = PyBuffWriteManager(
290 tissot_semimajor)
291 cdef PyBuffWriteManager tissot_semiminor_buff = PyBuffWriteManager(
292 tissot_semiminor)
279293 cdef PyBuffWriteManager dx_dlam_buff = PyBuffWriteManager(dx_dlam)
280294 cdef PyBuffWriteManager dx_dphi_buff = PyBuffWriteManager(dx_dphi)
281295 cdef PyBuffWriteManager dy_dlam_buff = PyBuffWriteManager(dy_dlam)
329343 meridional_scale_buff.data[iii] = pj_factors.meridional_scale
330344 parallel_scale_buff.data[iii] = pj_factors.parallel_scale
331345 areal_scale_buff.data[iii] = pj_factors.areal_scale
332 angular_distortion_buff.data[iii] = pj_factors.angular_distortion * _RAD2DG
333 meridian_parallel_angle_buff.data[iii] = pj_factors.meridian_parallel_angle * _RAD2DG
334 meridian_convergence_buff.data[iii] = pj_factors.meridian_convergence * _RAD2DG
346 angular_distortion_buff.data[iii] = (
347 pj_factors.angular_distortion * _RAD2DG
348 )
349 meridian_parallel_angle_buff.data[iii] = (
350 pj_factors.meridian_parallel_angle * _RAD2DG
351 )
352 meridian_convergence_buff.data[iii] = (
353 pj_factors.meridian_convergence * _RAD2DG
354 )
335355 tissot_semimajor_buff.data[iii] = pj_factors.tissot_semimajor
336356 tissot_semiminor_buff.data[iii] = pj_factors.tissot_semiminor
337357 dx_dlam_buff.data[iii] = pj_factors.dx_dlam
3232 }
3333
3434
35 AreaOfInterest = namedtuple("AreaOfInterest",
35 AreaOfInterest = namedtuple(
36 "AreaOfInterest",
3637 ["west_lon_degree", "south_lat_degree", "east_lon_degree", "north_lat_degree"]
3738 )
3839 AreaOfInterest.__doc__ = """
9899 if area_of_interest is not None:
99100 if not isinstance(area_of_interest, AreaOfInterest):
100101 raise ProjError(
101 "Area of interest must be of the type pyproj.transformer.AreaOfInterest."
102 "Area of interest must be of the type "
103 "pyproj.transformer.AreaOfInterest."
102104 )
103105 west_lon_degree = area_of_interest.west_lon_degree
104106 south_lat_degree = area_of_interest.south_lat_degree
212214 def _initialize_from_projobj(self):
213215 self.proj_info = proj_pj_info(self.projobj)
214216 if self.proj_info.id == NULL:
215 raise ProjError("Input is not a transformation.")
217 raise ProjError("Input is not a transformation.")
216218 cdef PJ_TYPE transformer_type = proj_get_type(self.projobj)
217219 self.type_name = _TRANSFORMER_TYPE_MAP[transformer_type]
218220 self._set_base_info()
276278 Create a transformer from CRS objects
277279 """
278280 cdef PJ_AREA *pj_area_of_interest = NULL
279 cdef double west_lon_degree, south_lat_degree, east_lon_degree, north_lat_degree
281 cdef double west_lon_degree
282 cdef double south_lat_degree
283 cdef double east_lon_degree
284 cdef double north_lat_degree
280285 cdef _Transformer transformer = _Transformer()
281286 try:
282287 if area_of_interest is not None:
283288 if not isinstance(area_of_interest, AreaOfInterest):
284289 raise ProjError(
285 "Area of interest must be of the type pyproj.transformer.AreaOfInterest."
290 "Area of interest must be of the type "
291 "pyproj.transformer.AreaOfInterest."
286292 )
287293 pj_area_of_interest = proj_area_create()
288294 west_lon_degree = area_of_interest.west_lon_degree
410416 bint radians,
411417 bint errcheck,
412418 ):
413 if self.projections_exact_same or (self.projections_equivalent and self.skip_equivalent):
419 if (
420 self.projections_exact_same
421 or (self.projections_equivalent and self.skip_equivalent)
422 ):
414423 return
415424 if radians and self.is_pipeline:
416425 warnings.warn(
506515 bint radians,
507516 bint errcheck,
508517 ):
509 if self.projections_exact_same or (self.projections_equivalent and self.skip_equivalent):
518 if (
519 self.projections_exact_same
520 or (self.projections_equivalent and self.skip_equivalent)
521 ):
510522 return
511523 tmp_pj_direction = _PJ_DIRECTION_MAP[TransformDirection.create(direction)]
512524 cdef PJ_DIRECTION pj_direction = <PJ_DIRECTION>tmp_pj_direction
575587 elif errcheck and ProjError.internal_proj_error is not None:
576588 raise ProjError("itransform error")
577589
578
579590 # radians to degrees
580591 if not radians and self._output_radians[pj_direction]:
581592 with nogil:
0 # -*- coding: utf-8 -*-
0 """
1 This module is for compatibility between string types
2 """
13
24
35 def cstrencode(pystr):
0 # -*- coding: utf-8 -*-
10 """
21 This module interfaces with PROJ to produce a pythonic interface
32 to the coordinate reference system (CRS) information through the CRS
43 class.
5
6 Original Author: Alan D. Snow [github.com/snowman2] (2019)
74 """
85
96 from pyproj._crs import ( # noqa: F401
0 """
1 This module is for building operations to be used when
2 building a CRS.
3
4 https://proj.org/operations/
5 """
06 import warnings
17 from distutils.version import LooseVersion
28 from typing import Any
0 """
1 This module is for building coordinate systems to be used when
2 building a CRS.
3 """
04 from typing import Union
15
26 from pyproj._crs import CoordinateSystem
0 # -*- coding: utf-8 -*-
10 """
21 This module interfaces with PROJ to produce a pythonic interface
32 to the coordinate reference system (CRS) information.
4
5 Original Author: Alan D. Snow [github.com/snowman2] (2019)
6
73 """
84 import json
95 import re
0 """
1 This module is for building datums to be used when
2 building a CRS.
3 """
04 from typing import Any, Dict, Optional, Union
15
26 from pyproj._crs import Datum, Ellipsoid, PrimeMeridian
00 """
1 Set the datadir path to the local data directory
1 Module for managing the PROJ data directory.
22 """
33 import os
44 import sys
0 # -*- coding: utf-8 -*-
10 """
21 Exceptions for pyproj
32 """
00 """
1 Cython wrapper to provide python interfaces to
2 PROJ (https://proj.org) functions.
3
4 Performs geodetic computations.
5
61 The Geod class can perform forward and inverse geodetic, or
72 Great Circle, computations. The forward computation involves
83 determining latitude, longitude and back azimuth of a terminus
105 azimuth and distance. The inverse computation involves
116 determining the forward and back azimuths and distance given the
127 latitudes and longitudes of an initial and terminus point.
13
14 Contact: Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov
15
16 copyright (c) 2006 by Jeffrey Whitaker.
17
18 Permission to use, copy, modify, and distribute this software
19 and its documentation for any purpose and without fee is hereby
20 granted, provided that the above copyright notice appear in all
21 copies and that both the copyright notice and this permission
22 notice appear in supporting documentation. THE AUTHOR DISCLAIMS
23 ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
25 SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
26 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
27 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
28 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
29 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """
8 """
309
3110 __all__ = ["Geod", "pj_ellps", "geodesic_version_str"]
3211
0 # -*- coding: utf-8 -*-
10 """
2 Cython wrapper to provide python interfaces to
3 PROJ (https://proj.org) functions.
4
5 Performs cartographic transformations and geodetic computations.
6
7 The Proj class can convert from geographic (longitude,latitude)
8 to native map projection (x,y) coordinates and vice versa, or
9 from one map projection coordinate system directly to another.
10 The module variable pj_list is a dictionary containing all the
11 available projections and their descriptions.
12
13 Input coordinates can be given as python arrays, lists/tuples,
14 scalars or numpy/Numeric/numarray arrays. Optimized for objects
15 that support the Python buffer protocol (regular python and
16 numpy array objects).
17
18 Download: http://python.org/pypi/pyproj
19
20 Contact: Jeffrey Whitaker <jeffrey.s.whitaker@noaa.gov
21
22 copyright (c) 2006 by Jeffrey Whitaker.
23
24 Permission to use, copy, modify, and distribute this software
25 and its documentation for any purpose and without fee is hereby
26 granted, provided that the above copyright notice appear in all
27 copies and that both the copyright notice and this permission
28 notice appear in supporting documentation. THE AUTHOR DISCLAIMS
29 ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
30 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
31 SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
32 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
33 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
34 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
35 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """
1 Performs cartographic transformations (converts from
2 longitude,latitude to native map projection x,y coordinates and
3 vice versa) using PROJ (https://proj.org).
4
5 A Proj class instance is initialized with proj map projection
6 control parameter key/value pairs. The key/value pairs can
7 either be passed in a dictionary, or as keyword arguments,
8 or as a PROJ string (compatible with the proj command). See
9 https://proj.org/operations/projections/index.html for examples of
10 key/value pairs defining different map projections.
11
12 Calling a Proj class instance with the arguments lon, lat will
13 convert lon/lat (in degrees) to x/y native map projection
14 coordinates (in meters).
15 """
3616 import re
3717 import warnings
3818 from typing import Any, Optional, Tuple, Type
5030 """
5131 Performs cartographic transformations (converts from
5232 longitude,latitude to native map projection x,y coordinates and
53 vice versa) using proj (https://proj.org).
33 vice versa) using PROJ (https://proj.org).
5434
5535 A Proj class instance is initialized with proj map projection
5636 control parameter key/value pairs. The key/value pairs can
0 # -*- coding: utf-8 -*-
10 """
21 The transformer module is for performing cartographic transformations.
3
4 Copyright (c) 2019 pyproj Contributors.
5
6 Permission to use, copy, modify, and distribute this software
7 and its documentation for any purpose and without fee is hereby
8 granted, provided that the above copyright notice appear in all
9 copies and that both the copyright notice and this permission
10 notice appear in supporting documentation. THE AUTHOR DISCLAIMS
11 ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
12 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
13 SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
14 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE."""
2 """
183
194 __all__ = [
205 "transform",
0 """
1 Utility functions used within pyproj
2 """
03 from array import array
14 from typing import Any, Tuple
25
148148 include_dirs = get_proj_incdirs(proj_dir)
149149
150150 # setup extension options
151 ext_options = dict(
152 include_dirs=include_dirs,
153 library_dirs=library_dirs,
154 runtime_library_dirs=library_dirs if os.name != "nt" else None,
155 libraries=get_libraries(library_dirs),
156 )
151 ext_options = {
152 "include_dirs": include_dirs,
153 "library_dirs": library_dirs,
154 "runtime_library_dirs": library_dirs if os.name != "nt" else None,
155 "libraries": get_libraries(library_dirs),
156 }
157157 # setup cythonized modules
158158 return cythonize(
159159 [
222222 author="Jeff Whitaker",
223223 author_email="jeffrey.s.whitaker@noaa.gov",
224224 platforms=["any"],
225 license="OSI Approved",
225 license="MIT",
226226 keywords=["python", "map projections", "GIS", "mapping", "maps"],
227227 classifiers=[
228228 "Development Status :: 4 - Beta",
229229 "Intended Audience :: Science/Research",
230 "License :: OSI Approved",
231230 "Programming Language :: Python :: 3",
232231 "Programming Language :: Python :: 3.5",
233232 "Programming Language :: Python :: 3.6",
3232 )
3333 awips221_from_dict = Proj(params, preserve_units=False)
3434
35 items = sorted([val for val in awips221.crs.srs.split() if val])
36 items_dict = sorted([val for val in awips221_from_dict.crs.srs.split() if val])
35 items = sorted(val for val in awips221.crs.srs.split() if val)
36 items_dict = sorted(val for val in awips221_from_dict.crs.srs.split() if val)
3737 self.assertEqual(items, items_dict)
3838
3939 expected = sorted(