This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository python-shapely.
commit 18684936d7507641e4b35798644ea7c8cdd302ec Author: Bas Couwenberg <[email protected]> Date: Mon Dec 12 18:34:47 2016 +0100 Imported Upstream version 1.6~b2 --- CHANGES.txt | 7 +++++++ README.rst | 16 +++++++++------- shapely/__init__.py | 2 +- shapely/geometry/geo.py | 7 +++++++ tests/test_collection.py | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ffe9922..a39734d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,13 @@ Changes ======= +1.6b2 (2016-12-12) +------------------ + +New features: + +- Add support for GeometryCollection to shape and asShape functions (#422). + 1.6b1 (2016-12-12) ------------------ diff --git a/README.rst b/README.rst index 28d8bfd..45d10ad 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,7 @@ Shapely .. image:: https://travis-ci.org/Toblerity/Shapely.png?branch=master :target: https://travis-ci.org/Toblerity/Shapely +.. image:: https://coveralls.io/repos/github/Toblerity/Shapely/badge.svg?branch=master :target: https://coveralls.io/github/Toblerity/Shapely?branch=master Manipulation and analysis of geometric objects in the Cartesian plane. @@ -32,7 +33,7 @@ Shapely 1.6.x requires * Python >=2.6 (including Python 3.x) * GEOS >=3.3 -Installing Shapely (1.6b1) +Installing Shapely (1.6b2) ========================== Windows users have two good installation options: the wheels at @@ -45,13 +46,13 @@ Python Package Index with a recent version of pip (8+): .. code-block:: console - $ pip install shapely==1.6b1 + $ pip install shapely==1.6b2 A few extra speedups that require Numpy can be had by running .. code-block:: console - $ pip install shapely[vectorized]==1.6b1 + $ pip install shapely[vectorized]==1.6b2 If you want to build Shapely from source for compatibility with other modules that depend on GEOS (such as cartopy or osgeo.ogr) @@ -62,8 +63,8 @@ you may ignore the binary wheels. $ pip install shapely --no-binary shapely Binary wheels are also available for Linux. To get them, use `pip shapely -shapely==1.6b1`. To avoid them, use `pip install shapely --no-binary -shapely==1.6b1`. +shapely==1.6b2`. To avoid them, use `pip install shapely --no-binary +shapely==1.6b2`. In other situations, install `geos_c` libs and headers by any means (for example, `brew install geos` on OS X or @@ -82,8 +83,9 @@ variable, e.g.: .. code-block:: console $ GEOS_CONFIG=/path/to/geos-config pip install shapely -Shapely is also provided by popular Python distributions like Canopy (Enthought) -and Anaconda (Continuum Analytics). + +Shapely is also provided by popular Python distributions like Canopy +(Enthought) and Anaconda (Continuum Analytics). Usage ===== diff --git a/shapely/__init__.py b/shapely/__init__.py index 8f4c864..fb79012 100644 --- a/shapely/__init__.py +++ b/shapely/__init__.py @@ -1 +1 @@ -__version__ = "1.6b1" +__version__ = "1.6b2" diff --git a/shapely/geometry/geo.py b/shapely/geometry/geo.py index 55d2d90..96f301c 100644 --- a/shapely/geometry/geo.py +++ b/shapely/geometry/geo.py @@ -8,6 +8,7 @@ from .polygon import Polygon, asPolygon from .multipoint import MultiPoint, asMultiPoint from .multilinestring import MultiLineString, asMultiLineString from .multipolygon import MultiPolygon, MultiPolygonAdapter +from .collection import GeometryCollection def box(minx, miny, maxx, maxy, ccw=True): @@ -38,6 +39,9 @@ def shape(context): return MultiLineString(ob["coordinates"]) elif geom_type == "multipolygon": return MultiPolygon(ob["coordinates"], context_type='geojson') + elif geom_type == "geometrycollection": + geoms = [shape(g) for g in ob.get("geometries", [])] + return GeometryCollection(geoms) else: raise ValueError("Unknown geometry type: %s" % geom_type) @@ -67,6 +71,9 @@ def asShape(context): return asMultiLineString(ob["coordinates"]) elif geom_type == "multipolygon": return MultiPolygonAdapter(ob["coordinates"], context_type='geojson') + elif geom_type == "geometrycollection": + geoms = [asShape(g) for g in ob.get("geometries", [])] + return GeometryCollection(geoms) else: raise ValueError("Unknown geometry type: %s" % geom_type) diff --git a/tests/test_collection.py b/tests/test_collection.py index a892c52..1e6f0a6 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -1,6 +1,8 @@ from . import unittest from shapely.geometry import LineString from shapely.geometry.collection import GeometryCollection +from shapely.geometry import shape +from shapely.geometry import asShape class CollectionTestCase(unittest.TestCase): @@ -24,6 +26,43 @@ class CollectionTestCase(unittest.TestCase): # access geometry, this should not seg fault as 1.2.15 did self.assertIsNotNone(child.wkt) + def test_geointerface(self): + d = {"type": "GeometryCollection","geometries": [ + {"type": "Point", "coordinates": (0, 3)}, + {"type": "LineString", "coordinates": ((2, 0), (1, 0))} + ]} + + # asShape + m = asShape(d) + self.assertEqual(m.geom_type, "GeometryCollection") + self.assertEqual(len(m), 2) + geom_types = [g.geom_type for g in m.geoms] + self.assertIn("Point", geom_types) + self.assertIn("LineString", geom_types) + + # shape + m = shape(d) + self.assertEqual(m.geom_type, "GeometryCollection") + self.assertEqual(len(m), 2) + geom_types = [g.geom_type for g in m.geoms] + self.assertIn("Point", geom_types) + self.assertIn("LineString", geom_types) + + def test_empty_geointerface(self): + d = {"type": "GeometryCollection", "geometries": []} + + # asShape + m = asShape(d) + self.assertEqual(m.geom_type, "GeometryCollection") + self.assertEqual(len(m), 0) + self.assertEqual(m.geoms, []) + + # shape + m = shape(d) + self.assertEqual(m.geom_type, "GeometryCollection") + self.assertEqual(len(m), 0) + self.assertEqual(m.geoms, []) + def test_suite(): return unittest.TestLoader().loadTestsFromTestCase(CollectionTestCase) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-shapely.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

