Hello,
I'm using Gpxpy to read two files (a track and a set of locations), and need to keep only locations that lie within the map (top+left, bottom+right) where the track lies.
Does Python provide a way to compare two tuples?
---
Edit: This returns no hits :-/
I'm using Gpxpy to read two files (a track and a set of locations), and need to keep only locations that lie within the map (top+left, bottom+right) where the track lies.
Does Python provide a way to compare two tuples?
#READ TRACK track_file = open(TRACK, mode='rt', encoding='utf-8') gpx = gpxpy.parse(track_file) track_file.close() full_track_points = [] for track in gpx.tracks: for segment in track.segments: for point in segment.points: full_track_points.append([point.latitude,point.longitude]) track_min_coords = min(full_track_points) track_max_coords = max(full_track_points) #LOOP THROUGH LOCATIONS, IGNORING THOSE LYING OUTSIDE TRACK MAP for waypoint in locations_gpx.waypoints: location_coords = (waypoint.latitude,waypoint.longitude) #HERE #How to check if a waypoint lies withing a map?Thank you.
---
Edit: This returns no hits :-/
if not (track_min_latitude < waypoint.latitude < track_max_latitude and track_min_longitude < waypoint.longitude < track_max_longitude): print("Not within map") else: print("Within map")