merlos / iOS-Open-GPX-Tracker

GPS Tracker app for iOS + WatchOS. Log your tracks without limits and share them; Open source GPX tracker app written in Swift
http://www.merlos.org/iOS-Open-GPX-Tracker/
GNU General Public License v3.0
605 stars 149 forks source link

I want to access the time attribute of saved gpx files #173

Closed gic01 closed 4 years ago

gic01 commented 4 years ago

What a great project this is! I have one question or issue though: when loading the data of a saved gpx file, I like to access and process the time values of the gpx object (as anchored in the tracks[].tracksegments[].trackpoints[].CoreGPX.GPXElement node). But - when I set a breakpoint after line 250 in the GPXFilesTableViewController.swift code to inspect the gpx object - the time values are all set to (Date?)nil. This seems like the end of story for me, because I have no way now to process the time information of the parsed gpx file. May I ask how I can access the time data? I like to access the time information of gpx files so that not only the route gets loaded into the map after the file-load action, but I can also report the time duration, the average speed and related details. I am a cyclist and started using the Open GPX Tracker for my rides.

vincentneo commented 4 years ago

@gic01, thanks for opening this issue. Appears to be a bug.

vincentneo commented 4 years ago

@gic01,

preliminary testing showed that it might not be a bug within this project/CoreGPX, but rather on Xcode. The Date object seems to be printable, meaning it is not nil, just that Xcode thinks its nil at debug time.

Could well be the issue described here: https://stackoverflow.com/questions/58255887/xcode-11-swift-dateformatter-always-return-nil

Try inserting

             print(gpx.tracks.first?.tracksegments.first?.trackpoints.first?.time) 

at line 255, and see if it prints out the first track's first track segment's first track point's time.

gic01 commented 4 years ago

Hello @vincentneo, your comments absolutely helped me move on. I confirm that the date actually gets correctly parsed and I can access it. It simply was what, as you found, appears to be a (maybe just cosmetic) bug on Xcode's debugger. Thanks a lot for getting back on this and sorting it out!

vincentneo commented 4 years ago

No problem!