ncssar / gpsio

GPSIO Browser Extension
GNU General Public License v2.0
8 stars 2 forks source link

GPX Read error: "Namespace prefix 'gpxtrkx' not declared" #1

Closed caver456 closed 2 years ago

caver456 commented 7 years ago

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.

caver456 commented 4 years ago

rather than filtering it out as junk, try to get gpsio to read it anyway - this file may have important data

caver456 commented 3 years ago

Here's another from Ken Taylor at academy - he transferred some stuff wirelessly, not sure which is which:

image

image (cursor is at 1098)

caver456 commented 3 years ago

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.

caver456 commented 2 years ago

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).

caver456 commented 2 years ago

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.

caver456 commented 2 years ago

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 ......