def get_2d_coordinate_list(gpxpy_instance): lat_list = [] lon_list = [] for latitude, longitude, elevation in iter_coordinates(gpxpy_instance): lat_list.append(latitude) lon_list.append(longitude) if not lat_list or not lon_list: raise GpxDataError("No track points in file!") return (lat_list, lon_list)
def get_identifier(gpxpy_instance): """ :return: Identifier named tuple """ time_bounds = gpxpy_instance.get_time_bounds() try: first_track = gpxpy_instance.tracks[0] except IndexError: raise GpxDataError("Can't get first track") try: first_segment = first_track.segments[0] except IndexError: raise GpxDataError("Can't get first segment") try: first_point = first_segment.points[0] except IndexError: raise GpxDataError("Can't get first segment point") try: last_track = gpxpy_instance.tracks[-1] except IndexError: raise GpxDataError("Can't get last track") try: last_segment = last_track.segments[-1] except IndexError: raise GpxDataError("Can't get last segment") try: last_point = last_segment.points[-1] except IndexError: raise GpxDataError("Can't get last segment point") return Identifier( time_bounds.start_time, first_point.latitude, first_point.longitude, time_bounds.end_time, last_point.latitude, last_point.longitude, )