Closed simonw closed 7 years ago
tl;dr - this is a by-product of stuff we do to accomodate CSV output, specifically ensuring that all the place records have the same keys so that the CSV headers/columns match.
The longer version is that we're starting with a response that looks like this:
{
"hierarchies": [
{
"neighbourhood_id": 85872423,
"continent_id": 102191575,
"macrohood_id": "1108794093",
"country_id": 85633793,
"locality_id": 85921881,
"county_id": 102086959,
"region_id": 85688637
},
{
"region_id": 85688637,
"continent_id": 102191575,
"country_id": 85633793,
"locality_id": 85921881,
"county_id": 102086959,
"neighbourhood_id": 85886709,
"macrohood_id": ""
}
],
"stat": "ok"
}
And WOF ID 85886709 is getting an empty macrohood_id
key to have parity with WOF ID 85872423
.
Either way, because WOF ID 85886709
has been superseded (and deprecated) we wouldn't re-assign it a new hierarchy anyway (think Sarajevo in 1988 versus Sarajevo in 2017).
But I agree, the end result is unsatisfying if you just want a blob of JSON. I will have a think about it...
Fixed.
CSV output:
curl -X GET 'https://whosonfirst-api.mapzen.com?method=whosonfirst.places.getHierarchiesByLatLon&api_key=mapzen-xxxxxx&latitude=37.7970594&longitude=-122.2778261&format=csv'
continent_id,country_id,county_id,locality_id,macrohood_id,neighbourhood_id,region_id
102191575,85633793,102086959,85921881,1108794093,85872423,85688637
102191575,85633793,102086959,85921881,,85886709,85688637
JSON output:
curl -X GET 'https://whosonfirst-api.mapzen.com?method=whosonfirst.places.getHierarchiesByLatLon&api_key=mapzen-xxxxxx&latitude=37.7970594&longitude=-122.2778261&format=json'
{
"hierarchies": [
{
"neighbourhood_id": 85872423,
"continent_id": 102191575,
"macrohood_id": "1108794093",
"country_id": 85633793,
"locality_id": 85921881,
"county_id": 102086959,
"region_id": 85688637
},
{
"region_id": 85688637,
"continent_id": 102191575,
"country_id": 85633793,
"locality_id": 85921881,
"county_id": 102086959,
"neighbourhood_id": 85886709
}
],
"stat": "ok"
}
Using this query:
https://whosonfirst-api.mapzen.com/?spr=1&longitude=-122.2778261&extras=geom%3A&latitude=37.7970594&method=whosonfirst.places.getHierarchiesByLatLon&api_key=mapzen-...
I got back a hierarchy list that included this:
The full response I got can be seen here: https://gist.github.com/simonw/1f385935f6746e7e376ec28ad5d5fa04