This is an automated email from the git hooks/post-receive script. johanvdw-guest pushed a commit to branch master in repository python-geojson.
commit 28db8f7d89a0ac97dfe228e537968477520db4ef Author: Johan Van de Wauw <johan.vandew...@gmail.com> Date: Thu Jan 29 20:56:45 2015 +0100 Add python 3 support --- debian/changelog | 4 +- debian/control | 29 +- debian/copyright | 12 +- .../dist-packages/geojson-1.0.9.egg-info/PKG-INFO | 322 +++++++++++++++++++++ .../geojson-1.0.9.egg-info/SOURCES.txt | 28 ++ .../geojson-1.0.9.egg-info/dependency_links.txt | 1 + .../geojson-1.0.9.egg-info/requires.txt | 1 + .../geojson-1.0.9.egg-info/top_level.txt | 1 + .../python2.7/dist-packages/geojson/__init__.py | 7 + .../lib/python2.7/dist-packages/geojson/base.py | 86 ++++++ .../lib/python2.7/dist-packages/geojson/codec.py | 59 ++++ .../usr/lib/python2.7/dist-packages/geojson/crs.py | 30 ++ .../python2.7/dist-packages/geojson/examples.py | 45 +++ .../lib/python2.7/dist-packages/geojson/factory.py | 9 + .../lib/python2.7/dist-packages/geojson/feature.py | 29 ++ .../python2.7/dist-packages/geojson/geometry.py | 62 ++++ .../lib/python2.7/dist-packages/geojson/mapping.py | 32 ++ .../lib/python2.7/dist-packages/geojson/utils.py | 35 +++ .../dist-packages/geojson-1.0.9.egg-info/PKG-INFO | 322 +++++++++++++++++++++ .../geojson-1.0.9.egg-info/SOURCES.txt | 28 ++ .../geojson-1.0.9.egg-info/dependency_links.txt | 1 + .../geojson-1.0.9.egg-info/requires.txt | 1 + .../geojson-1.0.9.egg-info/top_level.txt | 1 + .../python3.4/dist-packages/geojson/__init__.py | 7 + .../lib/python3.4/dist-packages/geojson/base.py | 86 ++++++ .../lib/python3.4/dist-packages/geojson/codec.py | 59 ++++ .../usr/lib/python3.4/dist-packages/geojson/crs.py | 30 ++ .../python3.4/dist-packages/geojson/examples.py | 45 +++ .../lib/python3.4/dist-packages/geojson/factory.py | 9 + .../lib/python3.4/dist-packages/geojson/feature.py | 29 ++ .../python3.4/dist-packages/geojson/geometry.py | 62 ++++ .../lib/python3.4/dist-packages/geojson/mapping.py | 32 ++ .../lib/python3.4/dist-packages/geojson/utils.py | 35 +++ debian/rules | 6 +- 34 files changed, 1526 insertions(+), 19 deletions(-) diff --git a/debian/changelog b/debian/changelog index fad8896..9767c13 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -python-geojson (1.0.4-1) UNRELEASED; urgency=medium +python-geojson (1.0.9-1) UNRELEASED; urgency=medium - * Initial upload (closes: #762869) + * Initial upload (closes: #xxx) -- Johan Van de Wauw <johan.vandew...@gmail.com> Thu, 25 Sep 2014 21:32:43 +0200 diff --git a/debian/control b/debian/control index 59e9bbd..2914a5f 100644 --- a/debian/control +++ b/debian/control @@ -6,8 +6,9 @@ Priority: optional Build-Depends: debhelper (>= 9), dh-python, python-setuptools, - python-dateutil, python-all, + python3-setuptools, + python3-all, Standards-Version: 3.9.6 Vcs-Browser: http://anonscm.debian.org/cgit/pkg-grass/python-geojson.git Vcs-Git: git://anonscm.debian.org/pkg-grass/python-geojson.git @@ -18,14 +19,24 @@ Package: python-geojson Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - python-lxml -Description: Client library for Open Geospatial (OGC) web services - OWSLib is a Python package for client programming with Open Geospatial - Consortium (OGC) web service (hence OWS) interface standards, and their - related content models. +Description: Python 2 bindings and utilities for GeoJSON + This library contains: . - Full documentation is available at http://geopython.github.io/OWSLib + - Functions for encoding and decoding GeoJSON formatted data + - Classes for all GeoJSON Objects + - An implementation of the Python geo_interface Specification . - OWSLib provides a common API for accessing service metadata and wrappers - for numerous OGC Web Service interfaces. + This is the Python 2 version of the library +Package: python3-geojson +Architecture: all +Depends: ${python3:Depends}, + ${misc:Depends}, +Description: Python 3 bindings and utilities for GeoJSON + This library contains: + . + - Functions for encoding and decoding GeoJSON_ formatted data + - Classes for all GeoJSON Objects + - An implementation of the Python geo_interface Specification + . + This is the Python 3 version of the library diff --git a/debian/copyright b/debian/copyright index bffbe4e..1ef9493 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,10 +1,14 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Contact: Tom Kralidis <tomkrali...@gmail.com> -Upstream-Name: OWSLib -Source: https://pypi.python.org/pypi/OWSLib +Upstream-Contact: Corey Farwell <cor...@rwell.org> +Upstream-Name: python-geojson +Source: https://github.com/frewsxcv/python-geojson Files: * -Copyright: 2006, Ancient World Mapping Center +Copyright: 2014, contributors of python-geojson +License: BSD-3-Clause + +Files: debian/* +Copyright: 2015, Johan Van de Wauw License: BSD-3-Clause License: BSD-3-Clause diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/PKG-INFO b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/PKG-INFO new file mode 100644 index 0000000..26f69ee --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/PKG-INFO @@ -0,0 +1,322 @@ +Metadata-Version: 1.1 +Name: geojson +Version: 1.0.9 +Summary: Python bindings and utilities for GeoJSON +Home-page: https://github.com/frewsxcv/python-geojson +Author: Corey Farwell +Author-email: cor...@rwell.org +License: BSD +Description: python-geojson + ============== + + .. image:: https://travis-ci.org/frewsxcv/python-geojson.png?branch=master + :target: https://travis-ci.org/frewsxcv/python-geojson + .. image:: https://coveralls.io/repos/frewsxcv/python-geojson/badge.png + :target: https://coveralls.io/r/frewsxcv/python-geojson + + This library contains: + + - Functions for encoding and decoding GeoJSON_ formatted data + - Classes for all GeoJSON Objects + - An implementation of the Python `__geo_interface__ Specification`_ + + **Table of Contents** + + .. contents:: + :backlinks: none + :local: + + Installation + ------------ + + python-geojson is compatible with Python 2.6, 2.7, 3.2, 3.3, and 3.4. It is listed on `PyPi as 'geojson'`_. The recommended way to install is via pip_: + + .. code:: + + pip install geojson + + .. _PyPi as 'geojson': https://pypi.python.org/pypi/geojson/ + .. _pip: http://www.pip-installer.org + + GeoJSON Objects + --------------- + + This library implements all the `GeoJSON Objects`_ described in `The GeoJSON Format Specification`_. + + .. _GeoJSON Objects: http://www.geojson.org/geojson-spec.html#geojson-objects + + Point + ~~~~~ + + .. code:: python + + >>> from geojson import Point + + >>> Point((-115.81, 37.24)) # doctest: +ELLIPSIS + {"coordinates": [-115.8..., 37.2...], "type": "Point"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/b5768a857f5598e405fa>`__. General information about Point can be found in `Section 2.1.2`_ and `Appendix A: Point`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.2: http://www.geojson.org/geojson-spec.html#point + .. _Appendix A\: Point: http://www.geojson.org/geojson-spec.html#id2 + + MultiPoint + ~~~~~~~~~~ + + .. code:: python + + >>> from geojson import MultiPoint + + >>> MultiPoint([(-155.52, 19.61), (-156.22, 20.74), (-157.97, 21.46)]) # doctest: +ELLIPSIS + {"coordinates": [[-155.5..., 19.6...], [-156.2..., 20.7...], [-157.9..., 21.4...]], "type": "MultiPoint"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/be02025c1eb3aa2040ee>`__. General information about MultiPoint can be found in `Section 2.1.3`_ and `Appendix A: MultiPoint`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.3: http://www.geojson.org/geojson-spec.html#multipoint + .. _Appendix A\: MultiPoint: http://www.geojson.org/geojson-spec.html#id5 + + + LineString + ~~~~~~~~~~ + + .. code:: python + + >>> from geojson import LineString + + >>> LineString([(8.919, 44.4074), (8.923, 44.4075)]) # doctest: +ELLIPSIS + {"coordinates": [[8.91..., 44.407...], [8.92..., 44.407...]], "type": "LineString"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/758563182ca49ce8e8bb>`__. General information about LineString can be found in `Section 2.1.4`_ and `Appendix A: LineString`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.4: http://www.geojson.org/geojson-spec.html#linestring + .. _Appendix A\: LineString: http://www.geojson.org/geojson-spec.html#id3 + + MultiLineString + ~~~~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import MultiLineString + + >>> MultiLineString([ + ... [(3.75, 9.25), (-130.95, 1.52)], + ... [(23.15, -34.25), (-1.35, -4.65), (3.45, 77.95)] + ... ]) # doctest: +ELLIPSIS + {"coordinates": [[[3.7..., 9.2...], [-130.9..., 1.52...]], [[23.1..., -34.2...], [-1.3..., -4.6...], [3.4..., 77.9...]]], "type": "MultiLineString"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/20b6522d8242ede00bb3>`__. General information about MultiLineString can be found in `Section 2.1.5`_ and `Appendix A: MultiLineString`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.5: http://www.geojson.org/geojson-spec.html#multilinestring + .. _Appendix A\: MultiLineString: http://www.geojson.org/geojson-spec.html#id6 + + Polygon + ~~~~~~~ + + .. code:: python + + >>> from geojson import Polygon + + >>> # no hole within polygon + >>> Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]]) # doctest: +ELLIPSIS + {"coordinates": [[[2.3..., 57.32...], [23.19..., -20.2...], [-120.4..., 19.1...]]], "type": "Polygon"} + + >>> # hole within polygon + >>> Polygon([ + ... [(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)], + ... [(-5.21, 23.51), (15.21, -10.81), (-20.51, 1.51), (-5.21, 23.51)] + ... ]) # doctest: +ELLIPSIS + {"coordinates": [[[2.3..., 57.32...], [23.19..., -20.2...], [-120.4..., 19.1...]], [[-5.2..., 23.5...], [15.2..., -10.8...], [-20.5..., 1.5...], [-5.2..., 23.5...]]], "type": "Polygon"} + + Visualize the results of the example above `here <https://gist.github.com/frewsxcv/b2f5c31c10e399a63679>`__. General information about Polygon can be found in `Section 2.1.6`_ and `Appendix A: Polygon`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.6: http://www.geojson.org/geojson-spec.html#polygon + .. _Appendix A\: Polygon: http://www.geojson.org/geojson-spec.html#id4 + + MultiPolygon + ~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import MultiPolygon + + >>> MultiPolygon([ + ... ([(3.78, 9.28), (-130.91, 1.52), (35.12, 72.234), (3.78, 9.28)],), + ... ([(23.18, -34.29), (-1.31, -4.61), (3.41, 77.91), (23.18, -34.29)],) + ... ]) # doctest: +ELLIPSIS + {"coordinates": [[[[3.7..., 9.2...], [-130.9..., 1.5...], [35.1..., 72.23...]]], [[[23.1..., -34.2...], [-1.3..., -4.6...], [3.4..., 77.9...]]]], "type": "MultiPolygon"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/e0388485e28392870b74>`__. General information about MultiPolygon can be found in `Section 2.1.7`_ and `Appendix A: MultiPolygon`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.7: http://www.geojson.org/geojson-spec.html#multipolygon + .. _Appendix A\: MultiPolygon: http://www.geojson.org/geojson-spec.html#id7 + + GeometryCollection + ~~~~~~~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import GeometryCollection, Point, LineString + + >>> my_point = Point((23.532, -63.12)) + + >>> my_line = LineString([(-152.62, 51.21), (5.21, 10.69)]) + + >>> GeometryCollection([my_point, my_line]) # doctest: +ELLIPSIS + {"geometries": [{"coordinates": [23.53..., -63.1...], "type": "Point"}, {"coordinates": [[-152.6..., 51.2...], [5.2..., 10.6...]], "type": "LineString"}], "type": "GeometryCollection"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/6ec8422e97d338a101b0>`__. General information about GeometryCollection can be found in `Section 2.1.8`_ and `Appendix A: GeometryCollection`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.8: http://www.geojson.org/geojson-spec.html#geometry-collection + .. _Appendix A\: GeometryCollection: http://www.geojson.org/geojson-spec.html#geometrycollection + + Feature + ~~~~~~~ + + .. code:: python + + >>> from geojson import Feature, Point + + >>> my_point = Point((-3.68, 40.41)) + + >>> Feature(geometry=my_point) # doctest: +ELLIPSIS + {"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "id": null, "properties": {}, "type": "Feature"} + + >>> Feature(geometry=my_point, properties={"country": "Spain"}) # doctest: +ELLIPSIS + {"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "id": null, "properties": {"country": "Spain"}, "type": "Feature"} + + >>> Feature(geometry=my_point, id=27) # doctest: +ELLIPSIS + {"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "id": 27, "properties": {}, "type": "Feature"} + + Visualize the results of the examples above `here <https://gist.github.com/frewsxcv/4488d30209d22685c075>`__. General information about Feature can be found in `Section 2.2`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.2: http://geojson.org/geojson-spec.html#feature-objects + + FeatureCollection + ~~~~~~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import Feature, Point, FeatureCollection + + >>> my_feature = Feature(geometry=Point((1.6432, -19.123))) + + >>> my_other_feature = Feature(geometry=Point((-80.234, -22.532))) + + >>> FeatureCollection([my_feature, my_other_feature]) # doctest: +ELLIPSIS + {"features": [{"geometry": {"coordinates": [1.643..., -19.12...], "type": "Point"}, "id": null, "properties": {}, "type": "Feature"}, {"geometry": {"coordinates": [-80.23..., -22.53...], "type": "Point"}, "id": null, "properties": {}, "type": "Feature"}], "type": "FeatureCollection"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/34513be6fb492771ef7b>`__. General information about FeatureCollection can be found in `Section 2.3`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.3: http://geojson.org/geojson-spec.html#feature-collection-objects + + GeoJSON encoding/decoding + ------------------------- + + All of the GeoJSON Objects implemented in this library can be encoded and decoded into raw GeoJSON with the ``geojson.dump``, ``geojson.dumps``, ``geojson.load``, and ``geojson.loads`` functions. + + .. code:: python + + >>> import geojson + + >>> my_point = geojson.Point((43.24, -1.532)) + + >>> my_point # doctest: +ELLIPSIS + {"coordinates": [43.2..., -1.53...], "type": "Point"} + + >>> dump = geojson.dumps(my_point, sort_keys=True) + + >>> dump # doctest: +ELLIPSIS + '{"coordinates": [43.2..., -1.53...], "type": "Point"}' + + >>> geojson.loads(dump) # doctest: +ELLIPSIS + {"coordinates": [43.2..., -1.53...], "type": "Point"} + + Custom classes + ~~~~~~~~~~~~~~ + + This encoding/decoding functionality shown in the previous can be extended to custom classes using the interface described by the `__geo_interface__ Specification`_. + + .. code:: python + + >>> import geojson + + >>> class MyPoint(): + ... def __init__(self, x, y): + ... self.x = x + ... self.y = y + ... + ... @property + ... def __geo_interface__(self): + ... return {'type': 'Point', 'coordinates': (self.x, self.y)} + + >>> point_instance = MyPoint(52.235, -19.234) + + >>> geojson.dumps(point_instance, sort_keys=True) # doctest: +ELLIPSIS + '{"coordinates": [52.23..., -19.23...], "type": "Point"}' + + Helpful utilities + ----------------- + + coords + ~~~~~~ + + :code:`geojson.utils.coords` yields all coordinate tuples from a geometry or feature object. + + .. code:: python + + >>> import geojson + + >>> my_line = LineString([(-152.62, 51.21), (5.21, 10.69)]) + + >>> my_feature = geojson.Feature(geometry=my_line) + + >>> list(geojson.utils.coords(my_feature)) # doctest: +ELLIPSIS + [(-152.62..., 51.21...), (5.21..., 10.69...)] + + map_coords + ~~~~~~~~~~ + + :code:`geojson.utils.map_coords` maps a function over all coordinate tuples and returns a geometry of the same type. Useful for translating a geometry in space or flipping coordinate order. + + .. code:: python + + >>> import geojson + + >>> new_point = geojson.utils.map_coords(lambda x: x/2, geojson.Point((-115.81, 37.24))) + + >>> geojson.dumps(new_point, sort_keys=True) # doctest: +ELLIPSIS + '{"coordinates": [-57.905..., 18.62...], "type": "Point"}' + + Development + ----------- + + To build this project, run :code:`python setup.py build`. To run the unit tests, run :code:`python setup.py test`. + + Credits + ------- + + * Sean Gillies <sgill...@frii.com> + * Matthew Russell <m...@sanoodi.com> + * Corey Farwell <cor...@rwell.org> + + + .. _GeoJSON: http://geojson.org/ + .. _The GeoJSON Format Specification: http://www.geojson.org/geojson-spec.html + .. _\_\_geo\_interface\_\_ Specification: https://gist.github.com/sgillies/2217756 + +Keywords: gis geography json +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: Science/Research +Classifier: License :: OSI Approved :: BSD License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.2 +Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Topic :: Scientific/Engineering :: GIS diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/SOURCES.txt b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/SOURCES.txt new file mode 100644 index 0000000..5196764 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/SOURCES.txt @@ -0,0 +1,28 @@ +CHANGELOG.rst +LICENSE.rst +MANIFEST.in +README.rst +setup.py +geojson/__init__.py +geojson/base.py +geojson/codec.py +geojson/crs.py +geojson/examples.py +geojson/factory.py +geojson/feature.py +geojson/geometry.py +geojson/mapping.py +geojson/utils.py +geojson.egg-info/PKG-INFO +geojson.egg-info/SOURCES.txt +geojson.egg-info/dependency_links.txt +geojson.egg-info/requires.txt +geojson.egg-info/top_level.txt +tests/__init__.py +tests/test_base.py +tests/test_coords.py +tests/test_crs.py +tests/test_features.py +tests/test_geo_interface.py +tests/test_null_geometries.py +tests/test_strict_json.py \ No newline at end of file diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/dependency_links.txt b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/requires.txt b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/requires.txt new file mode 100644 index 0000000..49fe098 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/requires.txt @@ -0,0 +1 @@ +setuptools diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/top_level.txt b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/top_level.txt new file mode 100644 index 0000000..e116fb3 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson-1.0.9.egg-info/top_level.txt @@ -0,0 +1 @@ +geojson diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/__init__.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/__init__.py new file mode 100644 index 0000000..4de7ca0 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/__init__.py @@ -0,0 +1,7 @@ +from geojson.codec import dump, dumps, load, loads, GeoJSONEncoder +from geojson.utils import coords, map_coords +from geojson.geometry import Point, LineString, Polygon +from geojson.geometry import MultiLineString, MultiPoint, MultiPolygon +from geojson.geometry import GeometryCollection +from geojson.feature import Feature, FeatureCollection +from geojson.base import GeoJSON diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/base.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/base.py new file mode 100644 index 0000000..1bd69dd --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/base.py @@ -0,0 +1,86 @@ +import geojson +from geojson.mapping import to_mapping + + +class GeoJSON(dict): + + def __init__(self, iterable=(), **extra): + super(GeoJSON, self).__init__(iterable) + self["type"] = getattr(self, "type", type(self).__name__) + self.update(extra) + + def __repr__(self): + return geojson.dumps(self, sort_keys=True) + + __str__ = __repr__ + + def __setattr__(self, name, value): + """ + Permit dictionary items to be set like object attributes + """ + self[name] = value + + def __getattr__(self, name): + """ + Permit dictionary items to be retrieved like object attributes + """ + try: + return self[name] + except KeyError: + raise AttributeError(name) + + def __delattr__(self, name): + """ + Permit dictionary items to be deleted like object attributes + """ + del self[name] + + @property + def __geo_interface__(self): + if self.type != "GeoJSON": + return self + + @classmethod + def to_instance(cls, ob, default=None, strict=False): + """Encode a GeoJSON dict into an GeoJSON object. + + Assumes the caller knows that the dict should satisfy a GeoJSON type. + """ + if ob is None and default is not None: + instance = default() + elif isinstance(ob, GeoJSON): + instance = ob + else: + mapping = to_mapping(ob) + d = {} + for k in mapping: + try: + str_key = str(k) + except (UnicodeEncodeError): + str_key = unicode(k) + d[str_key] = mapping[k] + try: + type_ = d.pop("type") + try: + type_ = str(type_) + except (UnicodeEncodeError): + # If the type contains non-ascii characters, we can assume + # it's not a valid GeoJSON type + raise AttributeError( + unicode("{0} is not a GeoJSON type").format( + unicode(type_))) + geojson_factory = getattr(geojson.factory, type_) + if not issubclass(geojson_factory, GeoJSON): + raise TypeError("""\ + Not a valid GeoJSON type: + %r (geojson_factory: %r, cls: %r) + """ % (type_, geojson_factory, cls)) + instance = geojson_factory(**d) + except (AttributeError, KeyError) as invalid: + if not strict: + instance = ob + else: + msg = "Cannot coerce %r into a valid GeoJSON structure: %s" + msg %= (ob, invalid) + raise ValueError(msg) + return instance diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/codec.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/codec.py new file mode 100644 index 0000000..eb8808b --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/codec.py @@ -0,0 +1,59 @@ +try: + import simplejson as json +except ImportError: + import json + +import geojson +import geojson.factory +from geojson.mapping import to_mapping + + +class GeoJSONEncoder(json.JSONEncoder): + + def default(self, obj): + return geojson.factory.GeoJSON.to_instance(obj) + + +# Wrap the functions from json, providing encoder, decoders, and +# object creation hooks. +# Here the defaults are set to only permit valid JSON as per RFC 4267 + +def _enforce_strict_numbers(obj): + if isinstance(obj, (int, float)): + raise ValueError("Number %r is not JSON compliant" % obj) + + +def dump(obj, fp, cls=GeoJSONEncoder, allow_nan=False, **kwargs): + return json.dump(to_mapping(obj), + fp, cls=cls, allow_nan=allow_nan, **kwargs) + + +def dumps(obj, cls=GeoJSONEncoder, allow_nan=False, **kwargs): + return json.dumps(to_mapping(obj), + cls=cls, allow_nan=allow_nan, **kwargs) + + +def load(fp, + cls=json.JSONDecoder, + parse_constant=_enforce_strict_numbers, + object_hook=geojson.base.GeoJSON.to_instance, + **kwargs): + return json.load(fp, + cls=cls, object_hook=object_hook, + parse_constant=parse_constant, + **kwargs) + + +def loads(s, + cls=json.JSONDecoder, + parse_constant=_enforce_strict_numbers, + object_hook=geojson.base.GeoJSON.to_instance, + **kwargs): + return json.loads(s, + cls=cls, object_hook=object_hook, + parse_constant=parse_constant, + **kwargs) + + +# Backwards compatibility +PyGFPEncoder = GeoJSONEncoder diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/crs.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/crs.py new file mode 100644 index 0000000..792adec --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/crs.py @@ -0,0 +1,30 @@ +from geojson.base import GeoJSON + + +class CoordinateReferenceSystem(GeoJSON): + + def __init__(self, properties=None, **extra): + super(CoordinateReferenceSystem, self).__init__(**extra) + self["properties"] = properties or {} + + +class Named(CoordinateReferenceSystem): + + def __init__(self, properties=None, **extra): + super(Named, self).__init__(properties=properties, **extra) + self["type"] = "name" + + def __repr__(self): + return super(Named, self).__repr__() + + +class Linked(CoordinateReferenceSystem): + + def __init__(self, properties=None, **extra): + super(Linked, self).__init__(properties=properties, **extra) + self["type"] = "link" + + +class Default(object): + + """GeoJSON default, long/lat WGS84, is not serialized.""" diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/examples.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/examples.py new file mode 100644 index 0000000..81dd88d --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/examples.py @@ -0,0 +1,45 @@ + +class SimpleWebFeature(object): + + """ + A simple, Atom-ish, single geometry (WGS84) GIS feature. + """ + + def __init__(self, id=None, geometry=None, title=None, summary=None, + link=None): + """Initialize.""" + self.id = id + self.geometry = geometry + self.properties = {} + self.properties['title'] = title + self.properties['summary'] = summary + self.properties['link'] = link + + def as_dict(self): + return { + "type": "Feature", + "id": self.id, + "properties": self.properties, + "geometry": self.geometry + } + + __geo_interface__ = property(as_dict) + + +def createSimpleWebFeature(o): + """Create an instance of SimpleWebFeature from a dict, o. If o does not + match a Python feature object, simply return o. This function serves as a + json decoder hook. See coding.load().""" + try: + id = o['id'] + g = o['geometry'] + p = o['properties'] + return SimpleWebFeature(str(id), { + 'type': str(g.get('type')), + 'coordinates': g.get('coordinates', [])}, + title=p.get('title'), + summary=p.get('summary'), + link=str(p.get('link'))) + except (KeyError, TypeError): + pass + return o diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/factory.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/factory.py new file mode 100644 index 0000000..aa79dd9 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/factory.py @@ -0,0 +1,9 @@ +from geojson.geometry import Point, LineString, Polygon +from geojson.geometry import MultiLineString, MultiPoint, MultiPolygon +from geojson.geometry import GeometryCollection +from geojson.feature import Feature, FeatureCollection +from geojson.base import GeoJSON +from geojson.crs import Named, Linked + +name = Named +link = Linked diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/feature.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/feature.py new file mode 100644 index 0000000..48db6c0 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/feature.py @@ -0,0 +1,29 @@ +""" +SimpleWebFeature is a working example of a class that satisfies the Python geo +interface. +""" + +from geojson.base import GeoJSON + + +class Feature(GeoJSON): + + """A (WGS84) GIS Feature.""" + + def __init__(self, id=None, geometry=None, properties=None, **extra): + super(Feature, self).__init__(**extra) + self["id"] = id + if geometry: + self["geometry"] = self.to_instance(geometry, strict=True) + else: + self["geometry"] = None + self["properties"] = properties or {} + + +class FeatureCollection(GeoJSON): + + """A collection of Features.""" + + def __init__(self, features, **extra): + super(FeatureCollection, self).__init__(**extra) + self["features"] = features diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/geometry.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/geometry.py new file mode 100644 index 0000000..22ea24a --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/geometry.py @@ -0,0 +1,62 @@ +from decimal import Decimal + +from geojson.base import GeoJSON + + +class Geometry(GeoJSON): + + """A (WGS84) GIS geometry.""" + + def __init__(self, coordinates=None, crs=None, **extra): + super(Geometry, self).__init__(**extra) + self["coordinates"] = coordinates or [] + self.clean_coordinates(self["coordinates"]) + if crs: + self["crs"] = self.to_instance(crs, strict=True) + + @classmethod + def clean_coordinates(cls, coords): + for coord in coords: + if isinstance(coord, (list, tuple)): + cls.clean_coordinates(coord) + elif not isinstance(coord, (float, int, Decimal)): + raise ValueError("%r is not JSON compliant number" % coord) + + +class GeometryCollection(GeoJSON): + + """A collection of (WGS84) GIS geometries.""" + + def __init__(self, geometries=None, **extra): + super(GeometryCollection, self).__init__(**extra) + self["geometries"] = geometries or [] + + +# Marker classes. + +class Point(Geometry): + pass + + +class MultiPoint(Geometry): + pass + + +class LineString(MultiPoint): + pass + + +class MultiLineString(Geometry): + pass + + +class Polygon(Geometry): + pass + + +class MultiPolygon(Geometry): + pass + + +class Default(object): + """GeoJSON default.""" diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/mapping.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/mapping.py new file mode 100644 index 0000000..fb24c33 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/mapping.py @@ -0,0 +1,32 @@ +from collections import MutableMapping +try: + import simplejson as json +except ImportError: + import json + +import geojson + + +mapping_base = MutableMapping + + +GEO_INTERFACE_MARKER = "__geo_interface__" + + +def is_mapping(obj): + return isinstance(obj, MutableMapping) + + +def to_mapping(obj): + mapping = getattr(obj, GEO_INTERFACE_MARKER, None) + + if mapping is not None: + return mapping + + if is_mapping(obj): + return obj + + if isinstance(obj, geojson.GeoJSON): + return dict(obj) + + return json.loads(json.dumps(obj)) diff --git a/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/utils.py b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/utils.py new file mode 100644 index 0000000..068b1c3 --- /dev/null +++ b/debian/python-python-geojson/usr/lib/python2.7/dist-packages/geojson/utils.py @@ -0,0 +1,35 @@ +"""Coordinate utility functions.""" + +def coords(obj): + """Yield all coordinate coordinate tuples from a geometry or feature.""" + if isinstance(obj, (tuple, list)): + coordinates = obj + elif 'geometry' in obj: + coordinates = obj['geometry']['coordinates'] + else: + coordinates = obj.get('coordinates', obj) + for e in coordinates: + if isinstance(e, (float, int)): + yield tuple(coordinates) + break + for f in coords(e): + yield f + +def map_coords(func, obj): + """Return coordinates, mapped pair-wise using the provided function.""" + if obj['type'] == 'Point': + coordinates = tuple(map(func, obj['coordinates'])) + elif obj['type'] in ['LineString', 'MultiPoint']: + coordinates = [tuple(map(func, c)) for c in obj['coordinates']] + elif obj['type'] in ['MultiLineString', 'Polygon']: + coordinates = [[ + tuple(map(func, c)) for c in curve] + for curve in obj['coordinates']] + elif obj['type'] == 'MultiPolygon': + coordinates = [[[ + tuple(map(func, c)) for c in curve] + for curve in part] + for part in obj['coordinates']] + else: + raise ValueError("Invalid geometry object %s" % repr(obj)) + return {'type': obj['type'], 'coordinates': coordinates} diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/PKG-INFO b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/PKG-INFO new file mode 100644 index 0000000..26f69ee --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/PKG-INFO @@ -0,0 +1,322 @@ +Metadata-Version: 1.1 +Name: geojson +Version: 1.0.9 +Summary: Python bindings and utilities for GeoJSON +Home-page: https://github.com/frewsxcv/python-geojson +Author: Corey Farwell +Author-email: cor...@rwell.org +License: BSD +Description: python-geojson + ============== + + .. image:: https://travis-ci.org/frewsxcv/python-geojson.png?branch=master + :target: https://travis-ci.org/frewsxcv/python-geojson + .. image:: https://coveralls.io/repos/frewsxcv/python-geojson/badge.png + :target: https://coveralls.io/r/frewsxcv/python-geojson + + This library contains: + + - Functions for encoding and decoding GeoJSON_ formatted data + - Classes for all GeoJSON Objects + - An implementation of the Python `__geo_interface__ Specification`_ + + **Table of Contents** + + .. contents:: + :backlinks: none + :local: + + Installation + ------------ + + python-geojson is compatible with Python 2.6, 2.7, 3.2, 3.3, and 3.4. It is listed on `PyPi as 'geojson'`_. The recommended way to install is via pip_: + + .. code:: + + pip install geojson + + .. _PyPi as 'geojson': https://pypi.python.org/pypi/geojson/ + .. _pip: http://www.pip-installer.org + + GeoJSON Objects + --------------- + + This library implements all the `GeoJSON Objects`_ described in `The GeoJSON Format Specification`_. + + .. _GeoJSON Objects: http://www.geojson.org/geojson-spec.html#geojson-objects + + Point + ~~~~~ + + .. code:: python + + >>> from geojson import Point + + >>> Point((-115.81, 37.24)) # doctest: +ELLIPSIS + {"coordinates": [-115.8..., 37.2...], "type": "Point"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/b5768a857f5598e405fa>`__. General information about Point can be found in `Section 2.1.2`_ and `Appendix A: Point`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.2: http://www.geojson.org/geojson-spec.html#point + .. _Appendix A\: Point: http://www.geojson.org/geojson-spec.html#id2 + + MultiPoint + ~~~~~~~~~~ + + .. code:: python + + >>> from geojson import MultiPoint + + >>> MultiPoint([(-155.52, 19.61), (-156.22, 20.74), (-157.97, 21.46)]) # doctest: +ELLIPSIS + {"coordinates": [[-155.5..., 19.6...], [-156.2..., 20.7...], [-157.9..., 21.4...]], "type": "MultiPoint"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/be02025c1eb3aa2040ee>`__. General information about MultiPoint can be found in `Section 2.1.3`_ and `Appendix A: MultiPoint`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.3: http://www.geojson.org/geojson-spec.html#multipoint + .. _Appendix A\: MultiPoint: http://www.geojson.org/geojson-spec.html#id5 + + + LineString + ~~~~~~~~~~ + + .. code:: python + + >>> from geojson import LineString + + >>> LineString([(8.919, 44.4074), (8.923, 44.4075)]) # doctest: +ELLIPSIS + {"coordinates": [[8.91..., 44.407...], [8.92..., 44.407...]], "type": "LineString"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/758563182ca49ce8e8bb>`__. General information about LineString can be found in `Section 2.1.4`_ and `Appendix A: LineString`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.4: http://www.geojson.org/geojson-spec.html#linestring + .. _Appendix A\: LineString: http://www.geojson.org/geojson-spec.html#id3 + + MultiLineString + ~~~~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import MultiLineString + + >>> MultiLineString([ + ... [(3.75, 9.25), (-130.95, 1.52)], + ... [(23.15, -34.25), (-1.35, -4.65), (3.45, 77.95)] + ... ]) # doctest: +ELLIPSIS + {"coordinates": [[[3.7..., 9.2...], [-130.9..., 1.52...]], [[23.1..., -34.2...], [-1.3..., -4.6...], [3.4..., 77.9...]]], "type": "MultiLineString"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/20b6522d8242ede00bb3>`__. General information about MultiLineString can be found in `Section 2.1.5`_ and `Appendix A: MultiLineString`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.5: http://www.geojson.org/geojson-spec.html#multilinestring + .. _Appendix A\: MultiLineString: http://www.geojson.org/geojson-spec.html#id6 + + Polygon + ~~~~~~~ + + .. code:: python + + >>> from geojson import Polygon + + >>> # no hole within polygon + >>> Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]]) # doctest: +ELLIPSIS + {"coordinates": [[[2.3..., 57.32...], [23.19..., -20.2...], [-120.4..., 19.1...]]], "type": "Polygon"} + + >>> # hole within polygon + >>> Polygon([ + ... [(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)], + ... [(-5.21, 23.51), (15.21, -10.81), (-20.51, 1.51), (-5.21, 23.51)] + ... ]) # doctest: +ELLIPSIS + {"coordinates": [[[2.3..., 57.32...], [23.19..., -20.2...], [-120.4..., 19.1...]], [[-5.2..., 23.5...], [15.2..., -10.8...], [-20.5..., 1.5...], [-5.2..., 23.5...]]], "type": "Polygon"} + + Visualize the results of the example above `here <https://gist.github.com/frewsxcv/b2f5c31c10e399a63679>`__. General information about Polygon can be found in `Section 2.1.6`_ and `Appendix A: Polygon`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.6: http://www.geojson.org/geojson-spec.html#polygon + .. _Appendix A\: Polygon: http://www.geojson.org/geojson-spec.html#id4 + + MultiPolygon + ~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import MultiPolygon + + >>> MultiPolygon([ + ... ([(3.78, 9.28), (-130.91, 1.52), (35.12, 72.234), (3.78, 9.28)],), + ... ([(23.18, -34.29), (-1.31, -4.61), (3.41, 77.91), (23.18, -34.29)],) + ... ]) # doctest: +ELLIPSIS + {"coordinates": [[[[3.7..., 9.2...], [-130.9..., 1.5...], [35.1..., 72.23...]]], [[[23.1..., -34.2...], [-1.3..., -4.6...], [3.4..., 77.9...]]]], "type": "MultiPolygon"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/e0388485e28392870b74>`__. General information about MultiPolygon can be found in `Section 2.1.7`_ and `Appendix A: MultiPolygon`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.7: http://www.geojson.org/geojson-spec.html#multipolygon + .. _Appendix A\: MultiPolygon: http://www.geojson.org/geojson-spec.html#id7 + + GeometryCollection + ~~~~~~~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import GeometryCollection, Point, LineString + + >>> my_point = Point((23.532, -63.12)) + + >>> my_line = LineString([(-152.62, 51.21), (5.21, 10.69)]) + + >>> GeometryCollection([my_point, my_line]) # doctest: +ELLIPSIS + {"geometries": [{"coordinates": [23.53..., -63.1...], "type": "Point"}, {"coordinates": [[-152.6..., 51.2...], [5.2..., 10.6...]], "type": "LineString"}], "type": "GeometryCollection"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/6ec8422e97d338a101b0>`__. General information about GeometryCollection can be found in `Section 2.1.8`_ and `Appendix A: GeometryCollection`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.1.8: http://www.geojson.org/geojson-spec.html#geometry-collection + .. _Appendix A\: GeometryCollection: http://www.geojson.org/geojson-spec.html#geometrycollection + + Feature + ~~~~~~~ + + .. code:: python + + >>> from geojson import Feature, Point + + >>> my_point = Point((-3.68, 40.41)) + + >>> Feature(geometry=my_point) # doctest: +ELLIPSIS + {"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "id": null, "properties": {}, "type": "Feature"} + + >>> Feature(geometry=my_point, properties={"country": "Spain"}) # doctest: +ELLIPSIS + {"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "id": null, "properties": {"country": "Spain"}, "type": "Feature"} + + >>> Feature(geometry=my_point, id=27) # doctest: +ELLIPSIS + {"geometry": {"coordinates": [-3.68..., 40.4...], "type": "Point"}, "id": 27, "properties": {}, "type": "Feature"} + + Visualize the results of the examples above `here <https://gist.github.com/frewsxcv/4488d30209d22685c075>`__. General information about Feature can be found in `Section 2.2`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.2: http://geojson.org/geojson-spec.html#feature-objects + + FeatureCollection + ~~~~~~~~~~~~~~~~~ + + .. code:: python + + >>> from geojson import Feature, Point, FeatureCollection + + >>> my_feature = Feature(geometry=Point((1.6432, -19.123))) + + >>> my_other_feature = Feature(geometry=Point((-80.234, -22.532))) + + >>> FeatureCollection([my_feature, my_other_feature]) # doctest: +ELLIPSIS + {"features": [{"geometry": {"coordinates": [1.643..., -19.12...], "type": "Point"}, "id": null, "properties": {}, "type": "Feature"}, {"geometry": {"coordinates": [-80.23..., -22.53...], "type": "Point"}, "id": null, "properties": {}, "type": "Feature"}], "type": "FeatureCollection"} + + Visualize the result of the example above `here <https://gist.github.com/frewsxcv/34513be6fb492771ef7b>`__. General information about FeatureCollection can be found in `Section 2.3`_ within `The GeoJSON Format Specification`_. + + .. _Section 2.3: http://geojson.org/geojson-spec.html#feature-collection-objects + + GeoJSON encoding/decoding + ------------------------- + + All of the GeoJSON Objects implemented in this library can be encoded and decoded into raw GeoJSON with the ``geojson.dump``, ``geojson.dumps``, ``geojson.load``, and ``geojson.loads`` functions. + + .. code:: python + + >>> import geojson + + >>> my_point = geojson.Point((43.24, -1.532)) + + >>> my_point # doctest: +ELLIPSIS + {"coordinates": [43.2..., -1.53...], "type": "Point"} + + >>> dump = geojson.dumps(my_point, sort_keys=True) + + >>> dump # doctest: +ELLIPSIS + '{"coordinates": [43.2..., -1.53...], "type": "Point"}' + + >>> geojson.loads(dump) # doctest: +ELLIPSIS + {"coordinates": [43.2..., -1.53...], "type": "Point"} + + Custom classes + ~~~~~~~~~~~~~~ + + This encoding/decoding functionality shown in the previous can be extended to custom classes using the interface described by the `__geo_interface__ Specification`_. + + .. code:: python + + >>> import geojson + + >>> class MyPoint(): + ... def __init__(self, x, y): + ... self.x = x + ... self.y = y + ... + ... @property + ... def __geo_interface__(self): + ... return {'type': 'Point', 'coordinates': (self.x, self.y)} + + >>> point_instance = MyPoint(52.235, -19.234) + + >>> geojson.dumps(point_instance, sort_keys=True) # doctest: +ELLIPSIS + '{"coordinates": [52.23..., -19.23...], "type": "Point"}' + + Helpful utilities + ----------------- + + coords + ~~~~~~ + + :code:`geojson.utils.coords` yields all coordinate tuples from a geometry or feature object. + + .. code:: python + + >>> import geojson + + >>> my_line = LineString([(-152.62, 51.21), (5.21, 10.69)]) + + >>> my_feature = geojson.Feature(geometry=my_line) + + >>> list(geojson.utils.coords(my_feature)) # doctest: +ELLIPSIS + [(-152.62..., 51.21...), (5.21..., 10.69...)] + + map_coords + ~~~~~~~~~~ + + :code:`geojson.utils.map_coords` maps a function over all coordinate tuples and returns a geometry of the same type. Useful for translating a geometry in space or flipping coordinate order. + + .. code:: python + + >>> import geojson + + >>> new_point = geojson.utils.map_coords(lambda x: x/2, geojson.Point((-115.81, 37.24))) + + >>> geojson.dumps(new_point, sort_keys=True) # doctest: +ELLIPSIS + '{"coordinates": [-57.905..., 18.62...], "type": "Point"}' + + Development + ----------- + + To build this project, run :code:`python setup.py build`. To run the unit tests, run :code:`python setup.py test`. + + Credits + ------- + + * Sean Gillies <sgill...@frii.com> + * Matthew Russell <m...@sanoodi.com> + * Corey Farwell <cor...@rwell.org> + + + .. _GeoJSON: http://geojson.org/ + .. _The GeoJSON Format Specification: http://www.geojson.org/geojson-spec.html + .. _\_\_geo\_interface\_\_ Specification: https://gist.github.com/sgillies/2217756 + +Keywords: gis geography json +Platform: UNKNOWN +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: Intended Audience :: Science/Research +Classifier: License :: OSI Approved :: BSD License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.2 +Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Topic :: Scientific/Engineering :: GIS diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/SOURCES.txt b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/SOURCES.txt new file mode 100644 index 0000000..5196764 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/SOURCES.txt @@ -0,0 +1,28 @@ +CHANGELOG.rst +LICENSE.rst +MANIFEST.in +README.rst +setup.py +geojson/__init__.py +geojson/base.py +geojson/codec.py +geojson/crs.py +geojson/examples.py +geojson/factory.py +geojson/feature.py +geojson/geometry.py +geojson/mapping.py +geojson/utils.py +geojson.egg-info/PKG-INFO +geojson.egg-info/SOURCES.txt +geojson.egg-info/dependency_links.txt +geojson.egg-info/requires.txt +geojson.egg-info/top_level.txt +tests/__init__.py +tests/test_base.py +tests/test_coords.py +tests/test_crs.py +tests/test_features.py +tests/test_geo_interface.py +tests/test_null_geometries.py +tests/test_strict_json.py \ No newline at end of file diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/dependency_links.txt b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/requires.txt b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/requires.txt new file mode 100644 index 0000000..49fe098 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/requires.txt @@ -0,0 +1 @@ +setuptools diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/top_level.txt b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/top_level.txt new file mode 100644 index 0000000..e116fb3 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson-1.0.9.egg-info/top_level.txt @@ -0,0 +1 @@ +geojson diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/__init__.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/__init__.py new file mode 100644 index 0000000..4de7ca0 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/__init__.py @@ -0,0 +1,7 @@ +from geojson.codec import dump, dumps, load, loads, GeoJSONEncoder +from geojson.utils import coords, map_coords +from geojson.geometry import Point, LineString, Polygon +from geojson.geometry import MultiLineString, MultiPoint, MultiPolygon +from geojson.geometry import GeometryCollection +from geojson.feature import Feature, FeatureCollection +from geojson.base import GeoJSON diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/base.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/base.py new file mode 100644 index 0000000..1bd69dd --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/base.py @@ -0,0 +1,86 @@ +import geojson +from geojson.mapping import to_mapping + + +class GeoJSON(dict): + + def __init__(self, iterable=(), **extra): + super(GeoJSON, self).__init__(iterable) + self["type"] = getattr(self, "type", type(self).__name__) + self.update(extra) + + def __repr__(self): + return geojson.dumps(self, sort_keys=True) + + __str__ = __repr__ + + def __setattr__(self, name, value): + """ + Permit dictionary items to be set like object attributes + """ + self[name] = value + + def __getattr__(self, name): + """ + Permit dictionary items to be retrieved like object attributes + """ + try: + return self[name] + except KeyError: + raise AttributeError(name) + + def __delattr__(self, name): + """ + Permit dictionary items to be deleted like object attributes + """ + del self[name] + + @property + def __geo_interface__(self): + if self.type != "GeoJSON": + return self + + @classmethod + def to_instance(cls, ob, default=None, strict=False): + """Encode a GeoJSON dict into an GeoJSON object. + + Assumes the caller knows that the dict should satisfy a GeoJSON type. + """ + if ob is None and default is not None: + instance = default() + elif isinstance(ob, GeoJSON): + instance = ob + else: + mapping = to_mapping(ob) + d = {} + for k in mapping: + try: + str_key = str(k) + except (UnicodeEncodeError): + str_key = unicode(k) + d[str_key] = mapping[k] + try: + type_ = d.pop("type") + try: + type_ = str(type_) + except (UnicodeEncodeError): + # If the type contains non-ascii characters, we can assume + # it's not a valid GeoJSON type + raise AttributeError( + unicode("{0} is not a GeoJSON type").format( + unicode(type_))) + geojson_factory = getattr(geojson.factory, type_) + if not issubclass(geojson_factory, GeoJSON): + raise TypeError("""\ + Not a valid GeoJSON type: + %r (geojson_factory: %r, cls: %r) + """ % (type_, geojson_factory, cls)) + instance = geojson_factory(**d) + except (AttributeError, KeyError) as invalid: + if not strict: + instance = ob + else: + msg = "Cannot coerce %r into a valid GeoJSON structure: %s" + msg %= (ob, invalid) + raise ValueError(msg) + return instance diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/codec.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/codec.py new file mode 100644 index 0000000..eb8808b --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/codec.py @@ -0,0 +1,59 @@ +try: + import simplejson as json +except ImportError: + import json + +import geojson +import geojson.factory +from geojson.mapping import to_mapping + + +class GeoJSONEncoder(json.JSONEncoder): + + def default(self, obj): + return geojson.factory.GeoJSON.to_instance(obj) + + +# Wrap the functions from json, providing encoder, decoders, and +# object creation hooks. +# Here the defaults are set to only permit valid JSON as per RFC 4267 + +def _enforce_strict_numbers(obj): + if isinstance(obj, (int, float)): + raise ValueError("Number %r is not JSON compliant" % obj) + + +def dump(obj, fp, cls=GeoJSONEncoder, allow_nan=False, **kwargs): + return json.dump(to_mapping(obj), + fp, cls=cls, allow_nan=allow_nan, **kwargs) + + +def dumps(obj, cls=GeoJSONEncoder, allow_nan=False, **kwargs): + return json.dumps(to_mapping(obj), + cls=cls, allow_nan=allow_nan, **kwargs) + + +def load(fp, + cls=json.JSONDecoder, + parse_constant=_enforce_strict_numbers, + object_hook=geojson.base.GeoJSON.to_instance, + **kwargs): + return json.load(fp, + cls=cls, object_hook=object_hook, + parse_constant=parse_constant, + **kwargs) + + +def loads(s, + cls=json.JSONDecoder, + parse_constant=_enforce_strict_numbers, + object_hook=geojson.base.GeoJSON.to_instance, + **kwargs): + return json.loads(s, + cls=cls, object_hook=object_hook, + parse_constant=parse_constant, + **kwargs) + + +# Backwards compatibility +PyGFPEncoder = GeoJSONEncoder diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/crs.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/crs.py new file mode 100644 index 0000000..792adec --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/crs.py @@ -0,0 +1,30 @@ +from geojson.base import GeoJSON + + +class CoordinateReferenceSystem(GeoJSON): + + def __init__(self, properties=None, **extra): + super(CoordinateReferenceSystem, self).__init__(**extra) + self["properties"] = properties or {} + + +class Named(CoordinateReferenceSystem): + + def __init__(self, properties=None, **extra): + super(Named, self).__init__(properties=properties, **extra) + self["type"] = "name" + + def __repr__(self): + return super(Named, self).__repr__() + + +class Linked(CoordinateReferenceSystem): + + def __init__(self, properties=None, **extra): + super(Linked, self).__init__(properties=properties, **extra) + self["type"] = "link" + + +class Default(object): + + """GeoJSON default, long/lat WGS84, is not serialized.""" diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/examples.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/examples.py new file mode 100644 index 0000000..81dd88d --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/examples.py @@ -0,0 +1,45 @@ + +class SimpleWebFeature(object): + + """ + A simple, Atom-ish, single geometry (WGS84) GIS feature. + """ + + def __init__(self, id=None, geometry=None, title=None, summary=None, + link=None): + """Initialize.""" + self.id = id + self.geometry = geometry + self.properties = {} + self.properties['title'] = title + self.properties['summary'] = summary + self.properties['link'] = link + + def as_dict(self): + return { + "type": "Feature", + "id": self.id, + "properties": self.properties, + "geometry": self.geometry + } + + __geo_interface__ = property(as_dict) + + +def createSimpleWebFeature(o): + """Create an instance of SimpleWebFeature from a dict, o. If o does not + match a Python feature object, simply return o. This function serves as a + json decoder hook. See coding.load().""" + try: + id = o['id'] + g = o['geometry'] + p = o['properties'] + return SimpleWebFeature(str(id), { + 'type': str(g.get('type')), + 'coordinates': g.get('coordinates', [])}, + title=p.get('title'), + summary=p.get('summary'), + link=str(p.get('link'))) + except (KeyError, TypeError): + pass + return o diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/factory.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/factory.py new file mode 100644 index 0000000..aa79dd9 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/factory.py @@ -0,0 +1,9 @@ +from geojson.geometry import Point, LineString, Polygon +from geojson.geometry import MultiLineString, MultiPoint, MultiPolygon +from geojson.geometry import GeometryCollection +from geojson.feature import Feature, FeatureCollection +from geojson.base import GeoJSON +from geojson.crs import Named, Linked + +name = Named +link = Linked diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/feature.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/feature.py new file mode 100644 index 0000000..48db6c0 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/feature.py @@ -0,0 +1,29 @@ +""" +SimpleWebFeature is a working example of a class that satisfies the Python geo +interface. +""" + +from geojson.base import GeoJSON + + +class Feature(GeoJSON): + + """A (WGS84) GIS Feature.""" + + def __init__(self, id=None, geometry=None, properties=None, **extra): + super(Feature, self).__init__(**extra) + self["id"] = id + if geometry: + self["geometry"] = self.to_instance(geometry, strict=True) + else: + self["geometry"] = None + self["properties"] = properties or {} + + +class FeatureCollection(GeoJSON): + + """A collection of Features.""" + + def __init__(self, features, **extra): + super(FeatureCollection, self).__init__(**extra) + self["features"] = features diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/geometry.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/geometry.py new file mode 100644 index 0000000..22ea24a --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/geometry.py @@ -0,0 +1,62 @@ +from decimal import Decimal + +from geojson.base import GeoJSON + + +class Geometry(GeoJSON): + + """A (WGS84) GIS geometry.""" + + def __init__(self, coordinates=None, crs=None, **extra): + super(Geometry, self).__init__(**extra) + self["coordinates"] = coordinates or [] + self.clean_coordinates(self["coordinates"]) + if crs: + self["crs"] = self.to_instance(crs, strict=True) + + @classmethod + def clean_coordinates(cls, coords): + for coord in coords: + if isinstance(coord, (list, tuple)): + cls.clean_coordinates(coord) + elif not isinstance(coord, (float, int, Decimal)): + raise ValueError("%r is not JSON compliant number" % coord) + + +class GeometryCollection(GeoJSON): + + """A collection of (WGS84) GIS geometries.""" + + def __init__(self, geometries=None, **extra): + super(GeometryCollection, self).__init__(**extra) + self["geometries"] = geometries or [] + + +# Marker classes. + +class Point(Geometry): + pass + + +class MultiPoint(Geometry): + pass + + +class LineString(MultiPoint): + pass + + +class MultiLineString(Geometry): + pass + + +class Polygon(Geometry): + pass + + +class MultiPolygon(Geometry): + pass + + +class Default(object): + """GeoJSON default.""" diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/mapping.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/mapping.py new file mode 100644 index 0000000..fb24c33 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/mapping.py @@ -0,0 +1,32 @@ +from collections import MutableMapping +try: + import simplejson as json +except ImportError: + import json + +import geojson + + +mapping_base = MutableMapping + + +GEO_INTERFACE_MARKER = "__geo_interface__" + + +def is_mapping(obj): + return isinstance(obj, MutableMapping) + + +def to_mapping(obj): + mapping = getattr(obj, GEO_INTERFACE_MARKER, None) + + if mapping is not None: + return mapping + + if is_mapping(obj): + return obj + + if isinstance(obj, geojson.GeoJSON): + return dict(obj) + + return json.loads(json.dumps(obj)) diff --git a/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/utils.py b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/utils.py new file mode 100644 index 0000000..068b1c3 --- /dev/null +++ b/debian/python3-python-geojson/usr/lib/python3.4/dist-packages/geojson/utils.py @@ -0,0 +1,35 @@ +"""Coordinate utility functions.""" + +def coords(obj): + """Yield all coordinate coordinate tuples from a geometry or feature.""" + if isinstance(obj, (tuple, list)): + coordinates = obj + elif 'geometry' in obj: + coordinates = obj['geometry']['coordinates'] + else: + coordinates = obj.get('coordinates', obj) + for e in coordinates: + if isinstance(e, (float, int)): + yield tuple(coordinates) + break + for f in coords(e): + yield f + +def map_coords(func, obj): + """Return coordinates, mapped pair-wise using the provided function.""" + if obj['type'] == 'Point': + coordinates = tuple(map(func, obj['coordinates'])) + elif obj['type'] in ['LineString', 'MultiPoint']: + coordinates = [tuple(map(func, c)) for c in obj['coordinates']] + elif obj['type'] in ['MultiLineString', 'Polygon']: + coordinates = [[ + tuple(map(func, c)) for c in curve] + for curve in obj['coordinates']] + elif obj['type'] == 'MultiPolygon': + coordinates = [[[ + tuple(map(func, c)) for c in curve] + for curve in part] + for part in obj['coordinates']] + else: + raise ValueError("Invalid geometry object %s" % repr(obj)) + return {'type': obj['type'], 'coordinates': coordinates} diff --git a/debian/rules b/debian/rules index cf34e20..fb56e05 100755 --- a/debian/rules +++ b/debian/rules @@ -1,9 +1,7 @@ #!/usr/bin/make -f # -*- makefile -*- -export PYBUILD_NAME=python-geojson +export PYBUILD_NAME=geojson %: - dh $@ --with python2 --buildsystem pybuild - - + dh $@ --with python2,python3 --buildsystem pybuild -- 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