Closed caver456 closed 2 years ago
rather than filtering it out as junk, try to get gpsio to read it anyway - this file may have important data
Here's another from Ken Taylor at academy - he transferred some stuff wirelessly, not sure which is which:
(cursor is at 1098)
Looks pretty straightforward: a file that reads OK has this in the header:
xmlns:gpxtrkx="http://www.garmin.com/xmlschemas/TrackStatsExtension/v1"
So maybe just tell gpsio to insert that text if no xmlns:gpxtrkx is found.
reopening. Turns out the current solution fails on mac:
Checking /tmp/gpsio-gpxtmp/gpsio2021_12_02_123606.gpx for 'xmlns:gpxtrkx' ... not found in original file. mmap: resizing not available--no mremap()
At this section of code:
orig_size=mm.size() offset=mm.find(b'xmlns:') mm.resize(orig_size+GPXTRKX_LENGTH+1) mm.move(offset+GPXTRKX_LENGTH+1,offset,orig_size-offset) mm.seek(offset) mm.write(GPXTRKX_TEXT+b' ')
Googling around, sure enough mac doesn't provide mremap (therefore doesn't provide mmap.resize).
decided to abandon mmap since it's not portable; using the standard splice and write commands instead. Working on mac, and committed; need to verify on Windows.
similar error occurs if gpxx is not in the file; will change the ensure_gpxtrkx function to a broader ensure_xmlns, where the namespace name and the full required text are passed as arguments. gpxx full text:
xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"
This is probably new in the last year or so; looking at an exported gpx, it is used to preserve track color, and probably other attributes:
<trk><name>AA</name><extensions><gpxx:TrackExtension><gpxx:DisplayColor>Red</gpxx:DisplayColor></gpxx:TrackExtension></extensions><trkseg><trkpt ......
Found by NCSSAR while importing using GPSIO from a Garmin 62; full error message in GPSIO import progress dialog:
Reading from GPS . . . GPS Exception: GPX Read error: "Namespace prefix 'gpxtrkx' not declared" File: "E:/Garmin/GPX/Archive/CLIFF1.gpx" Line: 1 Column: 1103
Initial report was by email thread on 6-1-17. I requested the file from the GPS owner (it's not one of the files I copied to read the track that we needed) and will post here if/when I get it.
Regardless of whether this file was created by the GPS device or not, it should get filtered out as junk so that sartopo never sees it.