Honor the configured generator input file - #120
Merged
Merged
Conversation
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.
Summary
OfflineSettings.InputFile.mapd generate --input-file PATHselectPATHinstead of the hard-coded default../map.osm.pbfCLI default.Motivation
The generate command declares
--input-file, defaults it to./map.osm.pbf, and copies the parsed value intoOfflineSettings.InputFile.GenerateOfflineignores that field and always opens the literal./map.osm.pbf.As a result, an explicit absolute or relative input works only when the default file also exists, and generation reads the default rather than the selected file. Conversely, a missing selected path is silently ignored when the default exists.
Implementation
GenerateOfflinenow passess.InputFiletoos.Open. The selected file then follows the existing scanner, generation, and error paths unchanged.The CLI remains the owner of the default value, so omitting
--input-filestill supplies./map.osm.pbf.Behavior
68813e05--input-fileomitted; default existsValidation
An external Linux oracle exercised the exported generator and a built CLI child process with a real locations-on-ways PBF fixture. Every successful case decoded the generated packed Cap'n Proto output and required one loaded tile containing ways.
68813e05ignored absolute, relative, missing, and empty selections; the explicit CLI selection failed when no default file existed.go test ./...,go test -race ./...,go vet ./..., andgo build ./...passed on Linux/amd64 with Go 1.25.1.135f703f449f9227477aca978258abf7ae0afa56; the branch-push workflow ran itsBuild binarystep.Compatibility
os.Open.OfflineSettings.InputFileempty must now provide the same explicit default that the CLI already supplies.Audit follow-up (head
92bfb64)An independent audit confirmed the flag was genuinely dead — base hardcoded
./map.osm.pbfand silently ignored--input-file/-i— and that the default path is byte-identical to base behavior.It also found that this change leaves the
generatesubcommand's own usage line stale, since it still advertised generation "from 'map.osm.pbf'" while the source is now configurable. Head92bfb64updates that text to refer to--input-file. FrogAi Build #54 passed for the exact head.Pre-existing and not addressed here: an input path that opens but cannot be parsed — a directory, or a truncated pbf — still produces zero-way tiles over the requested bounds instead of failing loudly. That behavior is unchanged by this PR, but it becomes easier to reach now that the path is user-supplied.
Composition with #97 is clean, verified by trial merge, build, and test, with the way-assignment loop byte-identical to
mainand untouched by both PRs.