Support new API for pelias import / reverse Geocoding
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32
- Forks
- 8
- Avg merge
- 13m
- Merged PRs (30d)
- 1
Description
Use-cases
The pelias pip-service API is supported by spatial via the endpoint /query/pip/_view/pelias/:lon/:lat.
This API is quite old and I think we can create a better one. The current one is an object of places grouped by their placetype.
{
"ocean": [
{
"id": 404528709,
"name": "North Atlantic Ocean",
"centroid": {
"lat": 34.226813,
"lon": -28.8395953
},
"bounding_box": "-81.520626,0.022273,6.557047,68.437167"
}
]
}
Proposal
I'm suggesting a new API, a bit simpler that will return a list of places.
[
{
"id": 404528709,
"name": "North Atlantic Ocean",
"type": "ocean",
"centroid": {
"lat": 34.226813,
"lon": -28.8395953
},
"bounding_box": "-81.520626,0.022273,6.557047,68.437167"
}
]
Why a list instead of a map ? The complexity this adds at Spatial and pelias levels.
- The SQLite query returns an array list of places
- spatial/server/routes/pip_pelias.js#parseRows will remap the list into an object complexity: θ(N)
- spatial/server/routes/pip_pelias.js#remapFromHierarchy will do some stuff about hierarchy costing θ(3 * N + 2 * supported-layers)
- wof-admin-lookup/src/lookupStream.js#createPipResolverStream will set parent on θ(supported-layers)
The final complexity is θ(4 * N + 3 * supported-layers) for this pipeline
I think my idea is not compatible with the hierarchy feature, we might remove parseRows and make some changes in remapFromHierarchy, the complexity of createPipResolverStream will be θ(N) and the whole complexity could be θ(3 * N )
BTW, this piece of code can be expensive for debug purpose only 😅
https://github.com/pelias/wof-admin-lookup/blob/dde07e2774111184cf04d7187960283ef84ea695/src/lookupStream.js#L45-L50
How to change the API ? For importer / pelias API services.spatial.version=2 and /query/pip/_view/pelias/:lon/:lat?version=2 query param for Spatial API ?
References
https://github.com/pelias/wof-admin-lookup/pull/331#pullrequestreview-3284378548
https://github.com/pelias/wof-admin-lookup/pull/331#issuecomment-3351926238
cc @missinglink
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
Start with server/routes/pip_pelias.js, especially parseRows and remapFromHierarchy, then read wof-admin-lookup/src/lookupStream.js at createPipResolverStream and the referenced debug section. Clarify how a versioned Spatial API should coexist with hierarchy handling and importer consumers; done means the agreed response shape and version behavior work across this pipeline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100