Add GetIdCommand for retrieving features by OSM ID#32
Open
JeremyBYU wants to merge 1 commit intoclarisma:mainfrom
Open
Add GetIdCommand for retrieving features by OSM ID#32JeremyBYU wants to merge 1 commit intoclarisma:mainfrom
JeremyBYU wants to merge 1 commit intoclarisma:mainfrom
Conversation
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Work
Adds a new
get-idCLI command for efficient OSM ID lookup using the index files generated bygol build -i. This is the CLI companion to libgeodesk PR #35, which provides the underlyinggetId()API.Requires: clarisma/libgeodesk#35 (ID index support in libgeodesk)
What Changed
get-idcommand (src/gol/GetIdCommand.cpp,src/gol/GetIdCommand.h)n123(node),w456(way),r789(relation)IdIndex::findById()for fast lookups via pre-built indexesGolTool.cppDesign Decision: Separate Command vs. Query Language Extension
The original libgeodesk PR mentioned future work to add
w[id=12345]syntax to the GOQL query language. This implementation takes a different approach: a dedicatedget-idcommand.Why not extend the query language?
Semantic mismatch - GOQL filters (
a[highway=primary]) conceptually select from a set. ID lookup returns exactly 0 or 1 features—it's a key lookup, not a filter.Awkward composition - What does
w[id=12345][highway=residential]mean? Apply both? It's redundant, the ID already uniquely identifies the feature.Different mental model - Users querying by ID typically want to retrieve a known feature, not filter an unknown set. A dedicated command makes this explicit.
Cleaner UX -
gol get-id world.gol w327189648is direct and obvious. No need to remember filter syntax for a fundamentally different operation.Usage Examples
Open Questions
Currently if the index does not exist you will get an error like this:
❯ ./build/gol get-id $DATA_DIR/osm/planet-latest.gol w327189648 -v ────── ID lookups require index files. Rebuild with: gol build -i ...We could also fallback to brute force. But I felt that was overkill.
Finally, I would write some tests but am unsure how your testing infrastructure works.
Amount of Risk
Low risk, additive change.