Skip to content

Commit

Permalink
Merge pull request #48 from hugovk/fix-empty-trkseg
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Oct 20, 2024
2 parents b7bdfc3 + 059ac47 commit b6810a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/stravavis/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def main():

print("Processing data...")
df = process_data(filenames)
if df.empty:
sys.exit("No data to plot")

activities = None
if args.activities_path:
Expand Down
7 changes: 5 additions & 2 deletions src/stravavis/process_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ def process_gpx(gpxfile: str) -> pd.DataFrame | None:

for activity_track in activity.tracks:
for segment in activity_track.segments:
x0 = activity.tracks[0].segments[0].points[0].longitude
y0 = activity.tracks[0].segments[0].points[0].latitude
if not segment.points:
continue

x0 = segment.points[0].longitude
y0 = segment.points[0].latitude
d0 = 0
for point in segment.points:
x = point.longitude
Expand Down
6 changes: 6 additions & 0 deletions tests/gpx/empty-trkseg.gpx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.1" xmlns="http://www.topografix.com/GPX/1/1" creator="https://github.com/georust/gpx">
<trk>
<trkseg />
</trk>
</gpx>

0 comments on commit b6810a9

Please sign in to comment.