jazzband / geojson

Python bindings and utilities for GeoJSON
https://pypi.python.org/pypi/geojson/
BSD 3-Clause "New" or "Revised" License
918 stars 122 forks source link

Fixed readme documentation #5

Closed alexlouden closed 11 years ago

alexlouden commented 11 years ago

Updated from text description to markdown

sgillies commented 11 years ago

First, the geojson package is no longer in development. Second, I'm -1 on Markdown because PyPI prefers RestructuredText. This pull request also breaks setup.py.

Are you using geojson in production anywhere? Does it do anything for you that Python's json doesn't?

alexlouden commented 11 years ago

Hi Sean,

I was under the impression that geojson was the recommended method of JSON serialising Shapely geometries. (From your blog - http://sgillies.net/blog/478/shapely-geometries-for-python/)

I've used it in a prototype, but not in production yet. I'm happy to fix setup.py (oops, sorry!), and use .rst instead. I could also set up Travis CI for unit testing to ensure future pull requests don't break anything else.

Thanks for your response and for Shapely, deacartes and geojson - these packages have saved me a great deal of time!

sgillies commented 11 years ago

Today, I think the best way to serialize Shapely geometries is this:

>>> import json
>>> from shapely.geometry import Point, shape, mapping
>>> pt1 = Point(-105, 40)
>>> pt2 = shape(json.loads(json.dumps(mapping(pt))))
>>> pt1.equals(pt2)
True

mapping() makes a mapping from a geometry and shape() makes a geometry from a mapping. Sort of like dumps and loads.

The geojson package was originally designed to be a reference implementation of the GeoJSON format. It took on a life of its own for a while, but is mostly obsolete now.

alexlouden commented 11 years ago

Ah okay, I'll use mapping() instead. If it's obsolete may I suggest that a note is added to the documentation?

Cheers!

alexlouden commented 11 years ago

I ended up creating a custom JSONEncoder and Decoder, so that I could use Shapely geometries in a larger data structure - see https://gist.github.com/alexlouden/5385305#file-shapely_json-py

frewsxcv commented 11 years ago

Is there any reason why this library should cease to exist even if Shapely exists? I like the simplicity of this library and can offer to contribute in improving the documentation

sgillies commented 11 years ago

@frewsxcv I'm going to close this particular issue, but please do send another for documentation fixes and then we should talk about making you a maintainer, because this package will need a new one if it's to live on.

frewsxcv commented 11 years ago

@sgillies Any change I could get involved in keeping this project alive / becoming a maintainer?