
struct RouteProfile: Codable {

    let min: Double

    let max: Double

    let ticks: Int

    let span: Double

    let scale: Double

    init(min: Double, max: Double, ticks: Int) {
        self.min = min
        self.max = max
        self.ticks = ticks
        self.span = max - min
        self.scale = 1 / span
    }

    func scale(_ value: Double) -> Double {
        if value < min {
            return 0
        }
        if value > max {
            return 1
        }
        return (value - min) / span
    }
}

