Begin statistics creation

This commit is contained in:
Christoph Hagen
2025-08-31 16:27:32 +02:00
parent f972a2c020
commit 96bd07bdb7
33 changed files with 1406 additions and 187 deletions

View File

@@ -144,6 +144,41 @@ extension Content {
}
}
// MARK: Routes
private func generateMapImage(route: FileResource) -> Bool {
let size = route.mapImageDimensions
let path = URL(fileURLWithPath: route.mapImagePath)
guard let workoutData = route.workoutData else {
print("ImageGenerator: Failed to get workout data for route \(route.identifier)")
return false
}
let mapImager = MapImageCreator(locations: workoutData.locations)
guard let (largeImage, points) = mapImager.createMapSnapshot(size: .init(width: size.width, height: size.height)) else {
print("ImageGenerator: Failed to generate map image for route \(route.identifier)")
return false
}
guard largeImage.writePng(to: path) else {
print("ImageGenerator: Failed to save map image for route \(route.identifier)")
return false
}
let statisticsGenerator = StatisticsFileGenerationJob(
mapCoordinates: points,
workout: workoutData,
path: route.statisticsFilePath,
numberOfSamples: 600
)
guard statisticsGenerator.run() else {
print("ImageGenerator: Failed to generate statistics for route \(route.identifier)")
return false
}
return true
}
// MARK: Find items by id
func page(_ pageId: String) -> Page? {