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

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

commit b79286becb5d3eabae2da6bd144fb6fdc626f5b7
Author: Bas Couwenberg <sebas...@xs4all.nl>
Date:   Sat Oct 24 11:18:49 2015 +0200

    Imported Upstream version 1.3.1
---
 .travis.yml              |  3 ++-
 CHANGELOG.rst            |  7 +++++++
 geojson/validation.py    |  9 +++++++--
 setup.py                 |  2 +-
 tests/test_validation.py | 10 ++++++----
 5 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 151293a..ec47617 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,10 @@
 language: "python"
+sudo: false
 python:
    - "2.7"
-   - "3.2"
    - "3.3"
    - "3.4"
+   - "3.5"
    - "pypy"
    - "pypy3"
 install:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 81095d2..73a1e67 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,13 @@
 Changes
 =======
 
+1.3.1 (2015-10-12)
+------------------
+
+- Fix validation bug for MultiPolygons
+
+  - https://github.com/frewsxcv/python-geojson/pull/63
+
 1.3.0 (2015-08-11)
 ------------------
 
diff --git a/geojson/validation.py b/geojson/validation.py
index 25a4103..6e8b54f 100644
--- a/geojson/validation.py
+++ b/geojson/validation.py
@@ -58,14 +58,19 @@ def is_valid(obj):
                           'must be equivalent')
 
     if isinstance(obj, geojson.MultiPolygon):
-        if checkListOfObjects(obj['coordinates'],
-                              lambda x: len(x) >= 4 and x[0] == x[-1]):
+        if checkListOfObjects(obj['coordinates'], lambda x: is_polygon(x)):
             return output('the "coordinates" member must be an array'
                           'of Polygon coordinate arrays')
 
     return output('')
 
 
+def is_polygon(coords):
+    lengths = all(len(elem) >= 4 for elem in coords)
+    isring = all(elem[0] == elem[-1] for elem in coords)
+    return lengths and isring
+
+
 def checkListOfObjects(coord, pred):
     """ This method provides checking list of geojson objects such Multipoint 
or
         MultiLineString that each element of the list is valid geojson object.
diff --git a/setup.py b/setup.py
index cf3fddd..26a3082 100644
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,7 @@ import multiprocessing  # NOQA
 
 setup(
     name="geojson",
-    version="1.3.0",
+    version="1.3.1",
     description="Python bindings and utilities for GeoJSON",
     license="BSD",
     keywords="gis geography json",
diff --git a/tests/test_validation.py b/tests/test_validation.py
index 4086d52..3b80d7b 100644
--- a/tests/test_validation.py
+++ b/tests/test_validation.py
@@ -99,9 +99,11 @@ class TestValidationMultiPolygon(unittest.TestCase):
         self.assertEqual(is_valid(multipoly)['valid'], NO)
 
     def test_valid_multipolygon(self):
-        poly1 = [(2.38, 57.322), (23.194, -20.28),
-                 (-120.43, 19.15), (2.38, 57.322)]
-        poly2 = [(-5.34, 3.71), (28.74, 31.44), (28.55, 19.10), (-5.34, 3.71)]
-        poly3 = [(3.14, 23.17), (51.34, 27.14), (22, -18.11), (3.14, 23.17)]
+        poly1 = [[(2.38, 57.322), (23.194, -20.28),
+                  (-120.43, 19.15), (2.38, 57.322)]]
+        poly2 = [[(-5.34, 3.71), (28.74, 31.44),
+                  (28.55, 19.10), (-5.34, 3.71)]]
+        poly3 = [[(3.14, 23.17), (51.34, 27.14),
+                  (22, -18.11), (3.14, 23.17)]]
         multipoly = geojson.MultiPolygon([poly1, poly2, poly3])
         self.assertEqual(is_valid(multipoly)['valid'], YES)

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

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to