From: lintondf Date: Wed, 1 Jul 2020 00:07:09 +0000 (-0400) Subject: Write garmin specific ilinks as gpxx:rpt elements (#598) X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~5^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=06dd0f9ebd2a061adea6ea96ff196c3b7d26ca8f;p=gpsbabel.git Write garmin specific ilinks as gpxx:rpt elements (#598) * Write garmin specific ilinks as gpxx:rpt elements when garminextensions option is specified * incorporate code review comments * comment corrected to reflect element being closed --- diff --git a/gpx.cc b/gpx.cc index 2fc109fff..1300d49a8 100644 --- a/gpx.cc +++ b/gpx.cc @@ -1289,7 +1289,10 @@ void GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_point_type point_type) const { // gpx version we are writing is >= 1.1. + garmin_fs_t* gmsd = (opt_garminext) ? garmin_fs_t::find(waypointp) : nullptr; // only needed if garmin extensions selected + if ((opt_humminbirdext && (WAYPT_HAS(waypointp, depth) || WAYPT_HAS(waypointp, temperature))) || + (opt_garminext && gpxpt_route==point_type && gmsd != nullptr && gmsd->ilinks != nullptr) || (opt_garminext && gpxpt_waypoint==point_type && (WAYPT_HAS(waypointp, proximity) || WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth))) || (opt_garminext && gpxpt_track==point_type && (WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth) || waypointp->heartrate != 0 || waypointp->cadence != 0))) { writer->writeStartElement(QStringLiteral("extensions")); @@ -1325,7 +1328,22 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin } break; case gpxpt_route: - /* we don't have any appropriate data for the children of gpxx:RoutePointExtension */ + if (gmsd != nullptr && gpxpt_route==point_type && gmsd->ilinks != nullptr) { + writer->writeStartElement(QStringLiteral("gpxx:RoutePointExtension")); + garmin_ilink_t* link = gmsd->ilinks; + garmin_ilink_t* prior = nullptr; // GDB files sometime contain repeated point; omit them + while (link != nullptr) { + if (prior == nullptr || prior->lat != link->lat || prior->lon != link->lon) { + writer->writeStartElement(QStringLiteral("gpxx:rpt")); + writer->writeAttribute(QStringLiteral("lat"), toString(link->lat)); + writer->writeAttribute(QStringLiteral("lon"), toString(link->lon)); + writer->writeEndElement(); // "gpxx:rpt" + } + prior = link; + link = link->next; + } + writer->writeEndElement(); // "gpxx:RoutePointExtension" + } break; case gpxpt_track: if (WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth) || waypointp->heartrate != 0 || waypointp->cadence != 0) { diff --git a/reference/gdb-sample-v3-ilinks.gdb b/reference/gdb-sample-v3-ilinks.gdb new file mode 100644 index 000000000..d82bab49a Binary files /dev/null and b/reference/gdb-sample-v3-ilinks.gdb differ diff --git a/reference/gdb-sample-v3-ilinks.gpx b/reference/gdb-sample-v3-ilinks.gpx new file mode 100644 index 000000000..eb81cd6c7 --- /dev/null +++ b/reference/gdb-sample-v3-ilinks.gpx @@ -0,0 +1,698 @@ + + + + + + + + + Birch Harbor + Birch Harbor + Birch Harbor + City (Small) + + + + Gouldsboro + Gouldsboro + Gouldsboro + City (Small) + + + + Prospect Harbor + Prospect Harbor + Prospect Harbor + City (Small) + + + + Schoodic Woods Campground + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Campground + + + + Sullivan Twn + Sullivan Twn + Sullivan Twn + City (Small) + + + Trip to Schoodic Woods Campground - Day 1 + + + false + Magenta + + + + + Sullivan Twn + Sullivan Twn + Sullivan Twn + City (Small) + + + + + + + + + 45.738 + 0001 + Get on Us1 and drive east + [PT6S] + Waypoint + + + + + + + + + 45.563 + 0002 + [PT23S] + Waypoint + + + + + + + + + + + + 44.266 + 0003 + [PT2M3S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + 28.781 + 0004 + [PT1M28S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + 26.887 + 0005 + [PT1M21S] + Waypoint + + + + + + + + + + + + + + + + + + + + + 20.605 + 0006 + [PT1M52S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + 38.840 + 0007 + Turn right onto S Gouldsboro Rd + [PT3M4S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 34.777 + 0008 + [PT2M12S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 38.371 + 0009 + [PT3S] + Waypoint + + + + + + + + + 38.293 + 0010 + [PT1M29S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + 36.547 + 0011 + [PT1M11S] + Waypoint + + + + + + + + + + + + + 24.645 + 0012 + [PT1M3S] + Waypoint + + + + + + + + + + + + + 15.426 + 0013 + [PT49S] + Waypoint + + + + + + + + + + + 11.945 + 0014 + [PT1M1S] + Waypoint + + + + + + + + + + + + 9.000 + 0015 + Turn left onto Main St + [PT1M35S] + Waypoint + + + + + + + + + + + + + + + + 15.344 + 0016 + [PT23S] + Waypoint + + + + + + + + + + + + 21.840 + 0017 + Turn right onto Moore Rd + [PT1M37S] + Waypoint + + + + + + + + + + + + + + + + + + 41.480 + 0018 + [PT0S] + Waypoint + + + + + + + + + + Schoodic Woods Campground + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Schoodic Woods Campground +Schoodic Loop Rd +Winter Harbor Twn, Maine, 04693, United States +207-288-1300 + Campground + + + + + + + + + 41.480 + 0019 + Get on Moore Rd and drive north + [PT1M16S] + Waypoint + + + + + + + + + + + + + + + + + + 21.840 + 0020 + Turn right onto Birch Harbor Rd + [PT1M13S] + Waypoint + + + + + + + + + + 29.652 + 0021 + [PT1M39S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + 29.453 + 0022 + [PT0S] + Waypoint + + + + + + + + 29.453 + 0023 + [PT0S] + Waypoint + + + + + + + + + + 1 Birch Harbor Rd + 1 Birch Harbor Rd +Winter Harbor, ME, 04693, USA + Flag, Blue + + + + + + + + + 29.453 + 0024 + [PT0S] + Waypoint + + + + + + + + 29.453 + 0025 + [PT41S] + Waypoint + + + + + + + + + + + 22.574 + 0026 + [PT1M29S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + 13.723 + 0027 + [PT2M28S] + Waypoint + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 13.098 + 0028 + [PT20S] + Waypoint + + + + + + + + + + + 12.836 + 0029 + [PT18S] + Waypoint + + + + + + + + + 12.707 + 0030 + [PT0S] + Waypoint + + + + + + + + + + Prospect Harbor + Prospect Harbor + Prospect Harbor + City (Small) + + + diff --git a/testo.d/gpx.test b/testo.d/gpx.test index 19ca6c83b..16afe9f6a 100644 --- a/testo.d/gpx.test +++ b/testo.d/gpx.test @@ -54,3 +54,7 @@ compare ${REFERENCE}/global.gpx ${TMPDIR}/global.gpx rm -f ${TMPDIR}/metadata.gpx gpsbabel -i gpx -f ${REFERENCE}/metadata.gpx -o gpx -F ${TMPDIR}/metadata.gpx compare ${REFERENCE}/metadata~gpx.gpx ${TMPDIR}/metadata.gpx + +# output ilinks if gpx garamextensions specified +gpsbabel -i gdb,dropwpt -f ${REFERENCE}/gdb-sample-v3-ilinks.gdb -o gpx,garminextensions -F ${TMPDIR}/gdb-sample-v3-ilinks.gpx +compare ${REFERENCE}/gdb-sample-v3-ilinks.gpx ${TMPDIR}/gdb-sample-v3-ilinks.gpx