Skip to content

Commit

Permalink
Cleanup and testing for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Archdoog committed Oct 14, 2024
1 parent 1d60749 commit 8b1643c
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 1 deletion.
126 changes: 126 additions & 0 deletions apple/Sources/Valhalla/Extensions/ValhallaConfig~.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import Foundation
import ValhallaModels

extension ValhallaConfig {

Check failure on line 4 in apple/Sources/Valhalla/Extensions/ValhallaConfig~.swift

View workflow job for this annotation

GitHub Actions / test (ValhallaMobile, platform=iOS Simulator,name=iPhone 14,OS=16.4)

cannot find type 'ValhallaConfig' in scope

/// Generate a ValhallaConfig using the defaults provided by the valhalla build scripts.
///
/// This can be used to manipulate select values as a var.
init() {
guard
let configJsonURL = Bundle.module.url(
forResource: "SupportData/default", withExtension: "json")
else {
fatalError(
"ValhallaConfig SupportData/default.json config resource not found in module bundle."
)
}

do {
try self.init(fromURL: configJsonURL)
} catch {
fatalError("ValhallaConfig default.json config resource invalid json.")
}
}

init(tileExtractTar: URL) throws {
let defaultConfig = ValhallaConfig.loadDefault()

let mjolnir = Mjolnir(
admin: defaultConfig.mjolnir.admin,
dataProcessing: defaultConfig.mjolnir.dataProcessing,
globalSynchronizedCache: defaultConfig.mjolnir.globalSynchronizedCache,
hierarchy: defaultConfig.mjolnir.hierarchy,
idTableSize: defaultConfig.mjolnir.idTableSize,
importBikeShareStations: defaultConfig.mjolnir.importBikeShareStations,
includeBicycle: defaultConfig.mjolnir.includeBicycle,
includeConstruction: defaultConfig.mjolnir.includeConstruction,
includeDriveways: defaultConfig.mjolnir.includeDriveways,
includeDriving: defaultConfig.mjolnir.includeDriving,
includePedestrian: defaultConfig.mjolnir.includePedestrian,
logging: defaultConfig.mjolnir.logging,
lruMemCacheHardControl: defaultConfig.mjolnir.lruMemCacheHardControl,
maxCacheSize: defaultConfig.mjolnir.maxCacheSize,
maxConcurrentReaderUsers: defaultConfig.mjolnir.maxConcurrentReaderUsers,
reclassifyLinks: defaultConfig.mjolnir.reclassifyLinks,
shortcuts: defaultConfig.mjolnir.shortcuts,
tileDir: defaultConfig.mjolnir.tileDir,
tileExtract: tileExtractTar.relativePath,
timezone: defaultConfig.mjolnir.timezone,
trafficExtract: defaultConfig.mjolnir.trafficExtract,
transitDir: defaultConfig.mjolnir.transitDir,
transitFeedsDir: defaultConfig.mjolnir.transitFeedsDir,
useLRUMemCache: defaultConfig.mjolnir.useLRUMemCache,
useSimpleMemCache: defaultConfig.mjolnir.useSimpleMemCache)

self.init(
additionalData: defaultConfig.additionalData,
httpd: defaultConfig.httpd,
loki: defaultConfig.loki,
meili: defaultConfig.meili,
mjolnir: mjolnir,
odin: defaultConfig.odin,
serviceLimits: defaultConfig.serviceLimits,
statsd: defaultConfig.statsd,
thor: defaultConfig.thor)
}

init(tilesDir: URL) throws {
let defaultConfig = ValhallaConfig.loadDefault()

let mjolnir = Mjolnir(
admin: defaultConfig.mjolnir.admin,
dataProcessing: defaultConfig.mjolnir.dataProcessing,
globalSynchronizedCache: defaultConfig.mjolnir.globalSynchronizedCache,
hierarchy: defaultConfig.mjolnir.hierarchy,
idTableSize: defaultConfig.mjolnir.idTableSize,
importBikeShareStations: defaultConfig.mjolnir.importBikeShareStations,
includeBicycle: defaultConfig.mjolnir.includeBicycle,
includeConstruction: defaultConfig.mjolnir.includeConstruction,
includeDriveways: defaultConfig.mjolnir.includeDriveways,
includeDriving: defaultConfig.mjolnir.includeDriving,
includePedestrian: defaultConfig.mjolnir.includePedestrian,
logging: defaultConfig.mjolnir.logging,
lruMemCacheHardControl: defaultConfig.mjolnir.lruMemCacheHardControl,
maxCacheSize: defaultConfig.mjolnir.maxCacheSize,
maxConcurrentReaderUsers: defaultConfig.mjolnir.maxConcurrentReaderUsers,
reclassifyLinks: defaultConfig.mjolnir.reclassifyLinks,
shortcuts: defaultConfig.mjolnir.shortcuts,
tileDir: tilesDir.relativePath,
tileExtract: defaultConfig.mjolnir.tileExtract,
timezone: defaultConfig.mjolnir.timezone,
trafficExtract: defaultConfig.mjolnir.trafficExtract,
transitDir: defaultConfig.mjolnir.transitDir,
transitFeedsDir: defaultConfig.mjolnir.transitFeedsDir,
useLRUMemCache: defaultConfig.mjolnir.useLRUMemCache,
useSimpleMemCache: defaultConfig.mjolnir.useSimpleMemCache)

self.init(
additionalData: defaultConfig.additionalData,
httpd: defaultConfig.httpd,
loki: defaultConfig.loki,
meili: defaultConfig.meili,
mjolnir: mjolnir,
odin: defaultConfig.odin,
serviceLimits: defaultConfig.serviceLimits,
statsd: defaultConfig.statsd,
thor: defaultConfig.thor)
}

static func loadDefault() -> ValhallaConfig {
guard
let configJsonURL = Bundle.module.url(
forResource: "SupportData/default", withExtension: "json")
else {
fatalError(
"ValhallaConfig SupportData/default.json config resource not found in module bundle."
)
}

do {
return try ValhallaConfig(fromURL: configJsonURL)
} catch {
fatalError("ValhallaConfig default.json config resource invalid json.")
}
}
}
2 changes: 1 addition & 1 deletion apple/Sources/Valhalla/ValhallaFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum ValhallaFileManager {
}

let tzdataFileData = try Data(contentsOf: tzdataFileURL)
let libraryURL = libraryDir.appendingPathComponent("tzdata")
let libraryURL = libraryDir.appendingPathComponent("tzdata.tar")

// Write the tar to Library/tzdata
// TODO: We can create our own tar extract here if we want to avoid the dependency
Expand Down

0 comments on commit 8b1643c

Please sign in to comment.