Begin statistics creation
This commit is contained in:
@@ -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? {
|
||||
|
||||
Reference in New Issue
Block a user