protomaps / OSMExpress

Fast database file format for OpenStreetMap
BSD 2-Clause "Simplified" License
229 stars 19 forks source link

Query for multiple nodes, ways, or relations at once by ID #15

Closed CloudNiner closed 4 years ago

CloudNiner commented 4 years ago

It would be nice if I could query for multiple ids at once per osm element and then have the result piped to stdout in a common data format such as CSV or GeoJSON. Something like

osmx query ./database.osmx way 1001 1002 1234
// or
osmx query ./database.osmx way 1001,1002,1234

I'm not that familiar with C++ or these APIs but it looks like if I wanted to do that myself using the osmexpress headers in code I'd have to make one getReader(id) call for each node, way or relation element that I wanted to pull from the database. Is that correct or is there another API call I can use to return a List of results?

bdon commented 4 years ago

@CloudNiner that's correct. calling getReader(id) costs almost nothing.

I think using the programmatic API is better than extending the command line API to handle multiple objects, it would be complicated to specify if you only wanted a subset of tags, or if you had more than several thousand IDs to look up. are you using Python? that may be more convenient to query the DB with, but will be slower than if you compile a C++ program against the headers

CloudNiner commented 4 years ago

👍 that makes sense -- we'll press forward with the programmatic API. Thanks again for the quick response!

bdon commented 4 years ago

My overall design goal is to make access via C++ or Python (see #4) very convenient so developers use that, instead of adding more flags and complexity to the command line interface, which can be limited to basic debugging use.

I've started to flesh out more examples of the programmatic API with Python: https://github.com/protomaps/OSMExpress/blob/master/python/examples/web_server.py