Skip to content

Commit

Permalink
Merge branch 'master' into develop_igc_options
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 authored Oct 28, 2023
2 parents 51a5ce3 + ae4ac82 commit c0ce611
Show file tree
Hide file tree
Showing 62 changed files with 3,841 additions and 443 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: Analyze
runs-on: ubuntu-latest
container:
image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_focal
image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_jammy
env:
CMAKE_GENERATOR: Ninja

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# version 32, though obsolete, uses Qt 5.14 so we keep it for that.
include:
- IMAGE: '32'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5'
- IMAGE: '35'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5'
- IMAGE: '37'
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
fail-fast: false
matrix:
include:
- IMAGE: 'focal'
SCRIPT: './tools/build_and_test_cmake.sh'
# focal has Qt 5.12, end of standard support 4/2025, end of life 4/2030.
#- IMAGE: 'focal'
# SCRIPT: './tools/build_and_test_cmake.sh'
- IMAGE: 'jammy'
CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5'
SCRIPT: './tools/build_and_test_cmake.sh'
Expand Down Expand Up @@ -63,12 +64,12 @@ jobs:
coverage:
name: coverage Build
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: install
run: |
sudo apt-get update
sudo apt-get install gcovr lcov libusb-1.0-0-dev qt5-default qtwebengine5-dev libqt5serialport5-dev ninja-build
sudo apt-get install gcovr lcov libusb-1.0-0-dev qtbase5-dev qtwebengine5-dev libqt5serialport5-dev ninja-build
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ jobs:
fail-fast: false
matrix:
include:
- QT_VERSION: '5.12.12'
- QT_VERSION: '5.15.2'
ARCH: 'amd64'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2017_64'
COMPILER: 'msvc2019_64'
METHOD: 'aqt'
GENERATOR: 'Visual Studio 16 2019'
RELEASE: false
os: windows-2019
- QT_VERSION: '5.12.12'
- QT_VERSION: '5.15.2'
ARCH: 'amd64'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2017_64'
COMPILER: 'msvc2019_64'
TOOLSET: 'v141,version=14.16.27023'
METHOD: 'aqt'
GENERATOR: 'Visual Studio 16 2019'
RELEASE: false
os: windows-2019
- QT_VERSION: '5.12.12'
- QT_VERSION: '5.15.2'
ARCH: 'x86'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2017'
COMPILER: 'msvc2019'
METHOD: 'aqt'
GENERATOR: 'Visual Studio 16 2019'
RELEASE: false
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ add_executable(gpsbabel)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core)
if(${Qt${QT_VERSION_MAJOR}Core_VERSION} VERSION_LESS 5.12)
message(FATAL_ERROR "Qt version ${Qt${QT_VERSION_MAJOR}Core_VERSION} found, but version 5.12 or newer is required.")
if(${Qt${QT_VERSION_MAJOR}Core_VERSION} VERSION_LESS 5.15)
message(FATAL_ERROR "Qt version ${Qt${QT_VERSION_MAJOR}Core_VERSION} found, but version 5.15 or newer is required.")
else()
message(STATUS "Using Qt${QT_VERSION_MAJOR} version ${Qt${QT_VERSION_MAJOR}Core_VERSION}")
endif()
Expand Down
1 change: 1 addition & 0 deletions formspec.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
enum FsType {
kFsUnknown = 0L,
kFsGpx = 0x67707800L,
kFsGpxWpt = 0x67707877L,
kFsOzi = 0x6f7a6900L,
kFsGmsd = 0x474d5344L, /* GMSD = Garmin specific data */
kFsQstarzBl1000 = 0x5173747aL,
Expand Down
148 changes: 55 additions & 93 deletions garmin_fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
*/

#include <cstdio> // for snprintf, sscanf
#include <cstdlib> // for strtod
#include <cstdio> // for snprintf, sscanf
#include <cstdlib> // for strtod

#include <QString> // for QString, QStringLiteral
#include <QXmlStreamWriter> // for QXmlStreamWriter
#include <Qt> // for CaseInsensitive
#include <QString> // for QString, QStringLiteral
#include <Qt> // for CaseInsensitive

#include "defs.h"
#include "garmin_fs.h"
#include "garmin_tables.h" // for gt_switch_display_mode_value, gt_display_mode_symbol, gt_display_mode_symbol_and_comment, gt_display_mode_symbol_and_name
#include "inifile.h" // for inifile_readstr
#include "garmin_tables.h" // for gt_switch_display_mode_value, gt_display_mode_symbol, gt_display_mode_symbol_and_comment, gt_display_mode_symbol_and_name
#include "inifile.h" // for inifile_readstr
#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter


#define MYNAME "garmin_fs"
Expand Down Expand Up @@ -80,113 +80,75 @@ garmin_fs_t::~garmin_fs_t()

void
garmin_fs_xml_fprint(const Waypoint* waypt,
QXmlStreamWriter* writer)
gpsbabel::XmlStreamWriter* writer)
{
garmin_fs_t* gmsd = garmin_fs_t::find(waypt);

if (gmsd == nullptr) {
return;
}
writer->stackOptionalStartElement(QStringLiteral("extensions"));
writer->stackOptionalStartElement(QStringLiteral("gpxx:WaypointExtension"));
writer->stackNamespace(QStringLiteral("http://www.garmin.com/xmlschemas/GpxExtensions/v3"),
"gpxx");

/* Find out if there is at least one field set */
QString addr = garmin_fs_t::get_addr(gmsd, "");
if (addr.isEmpty()) {
addr = garmin_fs_t::get_city(gmsd, "");
}
if (addr.isEmpty()) {
addr = garmin_fs_t::get_country(gmsd, "");
if (waypt->proximity_has_value()) {
writer->stackTextElement(QStringLiteral("gpxx:Proximity"), QString::number(waypt->proximity_value(), 'f', 6));
}
if (addr.isEmpty()) {
addr = garmin_fs_t::get_postal_code(gmsd, "");

if (waypt->temperature_has_value()) {
writer->stackTextElement(QStringLiteral("gpxx:Temperature"), QString::number(waypt->temperature_value(), 'f', 6));
}
if (addr.isEmpty()) {
addr = garmin_fs_t::get_state(gmsd, "");

if (waypt->depth_has_value()) {
writer->stackTextElement(QStringLiteral("gpxx:Depth"), QString::number(waypt->depth_value(), 'f', 6));
}

QString phone = garmin_fs_t::get_phone_nr(gmsd, "");

if (!addr.isEmpty() || !phone.isEmpty() ||
(gmsd->flags.category && gmsd->category) ||
waypt->depth_has_value() ||
waypt->proximity_has_value() ||
waypt->temperature_has_value() ||
gmsd->flags.display) {
writer->writeStartElement(QStringLiteral("extensions"));
writer->writeStartElement(QStringLiteral("gpxx:WaypointExtension"));
writer->writeNamespace(QStringLiteral("http://www.garmin.com/xmlschemas/GpxExtensions/v3"),
"gpxx");
if (waypt->proximity_has_value()) {
writer->writeTextElement(QStringLiteral("gpxx:Proximity"), QString::number(waypt->proximity_value(), 'f', 6));
}
if (waypt->temperature_has_value()) {
writer->writeTextElement(QStringLiteral("gpxx:Temperature"), QString::number(waypt->temperature_value(), 'f', 6));
}
if (waypt->depth_has_value()) {
writer->writeTextElement(QStringLiteral("gpxx:Depth"), QString::number(waypt->depth_value(), 'f', 6));
}
if (gmsd->flags.display) {
const char* cx;
switch (gmsd->display) {
case gt_display_mode_symbol:
cx = "SymbolOnly";
break;
case gt_display_mode_symbol_and_comment:
cx = "SymbolAndDescription";
break;
default:
cx = "SymbolAndName";
break;
}
writer->writeTextElement(QStringLiteral("gpxx:DisplayMode"), cx);
if (garmin_fs_t::has_display(gmsd)) {
const char* cx;
switch (gmsd->display) {
case gt_display_mode_symbol:
cx = "SymbolOnly";
break;
case gt_display_mode_symbol_and_comment:
cx = "SymbolAndDescription";
break;
default:
cx = "SymbolAndName";
break;
}
if (gmsd->flags.category && gmsd->category) {
uint16_t cx = gmsd->category;
writer->writeStartElement(QStringLiteral("gpxx:Categories"));
for (int i = 0; i < 16; i++) {
if (cx & 1) {
writer->writeTextElement(QStringLiteral("gpxx:Category"), QStringLiteral("Category %1").arg(i+1));
}
cx = cx >> 1;
}
writer->writeEndElement(); // gpxx:Categories
}
if (!addr.isEmpty()) {
QString str;
writer->writeStartElement(QStringLiteral("gpxx:Address"));
writer->stackTextElement(QStringLiteral("gpxx:DisplayMode"), cx);
}

if (!(str = garmin_fs_t::get_addr(gmsd, nullptr)).isEmpty()) {
writer->writeTextElement(QStringLiteral("gpxx:StreetAddress"), str);
}
if (!(str = garmin_fs_t::get_city(gmsd, nullptr)).isEmpty()) {
writer->writeTextElement(QStringLiteral("gpxx:City"), str);
}
if (!(str = garmin_fs_t::get_state(gmsd, nullptr)).isEmpty()) {
writer->writeTextElement(QStringLiteral("gpxx:State"), str);
}
if (!(str = garmin_fs_t::get_country(gmsd, nullptr)).isEmpty()) {
writer->writeTextElement(QStringLiteral("gpxx:Country"), str);
if (garmin_fs_t::has_category(gmsd)) {
uint16_t cx = gmsd->category;
writer->stackStartElement(QStringLiteral("gpxx:Categories"));
for (int i = 0; i < 16; i++) {
if (cx & 1) {
writer->stackTextElement(QStringLiteral("gpxx:Category"), QStringLiteral("Category %1").arg(i+1));
}
if (!(str = garmin_fs_t::get_postal_code(gmsd, nullptr)).isEmpty()) {
writer->writeTextElement(QStringLiteral("gpxx:PostalCode"), str);
}
writer->writeEndElement(); // /gpxx::Address
cx = cx >> 1;
}
writer->stackEndElement(); // gpxx:Categories
}

if (!phone.isEmpty()) {
writer->writeTextElement(QStringLiteral("gpxx:PhoneNumber"), phone);
}
writer->stackOptionalStartElement(QStringLiteral("gpxx:Address"));
writer->stackOptionalTextElement(QStringLiteral("gpxx:StreetAddress"), garmin_fs_t::get_addr(gmsd, nullptr));
writer->stackOptionalTextElement(QStringLiteral("gpxx:City"), garmin_fs_t::get_city(gmsd, nullptr));
writer->stackOptionalTextElement(QStringLiteral("gpxx:State"), garmin_fs_t::get_state(gmsd, nullptr));
writer->stackOptionalTextElement(QStringLiteral("gpxx:Country"), garmin_fs_t::get_country(gmsd, nullptr));
writer->stackOptionalTextElement(QStringLiteral("gpxx:PostalCode"), garmin_fs_t::get_postal_code(gmsd, nullptr));
writer->stackEndElement(); // gpxx:Address

writer->stackOptionalTextElement(QStringLiteral("gpxx:PhoneNumber"), garmin_fs_t::get_phone_nr(gmsd, nullptr));

writer->writeEndElement(); // /gpxx::WaypointExtension
writer->writeEndElement(); // /extensions.
}

writer->stackEndElement(); // gpxx:WaypointExtension
writer->stackEndElement(); // extensions
}

void
garmin_fs_xml_convert(const int base_tag, int tag, const QString& qstr, Waypoint* waypt)
{
// FIXME: eliminate C string copy/use here:
const char *cdatastr = xstrdup(qstr);
const char* cdatastr = xstrdup(qstr);
garmin_fs_t* gmsd = garmin_fs_t::find(waypt);
if (gmsd == nullptr) {
gmsd = garmin_fs_alloc(-1);
Expand Down
11 changes: 5 additions & 6 deletions garmin_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
#ifndef GARMIN_FS_H
#define GARMIN_FS_H

#include <cstddef> // for size_t
#include <cstdint> // for int32_t, int16_t, uint16_t
#include <cstdint> // for int32_t, int16_t, uint16_t

#include <QString> // for QString
#include <QXmlStreamWriter> // for QXmlStreamWriter
#include <QString> // for QString

#include "defs.h"
#include "formspec.h" // for FsChainFind, kFsGmsd, FormatSpecificData
#include "formspec.h" // for FsChainFind, kFsGmsd, FormatSpecificData
#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter


/* this order is used by most devices */
Expand Down Expand Up @@ -222,7 +221,7 @@ void garmin_fs_copy(void** dest, const void* src);

/* for GPX */
void garmin_fs_xml_convert(int base_tag, int tag, const QString& qstr, Waypoint* waypt);
void garmin_fs_xml_fprint(const Waypoint* waypt, QXmlStreamWriter*);
void garmin_fs_xml_fprint(const Waypoint* waypt, gpsbabel::XmlStreamWriter*);

/* common garmin_fs utilities */

Expand Down
Loading

0 comments on commit c0ce611

Please sign in to comment.