Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --first-feature option to the geocoder #56

Closed
perrygeo opened this issue Feb 22, 2016 · 1 comment
Closed

Add a --first-feature option to the geocoder #56

perrygeo opened this issue Feb 22, 2016 · 1 comment
Assignees

Comments

@perrygeo
Copy link
Contributor

perrygeo commented Feb 22, 2016

Instead of getting a featurecollection with the first 5 results, many use cases at the command line will require selecting a single result, usually the first feature.

I've been using this pattern to get a GeoJSON Feature

mapbox geocoding "place" | jq -c .features[0]

Useful for geocoding multiple places and making a GeoJSON FeatureCollection

cat places.txt | parallel mapbox geocoding {} | jq -c .features[0] | fio collect

But jq isn't installed everywhere (it should be, it's awesome) and the arguments are not immediately clear.

Proposal

A --first-feature option to output the first, highest-ranked Feature (without line-breaks to facilitate streaming) rather than a FeatureCollection.

The parallel geocoding of multiple addresses becomes a little cleaner:

cat places.txt | parallel mapbox geocoding --first-feature {} | fio collect

The only reason I'd hesitate to implement this would be our design principles #10:

We'll rely on other programs like sed, awk, jq for finer parsing of responses from APIs at first, absorbing some of this when it makes sense.

So, does --first-feature make sense? Or do we just rely on jq?

@KaiBot3000
Copy link

I like this idea, and if it makes your life easier I think it's worth the added complexity 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants