Valhalla Config Factory
Builds a ValhallaConfig from the same defaults iOS starts from.
Every function here mirrors an initializer on the Swift ValhallaConfig extension, so a config built on one platform matches the config built on the other:
| Kotlin | Swift |
|---|---|
| default | ValhallaConfig() |
| fromJson | ValhallaConfig(_:using:) |
| fromFile | ValhallaConfig(fromURL:) |
| usingTileExtract | ValhallaConfig(tileExtractTar:elevationDir:) |
| usingTilesDir | ValhallaConfig(tilesDir:elevationDir:) |
| usingTileUrl | ValhallaConfig(tilesUrl:tilesDir:tilesAreGzFiles:) |
The defaults are read from a bundled default.json rather than written out in Kotlin. That file is generated by valhalla's own scripts/valhalla_build_config from the pinned submodule — see scripts/generate_default_config.sh — and iOS bundles the identical bytes. Reading it is what keeps the two platforms' defaults from drifting apart, and it also sidesteps the defaults baked into the generated model classes, several of which do not match valhalla's.
None of this needs an Android android.content.Context: the config is a plain object, and it only becomes a file when ValhallaConfigManager writes it.
Functions
The defaults, pointed at a tile tarball.
The defaults, pointed at a directory of loose tiles.
The defaults, pointed at a tile server that tiles are downloaded from on demand and cached in tilesDir.