Begin statistics creation
This commit is contained in:
@@ -269,10 +269,11 @@ final class FileResource: Item, LocalizedItem {
|
||||
return prefix + "." + ext
|
||||
}
|
||||
|
||||
func imageSet(width: Int, height: Int, language: ContentLanguage, quality: CGFloat = 0.7, extraAttributes: String? = nil) -> ImageSet {
|
||||
func imageSet(type: FileType? = nil, width: Int, height: Int, language: ContentLanguage, quality: CGFloat = 0.7, extraAttributes: String? = nil) -> ImageSet {
|
||||
let description = self.localized(in: language)
|
||||
return .init(
|
||||
image: self,
|
||||
type: type,
|
||||
maxWidth: width,
|
||||
maxHeight: height,
|
||||
description: description,
|
||||
@@ -300,14 +301,34 @@ final class FileResource: Item, LocalizedItem {
|
||||
|
||||
// MARK: Workout
|
||||
|
||||
var routeOverview: RouteOverview? {
|
||||
#warning("Set correct map image size, ratio from settings?")
|
||||
var mapImageDimensions: (width: Int, height: Int) {
|
||||
(width: content.settings.pages.largeImageWidth, height: 0)
|
||||
}
|
||||
|
||||
var mapImagePath: String {
|
||||
let dimension = mapImageDimensions
|
||||
return outputPath(width: dimension.width, height: dimension.height, type: .png)
|
||||
}
|
||||
|
||||
var statisticsFilePath: URL {
|
||||
let path = "\(content.settings.paths.filesOutputFolderPath)/\(identifier.fileNameWithoutExtension).route"
|
||||
let fullPath = makeCleanAbsolutePath(path)
|
||||
return URL(filePath: fullPath, directoryHint: .notDirectory)
|
||||
}
|
||||
|
||||
var workoutData: WorkoutData? {
|
||||
guard type == .route else {
|
||||
return nil
|
||||
}
|
||||
guard let data = dataContent() else {
|
||||
return nil
|
||||
}
|
||||
return try? WorkoutData(data: data).overview
|
||||
return try? WorkoutData(data: data)
|
||||
}
|
||||
|
||||
var routeOverview: RouteOverview? {
|
||||
workoutData?.overview
|
||||
}
|
||||
|
||||
// MARK: Video thumbnail
|
||||
@@ -386,6 +407,21 @@ final class FileResource: Item, LocalizedItem {
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == ContentLabel {
|
||||
|
||||
mutating func insertOrReplace(icon: PageIcon, value: String) {
|
||||
insertOrReplace(label: .init(icon: icon, value: value))
|
||||
}
|
||||
|
||||
mutating func insertOrReplace(label: ContentLabel) {
|
||||
if let index = firstIndex(where: { $0.icon == label.icon }) {
|
||||
self[index] = label
|
||||
} else {
|
||||
append(label)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension FileResource: CustomStringConvertible {
|
||||
|
||||
var description: String {
|
||||
|
||||
Reference in New Issue
Block a user