This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository python-geojson.
commit 0048efc9e2719e3fef83c514b3d0ecc8bb552136 Author: Bas Couwenberg <sebas...@xs4all.nl> Date: Wed Aug 30 09:47:21 2017 +0200 New upstream version 2.1.0 --- CHANGELOG.rst | 7 +++++++ geojson/_version.py | 2 +- geojson/geometry.py | 4 ++++ tests/test_validation.py | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f56744b..d863f6d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ Changes ======= +2.1.0 (2017-08-29) +------------------ + +- Implement validation for GeometryCollection + + - https://github.com/frewsxcv/python-geojson/pull/102 + 2.0.0 (2017-07-28) ------------------ diff --git a/geojson/_version.py b/geojson/_version.py index 3394157..4edb268 100644 --- a/geojson/_version.py +++ b/geojson/_version.py @@ -1,2 +1,2 @@ -__version__ = "2.0.0" +__version__ = "2.1.0" __version_info__ = tuple(map(int, __version__.split("."))) diff --git a/geojson/geometry.py b/geojson/geometry.py index 517fe5b..8226c9c 100644 --- a/geojson/geometry.py +++ b/geojson/geometry.py @@ -53,6 +53,10 @@ class GeometryCollection(GeoJSON): super(GeometryCollection, self).__init__(**extra) self["geometries"] = geometries or [] + def errors(self): + errors = [geom.errors() for geom in self['geometries']] + return [err for err in errors if err] + # Marker classes. diff --git a/tests/test_validation.py b/tests/test_validation.py index 50331be..d104d89 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -136,3 +136,26 @@ class TestValidationMultiPolygon(unittest.TestCase): (22, -18.11), (3.14, 23.17)]] multipoly = geojson.MultiPolygon([poly1, poly2, poly3]) self.assertEqual(multipoly.is_valid, True) + + +class TestValidationGeometryCollection(unittest.TestCase): + + def test_invalid_geometrycollection(self): + point = geojson.Point((10, 20)) + bad_poly = geojson.Polygon([[(2.38, 57.322), (23.194, -20.28), + (-120.43, 19.15), (25.44, -17.91)]]) + + geom_collection = geojson.GeometryCollection( + geometries=[point, bad_poly] + ) + self.assertFalse(geom_collection.is_valid) + + def test_valid_geometrycollection(self): + point = geojson.Point((10, 20)) + poly = geojson.Polygon([[(2.38, 57.322), (23.194, -20.28), + (-120.43, 19.15), (2.38, 57.322)]]) + + geom_collection = geojson.GeometryCollection( + geometries=[point, poly] + ) + self.assertTrue(geom_collection.is_valid) -- 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