GPSBabel / gpsbabel

GPSBabel: convert, manipulate, and transfer data from GPS programs or GPS receivers. Open Source and supported on MacOS, Windows, Linux, and more. Pointy clicky GUI or a command line version...
https://www.gpsbabel.org
GNU General Public License v2.0
470 stars 125 forks source link

fix bugs with gpx passthrough. #1197

Closed tsteven4 closed 10 months ago

tsteven4 commented 10 months ago

These bugs exist for gpx 1.0 -> gpx 1.0 passthrough, and gpx 1.1 to gpx 1.1 passthrough. This work does not consider passthrough between different versions(#1194).

with gpx 1.0, any extension data that was a child of rte or trk was lost. I believe this used to work but has been broken for quite a while.

with gpx 1.0 extension data that was a child of gpx could be erroneously rewritten as part of the final wpt/rtept/trkpt.

with gpx 1.1 extension data that was a child of trkseg could be erroneously rewritten as part of the final wpt/rtept/trkpt.

with gpx 1.1 extension data that was a child of gpx could be erroneously rewritten as part of the final wpt/rtept/trkpt.

with gpx 1.1 extension data that was a child of waypoint and passed through would result in a schema violation, the required extension element was lost.

I note we currently drop any extension data that is a child of gpx, ,a child of trkseg, or a child of metadata.

tsteven4 commented 10 months ago

Bug demo. This runs the new test against the code without the fix to gpx.cc (from c6689168)

Running gpx.test
--- ./reference/gpxpassthrough10~gpx.gpx        2023-10-26 13:48:02.152519577 -0600
+++ /tmp/gpsbabel.56238/gpxpassthrough10~gpx.gpx        2023-10-26 13:48:22.840263458 -0600
@@ -24,7 +24,6 @@
   <rte>
     <name>Low Road</name>
     <desc>Generated from track Route</desc>
-    <foreign:something>rte</foreign:something>
     <rtept lat="36.339560000" lon="-117.422570000">
       <ele>479.300</ele>
       <name>RPT001</name>
@@ -41,7 +40,6 @@
   </rte>
   <trk>
     <name>meridian</name>
-    <foreign:something>trk</foreign:something>
     <trkseg>
       <trkpt lat="30.062183333" lon="-91.610350000">
         <ele>1.000</ele>
@@ -55,6 +53,7 @@
       <trkpt lat="30.062700000" lon="-91.608266667">
         <ele>0.000</ele>
         <time>2002-05-25T17:12:00.200Z</time>
+        <foreign:something>eof</foreign:something>
       </trkpt>
     </trkseg>
   </trk>
ERROR comparing ./reference/gpxpassthrough10~gpx.gpx /tmp/gpsbabel.56238/gpxpassthrough10~gpx.gpx
--- ./reference/gpxpassthrough11~gpx.gpx        2023-10-26 13:48:02.152519577 -0600
+++ /tmp/gpsbabel.56238/gpxpassthrough11~gpx.gpx        2023-10-26 13:48:22.850277205 -0600
@@ -15,9 +15,7 @@
     <name>Turn right at Airport Rd</name>
     <cmt>Turn right at Airport Rd</cmt>
     <desc>Turn right at Airport Rd</desc>
-    <extensions>
       <foreign:something>wpt</foreign:something>
-    </extensions>
   </wpt>
   <wpt lat="36.463640000" lon="-116.879200000">
     <ele>-67.300</ele>
@@ -67,6 +65,12 @@
       <trkpt lat="30.062700000" lon="-91.608266667">
         <ele>0.000</ele>
         <time>2002-05-25T17:12:00.200Z</time>
+        <extensions>
+          <foreign:something>trkseg</foreign:something>
+        </extensions>
+        <extensions>
+          <foreign:something>eof</foreign:something>
+        </extensions>
       </trkpt>
     </trkseg>
   </trk>
ERROR comparing ./reference/gpxpassthrough11~gpx.gpx /tmp/gpsbabel.56238/gpxpassthrough11~gpx.gpx
tsteven4 commented 10 months ago

All the new reference files have been validated against all used schema.

codacy-production[bot] commented 10 months ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.03% 73.33%
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (c66891680b364341d590fe6ed1b718da0f8ed768) | 23104 | 15989 | 69.21% | | | Head commit (02d5925843a2e4dbe95d11a210f30362ba7cac71) | 23115 (+11) | 16003 (+14) | 69.23% (**+0.03%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#1197) | 45 | 33 | **73.33%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences