Skip to content

Tracks without moving points break some functions #34

@kschweiger

Description

@kschweiger
pythontrack = PyTrack(
            points=[(1, 1), (1.0001, 1.0001), (1.0002, 1.0002), (1.0003, 1.0003)],
            elevations=[100, 105, 110, 110],
            times=[
                now,
                now + timedelta(minutes=1),
                now + timedelta(minutes=2),
                now + timedelta(minutes=3),
            ],
            extensions={
                "heart_rate": [120, 130, 140, 140],
                "power": [150, 160, 170, 170],
            },
        )

gives

   latitude  longitude  elevation speed   distance  time  cum_time  cum_time_moving  cum_distance  cum_distance_moving  cum_distance_stopped  moving  heart_rate  power  segment
0    1.0001     1.0001        105  None  16.516744  60.0      60.0                0     16.516744                    0             16.516744   False       130.0  160.0        0
1    1.0002     1.0002        110  None  16.516744  60.0     120.0                0     33.033488                    0             33.033488   False       140.0  170.0        0
2    1.0003     1.0003        110  None  15.741754  60.0     180.0                0     48.775241                    0             48.775241   False       140.0  170.0        0

fails with

  File "/../../../site-packages/geo_track_analyzer/track.py", line 228, in get_track_overview
    track_max_speed = track_data.speed[track_data.in_speed_percentile].max()

The column in_speed_percentile is only set if there are moving points. If you reduce the time delta to 30 seconds it works with:

   latitude  longitude  elevation     speed   distance  time  cum_time  cum_time_moving  cum_distance  cum_distance_moving  cum_distance_stopped  moving  power  heart_rate  segment  in_speed_percentile
0    1.0001     1.0001        105  0.550558  16.516744  30.0      30.0             30.0     16.516744            16.516744                     0    True  160.0       130.0        0                False
1    1.0002     1.0002        110  0.550558  16.516744  30.0      60.0             60.0     33.033488            33.033488                     0    True  170.0       140.0        0                 True
2    1.0003     1.0003        110  0.524725  15.741754  30.0      90.0             90.0     48.775241            48.775241                     0    True  170.0       140.0        0                 True

The column should just be there in any case

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions