[iOS] fix elevation profile zoom on short tracks

https://jira.mail.ru/browse/MAPSME-13527
This commit is contained in:
Aleksey Belousov 2020-04-02 23:18:17 +03:00 committed by Vladimir Byko-Ianko
parent dffd642315
commit fc6374714c

View file

@ -185,10 +185,6 @@ fileprivate struct ElevationProfileChartData {
init(_ elevationData: ElevationProfileData) {
points = ElevationProfileChartData.rearrangePoints(elevationData.points)
let values = points.map { Int($0.altitude) }
// let formatter = MKDistanceFormatter()
// formatter.unitStyle = .abbreviated
// formatter.units = .metric
// labels = points.map { formatter.string(fromDistance: $0.distance )}
distances = points.map { $0.distance }
let color = UIColor(red: 0.12, green: 0.59, blue: 0.94, alpha: 1)
let l1 = Line(values: values, name: "Altitude", color: color, type: .line)
@ -204,7 +200,7 @@ fileprivate struct ElevationProfileChartData {
var result: [ElevationHeightPoint] = []
let distance = points.last?.distance ?? 0
let step = floor(distance / Double(points.count))
let step = max(1, points.count > 50 ? floor(distance / Double(points.count)) : floor(distance / 50))
result.append(points[0])
var currentDistance = step
var i = 1
@ -223,6 +219,8 @@ fileprivate struct ElevationProfileChartData {
}
}
result.append(points.last!)
return result
}