Structure/Format geocoding Responses
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 768
- Forks
- 191
- PR merge metrics
- No merged PRs in 30d
Description
I have been experimenting with MapBox for the past month or so but I have hit a brick wall with implementing the Geocoder into my app because there doesn't seem to be a reliable way to structure geocoder results.
If you to this URL which is provided by the MapBox documentation you will get a big JSON obeject in response.
`curl "https://api.mapbox.com/geocoding/v5/mapbox.places/-73.989,40.733.json?access_token=pk.eyJ1IjoiYW50aG9ueWJ1ZGQ5NCIsImEiOiJjazhwOWJ0YzMwMWh6M2ZxcDRrN3gzc2ZmIn0.DQaN739dnbBKKZGn9C1WMg"`
In that response object is an array of GeoJSON features. An example of one of these feature objects is shown below. This object contains all of the address information within the `context` array and fragments of the address can be found in `text`, `place_name` and `address`
This response data is effectively useless, because real-world applications often need to be able to store the address in a database, thus require a structured result or a way to post-structure the result. I cannot find a documented reliable way to extract an address from the feature object, so I would get a the data like the expected output below.
**Expected Output**
```
{
"id": "address.8612486683353220",
"type": "Feature",
"place_type": [
"address"
],
...
address:{
address_line_1: '120 East 13th Street',
address_line_2: '',
city: 'New York',
state: 'New York',
zipcode: '10003',
country: 'United States',
}
...
}
```
**Current Output: GeoJSON Feature Object**
```
{
"id": "address.8612486683353220",
"type": "Feature",
"place_type": [
"address"
],
"relevance": 1,
"properties": {
"accuracy": "rooftop"
},
"text": "East 13th Street",
"place_name": "120 East 13th Street, New York, New York 10003, United States",
"center": [
-73.9888929,
40.7330031
],
"geometry": {
"type": "Point",
"coordinates": [
-73.9888929,
40.7330031
]
},
"address": "120",
"context": [
{
"id": "neighborhood.2103290",
"text": "Greenwich Village"
},
{
"id": "locality.12696928000137850",
"wikidata": "Q11299",
"text": "Manhattan"
},
{
"id": "postcode.13482670360296810",
"text": "10003"
},
{
"id": "place.15278078705964500",
"wikidata": "Q60",
"text": "New York"
},
{
"id": "region.10003493535855570",
"short_code": "US-NY",
"wikidata": "Q1384",
"text": "New York"
},
{
"id": "country.19352517729256050",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files, tests, or entry points; begin by locating the JavaScript geocoding response handling and its related tests. Done would require an agreed, reliable structured address representation matching the expected output, along with documented behavior and coverage for the shown Mapbox response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100