[python-shapely] 125/148: Imported Upstream version 1.4.3

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Thu Aug 20 17:42:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository python-shapely.

commit 11f36a010d559f850a6294fa5a56970fadec5a6d
Author: Pietro Battiston <me at pietrobattiston.it>
Date:   Thu Oct 2 22:58:31 2014 +0200

    Imported Upstream version 1.4.3
---
 CHANGES.txt                    |  13 ++--
 CREDITS.txt                    |   4 +-
 README.rst                     | 131 ++++++++++++++++++-----------------------
 setup.py                       |   9 +--
 shapely/__init__.py            |   2 +-
 shapely/ctypes_declarations.py |   5 +-
 shapely/geometry/base.py       |  14 ++++-
 shapely/geos.py                |  18 ++++--
 shapely/impl.py                |   6 +-
 tests/test_persist.py          |  39 +++++++++++-
 10 files changed, 139 insertions(+), 102 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 47399f9..72f8245 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,14 @@
 Changes
 =======
 
+1.4.3 (2014-10-01)
+------------------
+- Fix for endianness bug in WKB writer (#174).
+
+1.4.2 (2014-09-29)
+------------------
+- Fix bungled 1.4.1 release (#176).
+
 1.4.1 (2014-09-23)
 ------------------
 - Return of support for GEOS 3.2 (#176, #178).
@@ -21,11 +29,6 @@ Changes
 - Allow single-part geometries as argument to ops.cacaded_union() (#135).
 - Support affine transformations of LinearRings (#112).
 
-1.3.3 (2014-07-23)
-------------------
-- Allow single-part geometries as argument to ops.cacaded_union() (#135).
-- Support affine transformations of LinearRings (#112).
-
 1.3.2 (2014-05-13)
 ------------------
 - Let LineString() take a sequence of Points (#130).
diff --git a/CREDITS.txt b/CREDITS.txt
index a838183..3433530 100644
--- a/CREDITS.txt
+++ b/CREDITS.txt
@@ -19,7 +19,7 @@ Patches contributed by:
 * Bertrand Gervais (https://github.com/BertrandGervais)
 * Marc Jansen (https://github.com/marcjansen)
 * Kelsey Jordahl (https://github.com/kjordahl)
-* Fr |eaigue| d |eaigue| ric Junod
+* Frédéric Junod
 * Thomas Kluyver (https://github.com/takluyver)
 * William Kyngesburye (https://github.com/kyngchaos)
 * Eric Lemoine
@@ -49,6 +49,4 @@ Additional help from:
 Major portions of this work were supported by a grant (for Pleiades_) from the
 U.S. National Endowment for the Humanities (http://www.neh.gov).
 
-.. |eaigue| unicode:: U+00E9
-   :trim:
 .. _Pleiades: http://pleiades.stoa.org
diff --git a/README.rst b/README.rst
index 3495165..5c2005f 100644
--- a/README.rst
+++ b/README.rst
@@ -12,13 +12,15 @@ Manipulation and analysis of geometric objects in the Cartesian plane.
    :height: 400
 
 Shapely is a BSD-licensed Python package for manipulation and analysis of
-planar geometric objects. It is based on the widely deployed GEOS_ (the engine
-of PostGIS_) and JTS_ (from which GEOS is ported) libraries. Shapely is not
-concerned with data formats or coordinate systems, but can be readily
-integrated with packages that are. For more details, see:
+planar geometric objects. It is based on the widely deployed `GEOS
+<http://trac.osgeo.org/geos/>`__ (the engine of `PostGIS
+<http://postgis.org>`__) and `JTS
+<http://www.vividsolutions.com/jts/jtshome.htm>`__ (from which GEOS is ported)
+libraries. Shapely is not concerned with data formats or coordinate systems,
+but can be readily integrated with packages that are. For more details, see:
 
-* Shapely manual_
-* Shapely `example apps`_
+* Shapely on `GitHub <https://github.com/Toblerity/Shapely>`__
+* The Shapely `manual <http://toblerity.github.com/shapely/manual.html>`__
 
 Requirements
 ============
@@ -37,16 +39,10 @@ is on the system library path, and install from the Python package index.
 
 .. code-block:: console
 
-  $ pip install shapely
+    $ pip install shapely
 
-Shapely is also provided by popular Python distributions like Enthought Canopy
-and Continuum Analytics Anaconda. 
-
-.. warning:: Windows users:
-   do not under any circumstances use pip (or easy_install) to uninstall
-   Shapely versions < 1.2.17. Due to the way Shapely used to install its GEOS
-   DLL and a distribute or setuptools bug, your Python installation may be
-   broken by an uninstall command. Shapely 1.2.17 will uninstall safely.
+Shapely is also provided by popular Python distributions like Canopy (Enthought)
+and Anaconda (Continuum Analytics).
 
 Usage
 =====
@@ -56,15 +52,15 @@ buffering a point.
 
 .. code-block:: pycon
 
-  >>> from shapely.geometry import Point
-  >>> patch = Point(0.0, 0.0).buffer(10.0)
-  >>> patch
-  <shapely.geometry.polygon.Polygon object at 0x...>
-  >>> patch.area
-  313.65484905459385
+    >>> from shapely.geometry import Point
+    >>> patch = Point(0.0, 0.0).buffer(10.0)
+    >>> patch
+    <shapely.geometry.polygon.Polygon object at 0x...>
+    >>> patch.area
+    313.65484905459385
 
-See the manual_ for comprehensive usage snippets and the dissolve.py and
-intersect.py `example apps`_.
+See the manual for comprehensive usage snippets and the dissolve.py and
+intersect.py examples.
 
 Integration
 ===========
@@ -75,60 +71,60 @@ modules provide dumpers and loaders inspired by Python's pickle module.
 
 .. code-block:: pycon
 
-  >>> from shapely.wkt import dumps, loads
-  >>> dumps(loads('POINT (0 0)'))
-  'POINT (0.0000000000000000 0.0000000000000000)'
+    >>> from shapely.wkt import dumps, loads
+    >>> dumps(loads('POINT (0 0)'))
+    'POINT (0.0000000000000000 0.0000000000000000)'
 
 All linear objects, such as the rings of a polygon (like ``patch`` above),
 provide the Numpy array interface.
 
 .. code-block:: pycon
 
-  >>> import numpy as np
-  >>> np.array(patch.exterior)
-  array([[  1.00000000e+01,   0.00000000e+00],
-         [  9.95184727e+00,  -9.80171403e-01],
-         [  9.80785280e+00,  -1.95090322e+00],
-         ...
-         [  1.00000000e+01,   0.00000000e+00]])
+    >>> import numpy as np
+    >>> np.array(patch.exterior)
+    array([[  1.00000000e+01,   0.00000000e+00],
+           [  9.95184727e+00,  -9.80171403e-01],
+           [  9.80785280e+00,  -1.95090322e+00],
+           ...
+           [  1.00000000e+01,   0.00000000e+00]])
 
-That yields a Numpy array of `[x, y]` arrays. This is not always exactly what one
+That yields a Numpy array of ``[x, y]`` arrays. This is not always exactly what one
 wants for plotting shapes with Matplotlib (for example), so Shapely adds
-a `xy` property for obtaining separate arrays of coordinate x and y values.
+a ``xy`` property for obtaining separate arrays of coordinate x and y values.
 
 .. code-block:: pycon
 
-  >>> x, y = patch.exterior.xy
-  >>> np.array(x)
-  array([  1.00000000e+01,   9.95184727e+00,   9.80785280e+00,  ...])
+    >>> x, y = patch.exterior.xy
+    >>> np.array(x)
+    array([  1.00000000e+01,   9.95184727e+00,   9.80785280e+00,  ...])
 
-Numpy arrays of `[x, y]` arrays can also be adapted to Shapely linestrings.
+Numpy arrays of ``[x, y]`` arrays can also be adapted to Shapely linestrings.
 
 .. code-block:: pycon
 
-  >>> from shapely.geometry import LineString
-  >>> LineString(np.array(patch.exterior)).length
-  62.806623139095073
+    >>> from shapely.geometry import LineString
+    >>> LineString(np.array(patch.exterior)).length
+    62.806623139095073
 
 Numpy arrays of x and y must be transposed.
 
-.. code-block::
+.. code-block:: pycon
 
-  >>> LineString(np.transpose(np.array(patch.exterior.xy))).length
-  62.80662313909507
+    >>> LineString(np.transpose(np.array(patch.exterior.xy))).length
+    62.80662313909507
 
 Shapely can also integrate with other Python GIS packages using data modeled
 after GeoJSON.
 
-.. sourcecode:: pycon
+.. code-block:: pycon
 
-  >>> import json
-  >>> from shapely.geometry import mapping, shape
-  >>> s = shape(json.loads('{"type": "Point", "coordinates": [0.0, 0.0]}'))
-  >>> s
-  <shapely.geometry.point.Point object at 0x...>
-  >>> print(json.dumps(mapping(s)))
-  {"type": "Point", "coordinates": [0.0, 0.0]}
+    >>> import json
+    >>> from shapely.geometry import mapping, shape
+    >>> s = shape(json.loads('{"type": "Point", "coordinates": [0.0, 0.0]}'))
+    >>> s
+    <shapely.geometry.point.Point object at 0x...>
+    >>> print(json.dumps(mapping(s)))
+    {"type": "Point", "coordinates": [0.0, 0.0]}
 
 Development and Testing
 =======================
@@ -139,16 +135,16 @@ Use of a virtual environment is strongly recommended.
 
 .. code-block:: console
 
-  $ virtualenv .
-  $ source bin/activate
-  (env)$ pip install -r requirements-dev.txt
-  (env)$ pip install -e .
+    $ virtualenv .
+    $ source bin/activate
+    (env)$ pip install -r requirements-dev.txt
+    (env)$ pip install -e .
 
 We use py.test to run Shapely's suite of unittests and doctests.
 
 .. code-block:: console
 
-  (env)$ py.test tests
+    (env)$ py.test tests
 
 Roadmap and Maintenance
 =======================
@@ -157,12 +153,7 @@ Shapely 1.2.x is a maintenance-only branch which supports Python 2.4-2.6, but
 not Python 3+. There will be no new features in Shapely 1.2.x and only fixes
 for major bugs.
 
-Shapely 1.3.x is a maintenance-only branch supporting Pythons 2.7 and 3+.
-
-"Shapely 3000" is the name of the next milestone. New features will include
-vectorized operations, better integration with IPython Notebook, support for
-fixed precision models, and more. Less ctypes and more Cython is another theme
-in this branch. A 1.4 release should come out of this by Summer, 2014.
+Shapely 1.4.x is a maintenance-only branch supporting Pythons 2.7 and 3.3+.
 
 Support
 =======
@@ -170,14 +161,4 @@ Support
 Please discuss Shapely with us at
 http://lists.gispython.org/mailman/listinfo/community.
 
-Bugs may be reported at https://github.com/Toblerity/Shapely.
-
-.. include:: CREDITS.txt
-
-.. _JTS: http://www.vividsolutions.com/jts/jtshome.htm
-.. _PostGIS: http://postgis.org
-.. _GEOS: http://trac.osgeo.org/geos/
-.. _example apps: https://github.com/Toblerity/shapely/tree/master/shapely/examples
-.. _manual: http://toblerity.github.com/shapely/manual.html
-.. _Pleiades: http://pleiades.stoa.org
-
+Bugs may be reported at https://github.com/Toblerity/Shapely/issues.
diff --git a/setup.py b/setup.py
index ea428c0..1602923 100755
--- a/setup.py
+++ b/setup.py
@@ -43,14 +43,15 @@ with open('VERSION.txt', 'w', **open_kwds) as fp:
     fp.write(version)
 
 with open('README.rst', 'r', **open_kwds) as fp:
-    readme_text = fp.read()
-readme_text = readme_text.replace(".. include:: CREDITS.txt", "")
+    readme = fp.read()
 
 with open('CREDITS.txt', 'r', **open_kwds) as fp:
     credits = fp.read()
 
 with open('CHANGES.txt', 'r', **open_kwds) as fp:
-    changes_text = fp.read()
+    changes = fp.read()
+
+long_description = readme + '\n\n' + credits + '\n\n' + changes
 
 setup_args = dict(
     name                = 'Shapely',
@@ -64,7 +65,7 @@ setup_args = dict(
     maintainer          = 'Sean Gillies',
     maintainer_email    = 'sean.gillies at gmail.com',
     url                 = 'https://github.com/Toblerity/Shapely',
-    long_description    = readme_text + "\n" + credits + "\n" + changes_text,
+    long_description    = long_description,
     packages            = [
         'shapely',
         'shapely.geometry',
diff --git a/shapely/__init__.py b/shapely/__init__.py
index bf25615..aa56ed4 100644
--- a/shapely/__init__.py
+++ b/shapely/__init__.py
@@ -1 +1 @@
-__version__ = "1.4.1"
+__version__ = "1.4.3"
diff --git a/shapely/ctypes_declarations.py b/shapely/ctypes_declarations.py
index 2c0a305..ffe9912 100644
--- a/shapely/ctypes_declarations.py
+++ b/shapely/ctypes_declarations.py
@@ -276,8 +276,9 @@ def prototype(lgeos, geos_version):
     lgeos.GEOSisRing.restype = c_byte
     lgeos.GEOSisRing.argtypes = [c_void_p]
 
-    lgeos.GEOSisClosed.restype = c_byte
-    lgeos.GEOSisClosed.argtypes = [c_void_p]
+    if geos_version >= (3, 3, 0):
+        lgeos.GEOSisClosed.restype = c_byte
+        lgeos.GEOSisClosed.argtypes = [c_void_p]
 
     lgeos.GEOSHasZ.restype = c_byte
     lgeos.GEOSHasZ.argtypes = [c_void_p]
diff --git a/shapely/geometry/base.py b/shapely/geometry/base.py
index a62b40f..0a34998 100644
--- a/shapely/geometry/base.py
+++ b/shapely/geometry/base.py
@@ -560,8 +560,18 @@ class BaseGeometry(object):
 
     @property
     def is_closed(self):
-        """True if the geometry is closed, else False"""
-        return bool(self.impl['is_closed'](self))
+        """True if the geometry is closed, else False
+        
+        Applicable only to 1-D geometries."""
+        if self.geom_type == 'LinearRing':
+            return True
+        elif self.geom_type == 'LineString':
+            if 'is_closed' in self.impl:
+                return bool(self.impl['is_closed'](self))
+            else:
+                return self.coords[0] == self.coords[-1]
+        else:
+            return False
 
     @property
     def is_simple(self):
diff --git a/shapely/geos.py b/shapely/geos.py
index 6061ed3..564f3cc 100644
--- a/shapely/geos.py
+++ b/shapely/geos.py
@@ -383,6 +383,10 @@ class WKBWriter(object):
     _lgeos = None
     _writer = None
 
+    # EndianType enum in ByteOrderValues.h
+    _ENDIAN_BIG = 0
+    _ENDIAN_LITTLE = 1
+
     # Establish default output setting
     defaults = {'output_dimension': 3}
 
@@ -399,11 +403,13 @@ class WKBWriter(object):
     @property
     def big_endian(self):
         """Byte order is big endian, True (default) or False"""
-        return bool(self._lgeos.GEOSWKBWriter_getByteOrder(self._writer))
+        return (self._lgeos.GEOSWKBWriter_getByteOrder(self._writer) ==
+            self._ENDIAN_BIG)
 
     @big_endian.setter
     def big_endian(self, value):
-        self._lgeos.GEOSWKBWriter_setByteOrder(self._writer, bool(value))
+        self._lgeos.GEOSWKBWriter_setByteOrder(
+            self._writer, self._ENDIAN_BIG if value else self._ENDIAN_LITTLE)
 
     @property
     def include_srid(self):
@@ -545,7 +551,6 @@ class LGEOS300(LGEOSBase):
                 self.GEOSisValid,
                 self.GEOSisSimple,
                 self.GEOSisRing,
-                self.GEOSisClosed,
                 self.GEOSHasZ):
             pred.errcheck = errcheck_predicate
 
@@ -561,7 +566,6 @@ class LGEOS300(LGEOSBase):
         self.methods['has_z'] = self.GEOSHasZ
         self.methods['is_empty'] = self.GEOSisEmpty
         self.methods['is_ring'] = self.GEOSisRing
-        self.methods['is_closed'] = self.GEOSisClosed
         self.methods['is_simple'] = self.GEOSisSimple
         self.methods['is_valid'] = self.GEOSisValid
         self.methods['disjoint'] = self.GEOSDisjoint
@@ -622,7 +626,6 @@ class LGEOS310(LGEOSBase):
                 self.GEOSisValid,
                 self.GEOSisSimple,
                 self.GEOSisRing,
-                self.GEOSisClosed,
                 self.GEOSHasZ):
             pred.func.errcheck = errcheck_predicate
 
@@ -640,7 +643,6 @@ class LGEOS310(LGEOSBase):
         self.methods['has_z'] = self.GEOSHasZ
         self.methods['is_empty'] = self.GEOSisEmpty
         self.methods['is_ring'] = self.GEOSisRing
-        self.methods['is_closed'] = self.GEOSisClosed
         self.methods['is_simple'] = self.GEOSisSimple
         self.methods['is_valid'] = self.GEOSisValid
         self.methods['disjoint'] = self.GEOSDisjoint
@@ -713,7 +715,11 @@ class LGEOS330(LGEOS320):
         attr.__name__ = func.__name__
         setattr(self, key, attr)
 
+        for pred in (self.GEOSisClosed,):
+            pred.func.errcheck = errcheck_predicate
+
         self.methods['unary_union'] = self.GEOSUnaryUnion
+        self.methods['is_closed'] = self.GEOSisClosed
         self.methods['cascaded_union'] = self.methods['unary_union']
 
 
diff --git a/shapely/impl.py b/shapely/impl.py
index bc804b7..2d670cf 100644
--- a/shapely/impl.py
+++ b/shapely/impl.py
@@ -71,7 +71,6 @@ IMPL300 = {
     'has_z': (UnaryPredicate, 'has_z'),
     'is_empty': (UnaryPredicate, 'is_empty'),
     'is_ring': (UnaryPredicate, 'is_ring'),
-    'is_closed': (UnaryPredicate, 'is_closed'),
     'is_simple': (UnaryPredicate, 'is_simple'),
     'is_valid': (UnaryPredicate, 'is_valid'),
     #
@@ -113,6 +112,9 @@ IMPL320 = {
     'buffer_with_style': (UnaryTopologicalOp, 'buffer_with_style'),
     }
 
+IMPL330 = {
+    'is_closed': (UnaryPredicate, 'is_closed')}
+
 def impl_items(defs):
     return [(k, v[0](v[1])) for k, v in list(defs.items())]
 
@@ -123,5 +125,7 @@ if lgeos.geos_version >= (3, 1, 1):
     imp.update(impl_items(IMPL311))
 if lgeos.geos_version >= (3, 2, 0):
     imp.update(impl_items(IMPL320))
+if lgeos.geos_version >= (3, 3, 0):
+    imp.update(impl_items(IMPL330))
 
 DefaultImplementation = imp
diff --git a/tests/test_persist.py b/tests/test_persist.py
index 251459f..a1b9bdc 100644
--- a/tests/test_persist.py
+++ b/tests/test_persist.py
@@ -4,10 +4,19 @@ from . import unittest
 import pickle
 from shapely import wkb, wkt
 from shapely.geometry import Point
+import struct
 
 
 class PersistTestCase(unittest.TestCase):
 
+    @staticmethod
+    def _byte(i):
+        """Convert an integer in the range [0, 256) to a byte."""
+        if bytes == str: # Python 2
+            return chr(i)
+        else: # Python 3
+            return int(i)
+
     def test_pickle(self):
 
         p = Point(0.0, 0.0)
@@ -18,9 +27,33 @@ class PersistTestCase(unittest.TestCase):
     def test_wkb(self):
 
         p = Point(0.0, 0.0)
-        bytes = wkb.dumps(p)
-        pb = wkb.loads(bytes)
-        self.assertTrue(pb.equals(p))
+        wkb_big_endian = wkb.dumps(p, big_endian=True)
+        wkb_little_endian = wkb.dumps(p, big_endian=False)
+        # Regardless of byte order, loads ought to correctly recover the
+        # geometry
+        self.assertTrue(p.equals(wkb.loads(wkb_big_endian)))
+        self.assertTrue(p.equals(wkb.loads(wkb_little_endian)))
+
+    def test_wkb_dumps_endianness(self):
+
+        p = Point(0.5, 2.0)
+        wkb_big_endian = wkb.dumps(p, big_endian=True)
+        wkb_little_endian = wkb.dumps(p, big_endian=False)
+        self.assertNotEqual(wkb_big_endian, wkb_little_endian)
+        # According to WKB specification in section 3.3 of OpenGIS
+        # Simple Features Specification for SQL, revision 1.1, the
+        # first byte of a WKB representation indicates byte order.
+        # Big-endian is 0, little-endian is 1.
+        self.assertEqual(wkb_big_endian[0], self._byte(0))
+        self.assertEqual(wkb_little_endian[0], self._byte(1))
+        # Check that the doubles (0.5, 2.0) are in correct byte order
+        double_size = struct.calcsize('d')
+        self.assertEqual(
+            wkb_big_endian[(-2 * double_size):],
+            struct.pack('>2d', p.x, p.y))
+        self.assertEqual(
+            wkb_little_endian[(-2 * double_size):],
+            struct.pack('<2d', p.x, p.y))
 
     def test_wkt(self):
         p = Point(0.0, 0.0)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-shapely.git



More information about the Pkg-grass-devel mailing list