simplegeo / python-simplegeo

A client interface for SimpleGeo's API.
http://simplegeo.com
104 stars 18 forks source link

Adding ability to use filter parameter in Context client. #23

Closed mager closed 13 years ago

aguynamedben commented 13 years ago

Merged and built. I removed the get_centroid function since it's getting the middle of a bbox, not the centroid. You may want to implement that using Shapely, or writing a tutorial for our users showing them how to do it with Shapely. Also, I renamed the bbox variables because you had NW_lat and SE_lon, which isn't right. I made the order align with our API.

One confusing thing that will happen: we give the "bounds" of a polygon (what should be "bbox") as GeoJSON, which means we give the users [sw_lon, sw_lat, ne_lon, ne_lat]. We always return GeoJSON for responses, so that's why we do that. BUT when we ask users to query our API, we ask them to do it in the "normal" (ie non-GeoJSON) format of lat,lon instead of GeoJSON's lat,lon. So when the user does simplegeo.context.get_context_by_bbox, I made the parameters (sw_lat, sw_lon, ne_lat, ne_lon). This is the order the API endpoint receives the parameters, so it's most consistent with our API docs. Users wanting to take the "bounds" given back from a Context response will need to make sure they convert their bbox appropriately when calling get_context_by_bbox, using a GeoJSON library or their own simple logic.