API - do not return elevation in chart data when no elevation in file
This commit is contained in:
@ -42,7 +42,7 @@ def get_gpx_data(
|
||||
gpx_data['elevation_max'] = ele.maximum
|
||||
gpx_data['elevation_min'] = ele.minimum
|
||||
|
||||
# gpx file contains elevation datat (<ele> element)
|
||||
# gpx file contains elevation data (<ele> element)
|
||||
if ele.maximum is not None:
|
||||
hill = parsed_gpx.get_uphill_downhill()
|
||||
gpx_data['uphill'] = hill.uphill
|
||||
@ -242,29 +242,23 @@ def get_chart_data(
|
||||
if segment.get_speed(point_idx) is not None
|
||||
else 0
|
||||
)
|
||||
chart_data.append(
|
||||
{
|
||||
'distance': (
|
||||
round(distance / 1000, 2)
|
||||
if distance is not None
|
||||
else 0
|
||||
),
|
||||
'duration': point.time_difference(first_point),
|
||||
'elevation': (
|
||||
round(point.elevation, 1)
|
||||
if point.elevation is not None
|
||||
else 0
|
||||
),
|
||||
'latitude': point.latitude,
|
||||
'longitude': point.longitude,
|
||||
'speed': speed,
|
||||
# workaround
|
||||
# https://github.com/tkrajina/gpxpy/issues/209
|
||||
'time': point.time.replace(
|
||||
tzinfo=timezone(point.time.utcoffset())
|
||||
),
|
||||
}
|
||||
)
|
||||
data = {
|
||||
'distance': (
|
||||
round(distance / 1000, 2) if distance is not None else 0
|
||||
),
|
||||
'duration': point.time_difference(first_point),
|
||||
'latitude': point.latitude,
|
||||
'longitude': point.longitude,
|
||||
'speed': speed,
|
||||
# workaround
|
||||
# https://github.com/tkrajina/gpxpy/issues/209
|
||||
'time': point.time.replace(
|
||||
tzinfo=timezone(point.time.utcoffset())
|
||||
),
|
||||
}
|
||||
if point.elevation:
|
||||
data['elevation'] = round(point.elevation, 1)
|
||||
chart_data.append(data)
|
||||
previous_point = point
|
||||
previous_distance = distance
|
||||
|
||||
|
Reference in New Issue
Block a user