CityofSantaMonica / mds-provider

Python tools for working with MDS Provider data
https://github.com/openmobilityfoundation/mobility-data-specification
MIT License
18 stars 20 forks source link

Convert shapely to geojson dict #48

Closed johnclary closed 5 years ago

johnclary commented 5 years ago

Fixes #47.

I considering using geomet, which has robust functionality for WKT to geoJSON conversion. But our need here is so simple that I think we can get by with this solution:

The updated to_feature() method will handle shapley Point and Polygon classes. Multipolygon will break it.

thekaveman commented 5 years ago

Thanks @johnclary! I made a few minor tweaks to the import statements and removed the dependency from setup.py for completeness... does this look good to you?

johnclary commented 5 years ago

@thekaveman looks great.

TBH I haven't tested to_feature() as it's called in provider.py. The tuple/list conversion may be unnecessary (though it does make the feature objects feel more like a geoJSON)

https://github.com/CityofSantaMonica/mds-provider/blob/2262443d93c8370ca900db63e87ec8e51bc7aee8/mds/json.py#L57

thekaveman commented 5 years ago

I tested it with:

from mds.json import parse_boundary, to_feature

url = "https://opendata.arcgis.com/datasets/63595d717c494165b3c6b3b85c2463ae_0.geojson"
boundary = parse_boundary(url)
feature = to_feature(boundary)

That URL is a multipolygon of neighborhoods in Santa Monica, parse_boundary melds into a single Polygon. Seems to work.

thekaveman commented 5 years ago

@johnclary are you no longer interested in having this merged? I still think it's worthwhile, if you don't mind me taking the changes.

johnclary commented 5 years ago

@thekaveman go for it. did not mean to close this.

thekaveman commented 5 years ago

@johnclary if you'd like to resubmit I'll merge it in ASAP. If you'd rather not deal with, no problem I'll get it in.