Skip to content

Commit

Permalink
fix SchemaArrayField/SchemaArrayData mismatch
Browse files Browse the repository at this point in the history
related to IGC additions from GPSBabel#1060 and GPSBabel#1054.
  • Loading branch information
tsteven4 committed Sep 12, 2023
1 parent 0a981dc commit 0a3facf
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 234 deletions.
1 change: 1 addition & 0 deletions formspec.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum FsType {
kFsQstarzBl1000 = 0x5173747aL,
kFsLowranceusr4 = 0x615f234cL,
kFsIGC = 69676308L, /* IGC format, amendment 8 (2023-02-08) */
kFsKML = 0x4B4D4C00L
};

struct FormatSpecificData {
Expand Down
335 changes: 165 additions & 170 deletions kml.cc

Large diffs are not rendered by default.

51 changes: 28 additions & 23 deletions kml.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef KML_H_INCLUDED_
#define KML_H_INCLUDED_

#include <bitset> // for bitset
#include <tuple> // for tuple, make_tuple, tie

#include <QList> // for QList
Expand Down Expand Up @@ -69,7 +70,7 @@ class KmlFormat : public Format
// Helper to write gx:SimpleList, iterating over a route queue and writing out.

enum class wp_field {
cadence,
cadence = 0,
depth,
heartrate,
temperature,
Expand All @@ -84,8 +85,9 @@ class KmlFormat : public Format
igc_fxa, // Fix Accuracy
igc_gfo, // G Force
igc_siu, // Satellites In Use
igc_acz // Z Acceleration
igc_acz, // Z Acceleration
};
static constexpr int number_wp_fields = 16;

private:
/* Types */
Expand All @@ -99,6 +101,24 @@ class KmlFormat : public Format
kmlpt_other
};

struct mt_field_t {
wp_field id;
const QString name;
const QString displayName;
const QString type;
};

struct kml_fsdata : FormatSpecificData {
kml_fsdata() : FormatSpecificData(kFsKML) {}

kml_fsdata* clone() const override
{
return new kml_fsdata(*this);
}

std::bitset<number_wp_fields> traits;
};

/* Constants */
static constexpr const char* default_precision = "6";
static constexpr int kml_color_limit = 204; /* allowed range [0,255] */
Expand All @@ -118,25 +138,6 @@ class KmlFormat : public Format
nullptr
};

// Multitrack ids to correlate Schema to SchemaData
static constexpr const char* kmt_heartrate = "heartrate";
static constexpr const char* kmt_cadence = "cadence";
static constexpr const char* kmt_temperature = "temperature";
static constexpr const char* kmt_depth = "depth";
static constexpr const char* kmt_power = "power";
static constexpr const char* kmt_sat = "satellites";
// Constants pertaining to IGC files would be better defined in either igc.h or formspec.h
static constexpr const char* kmt_igc_enl = "Engine Noise";
static constexpr const char* kmt_igc_vat = "Ttl Enrg Vario";
static constexpr const char* kmt_igc_tas = "True Airspd";
static constexpr const char* kmt_igc_oat = "Otsd Air Temp";
static constexpr const char* kmt_igc_trt = "True Track";
static constexpr const char* kmt_igc_gsp = "Ground Speed";
static constexpr const char* kmt_igc_fxa = "Fix Accuracy";
static constexpr const char* kmt_igc_gfo = "G Force?";
static constexpr const char* kmt_igc_siu = "# Of Sats";
static constexpr const char* kmt_igc_acz = "Z Accel";

// IGC option compile-time flags
static constexpr bool kIncludeIGCSIU = true;
static constexpr bool kIncludeIGCTRT = false;
Expand Down Expand Up @@ -196,20 +197,24 @@ class KmlFormat : public Format
void kml_track_hdr(const route_head* header) const;
void kml_track_disp(const Waypoint* waypointp) const;
void kml_track_tlr(const route_head* header);
void kml_mt_simple_array(const route_head* header, const char* name, wp_field member) const;
void kml_mt_simple_array(const route_head* header, const QString& name, wp_field member) const;
static bool track_has_time(const route_head* header);
void write_as_linestring(const route_head* header);
void kml_accumulate_traits(const route_head* rte);
void kml_mt_hdr(const route_head* header);
void kml_mt_tlr(const route_head* header) const;
void kml_route_hdr(const route_head* header) const;
void kml_route_disp(const Waypoint* waypointp) const;
void kml_route_tlr(const route_head* header);
void kml_write_AbstractView();
void kml_mt_array_schema(const char* field_name, const char* display_name, const char* type) const;
void kml_mt_array_schema(const QString& field_name, const QString& display_name, const QString& type) const;
static QString kml_get_posn_icon(int freshness);

/* Data Members */

static const QVector<mt_field_t> mt_fields_def;
std::bitset<number_wp_fields> kml_traits;

// options
char* opt_deficon{nullptr};
char* opt_export_lines{nullptr};
Expand Down
14 changes: 7 additions & 7 deletions reference/realtime.kml
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@
</LineStyle>
</Style>
<Schema id="schema">
<gx:SimpleArrayField name="heartrate" type="int">
<displayName>Heart Rate</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="cadence" type="int">
<displayName>Cadence</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="power" type="float">
<displayName>Power</displayName>
<gx:SimpleArrayField name="depth" type="float">
<displayName>Depth</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="heartrate" type="int">
<displayName>Heart Rate</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="temperature" type="float">
<displayName>Temperature</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="depth" type="float">
<displayName>Depth</displayName>
<gx:SimpleArrayField name="power" type="float">
<displayName>Power</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="satellites" type="int">
<displayName>Satellites</displayName>
Expand Down
49 changes: 35 additions & 14 deletions reference/track/92GV66G1.igc.kml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,27 @@
</LineStyle>
</Style>
<Schema id="schema">
<gx:SimpleArrayField name="igc_enl" type="double">
<displayName>Engine Noise</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="igc_tas" type="double">
<displayName>True Airspd</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="igc_oat" type="double">
<displayName>Otsd Air Temp</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="igc_vat" type="double">
<displayName>Ttl Enrg Vario</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="igc_gsp" type="double">
<displayName>Ground Speed</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="igc_fxa" type="double">
<displayName>Fix Accuracy</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="igc_acz" type="double">
<displayName>Z Accel</displayName>
</gx:SimpleArrayField>
<gx:SimpleArrayField name="temperature" type="float">
<displayName>Temperature</displayName>
</gx:SimpleArrayField>
Expand Down Expand Up @@ -1572,7 +1593,7 @@
<gx:coord>-81.838083 28.408050 51.00</gx:coord>
<ExtendedData>
<SchemaData schemaUrl="#schema">
<gx:SimpleArrayData name="Engine Noise">
<gx:SimpleArrayData name="igc_enl">
<gx:value>31</gx:value>
<gx:value>1</gx:value>
<gx:value>4</gx:value>
Expand Down Expand Up @@ -2298,7 +2319,7 @@
<gx:value>15</gx:value>
<gx:value>4</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="True Airspd">
<gx:SimpleArrayData name="igc_tas">
<gx:value>0</gx:value>
<gx:value>0</gx:value>
<gx:value>0</gx:value>
Expand Down Expand Up @@ -3024,7 +3045,7 @@
<gx:value>0</gx:value>
<gx:value>0</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Otsd Air Temp">
<gx:SimpleArrayData name="igc_oat">
<gx:value>26.1</gx:value>
<gx:value>26.1</gx:value>
<gx:value>26.1</gx:value>
Expand Down Expand Up @@ -3750,7 +3771,7 @@
<gx:value>22.6</gx:value>
<gx:value>22.6</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Ttl Enrg Vario">
<gx:SimpleArrayData name="igc_vat">
<gx:value>1.1</gx:value>
<gx:value>0.7</gx:value>
<gx:value>0.3</gx:value>
Expand Down Expand Up @@ -4476,7 +4497,7 @@
<gx:value>0</gx:value>
<gx:value>-0.1</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Ground Speed">
<gx:SimpleArrayData name="igc_gsp">
<gx:value>0.31</gx:value>
<gx:value>0.08</gx:value>
<gx:value>0.05</gx:value>
Expand Down Expand Up @@ -5202,7 +5223,7 @@
<gx:value>0.02</gx:value>
<gx:value>0.01</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Fix Accuracy">
<gx:SimpleArrayData name="igc_fxa">
<gx:value>7</gx:value>
<gx:value>6</gx:value>
<gx:value>7</gx:value>
Expand Down Expand Up @@ -5928,7 +5949,7 @@
<gx:value>7</gx:value>
<gx:value>7</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Z Accel">
<gx:SimpleArrayData name="igc_acz">
<gx:value>9</gx:value>
<gx:value>9</gx:value>
<gx:value>9</gx:value>
Expand Down Expand Up @@ -8113,7 +8134,7 @@
<gx:coord>-81.838083 28.408050 28.00</gx:coord>
<ExtendedData>
<SchemaData schemaUrl="#schema">
<gx:SimpleArrayData name="Engine Noise">
<gx:SimpleArrayData name="igc_enl">
<gx:value>31</gx:value>
<gx:value>1</gx:value>
<gx:value>4</gx:value>
Expand Down Expand Up @@ -8839,7 +8860,7 @@
<gx:value>15</gx:value>
<gx:value>4</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="True Airspd">
<gx:SimpleArrayData name="igc_tas">
<gx:value>0</gx:value>
<gx:value>0</gx:value>
<gx:value>0</gx:value>
Expand Down Expand Up @@ -9565,7 +9586,7 @@
<gx:value>0</gx:value>
<gx:value>0</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Otsd Air Temp">
<gx:SimpleArrayData name="igc_oat">
<gx:value>26.1</gx:value>
<gx:value>26.1</gx:value>
<gx:value>26.1</gx:value>
Expand Down Expand Up @@ -10291,7 +10312,7 @@
<gx:value>22.6</gx:value>
<gx:value>22.6</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Ttl Enrg Vario">
<gx:SimpleArrayData name="igc_vat">
<gx:value>1.1</gx:value>
<gx:value>0.7</gx:value>
<gx:value>0.3</gx:value>
Expand Down Expand Up @@ -11017,7 +11038,7 @@
<gx:value>0</gx:value>
<gx:value>-0.1</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Ground Speed">
<gx:SimpleArrayData name="igc_gsp">
<gx:value>0.31</gx:value>
<gx:value>0.08</gx:value>
<gx:value>0.05</gx:value>
Expand Down Expand Up @@ -11743,7 +11764,7 @@
<gx:value>0.02</gx:value>
<gx:value>0.01</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Fix Accuracy">
<gx:SimpleArrayData name="igc_fxa">
<gx:value>7</gx:value>
<gx:value>6</gx:value>
<gx:value>7</gx:value>
Expand Down Expand Up @@ -12469,7 +12490,7 @@
<gx:value>7</gx:value>
<gx:value>7</gx:value>
</gx:SimpleArrayData>
<gx:SimpleArrayData name="Z Accel">
<gx:SimpleArrayData name="igc_acz">
<gx:value>9</gx:value>
<gx:value>9</gx:value>
<gx:value>9</gx:value>
Expand Down
Loading

0 comments on commit 0a3facf

Please sign in to comment.