[Git][debian-gis-team/python-pyproj][upstream] New upstream version 2.1.1+ds

Bas Couwenberg gitlab at salsa.debian.org
Mon Mar 18 06:26:27 GMT 2019


Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-pyproj


Commits:
69dd1991 by Bas Couwenberg at 2019-03-18T06:19:35Z
New upstream version 2.1.1+ds
- - - - -


7 changed files:

- README.md
- pyproj/__init__.py
- pyproj/_transformer.pyx
- pyproj/transformer.py
- requirements-dev.txt
- sphinx/history.rst
- unittest/test_transformer.py


Changes:

=====================================
README.md
=====================================
@@ -12,7 +12,7 @@ pyproj
 
 [![Anaconda-Server Badge](https://anaconda.org/conda-forge/pyproj/badges/version.svg)](https://anaconda.org/conda-forge/pyproj)
 
-[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2592233.svg)](https://doi.org/10.5281/zenodo.2592233)
+[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2592232.svg)](https://doi.org/10.5281/zenodo.2592232)
 
 Python interface to [PROJ.4](https://github.com/OSGeo/proj.4).
 


=====================================
pyproj/__init__.py
=====================================
@@ -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.1.0"
+__version__ = "2.1.1"
 __all__ = [
     "Proj",
     "Geod",


=====================================
pyproj/_transformer.pyx
=====================================
@@ -96,7 +96,7 @@ cdef class _Transformer:
             return cstrencode(in_proj.srs)
         return cstrencode(in_proj.to_wkt())
 
-    def _transform(self, inx, iny, inz, radians):
+    def _transform(self, inx, iny, inz, radians, errcheck=False):
         # private function to call pj_transform
         cdef void *xdata
         cdef void *ydata
@@ -145,7 +145,7 @@ cdef class _Transformer:
             NULL, 0, 0,
         )
         cdef int errno = proj_errno(self.projpj)
-        if errno:
+        if errno and errcheck:
             raise ProjError("proj_trans_generic error: {}".format(
                 pystrdecode(proj_errno_string(errno))))
 
@@ -161,7 +161,8 @@ cdef class _Transformer:
                 yy[i] = yy[i]*_DG2RAD
 
 
-    def _transform_sequence(self, Py_ssize_t stride, inseq, bint switch, radians):
+    def _transform_sequence(self, Py_ssize_t stride, inseq, bint switch,
+            radians, errcheck=False):
         # private function to itransform function
         cdef:
             void *buffer
@@ -215,7 +216,7 @@ cdef class _Transformer:
         )
 
         cdef int errno = proj_errno(self.projpj)
-        if errno:
+        if errno and errcheck:
             raise ProjError("proj_trans_generic error: {}".format(
                 proj_errno_string(errno)))
 


=====================================
pyproj/transformer.py
=====================================
@@ -100,7 +100,7 @@ class Transformer(object):
         transformer._transformer = _Transformer.from_pipeline(cstrencode(proj_pipeline))
         return transformer
 
-    def transform(self, xx, yy, zz=None, radians=False):
+    def transform(self, xx, yy, zz=None, radians=False, errcheck=False):
         """
         Transform points between two coordinate systems.
 
@@ -116,6 +116,10 @@ class Transformer(object):
             If True, will expect input data to be in radians and will return radians
             if the projection is geographic. Default is False (degrees). Ignored for
             pipeline transformations.
+        errcheck: boolean, optional (default False)
+            If True an exception is raised if the transformation is invalid.
+            By default errcheck=False and an invalid transformation 
+            returns ``inf`` and no exception is raised.
 
 
         Example:
@@ -148,7 +152,7 @@ class Transformer(object):
         else:
             inz = None
         # call pj_transform.  inx,iny,inz buffers modified in place.
-        self._transformer._transform(inx, iny, inz, radians)
+        self._transformer._transform(inx, iny, inz, radians, errcheck=errcheck)
         # if inputs were lists, tuples or floats, convert back.
         outx = _convertback(xisfloat, xislist, xistuple, inx)
         outy = _convertback(yisfloat, yislist, xistuple, iny)
@@ -158,7 +162,7 @@ class Transformer(object):
         else:
             return outx, outy
 
-    def itransform(self, points, switch=False, radians=False):
+    def itransform(self, points, switch=False, radians=False, errcheck=False):
         """
         Iterator/generator version of the function pyproj.Transformer.transform.
 
@@ -174,6 +178,10 @@ class Transformer(object):
             If True, will expect input data to be in radians and will return radians
             if the projection is geographic. Default is False (degrees). Ignored for
             pipeline transformations.
+        errcheck: boolean, optional (default False)
+            If True an exception is raised if the transformation is invalid.
+            By default errcheck=False and an invalid transformation 
+            returns ``inf`` and no exception is raised.
 
 
         Example:
@@ -218,13 +226,14 @@ class Transformer(object):
             if len(buff) == 0:
                 break
 
-            self._transformer._transform_sequence(stride, buff, switch, radians)
+            self._transformer._transform_sequence(stride, buff, switch,
+                    radians, errcheck=errcheck)
 
             for pt in zip(*([iter(buff)] * stride)):
                 yield pt
 
 
-def transform(p1, p2, x, y, z=None, radians=False):
+def transform(p1, p2, x, y, z=None, radians=False, errcheck=False):
     """
     x2, y2, z2 = transform(p1, p2, x1, y1, z1)
 
@@ -239,6 +248,10 @@ def transform(p1, p2, x, y, z=None, radians=False):
     'radians' is True (default is False), then all input and 
     output coordinates will be in radians instead of the default 
     of degrees for geographic input/output projections.
+    If the optional keyword 'errcheck' is set to True an 
+    exception is raised if the transformation is
+    invalid. By default errcheck=False and ``inf`` is returned for an
+    invalid transformation (and no exception is raised).
 
     In addition to converting between cartographic and geographic
     projection coordinates, this function can take care of datum
@@ -304,10 +317,11 @@ def transform(p1, p2, x, y, z=None, radians=False):
     >>> "%.3f %.3f" % (xr, yr)
     '2.031 0.696'
     """
-    return Transformer.from_proj(p1, p2).transform(x, y, z, radians)
+    return Transformer.from_proj(p1, p2).transform(x, y, z, radians,
+            errcheck=errcheck)
 
 
-def itransform(p1, p2, points, switch=False, radians=False):
+def itransform(p1, p2, points, switch=False, radians=False, errcheck=False):
     """
     points2 = itransform(p1, p2, points1)
     Iterator/generator version of the function pyproj.transform.
@@ -351,4 +365,5 @@ def itransform(p1, p2, points, switch=False, radians=False):
     >>> for pt in itransform(pj, Proj(4326), [(pjx, pjy)], radians=True): '{:.3f} {:.3f}'.format(*pt)
     '2.031 0.696'
     """
-    return Transformer.from_proj(p1, p2).itransform(points, switch, radians)
+    return Transformer.from_proj(p1, p2).itransform(points, switch, radians,
+            errcheck=errcheck)


=====================================
requirements-dev.txt
=====================================
@@ -4,3 +4,4 @@ nose2[coverage_plugin]>=0.6.5
 pytest
 cov-core
 coverage>=4.0
+numpy


=====================================
sphinx/history.rst
=====================================
@@ -1,5 +1,11 @@
 Change Log
 ==========
+2.1.1
+~~~~~
+* Restore behavior of 1.9.6 when illegal projection transformation requested
+  (return ``inf`` instead of raising an exception, issue #202).  kwarg ``errcheck``
+  added to :func:`pyproj.transform` and :func:`pyproj.itransform`
+  (default ``False``). When ``errcheck=True`` an exception is raised.
 
 2.1.0
 ~~~~~


=====================================
unittest/test_transformer.py
=====================================
@@ -1,4 +1,7 @@
 import pyproj
+import numpy as np
+from numpy.testing import assert_equal
+from pyproj.exceptions import ProjError
 
 
 def test_tranform_wgs84_to_custom():
@@ -18,3 +21,16 @@ def test_transform_wgs84_to_alaska():
     test = (-179.72638, 49.752533)
     xx, yy = pyproj.transform(lat_lon_proj, alaska_aea_proj, *test)
     assert "{:.3f} {:.3f}".format(xx, yy) == "-1824924.495 330822.800"
+
+def test_illegal_transformation():
+    # issue 202
+    p1 = pyproj.Proj(init='epsg:4326')
+    p2 = pyproj.Proj(init='epsg:3857')
+    xx, yy = pyproj.transform(p1,p2,(-180,-180,180,180,-180),(-90,90,90,-90,-90))
+    assert np.all(np.isinf(xx))
+    assert np.all(np.isinf(yy))
+    try:
+        xx,yy = pyproj.transform(p1,p2,(-180,-180,180,180,-180),(-90,90,90,-90,-90),errcheck=True)
+        assert_equal(None, 'Should throw an exception when errcheck=True')
+    except ProjError:
+        pass



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-pyproj/commit/69dd1991a355e68c2254e3ba51c60caef1a9883f

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-pyproj/commit/69dd1991a355e68c2254e3ba51c60caef1a9883f
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20190318/7136ebf8/attachment-0001.html>


More information about the Pkg-grass-devel mailing list