Closed simonw closed 7 years ago
We can do null
. That might be done by the time you read or, if not, then shortly thereafter!
Done!
curl -X GET 'https://whosonfirst-api.mapzen.com?method=whosonfirst.places.getHierarchiesByLatLon&api_key=mapzen-xxxxxx&latitude=36.7232166&longitude=-4.3704579&spr=1&format=json'
{
"hierarchies": [
{
"region": null,
"continent": null,
"country": {
"wof:id": 85633129,
"wof:parent_id": "102191581",
"wof:name": "Spain",
"wof:placetype": "country",
"wof:country": "ES",
"wof:repo": "whosonfirst-data"
},
"locality": {
"wof:id": 101748185,
"wof:parent_id": "404339241",
"wof:name": "Málaga",
"wof:placetype": "locality",
"wof:country": "ES",
"wof:repo": "whosonfirst-data"
},
"county": null,
"neighbourhood": {
"wof:id": 85863513,
"wof:parent_id": "101748185",
"wof:name": "Valle Los Galanes",
"wof:placetype": "neighbourhood",
"wof:country": "ES",
"wof:repo": "whosonfirst-data"
}
}
],
"stat": "ok"
}
Consider this response:
https://whosonfirst-api.mapzen.com/?method=whosonfirst.places.getHierarchiesByLatLon&latitude=36.7232166&longitude=-4.3704579&api_key=mapzen-XXX
The region_id, continent_id and county_id are all -1 - which is surprising, because this is a perfectly regular point somewhere in Spain... https://whosonfirst.mapzen.com/spelunker/id/85863513/ - but that's not the bug I'm reporting here.
If I add &spr=1 to the above, I get this:
https://whosonfirst-api.mapzen.com/?method=whosonfirst.places.getHierarchiesByLatLon&latitude=36.7232166&longitude=-4.3704579&api_key=mapzen-xxx&spr=1
Note how county, region and continent are now all represented as empty arrays []. This is unexpected, since normally those would be an object {}.
Proposed solution: either omit those keys entirely, or set their value to null (this is my preferred solution), or set their value to an empty {} object. The null version would look like this: