Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: include distance_from_start in NearestLocationsData class #274

Open
pleasantone opened this issue Dec 15, 2023 · 1 comment

Comments

@pleasantone
Copy link

I've added a a change to the code in my own private repo that includes the distance_from_start returned from get_points_data() into the named tuple returned by the get_nearest_location and get_nearest_locations routines.

I'm not going to bombard you with a pull request before asking if this change would even be welcome?

My hesitancy in submitting is that it does add an additional element to the NearestLocationsData class, so if someone is accessing it as a tuple, for example, in a for loop, it could cause issues and break the API. However, I doubt many people do, since it is a named tuple, but it is possible.

Why is this useful?

It's carries over expensive to calculate data from get_points_data(), and it's really wonderful to have if you're matching waypoints to tracks for printing out data about a route. https://github.com/pleasantone/gpxtr uses it (had to extend the GPXTrack class since monkey patching wasn't working for me) to produce nice little tables about a given multi-day route:

day1 210 miles: Sunrise: 07:20, Starts: 08:00, Ends: 14:59, Sunset: 16:56

Lat,Lon Name Dist. G ETA Notes
37.2563,-121.7922 11 SilverCreek 0 08:00 Circle, Green
36.7905,-121.3219 12 Tres Pinos 54/54 G 09:49 Gas Station (+0:15)
36.1369,-120.3626 13 Coalinga 90/144 G 12:49 Gas Station (+0:15)
36.3267,-119.3442 14 Visalia 65/209 14:59 Lodging

day2 208 miles: Sunrise: 07:08, Starts: 08:00, Ends: 14:54, Sunset: 16:49

Lat,Lon Name Dist. G ETA Notes
36.3267,-119.3442 14 Visalia 0 08:00 Lodging
36.6830,-119.0225 21 CA245 44 09:28 Waypoint
36.7545,-119.1720 22 Clingans 57/57 G 09:55 Gas Station (+0:15)
37.1070,-119.3189 23 Shaver Lake 57/115 G 11:49 Gas Station (+0:15)
37.2356,-119.2340 24 Huntington 126 12:13 Waypoint
37.2356,-119.2340 24 Huntington 131 12:22 Waypoint
37.1070,-119.3189 23 Shaver Lake 41/156 G 13:12 Gas Station (+0:15)
37.3397,-119.6442 25 Oakhurst 51/207 14:54 Lodging

day3 167 miles: Sunrise: 07:12, Starts: 08:00, Ends: 13:35, Sunset: 16:48

Lat,Lon Name Dist. G ETA Notes
37.3397,-119.6442 25 Oakhurst 0 08:00 Lodging
37.5512,-119.9235 31 Midpines 30 08:59 Waypoint
37.7107,-120.1971 32 Coulterville 66 10:13 Waypoint
37.6848,-120.3306 33 La Grange 77/77 G 10:34 Gas Station (+0:15)
37.7121,-121.7237 34 Livermore 90/167 G 13:35 Gas Station (+0:15)

Some of the changes I needed to make were supporting the idea that "a track might be part of a multi-stop(day) ride" and I needed to have a track-specific version of get_nearest_locations(), and the idea that if a path crosses itself (see day 2), the waypoints should show up multiple times, hence not being able to use get_nearest_location().

The milage was pulled off of my extended version of NearestLocationData returned by get_nearest_locations().

@pleasantone
Copy link
Author

pleasantone commented Dec 15, 2023

I'm happy to submit a pull request if the concept of adding another field to the tuple is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant