This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Includes a Geocoder class and a mapbaux-geocode command. It's 'mapbaux' for now because there's another command sitting on 'mapbox'.
100% test coverage. \m/
@dnomadb @sbma44 @rclark @tmcw this is ready for wider review. As in the README, usage is like this. >>> import mapbox
>>> geocoder = mapbox.Geocoder(access_token='YOUR_ACCESS_TOKEN')
>>> response = geocoder.fwd('Chester, NJ')
>>> print response.status_code
200 Rate limit info is in the headers. >>> import pprint
>>> pprint.pprint(response.headers.items())
[('x-rate-limit-remaining', '599'),
('content-length', '2488'),
('via', '1.1 38ddaa14c744d77c512b550361fc57b5.cloudfront.net (CloudFront)'),
('date', 'Wed, 29 Jul 2015 19:28:54 GMT'),
('x-cache', 'Miss from cloudfront'),
('access-control-expose-headers',
'x-rate-limit-interval,x-rate-limit-limit,x-rate-limit-remaining,x-rate-limit-reset'),
('x-powered-by', 'Express'),
('server', 'nginx'),
('last-modified', 'Wed, 29 Jul 2015 19:28:54 GMT'),
('connection', 'keep-alive'),
('etag', '"cee0e2b6e2919fbddb44552c59865744"'),
('x-amz-cf-id', 'OItwPHnRuB2Q2XmYWJdgLi7tOcz34Fa_PFPfmVrqOa7_lSP7SOiOhA=='),
('x-rate-limit-reset', '1438198194'),
('cache-control', 'max-age=3600'),
('x-rate-limit-interval', '60'),
('x-rate-limit-limit', '600'),
('access-control-allow-origin', '*'),
('content-type', 'application/vnd.geo+json; charset=utf-8')] The response's >>> pprint.pprint(response.json())
{u'attribution': u'NOTICE: You may cache this data for up to 30 days. \xa9 2015 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service. (https://www.mapbox.com/about/maps/)',
u'features': [{u'bbox': [-74.74063500935817,
40.71945199088977,
-74.62370799008399,
40.83360800937651],
u'center': [-74.7083, 40.7851],
u'context': [{u'id': u'postcode.1038615627',
u'text': u'07930'},
{u'id': u'region.2035022604',
u'text': u'New Jersey'},
{u'id': u'country.4150104525',
u'text': u'United States'}],
u'geometry': {u'coordinates': [-74.7083, 40.7851],
u'type': u'Point'},
u'id': u'place.7274',
u'place_name': u'Chester, 07930, New Jersey, United States',
u'properties': {},
u'relevance': 0.999,
u'text': u'Chester',
u'type': u'Feature'},
{u'bbox': [-75.56053799999998,
38.788656999999986,
-73.88665199999998,
41.35735999999999],
u'center': [-74.436931, 40.07478],
u'context': [{u'id': u'country.4150104525',
u'text': u'United States'}],
u'geometry': {u'coordinates': [-74.436931, 40.07478],
u'type': u'Point'},
u'id': u'region.2035022604',
u'place_name': u'New Jersey, United States',
u'properties': {},
u'relevance': 0.49,
u'text': u'New Jersey',
u'type': u'Feature'},
{u'bbox': [43.6384461237896,
16.947442118958687,
47.745127394014034,
19.531262926143192],
u'center': [45.622228, 18.242401],
u'context': [{u'id': u'country.3267341775',
u'text': u'Saudi Arabia'}],
u'geometry': {u'coordinates': [45.622228, 18.242401],
u'type': u'Point'},
u'id': u'region.1348222286',
u'place_name': u'Najran, Saudi Arabia',
u'properties': {},
u'relevance': 0.49,
u'text': u'Najran',
u'type': u'Feature'},
{u'bbox': [-2.943733999999999,
53.164426999999996,
-2.8541059999999994,
53.26897499999998],
u'center': [-2.8919, 53.1905],
u'context': [{u'id': u'postcode.451190028',
u'text': u'CH1 2HG'},
{u'id': u'region.1961842095',
u'text': u'Cheshire West and Chester'},
{u'id': u'country.2794958072',
u'text': u'United Kingdom'}],
u'geometry': {u'coordinates': [-2.8919, 53.1905],
u'type': u'Point'},
u'id': u'place.122617',
u'place_name': u'Chester, CH1 2HG, Cheshire West and Chester, United Kingdom',
u'properties': {},
u'relevance': 0.49,
u'text': u'Chester',
u'type': u'Feature'},
{u'bbox': [-75.42394100421112,
39.822347993547226,
-75.3437349914335,
39.875822009918124],
u'center': [-75.3557, 39.8496],
u'context': [{u'id': u'postcode.1785325442',
u'text': u'19013'},
{u'id': u'region.2184819983',
u'text': u'Pennsylvania'},
{u'id': u'country.4150104525',
u'text': u'United States'}],
u'geometry': {u'coordinates': [-75.3557, 39.8496],
u'type': u'Point'},
u'id': u'place.10507',
u'place_name': u'Chester, 19013, Pennsylvania, United States',
u'properties': {},
u'relevance': 0.49,
u'text': u'Chester',
u'type': u'Feature'}],
u'query': [u'chester', u'nj'],
u'type': u'FeatureCollection'} |
Nice! Thank you so much for getting this going. One suggestion: elsewhere we've using the |
@sbma44 agreed. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Including a CLI. We've got a name conflict with another package to resolve, so for now it's 'mapbaux'.
@dnomadb this is about 30% ready to go, I'd still like to get tests passing on Travis before we merge.