ValhallaConfigFactory

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:

KotlinSwift
defaultValhallaConfig()
fromJsonValhallaConfig(_:using:)
fromFileValhallaConfig(fromURL:)
usingTileExtractValhallaConfig(tileExtractTar:elevationDir:)
usingTilesDirValhallaConfig(tilesDir:elevationDir:)
usingTileUrlValhallaConfig(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

Link copied to clipboard
fun default(): ValhallaConfig

The valhalla defaults for the version this library is built against.

Link copied to clipboard
fun fromFile(file: File, moshi: Moshi = defaultMoshi): ValhallaConfig

Parses a complete valhalla config from a file on disk.

Link copied to clipboard
fun fromJson(json: String, moshi: Moshi = defaultMoshi): ValhallaConfig

Parses a complete valhalla config from a JSON string.

Link copied to clipboard
fun usingTileExtract(tileExtractTar: String, elevationDir: String? = null): ValhallaConfig

The defaults, pointed at a tile tarball.

Link copied to clipboard
fun usingTilesDir(tilesDir: String, elevationDir: String? = null): ValhallaConfig

The defaults, pointed at a directory of loose tiles.

Link copied to clipboard
fun usingTileUrl(tilesUrl: String, tilesDir: String, tilesAreGzFiles: Boolean = false): ValhallaConfig

The defaults, pointed at a tile server that tiles are downloaded from on demand and cached in tilesDir.