From cfe18de076d573d86b4e4666710f96d2bb69acd6 Mon Sep 17 00:00:00 2001
From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
Date: Sat, 7 Jan 2023 08:18:02 -0700
Subject: [PATCH] mimic std::optional for flagged Waypoint fields. (#975)
* mimic std::optional for flagged Waypoint fields.
* manual adjustments to waypt access usage.
* split optional Waypoint flags, tune packing.
* bring op_flags into Waypoint.
* add comments about future Waypoint optional fields.
* sort Waypoint class almost normally.
private members refered to with decltype need to be defined
before they are referred to.
* remove extra parens around *has_value().
* remove extra parens around *value_or().
* remove more extra parens.
---
defs.h | 153 ++++++++++++++++++++++++++++++---------------
dg-100.cc | 2 +-
exif.cc | 21 +++----
garmin.cc | 26 +++++---
garmin_fit.cc | 4 +-
garmin_fit.h | 2 +-
garmin_fs.cc | 24 +++----
garmin_gpi.cc | 26 ++++----
garmin_txt.cc | 24 +++----
gdb.cc | 20 +++---
globalsat_sport.cc | 2 +-
gpssim.cc | 4 +-
gpx.cc | 58 ++++++++---------
gtrnctr.cc | 8 +--
humminbird.cc | 8 +--
kml.cc | 34 +++++-----
lowranceusr.cc | 10 +--
mtk_logger.cc | 4 +-
navilink.cc | 12 ++--
nmea.cc | 34 +++++-----
ozi.cc | 6 +-
qstarz_bl_1000.cc | 4 +-
random.cc | 10 +--
route.cc | 17 +++--
sbn.cc | 4 +-
skytraq.cc | 4 +-
subrip.cc | 4 +-
trackfilter.cc | 30 ++++-----
unicsv.cc | 42 ++++++-------
v900.cc | 4 +-
waypt.cc | 31 ++++-----
xcsv.cc | 42 ++++++-------
32 files changed, 365 insertions(+), 309 deletions(-)
diff --git a/defs.h b/defs.h
index e159b4319..b49d0ab4d 100644
--- a/defs.h
+++ b/defs.h
@@ -259,30 +259,12 @@ class wp_flags
wp_flags() :
shortname_is_synthetic(0),
fmt_use(0),
- temperature(0),
- proximity(0),
- course(0),
- speed(0),
- geoidheight(0),
- depth(0),
is_split(0),
new_trkseg(0) {}
unsigned int shortname_is_synthetic:1;
unsigned int fmt_use:2; /* lightweight "extra data" */
- /* "flagged fields" */
- unsigned int temperature:1; /* temperature field is set */
- unsigned int proximity:1; /* proximity field is set */
- unsigned int course:1; /* course field is set */
- unsigned int speed:1; /* speed field is set */
- unsigned int geoidheight:1; /* geoidheight field is set */
- unsigned int depth:1; /* depth field is set */
- /* !ToDo!
- unsigned int altitude:1; /+ altitude field is set +/
- ... and others
- */
unsigned int is_split:1; /* the waypoint represents a split */
unsigned int new_trkseg:1; /* True if first in new trkseg. */
-
};
// These are dicey as they're collected on read. Subsequent filters may change
@@ -319,14 +301,6 @@ struct bounds {
double min_alt; /* -unknown_alt => invalid */
};
-#define WAYPT_SET(wpt,member,val) do { (wpt)->member = (val); (wpt)->wpt_flags.member = 1; } while (0)
-#define WAYPT_GET(wpt,member,def) (((wpt)->wpt_flags.member) ? ((wpt)->member) : (def))
-#define WAYPT_UNSET(wpt,member) wpt->wpt_flags.member = 0
-#define WAYPT_HAS(wpt,member) ((wpt)->wpt_flags.member)
-#define WAYPT_EQUAL(wpta,wptb,member) (((wpta)->wpt_flags.member && (wptb)->wpt_flags.member && \
- ((wpta)->member == (wptb)->member)) || \
- (!(wpta)->wpt_flags.member && !(wptb)->wpt_flags.member))
-
/*
* This is a waypoint, as stored in the GPSR. It tries to not
* cater to any specific model or protocol. Anything that needs to
@@ -336,13 +310,36 @@ struct bounds {
class Waypoint
{
private:
- static Geocache empty_gc_data;
-public:
+ /* Types */
+
+ class op_flags
+ {
+ public:
+ op_flags() :
+ temperature(false),
+ proximity(false),
+ course(false),
+ speed(false),
+ geoidheight(false),
+ depth(false) {}
+ bool temperature:1; /* temperature field is set */
+ bool proximity:1; /* proximity field is set */
+ bool course:1; /* course field is set */
+ bool speed:1; /* speed field is set */
+ bool geoidheight:1; /* geoidheight field is set */
+ bool depth:1; /* depth field is set */
+ /* !ToDo!
+ unsigned int altitude:1; /+ altitude field is set +/
+ ... and hdop,pdop,vdop,fix,sat,heartrate,cadence,power,
+ odometer_distance
+ */
+ };
+
+ /* Data Members */
+
+ static Geocache empty_gc_data;
- double latitude; /* Degrees */
- double longitude; /* Degrees */
- double altitude; /* Meters. */
double geoidheight; /* Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. */
/*
@@ -358,6 +355,79 @@ class Waypoint
* The units are meters.
*/
double proximity;
+ float course; /* Optional: degrees true */
+ float speed; /* Optional: meters per second. */
+ float temperature; /* Degrees celsius */
+ op_flags opt_flags;
+
+public:
+
+ /* Special Member Functions */
+
+ Waypoint();
+ ~Waypoint();
+ Waypoint(const Waypoint& other);
+ Waypoint& operator=(const Waypoint& other);
+
+ /* Member Functions */
+
+ bool HasUrlLink() const;
+ const UrlLink& GetUrlLink() const;
+ void AddUrlLink(const UrlLink& l);
+ QString CreationTimeXML() const;
+ gpsbabel::DateTime GetCreationTime() const;
+ void SetCreationTime(const gpsbabel::DateTime& t);
+ void SetCreationTime(qint64 t, qint64 ms = 0);
+ Geocache* AllocGCData();
+ int EmptyGCData() const;
+
+// mimic std::optional interface, but use our more space
+// efficient wp_flags.
+#define GEN_WAYPT_METHODS(field) \
+ bool field##_has_value() const \
+ { \
+ return opt_flags.field; \
+ } \
+ decltype(field) field##_value() const \
+ { \
+ if (!opt_flags.field) { \
+ throw std::bad_optional_access(); \
+ } \
+ return field; \
+ } \
+ bool field##s_equal(const Waypoint& other) const \
+ { \
+ return (opt_flags.field && other.opt_flags.field && (field == other.field)) || \
+ (!opt_flags.field && !other.opt_flags.field); \
+ } \
+ decltype(field) field##_value_or(decltype(field) p) const \
+ { \
+ return (opt_flags.field)? field : p; \
+ } \
+ void set_##field(decltype(field) p) \
+ { \
+ field = p; \
+ opt_flags.field = 1; \
+ } \
+ void reset_##field() \
+ { \
+ opt_flags.field = 0; \
+ }
+
+ GEN_WAYPT_METHODS(temperature)
+ GEN_WAYPT_METHODS(proximity)
+ GEN_WAYPT_METHODS(course)
+ GEN_WAYPT_METHODS(speed)
+ GEN_WAYPT_METHODS(geoidheight)
+ GEN_WAYPT_METHODS(depth)
+
+#undef GEN_WAYPT_METHODS
+
+ /* Data Members */
+
+ double latitude; /* Degrees */
+ double longitude; /* Degrees */
+ double altitude; /* Meters. */
/* shortname is a waypoint name as stored in receiver. It should
* strive to be, well, short, and unique. Enforcing length and
@@ -382,11 +452,11 @@ class Waypoint
UrlList urls;
- wp_flags wpt_flags;
QString icon_descr;
gpsbabel::DateTime creation_time;
+ wp_flags wpt_flags;
/*
* route priority is for use by the simplify filter. If we have
* some reason to believe that the route point is more important,
@@ -405,36 +475,17 @@ class Waypoint
float hdop;
float vdop;
float pdop;
- float course; /* Optional: degrees true */
- float speed; /* Optional: meters per second. */
fix_type fix; /* Optional: 3d, 2d, etc. */
int sat; /* Optional: number of sats used for fix */
unsigned char heartrate; /* Beats/min. likely to get moved to fs. */
unsigned char cadence; /* revolutions per minute */
float power; /* watts, as measured by cyclists */
- float temperature; /* Degrees celsius */
float odometer_distance; /* Meters */
Geocache* gc_data;
FormatSpecificDataList fs;
const session_t* session; /* pointer to a session struct */
void* extra_data; /* Extra data added by, say, a filter. */
-
-public:
- Waypoint();
- ~Waypoint();
- Waypoint(const Waypoint& other);
- Waypoint& operator=(const Waypoint& other);
-
- bool HasUrlLink() const;
- const UrlLink& GetUrlLink() const;
- void AddUrlLink(const UrlLink& l);
- QString CreationTimeXML() const;
- gpsbabel::DateTime GetCreationTime() const;
- void SetCreationTime(const gpsbabel::DateTime& t);
- void SetCreationTime(qint64 t, qint64 ms = 0);
- Geocache* AllocGCData();
- int EmptyGCData() const;
};
using waypt_cb = void (*)(const Waypoint*);
diff --git a/dg-100.cc b/dg-100.cc
index 037dec97c..53bc50fd8 100644
--- a/dg-100.cc
+++ b/dg-100.cc
@@ -228,7 +228,7 @@ Dg100Format::process_gpsfile(uint8_t data[], route_head** track) const
* with a scaling factor of 100, in km/h.
* The waypoint struct wants the speed as a
* floating-point number, in m/s. */
- WAYPT_SET(wpt, speed, KPH_TO_MPS(be_read32(data + i + 16) / 100.0));
+ wpt->set_speed(KPH_TO_MPS(be_read32(data + i + 16) / 100.0));
}
if (style >= 2) {
diff --git a/exif.cc b/exif.cc
index 301488fc3..02269a77c 100644
--- a/exif.cc
+++ b/exif.cc
@@ -790,7 +790,7 @@ ExifFormat::exif_waypt_from_exif_app(ExifApp* app) const
speed_ref = tag->data.at(0).toByteArray().at(0);
break;
case GPS_IFD_TAG_SPEED:
- WAYPT_SET(wpt, speed, exif_read_double(tag, 0));
+ wpt->set_speed(exif_read_double(tag, 0));
break;
case GPS_IFD_TAG_DATUM:
datum = exif_read_str(tag);
@@ -854,25 +854,24 @@ ExifFormat::exif_waypt_from_exif_app(ExifApp* app) const
}
}
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
switch (speed_ref) {
case 'K':
- wpt->speed = KPH_TO_MPS(wpt->speed);
+ wpt->set_speed(KPH_TO_MPS(wpt->speed_value()));
break;
case 'M':
- wpt->speed = MPH_TO_MPS(wpt->speed);
+ wpt->set_speed(MPH_TO_MPS(wpt->speed_value()));
break;
case 'N':
- wpt->speed = KNOTS_TO_MPS(wpt->speed);
+ wpt->set_speed(KNOTS_TO_MPS(wpt->speed_value()));
break;
default:
- wpt->speed = 0;
- WAYPT_UNSET(wpt, speed);
+ wpt->reset_speed();
warning(MYNAME ": Unknown GPSSpeedRef unit %c (0x%02x)!\n", speed_ref, speed_ref);
}
if (global_opts.debug_level >= 3) {
- if WAYPT_HAS(wpt, speed) {
- printf(MYNAME "-GPSSpeed = %12.2f m/s\n", wpt->speed);
+ if (wpt->speed_has_value()) {
+ printf(MYNAME "-GPSSpeed = %12.2f m/s\n", wpt->speed_value());
}
}
}
@@ -1582,9 +1581,9 @@ ExifFormat::write()
exif_remove_tag(GPS_IFD, GPS_IFD_TAG_DOP);
}
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
exif_put_str(GPS_IFD, GPS_IFD_TAG_SPEEDREF, "K");
- exif_put_double(GPS_IFD, GPS_IFD_TAG_SPEED, 0, MPS_TO_KPH(wpt->speed));
+ exif_put_double(GPS_IFD, GPS_IFD_TAG_SPEED, 0, MPS_TO_KPH(wpt->speed_value()));
} else {
exif_remove_tag(GPS_IFD, GPS_IFD_TAG_SPEEDREF);
exif_remove_tag(GPS_IFD, GPS_IFD_TAG_SPEED);
diff --git a/garmin.cc b/garmin.cc
index 8dc14600e..63516c3ad 100644
--- a/garmin.cc
+++ b/garmin.cc
@@ -560,10 +560,10 @@ track_read()
next_is_new_trkseg = 0;
if (array[i]->dpth < 1.0e25f) {
- WAYPT_SET(wpt, depth, array[i]->dpth);
+ wpt->set_depth(array[i]->dpth);
}
if (array[i]->temperature_populated) {
- WAYPT_SET(wpt, temperature, array[i]->temperature);
+ wpt->set_temperature(array[i]->temperature);
}
track_add_wpt(trk_head, wpt);
@@ -641,10 +641,10 @@ pvt2wpt(GPS_PPvt_Data pvt, Waypoint* wpt)
wpt->latitude = pvt->lat;
wpt->longitude = pvt->lon;
- WAYPT_SET(wpt, course, 180 + DEG(std::atan2(-pvt->east, -pvt->north)));
+ wpt->set_course(180 + DEG(std::atan2(-pvt->east, -pvt->north)));
/* velocity in m/s */
- WAYPT_SET(wpt,speed, std::sqrt(pvt->north*pvt->north + pvt->east*pvt->east));
+ wpt->set_speed(std::sqrt(pvt->north*pvt->north + pvt->east*pvt->east));
// wpt->vs = pvt->up;
/*
@@ -1229,13 +1229,13 @@ garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid
garmin_fs_t::set_category(gmsd, way->category);
}
if (way->dst < 1.0e25f) {
- WAYPT_SET(wpt, proximity, way->dst);
+ wpt->set_proximity(way->dst);
}
if (way->temperature_populated) {
- WAYPT_SET(wpt, temperature, way->temperature);
+ wpt->set_temperature(way->temperature);
}
if (way->dpth < 1.0e25f) {
- WAYPT_SET(wpt, depth, way->dpth);
+ wpt->set_depth(way->dpth);
}
/* will copy until a null character or the end of the fixed length way field is reached, whichever comes first. */
garmin_fs_t::set_cc(gmsd, str_to_unicode(QByteArray(way->cc, qstrnlen(way->cc, sizeof(way->cc)))));
@@ -1263,9 +1263,15 @@ garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, const int proto
way->dspl = gt_switch_display_mode_value(
garmin_fs_t::get_display(gmsd, way->dspl), gps_waypt_type, 0);
way->category = garmin_fs_t::get_category(gmsd, way->category);
- way->dpth = WAYPT_GET(wpt, depth, way->dpth);
- way->dst = WAYPT_GET(wpt, proximity, way->dpth);
- way->temperature = WAYPT_GET(wpt, temperature, way->temperature);
+ if (wpt->depth_has_value()) {
+ way->dpth = wpt->depth_value();
+ }
+ if (wpt->proximity_has_value()) {
+ way->dst = wpt->proximity_value();
+ }
+ if (wpt->temperature_has_value()) {
+ way->temperature = wpt->temperature_value();
+ }
/* destination may not be null terminated, but we will fill with nulls if necessary */
strncpy(way->cc, str_from_unicode(garmin_fs_t::get_cc(gmsd, nullptr)).constData(), sizeof(way->cc));
diff --git a/garmin_fit.cc b/garmin_fit.cc
index 2e68b4995..8edb39584 100644
--- a/garmin_fit.cc
+++ b/garmin_fit.cc
@@ -696,7 +696,7 @@ GarminFitFormat::fit_parse_data(const fit_message_def& def, int time_offset)
}
waypt->SetCreationTime(GPS_Math_Gtime_To_Utime(timestamp));
if (speed != 0xffff) {
- WAYPT_SET(waypt, speed, speed / 1000.0f);
+ waypt->set_speed(speed / 1000.0f);
}
if (heartrate != 0xff) {
waypt->heartrate = heartrate;
@@ -708,7 +708,7 @@ GarminFitFormat::fit_parse_data(const fit_message_def& def, int time_offset)
waypt->power = power;
}
if (temperature != 0x7f) {
- WAYPT_SET(waypt, temperature, temperature);
+ waypt->set_temperature(temperature);
}
if (new_trkseg) {
waypt->wpt_flags.new_trkseg = 1;
diff --git a/garmin_fit.h b/garmin_fit.h
index da673c1e5..6336f541e 100644
--- a/garmin_fit.h
+++ b/garmin_fit.h
@@ -100,7 +100,7 @@ class GarminFitFormat : public Format
: lat(wpt.latitude),
lon(wpt.longitude),
altitude(wpt.altitude),
- speed(WAYPT_GET(&wpt, speed, -1)),
+ speed(wpt.speed_value_or(-1)),
odometer_distance(wpt.odometer_distance),
creation_time(wpt.creation_time),
shortname(wpt.shortname),
diff --git a/garmin_fs.cc b/garmin_fs.cc
index 753bc5395..1827fe120 100644
--- a/garmin_fs.cc
+++ b/garmin_fs.cc
@@ -107,22 +107,22 @@ garmin_fs_xml_fprint(const Waypoint* waypt,
if (!addr.isEmpty() || !phone.isEmpty() ||
(gmsd->flags.category && gmsd->category) ||
- WAYPT_HAS(waypt, depth) ||
- WAYPT_HAS(waypt, proximity) ||
- WAYPT_HAS(waypt, temperature) ||
+ 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_HAS(waypt, proximity) {
- writer->writeTextElement(QStringLiteral("gpxx:Proximity"), QString::number(waypt->proximity, 'f', 6));
+ if (waypt->proximity_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Proximity"), QString::number(waypt->proximity_value(), 'f', 6));
}
- if WAYPT_HAS(waypt, temperature) {
- writer->writeTextElement(QStringLiteral("gpxx:Temperature"), QString::number(waypt->temperature, 'f', 6));
+ if (waypt->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Temperature"), QString::number(waypt->temperature_value(), 'f', 6));
}
- if WAYPT_HAS(waypt, depth) {
- writer->writeTextElement(QStringLiteral("gpxx:Depth"), QString::number(waypt->depth, '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;
@@ -212,17 +212,17 @@ garmin_fs_xml_convert(const int base_tag, int tag, const QString& qstr, Waypoint
switch (tag) {
case 1:
if (*cdatastr) {
- WAYPT_SET(waypt, proximity, strtod(cdatastr, nullptr));
+ waypt->set_proximity(strtod(cdatastr, nullptr));
}
break;
case 2:
if (*cdatastr) {
- WAYPT_SET(waypt, temperature, strtod(cdatastr, nullptr));
+ waypt->set_temperature(strtod(cdatastr, nullptr));
}
break;
case 3:
if (*cdatastr) {
- WAYPT_SET(waypt, depth, strtod(cdatastr, nullptr));
+ waypt->set_depth(strtod(cdatastr, nullptr));
}
break;
case 4:
diff --git a/garmin_gpi.cc b/garmin_gpi.cc
index 8c2d3c8e4..095cf6781 100644
--- a/garmin_gpi.cc
+++ b/garmin_gpi.cc
@@ -380,11 +380,11 @@ GarminGPIFormat::read_tag(const char* caller, const int tag, Waypoint* wpt)
speed = (double)gbfgetint16(fin) / 100; /* speed in meters per second */
if (dist > 0) {
- WAYPT_SET(wpt, proximity, dist);
+ wpt->set_proximity(dist);
}
if (speed > 0) {
/* speed isn't part of a normal waypoint
- WAYPT_SET(wpt, speed, speed);
+ wpt->set_speed(speed);
*/
if ((wpt->shortname.isEmpty() || ((wpt->shortname).indexOf('@'))==-1)) {
if (units == 's') {
@@ -725,21 +725,21 @@ GarminGPIFormat::wdata_compute_size(writer_data_t* data) const
double speed = 0;
parse_speed(wpt->shortname.mid(pidx + 1), &speed, scale, MYNAME);
if (speed > 0) {
- WAYPT_SET(wpt, speed, speed);
+ wpt->set_speed(speed);
}
#if 0
wpt->shortname.truncate(pidx);
#endif
- } else if ((opt_speed) && (! WAYPT_HAS(wpt, speed))) {
- WAYPT_SET(wpt, speed, defspeed);
+ } else if ((opt_speed) && (!wpt->speed_has_value())) {
+ wpt->set_speed(defspeed);
}
- if ((opt_proximity) && (! WAYPT_HAS(wpt, proximity))) {
- WAYPT_SET(wpt, proximity, defproximity);
+ if ((opt_proximity) && (!wpt->proximity_has_value())) {
+ wpt->set_proximity(defproximity);
}
- if ((WAYPT_HAS(wpt, speed) && (wpt->speed > 0)) ||
- (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0))) {
+ if ((wpt->speed_has_value() && (wpt->speed_value() > 0)) ||
+ (wpt->proximity_has_value() && (wpt->proximity_value() > 0))) {
data->alert = 1;
dt->alerts++;
res += 20; /* tag(3) */
@@ -897,14 +897,14 @@ GarminGPIFormat::wdata_write(const writer_data_t* data) const
gbfputint32(3, fout); /* tag(3) */
gbfputint32(12, fout); /* always 12 */
- if (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0)) {
- gbfputint16((int) wpt->proximity, fout);
+ if (wpt->proximity_has_value() && (wpt->proximity_value() > 0)) {
+ gbfputint16((int) wpt->proximity_value(), fout);
flag = 4;
} else {
gbfputint16(0, fout);
}
- if (WAYPT_HAS(wpt, speed) && (wpt->speed > 0)) {
- gbfputint16((int)(wpt->speed * 100), fout);
+ if (wpt->speed_has_value() && (wpt->speed_value() > 0)) {
+ gbfputint16((int)(wpt->speed_value() * 100), fout);
flag = 5;
} else {
gbfputint16(0, fout);
diff --git a/garmin_txt.cc b/garmin_txt.cc
index e544a2907..2c8151770 100644
--- a/garmin_txt.cc
+++ b/garmin_txt.cc
@@ -565,19 +565,19 @@ write_waypt(const Waypoint* wpt)
}
*fout << "\t";
- double x = WAYPT_GET(wpt, depth, unknown_alt);
+ double x = wpt->depth_value_or(unknown_alt);
if (x != unknown_alt) {
print_distance(x, 1, 0, 1);
}
*fout << "\t";
- x = WAYPT_GET(wpt, proximity, unknown_alt);
+ x = wpt->proximity_value_or(unknown_alt);
if (x != unknown_alt) {
print_distance(x, 0, 0, 0);
}
*fout << "\t";
- x = WAYPT_GET(wpt, temperature, -999);
+ x = wpt->temperature_value_or(-999);
if (x != -999) {
print_temperature(x);
}
@@ -711,7 +711,7 @@ track_disp_wpt_cb(const Waypoint* wpt)
}
*fout << "\t";
- double depth = WAYPT_GET(wpt, depth, unknown_alt);
+ double depth = wpt->depth_value_or(unknown_alt);
if (depth != unknown_alt) {
print_distance(depth, 1, 0, 1);
}
@@ -719,7 +719,7 @@ track_disp_wpt_cb(const Waypoint* wpt)
if (prev != nullptr) {
*fout << "\t";
delta = wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t();
- float temp = WAYPT_GET(wpt, temperature, -999);
+ float temp = wpt->temperature_value_or(-999);
if (temp != -999) {
print_temperature(temp);
}
@@ -1143,17 +1143,17 @@ parse_waypoint(const QStringList& lineparts)
break;
case 6:
if (parse_distance(str, &d, 1, MYNAME)) {
- WAYPT_SET(wpt, depth, d);
+ wpt->set_depth(d);
}
break;
case 7:
if (parse_distance(str, &d, 1, MYNAME)) {
- WAYPT_SET(wpt, proximity, d);
+ wpt->set_proximity(d);
}
break;
case 8:
if (parse_temperature(str, &d)) {
- WAYPT_SET(wpt, temperature, d);
+ wpt->set_temperature(d);
}
break;
case 9:
@@ -1319,21 +1319,21 @@ parse_track_waypoint(const QStringList& lineparts)
break;
case 4:
if (parse_distance(str, &x, 1, MYNAME)) {
- WAYPT_SET(wpt, depth, x);
+ wpt->set_depth(x);
}
break;
case 5:
if (parse_temperature(str, &x)) {
- WAYPT_SET(wpt, temperature, x);
+ wpt->set_temperature(x);
}
break;
case 8:
if (parse_speed(str, &x, 1, MYNAME)) {
- WAYPT_SET(wpt, speed, x);
+ wpt->set_speed(x);
}
break;
case 9:
- WAYPT_SET(wpt, course, xstrtoi(CSTR(str), nullptr, 10));
+ wpt->set_course(xstrtoi(CSTR(str), nullptr, 10));
break;
}
}
diff --git a/gdb.cc b/gdb.cc
index e205c2d55..b42b53604 100644
--- a/gdb.cc
+++ b/gdb.cc
@@ -492,7 +492,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
qPrintable(QString(res->notes).replace("\r\n", ", ")));
#endif
if (FREAD_C == 1) {
- WAYPT_SET(res, proximity, FREAD_DBL);
+ res->set_proximity(FREAD_DBL);
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, 1)
printf(MYNAME "-wpt \"%s\" (%d): Proximity = %.1f\n",
@@ -528,7 +528,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
FREAD(buf, 1);
if (FREAD_C == 1) {
- WAYPT_SET(res, depth, FREAD_DBL);
+ res->set_depth(FREAD_DBL);
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, 1)
printf(MYNAME "-wpt \"%s\" (%d): Depth = %.1f\n",
@@ -617,7 +617,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
#endif
if (FREAD_C == 1) {
- WAYPT_SET(res, temperature, FREAD_DBL);
+ res->set_temperature(FREAD_DBL);
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, 1)
printf(MYNAME "-wpt \"%s\" (%d): temperature = %.1f\n",
@@ -938,10 +938,10 @@ GdbFormat::read_track()
wpt->SetCreationTime(FREAD_i32);
}
if (FREAD_C == 1) {
- WAYPT_SET(wpt, depth, FREAD_DBL);
+ wpt->set_depth(FREAD_DBL);
}
if (FREAD_C == 1) {
- WAYPT_SET(wpt, temperature, FREAD_DBL);
+ wpt->set_temperature(FREAD_DBL);
}
track_add_wpt(res, wpt);
@@ -1277,7 +1277,7 @@ GdbFormat::write_waypoint(
} else {
FWRITE_CSTR(wpt->description);
}
- FWRITE_DBL(WAYPT_GET(wpt, proximity, unknown_alt), unknown_alt); /* proximity */
+ FWRITE_DBL(wpt->proximity_value_or(unknown_alt), unknown_alt); /* proximity */
FWRITE_i32(display); /* display */
FWRITE_i32(0); /* color */
FWRITE_i32(icon); /* icon */
@@ -1285,7 +1285,7 @@ GdbFormat::write_waypoint(
FWRITE_CSTR(garmin_fs_t::get_state(gmsd, "")); /* state */
FWRITE_CSTR(garmin_fs_t::get_facility(gmsd, "")); /* facility */
FWRITE_C(0); /* unknown */
- FWRITE_DBL(WAYPT_GET(wpt, depth, unknown_alt), unknown_alt); /* depth */
+ FWRITE_DBL(wpt->depth_value_or(unknown_alt), unknown_alt); /* depth */
/* VERSION DEPENDENT CODE */
if (gdb_ver <= GDB_VER_2) {
@@ -1345,7 +1345,7 @@ GdbFormat::write_waypoint(
}
FWRITE_i16(garmin_fs_t::get_category(gmsd, gdb_category));
- FWRITE_DBL(WAYPT_GET(wpt, temperature, 0), 0);
+ FWRITE_DBL(wpt->temperature_value_or(0), 0);
FWRITE_TIME(wpt->GetCreationTime().toTime_t());
/* VERSION DEPENDENT CODE */
@@ -1530,9 +1530,9 @@ GdbFormat::write_track(const route_head* trk, const QString& trk_name)
FWRITE_LATLON(wpt->longitude);
FWRITE_DBL(wpt->altitude, unknown_alt);
FWRITE_TIME(wpt->GetCreationTime().toTime_t());
- double d = WAYPT_GET(wpt, depth, unknown_alt);
+ double d = wpt->depth_value_or(unknown_alt);
FWRITE_DBL(d, unknown_alt);
- d = WAYPT_GET(wpt, temperature, -99999);
+ d = wpt->temperature_value_or(-99999);
FWRITE_DBL(d, -99999);
}
diff --git a/globalsat_sport.cc b/globalsat_sport.cc
index 7de020fe7..8cef720e8 100644
--- a/globalsat_sport.cc
+++ b/globalsat_sport.cc
@@ -644,7 +644,7 @@ GlobalsatSportFormat::track_read()
wpt->longitude = ((int32_t) point.Longitude) / 1000000.0;
wpt->latitude = ((int32_t) point.Latitude) / 1000000.0;
wpt->altitude = point.Altitude;
- WAYPT_SET(wpt, speed, ((double) point.Speed / 100.0) * 1000.0 / 3600.0);
+ wpt->set_speed(((double) point.Speed / 100.0) * 1000.0 / 3600.0);
wpt->heartrate = point.HeartRate;
wpt->cadence = point.Cadence; //TODO convert in any way??
wpt->power = point.Power; //TODO convert in any way??
diff --git a/gpssim.cc b/gpssim.cc
index 86865f442..322564b16 100644
--- a/gpssim.cc
+++ b/gpssim.cc
@@ -109,8 +109,8 @@ gpssim_write_pt(const Waypoint* wpt)
{
char obuf[1024];
- if WAYPT_HAS(wpt, speed) {
- gpssim_write_spd(MPS_TO_KNOTS(wpt->speed));
+ if (wpt->speed_has_value()) {
+ gpssim_write_spd(MPS_TO_KNOTS(wpt->speed_value()));
}
double lat = degrees2ddmm(wpt->latitude);
diff --git a/gpx.cc b/gpx.cc
index 9bd27a10c..19c626b35 100644
--- a/gpx.cc
+++ b/gpx.cc
@@ -599,7 +599,7 @@ GpxFormat::gpx_end(QStringView /*unused*/)
*/
case tt_humminbird_wpt_depth:
case tt_humminbird_trk_trkseg_trkpt_depth:
- WAYPT_SET(wpt_tmp, depth, cdatastr.toDouble() / 100.0);
+ wpt_tmp->set_depth(cdatastr.toDouble() / 100.0);
break;
/*
* Route-specific tags.
@@ -687,10 +687,10 @@ GpxFormat::gpx_end(QStringView /*unused*/)
trk_head->rte_num = cdatastr.toInt();
break;
case tt_trk_trkseg_trkpt_course:
- WAYPT_SET(wpt_tmp, course, cdatastr.toDouble());
+ wpt_tmp->set_course(cdatastr.toDouble());
break;
case tt_trk_trkseg_trkpt_speed:
- WAYPT_SET(wpt_tmp, speed, cdatastr.toDouble());
+ wpt_tmp->set_speed(cdatastr.toDouble());
break;
case tt_trk_trkseg_trkpt_heartrate:
wpt_tmp->heartrate = cdatastr.toDouble();
@@ -731,7 +731,7 @@ GpxFormat::gpx_end(QStringView /*unused*/)
wpt_tmp->SetCreationTime(xml_parse_time(cdatastr));
break;
case tt_wpttype_geoidheight:
- WAYPT_SET(wpt_tmp, geoidheight, cdatastr.toDouble());
+ wpt_tmp->set_geoidheight(cdatastr.toDouble());
break;
case tt_wpttype_cmt:
wpt_tmp->description = cdatastr;
@@ -1180,16 +1180,16 @@ GpxFormat::gpx_write_common_position(const Waypoint* waypointp, const gpx_point_
writer->writeOptionalTextElement(QStringLiteral("time"), t);
if (gpxpt_track==point_type && gpx_1_0 == gpx_write_version) {
/* These were accidentally removed from 1.1, and were only a part of trkpts in 1.0 */
- if WAYPT_HAS(waypointp, course) {
- writer->writeTextElement(QStringLiteral("course"), toString(waypointp->course));
+ if (waypointp->course_has_value()) {
+ writer->writeTextElement(QStringLiteral("course"), toString(waypointp->course_value()));
}
- if WAYPT_HAS(waypointp, speed) {
- writer->writeTextElement(QStringLiteral("speed"), toString(waypointp->speed));
+ if (waypointp->speed_has_value()) {
+ writer->writeTextElement(QStringLiteral("speed"), toString(waypointp->speed_value()));
}
}
/* TODO: magvar should go here */
- if (WAYPT_HAS(waypointp, geoidheight)) {
- writer->writeOptionalTextElement(QStringLiteral("geoidheight"),QString::number(waypointp->geoidheight, 'f', 1));
+ if (waypointp->geoidheight_has_value()) {
+ writer->writeOptionalTextElement(QStringLiteral("geoidheight"),QString::number(waypointp->geoidheight_value(), 'f', 1));
}
}
@@ -1199,18 +1199,18 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin
// 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))) ||
+ if ((opt_humminbirdext && (waypointp->depth_has_value() || waypointp->temperature_has_value())) ||
(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))) {
+ (opt_garminext && gpxpt_waypoint==point_type && (waypointp->proximity_has_value() || waypointp->temperature_has_value() || waypointp->depth_has_value())) ||
+ (opt_garminext && gpxpt_track==point_type && (waypointp->temperature_has_value() || waypointp->depth_has_value() || waypointp->heartrate != 0 || waypointp->cadence != 0))) {
writer->writeStartElement(QStringLiteral("extensions"));
if (opt_humminbirdext) {
- if (WAYPT_HAS(waypointp, depth)) {
- writer->writeTextElement(QStringLiteral("h:depth"), toString(waypointp->depth * 100.0));
+ if (waypointp->depth_has_value()) {
+ writer->writeTextElement(QStringLiteral("h:depth"), toString(waypointp->depth_value() * 100.0));
}
- if (WAYPT_HAS(waypointp, temperature)) {
- writer->writeTextElement(QStringLiteral("h:temperature"), toString(waypointp->temperature));
+ if (waypointp->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("h:temperature"), toString(waypointp->temperature_value()));
}
}
@@ -1221,16 +1221,16 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin
// Although not required by the schema we assume that gpxtpx:TrackPointExtension must be a child of gpx:trkpt.
switch (point_type) {
case gpxpt_waypoint:
- if (WAYPT_HAS(waypointp, proximity) || WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth)) {
+ if (waypointp->proximity_has_value() || waypointp->temperature_has_value() || waypointp->depth_has_value()) {
writer->writeStartElement(QStringLiteral("gpxx:WaypointExtension"));
- if (WAYPT_HAS(waypointp, proximity)) {
- writer->writeTextElement(QStringLiteral("gpxx:Proximity"), toString(waypointp->proximity));
+ if (waypointp->proximity_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Proximity"), toString(waypointp->proximity_value()));
}
- if (WAYPT_HAS(waypointp, temperature)) {
- writer->writeTextElement(QStringLiteral("gpxx:Temperature"), toString(waypointp->temperature));
+ if (waypointp->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Temperature"), toString(waypointp->temperature_value()));
}
- if (WAYPT_HAS(waypointp, depth)) {
- writer->writeTextElement(QStringLiteral("gpxx:Depth"), toString(waypointp->depth));
+ if (waypointp->depth_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxx:Depth"), toString(waypointp->depth_value()));
}
writer->writeEndElement(); // "gpxx:WaypointExtension"
}
@@ -1254,14 +1254,14 @@ GpxFormat::gpx_write_common_extensions(const Waypoint* waypointp, const gpx_poin
}
break;
case gpxpt_track:
- if (WAYPT_HAS(waypointp, temperature) || WAYPT_HAS(waypointp, depth) || waypointp->heartrate != 0 || waypointp->cadence != 0) {
+ if (waypointp->temperature_has_value() || waypointp->depth_has_value() || waypointp->heartrate != 0 || waypointp->cadence != 0) {
// gpxtpx:TrackPointExtension is a replacement for gpxx:TrackPointExtension.
writer->writeStartElement(QStringLiteral("gpxtpx:TrackPointExtension"));
- if (WAYPT_HAS(waypointp, temperature)) {
- writer->writeTextElement(QStringLiteral("gpxtpx:atemp"), toString(waypointp->temperature));
+ if (waypointp->temperature_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxtpx:atemp"), toString(waypointp->temperature_value()));
}
- if (WAYPT_HAS(waypointp, depth)) {
- writer->writeTextElement(QStringLiteral("gpxtpx:depth"), toString(waypointp->depth));
+ if (waypointp->depth_has_value()) {
+ writer->writeTextElement(QStringLiteral("gpxtpx:depth"), toString(waypointp->depth_value()));
}
if (waypointp->heartrate != 0) {
writer->writeTextElement(QStringLiteral("gpxtpx:hr"), QString::number(waypointp->heartrate));
diff --git a/gtrnctr.cc b/gtrnctr.cc
index b9ff1b816..f127ff829 100644
--- a/gtrnctr.cc
+++ b/gtrnctr.cc
@@ -192,12 +192,12 @@ GtrnctrFormat::gtc_waypt_pr(const Waypoint* wpt)
if (wpt->cadence) {
gtc_write_xml(0, "%d\n", wpt->cadence);
}
- if (WAYPT_HAS(wpt, speed) || wpt->power) {
+ if (wpt->speed_has_value() || wpt->power) {
gtc_write_xml(1, "\n");
gtc_write_xml(1, "\n");
/* see http://www8.garmin.com/xmlschemas/ActivityExtensionv2.xsd */
- if (WAYPT_HAS(wpt, speed)) {
- gtc_write_xml(0, "%.3f\n", wpt->speed);
+ if (wpt->speed_has_value()) {
+ gtc_write_xml(0, "%.3f\n", wpt->speed_value());
}
if (wpt->power) {
gtc_write_xml(0, "%.0f\n", wpt->power);
@@ -459,7 +459,7 @@ GtrnctrFormat::gtc_trk_pwr(xg_string args, const QXmlStreamAttributes* /*unused*
void
GtrnctrFormat::gtc_trk_spd(xg_string args, const QXmlStreamAttributes* /*unused*/)
{
- WAYPT_SET(wpt_tmp, speed, args.toDouble());
+ wpt_tmp->set_speed(args.toDouble());
}
void
diff --git a/humminbird.cc b/humminbird.cc
index 3f5979105..6f80e4af5 100644
--- a/humminbird.cc
+++ b/humminbird.cc
@@ -259,7 +259,7 @@ HumminbirdBase::humminbird_read_wpt(gbfile* fin)
wpt->altitude = 0.0; /* It's from a fishfinder... */
if (w.depth != 0) {
- WAYPT_SET(wpt,depth,(double)w.depth / 100.0);
+ wpt->set_depth((double)w.depth / 100.0);
}
int num_icons = sizeof(humminbird_icons) / sizeof(humminbird_icons[0]);
@@ -426,7 +426,7 @@ HumminbirdBase::humminbird_read_track(gbfile* fin)
wpt->altitude = 0.0;
if (points[i].depth != 0) {
- WAYPT_SET(wpt,depth,(double)points[i].depth / 100.0);
+ wpt->set_depth((double)points[i].depth / 100.0);
}
if (i == th.num_points-2 && th.time != 0) {
@@ -657,7 +657,7 @@ HumminbirdFormat::humminbird_write_waypoint(const Waypoint* wpt)
}
}
- hum.depth = qRound(WAYPT_GET(wpt, depth, 0)*100.0);
+ hum.depth = qRound(wpt->depth_value_or(0) * 100.0);
be_write16(&hum.depth, hum.depth);
be_write32(&hum.time, wpt->GetCreationTime().toTime_t());
@@ -769,7 +769,7 @@ HumminbirdHTFormat::humminbird_track_cb(const Waypoint* wpt)
int j = i-1;
trk_points[j].deltaeast = east - last_east;
trk_points[j].deltanorth = north - last_north;
- trk_points[j].depth = qRound(WAYPT_GET(wpt, depth, 0)*100.0);
+ trk_points[j].depth = qRound(wpt->depth_value_or(0) * 100.0);
/* BE-ify */
be_write16(&trk_points[j].deltaeast, trk_points[j].deltaeast);
diff --git a/kml.cc b/kml.cc
index 350aa4b6a..625a4678f 100644
--- a/kml.cc
+++ b/kml.cc
@@ -753,22 +753,22 @@ void KmlFormat::kml_output_description(const Waypoint* pt) const
}
/* Which unit is this temp in? C? F? K? */
- if WAYPT_HAS(pt, temperature) {
- kml_td(hwriter, QStringLiteral("Temperature: %1 ").arg(QString::number(pt->temperature, 'f', 1)));
+ if (pt->temperature_has_value()) {
+ kml_td(hwriter, QStringLiteral("Temperature: %1 ").arg(QString::number(pt->temperature_value(), 'f', 1)));
}
- if WAYPT_HAS(pt, depth) {
- auto [depth, depth_units] = unitsformatter->fmt_distance(pt->depth);
+ if (pt->depth_has_value()) {
+ auto [depth, depth_units] = unitsformatter->fmt_distance(pt->depth_value());
kml_td(hwriter, QStringLiteral("Depth: %1 %2 ").arg(QString::number(depth, 'f', 1), depth_units));
}
- if WAYPT_HAS(pt, speed) {
- auto [spd, spd_units] = unitsformatter->fmt_speed(pt->speed);
+ if (pt->speed_has_value()) {
+ auto [spd, spd_units] = unitsformatter->fmt_speed(pt->speed_value());
kml_td(hwriter, QStringLiteral("Speed: %1 %2 ").arg(QString::number(spd, 'f', 1), spd_units));
}
- if WAYPT_HAS(pt, course) {
- kml_td(hwriter, QStringLiteral("Heading: %1 ").arg(QString::number(pt->course, 'f', 1)));
+ if (pt->course_has_value()) {
+ kml_td(hwriter, QStringLiteral("Heading: %1 ").arg(QString::number(pt->course_value(), 'f', 1)));
}
/* This really shouldn't be here, but as of this writing,
@@ -846,12 +846,12 @@ void KmlFormat::kml_output_point(const Waypoint* waypointp, kml_point_type pt_ty
} else {
if (trackdirection && (pt_type == kmlpt_track)) {
QString value;
- if (!WAYPT_HAS(waypointp, speed) || !WAYPT_HAS(waypointp, course) ||
- (waypointp->speed < 1.0f)) {
+ if (!waypointp->speed_has_value() || !waypointp->course_has_value() ||
+ (waypointp->speed_value() < 1.0f)) {
value = QStringLiteral("%1-none").arg(style);
} else {
value = QStringLiteral("%1-%2").arg(style)
- .arg(qRound(waypointp->course / 22.5) % 16);
+ .arg(qRound(waypointp->course_value() / 22.5) % 16);
}
writer->writeTextElement(QStringLiteral("styleUrl"), value);
} else {
@@ -1480,16 +1480,16 @@ void KmlFormat::kml_mt_simple_array(const route_head* header,
QString::number(wpt->cadence) : QString());
break;
case fld_depth:
- writer->writeTextElement(QStringLiteral("gx:value"), WAYPT_HAS(wpt, depth)?
- QString::number(wpt->depth, 'f', 1) : QString());
+ writer->writeTextElement(QStringLiteral("gx:value"), wpt->depth_has_value()?
+ QString::number(wpt->depth_value(), 'f', 1) : QString());
break;
case fld_heartrate:
writer->writeTextElement(QStringLiteral("gx:value"), wpt->heartrate?
QString::number(wpt->heartrate) : QString());
break;
case fld_temperature:
- writer->writeTextElement(QStringLiteral("gx:value"), WAYPT_HAS(wpt, temperature)?
- QString::number(wpt->temperature, 'f', 1) : QString());
+ writer->writeTextElement(QStringLiteral("gx:value"), wpt->temperature_has_value()?
+ QString::number(wpt->temperature_value(), 'f', 1) : QString());
break;
default:
fatal("Bad member type");
@@ -1575,13 +1575,13 @@ void KmlFormat::kml_mt_hdr(const route_head* header)
if (tpt->cadence) {
has_cadence = true;
}
- if (WAYPT_HAS(tpt, depth)) {
+ if (tpt->depth_has_value()) {
has_depth = true;
}
if (tpt->heartrate) {
has_heartrate = true;
}
- if (WAYPT_HAS(tpt, temperature)) {
+ if (tpt->temperature_has_value()) {
has_temperature = true;
}
if (tpt->power) {
diff --git a/lowranceusr.cc b/lowranceusr.cc
index ece237a69..79b74587d 100644
--- a/lowranceusr.cc
+++ b/lowranceusr.cc
@@ -501,7 +501,7 @@ LowranceusrFormat::lowranceusr_parse_waypt(Waypoint* wpt_tmp, int object_num_pre
if (reading_version == 3) {
float depth_feet = gbfgetflt(file_in);
if (std::abs(depth_feet - 99999.0) > .1) {
- WAYPT_SET(wpt_tmp, depth, FEET_TO_METERS(depth_feet));
+ wpt_tmp->set_depth(FEET_TO_METERS(depth_feet));
if (global_opts.debug_level == 99) {
printf(" %10.1f", depth_feet);
}
@@ -576,7 +576,7 @@ LowranceusrFormat::lowranceusr4_parse_waypt(Waypoint* wpt_tmp) const
/* Alarm radius; XXX: I'm not sure what the units are here,
assuming meters but may be feet? */
- WAYPT_SET(wpt_tmp, proximity, gbfgetflt(file_in));
+ wpt_tmp->set_proximity(gbfgetflt(file_in));
/* Creation date/time */
/* The date is a Julian day number, and the time is a unix timestamp. */
@@ -1365,8 +1365,8 @@ LowranceusrFormat::lowranceusr_waypt_disp(const Waypoint* wpt) const
gbfputint16(WayptType, file_out);
if (writing_version == 3) {
- float depth = WAYPT_HAS(wpt, depth) ?
- METERS_TO_FEET(wpt->depth) : -99999.0;
+ float depth = wpt->depth_has_value() ?
+ METERS_TO_FEET(wpt->depth_value()) : -99999.0;
gbfputint32(depth, file_out);
}
@@ -1437,7 +1437,7 @@ LowranceusrFormat::lowranceusr4_waypt_disp(const Waypoint* wpt)
lowranceusr4_writestr(wpt->description, file_out, 2);
/* Alarm radius */
- gbfputflt(WAYPT_GET(wpt, proximity, 0.0), file_out);
+ gbfputflt(wpt->proximity_value_or(0.0), file_out);
/* Creation date/time */
auto ts = lowranceusr4_jd_from_timestamp(wpt->GetCreationTime());
diff --git a/mtk_logger.cc b/mtk_logger.cc
index d94b47854..c6b7c906f 100644
--- a/mtk_logger.cc
+++ b/mtk_logger.cc
@@ -842,10 +842,10 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
}
if (bmask & (1U<heading);
+ trk->set_course(itm->heading);
}
if (bmask & (1U<speed));
+ trk->set_speed(KPH_TO_MPS(itm->speed));
}
if (bmask & (1U<valid) {
diff --git a/navilink.cc b/navilink.cc
index 49e61f920..e258d4e84 100644
--- a/navilink.cc
+++ b/navilink.cc
@@ -449,8 +449,8 @@ decode_trackpoint(const unsigned char* buffer)
decode_position(buffer + 12, waypt);
waypt->SetCreationTime(decode_datetime(buffer + 22));
- WAYPT_SET(waypt, course, le_read16(buffer + 2));
- WAYPT_SET(waypt, speed, KPH_TO_MPS(buffer[29] * 2));
+ waypt->set_course(le_read16(buffer + 2));
+ waypt->set_speed(KPH_TO_MPS(buffer[29] * 2));
return waypt;
}
@@ -466,13 +466,13 @@ encode_trackpoint(const Waypoint* waypt, unsigned serial, unsigned char* buffer)
GPS_Math_WGS84_To_UTM_EN(waypt->latitude, waypt->longitude, &x, &y, &z, &zc);
le_write16(buffer + 0, serial);
- le_write16(buffer + 2, WAYPT_GET(waypt, course, 0));
+ le_write16(buffer + 2, waypt->course_value_or(0));
le_write32(buffer + 4, x);
le_write32(buffer + 8, y);
encode_position(waypt, buffer + 12);
encode_datetime(waypt->GetCreationTime().toTime_t(), buffer + 22);
buffer[28] = z;
- buffer[29] = MPS_TO_KPH(WAYPT_GET(waypt, speed, 0) / 2);
+ buffer[29] = MPS_TO_KPH(waypt->speed_value_or(0) / 2);
buffer[30] = 0x5a;
buffer[31] = 0x7e;
}
@@ -836,8 +836,8 @@ navilink_decode_logpoint(const unsigned char* buffer)
waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4),
decode_sbp_msec(buffer + 2));
decode_sbp_position(buffer + 12, waypt);
- WAYPT_SET(waypt, speed, le_read16(buffer + 24) * 0.01f);
- WAYPT_SET(waypt, course, le_read16(buffer + 26) * 0.01f);
+ waypt->set_speed(le_read16(buffer + 24) * 0.01f);
+ waypt->set_course(le_read16(buffer + 26) * 0.01f);
return waypt;
}
diff --git a/nmea.cc b/nmea.cc
index fc63c610a..442d5857a 100644
--- a/nmea.cc
+++ b/nmea.cc
@@ -479,7 +479,7 @@ NmeaFormat::gpgga_parse(const QString& ibuf)
waypt->altitude = alt;
- WAYPT_SET(waypt, geoidheight, geoidheight);
+ waypt->set_geoidheight(geoidheight);
waypt->sat = nsats;
@@ -547,11 +547,11 @@ NmeaFormat::gprmc_parse(const QString& ibuf)
if (posn_type == gpgga) {
/* capture useful data update and exit */
if (curr_waypt) {
- if (! WAYPT_HAS(curr_waypt, speed)) {
- WAYPT_SET(curr_waypt, speed, KNOTS_TO_MPS(speed));
+ if (!curr_waypt->speed_has_value()) {
+ curr_waypt->set_speed(KNOTS_TO_MPS(speed));
}
- if (! WAYPT_HAS(curr_waypt, course)) {
- WAYPT_SET(curr_waypt, course, course);
+ if (!curr_waypt->course_has_value()) {
+ curr_waypt->set_course(course);
}
/* The change of date wasn't recorded when
* going from 235959 to 000000. */
@@ -567,8 +567,8 @@ NmeaFormat::gprmc_parse(const QString& ibuf)
Waypoint* waypt = nmea_new_wpt();
- WAYPT_SET(waypt, speed, KNOTS_TO_MPS(speed));
- WAYPT_SET(waypt, course, course);
+ waypt->set_speed(KNOTS_TO_MPS(speed));
+ waypt->set_course(course);
nmea_set_waypoint_time(waypt, &prev_datetime, dmy, hms);
@@ -706,11 +706,11 @@ NmeaFormat::gpvtg_parse(const QString& ibuf) const
if (fields.size() > 7) speed_k = fields[7].toDouble();
if (curr_waypt) {
- WAYPT_SET(curr_waypt, course, course);
+ curr_waypt->set_course(course);
if (speed_k > 0) {
- WAYPT_SET(curr_waypt, speed, KPH_TO_MPS(speed_k));
+ curr_waypt->set_speed(KPH_TO_MPS(speed_k));
} else {
- WAYPT_SET(curr_waypt, speed, KNOTS_TO_MPS(speed_n));
+ curr_waypt->set_speed(KNOTS_TO_MPS(speed_n));
}
}
@@ -1242,8 +1242,8 @@ NmeaFormat::nmea_trackpt_pr(const Waypoint* wpt)
fix=='0' ? 'V' : 'A',
fabs(lat), lat < 0 ? 'S' : 'N',
fabs(lon), lon < 0 ? 'W' : 'E',
- WAYPT_HAS(wpt, speed) ? MPS_TO_KNOTS(wpt->speed):(0),
- WAYPT_HAS(wpt, course) ? (wpt->course):(0),
+ wpt->speed_has_value() ? MPS_TO_KNOTS(wpt->speed_value()):(0),
+ wpt->course_value_or(0),
dmy.constData());
cksum = nmea_cksum(obuf);
@@ -1264,15 +1264,15 @@ NmeaFormat::nmea_trackpt_pr(const Waypoint* wpt)
(wpt->sat>0)?(wpt->sat):(0),
(wpt->hdop>0)?(wpt->hdop):(0.0),
wpt->altitude == unknown_alt ? 0 : wpt->altitude,
- WAYPT_HAS(wpt, geoidheight)? (wpt->geoidheight) : (0)); /* TODO: we could look up the geoidheight if needed */
+ wpt->geoidheight_value_or(0)); /* TODO: we could look up the geoidheight if needed */
cksum = nmea_cksum(obuf);
gbfprintf(file_out, "$%s*%02X\n", obuf, cksum);
}
- if ((opt_gpvtg) && (WAYPT_HAS(wpt, course) || WAYPT_HAS(wpt, speed))) {
+ if ((opt_gpvtg) && (wpt->course_has_value() || wpt->speed_has_value())) {
snprintf(obuf,sizeof(obuf),"GPVTG,%.3f,T,0,M,%.3f,N,%.3f,K",
- WAYPT_HAS(wpt, course) ? (wpt->course):(0),
- WAYPT_HAS(wpt, speed) ? MPS_TO_KNOTS(wpt->speed):(0),
- WAYPT_HAS(wpt, speed) ? MPS_TO_KPH(wpt->speed):(0));
+ wpt->course_value_or(0),
+ wpt->speed_has_value() ? MPS_TO_KNOTS(wpt->speed_value()):(0),
+ wpt->speed_has_value() ? MPS_TO_KPH(wpt->speed_value()):(0));
cksum = nmea_cksum(obuf);
gbfprintf(file_out, "$%s*%02X\n", obuf, cksum);
diff --git a/ozi.cc b/ozi.cc
index c6d01622d..83d5e3a61 100644
--- a/ozi.cc
+++ b/ozi.cc
@@ -560,7 +560,7 @@ ozi_parse_waypt(int field, const QString& str, Waypoint* wpt_tmp, ozi_fsdata* fs
break;
case 13:
/* proximity distance - meters */
- WAYPT_SET(wpt_tmp, proximity, str.toDouble() * prox_scale);
+ wpt_tmp->set_proximity(str.toDouble() * prox_scale);
break;
case 14:
/* altitude */
@@ -918,8 +918,8 @@ ozi_waypt_pr(const Waypoint* wpt)
<< fs->fgcolor << ','
<< fs->bgcolor << ','
<< description << ",0,0,";
- if (WAYPT_HAS(wpt, proximity) && (wpt->proximity > 0)) {
- *stream << qSetRealNumberPrecision(1) << wpt->proximity * prox_scale << ',';
+ if (wpt->proximity_has_value() && (wpt->proximity_value() > 0)) {
+ *stream << qSetRealNumberPrecision(1) << wpt->proximity_value() * prox_scale << ',';
} else if (proximity > 0) {
*stream << qSetRealNumberPrecision(1) << proximity * prox_scale << ',';
} else {
diff --git a/qstarz_bl_1000.cc b/qstarz_bl_1000.cc
index b4cfc30f5..2910a4ab1 100644
--- a/qstarz_bl_1000.cc
+++ b/qstarz_bl_1000.cc
@@ -233,9 +233,9 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head*
waypoint->fix = fix;
waypoint->sat = satelliteCountUsed;
- WAYPT_SET(waypoint, speed, KPH_TO_MPS(speed));
+ waypoint->set_speed(KPH_TO_MPS(speed));
- WAYPT_SET(waypoint, course, heading);
+ waypoint->set_course(heading);
waypoint->SetCreationTime(time, milliseconds);
auto* fsdata = new qstarz_bl_1000_fsdata;
diff --git a/random.cc b/random.cc
index 27d7c9991..7026a9e53 100644
--- a/random.cc
+++ b/random.cc
@@ -120,13 +120,13 @@ RandomFormat::random_generate_wpt(int i, const QDateTime& time, const Waypoint*
wpt->altitude = rand_dbl(100.0);
}
if RND(3) {
- WAYPT_SET(wpt, temperature, rand_flt(32.0f));
+ wpt->set_temperature(rand_flt(32.0f));
}
if RND(3) {
- WAYPT_SET(wpt, proximity, rand_dbl(1000.0));
+ wpt->set_proximity(rand_dbl(1000.0));
}
if RND(3) {
- WAYPT_SET(wpt, depth, rand_dbl(1000.0));
+ wpt->set_depth(rand_dbl(1000.0));
}
if RND(3) {
wpt->AddUrlLink(rand_str(8, "http://link1.example.com/%s"));
@@ -144,8 +144,8 @@ RandomFormat::random_generate_wpt(int i, const QDateTime& time, const Waypoint*
if (i > 0) {
wpt->latitude = prev->latitude + rand_dbl(0.001);
wpt->longitude = prev->longitude + rand_dbl(0.001);
- WAYPT_SET(wpt, course, waypt_course(prev, wpt));
- WAYPT_SET(wpt, speed, waypt_speed(prev, wpt));
+ wpt->set_course(waypt_course(prev, wpt));
+ wpt->set_speed(waypt_speed(prev, wpt));
}
wpt->sat = rand_int(12 + 1);
wpt->hdop = rand_flt(50.0f);
diff --git a/route.cc b/route.cc
index 8b9365c5c..f7cd571d2 100644
--- a/route.cc
+++ b/route.cc
@@ -264,8 +264,7 @@ computed_trkdata track_recompute(const route_head* trk)
double tlon = RAD(thisw->longitude);
double plat = RAD(prev->latitude);
double plon = RAD(prev->longitude);
- WAYPT_SET(thisw, course, heading_true_degrees(plat, plon,
- tlat, tlon));
+ thisw->set_course(heading_true_degrees(plat, plon, tlat, tlon));
double dist = radtometers(gcdist(plat, plon, tlat, tlon));
/*
@@ -279,7 +278,7 @@ computed_trkdata track_recompute(const route_head* trk)
* If we've moved as much as a meter,
* conditionally recompute speeds.
*/
- if (!WAYPT_HAS(thisw, speed) && (dist > 1)) {
+ if (!thisw->speed_has_value() && (dist > 1)) {
// Only recompute speed if the waypoint
// didn't already have a speed
if (thisw->GetCreationTime().isValid() &&
@@ -287,15 +286,15 @@ computed_trkdata track_recompute(const route_head* trk)
thisw->GetCreationTime() > prev->GetCreationTime()) {
double timed =
prev->GetCreationTime().msecsTo(thisw->GetCreationTime()) / 1000.0;
- WAYPT_SET(thisw, speed, dist / timed);
+ thisw->set_speed(dist / timed);
}
}
- if (WAYPT_HAS(thisw, speed)) {
- if ((!tdata.min_spd) || (thisw->speed < tdata.min_spd)) {
- tdata.min_spd = thisw->speed;
+ if (thisw->speed_has_value()) {
+ if ((!tdata.min_spd) || (thisw->speed_value() < tdata.min_spd)) {
+ tdata.min_spd = thisw->speed_value();
}
- if ((!tdata.max_spd) || (thisw->speed > tdata.max_spd)) {
- tdata.max_spd = thisw->speed;
+ if ((!tdata.max_spd) || (thisw->speed_value() > tdata.max_spd)) {
+ tdata.max_spd = thisw->speed_value();
}
}
diff --git a/sbn.cc b/sbn.cc
index 735f87a07..7ee6edcc0 100644
--- a/sbn.cc
+++ b/sbn.cc
@@ -254,8 +254,8 @@ decode_sbn_record(unsigned char* buffer)
decode_sbn_datetime(buffer + 10, waypt);
decode_sbn_position(buffer + 22, waypt);
- WAYPT_SET(waypt, speed, be_read16(buffer + 39) * 0.01f);
- WAYPT_SET(waypt, course, be_read16(buffer + 41) * 0.01f);
+ waypt->set_speed(be_read16(buffer + 39) * 0.01f);
+ waypt->set_course(be_read16(buffer + 41) * 0.01f);
waypt->sat = buffer[87];
waypt->hdop = buffer[88] * 0.2f;
diff --git a/skytraq.cc b/skytraq.cc
index 92f2c5b1a..d5b791e7f 100644
--- a/skytraq.cc
+++ b/skytraq.cc
@@ -673,7 +673,7 @@ SkytraqBase::process_data_item(struct read_state* pst, const item_frame* pitem,
alt = m.alt * POW_2_M7;
tpt = make_trackpoint(pst, lat, lon, alt);
- WAYPT_SET(tpt, speed, spe); /* convert speed to m/s */
+ tpt->set_speed(spe); /* convert speed to m/s */
track_add_wpt(pst->route_head_, tpt);
res = MULTI_HZ_ITEM_LEN;
@@ -750,7 +750,7 @@ SkytraqBase::process_data_item(struct read_state* pst, const item_frame* pitem,
ECEF_to_LLA(pst->x, pst->y, pst->z, &lat, &lon, &alt);
// GPS_Math_XYZ_To_WGS84LatLonH(&lat, &lon, &alt, pst->x, pst->y, pst->z);
tpt = make_trackpoint(pst, lat, lon, alt);
- WAYPT_SET(tpt, speed, KPH_TO_MPS(ITEM_SPEED(pitem))); /* convert speed to m/s */
+ tpt->set_speed(KPH_TO_MPS(ITEM_SPEED(pitem))); /* convert speed to m/s */
if (poi) {
waypt_add(new Waypoint(*tpt));
diff --git a/subrip.cc b/subrip.cc
index 6b5757d81..1fda7ad07 100644
--- a/subrip.cc
+++ b/subrip.cc
@@ -90,8 +90,8 @@ SubripFormat::subrip_prevwp_pr(const Waypoint* waypointp)
switch (fmt) {
case 's':
- if WAYPT_HAS(prevwpp, speed) {
- gbfprintf(fout, "%2.1f", MPS_TO_KPH(prevwpp->speed));
+ if (prevwpp->speed_has_value()) {
+ gbfprintf(fout, "%2.1f", MPS_TO_KPH(prevwpp->speed_value()));
} else {
gbfprintf(fout, "--.-");
}
diff --git a/trackfilter.cc b/trackfilter.cc
index 4482afe35..349ea190a 100644
--- a/trackfilter.cc
+++ b/trackfilter.cc
@@ -619,11 +619,11 @@ void TrackFilter::trackfilter_synth()
if (first) {
if (opt_course) {
// TODO: the course value 0 isn't valid, wouldn't it be better to UNSET course?
- WAYPT_SET(wpt, course, 0);
+ wpt->set_course(0);
}
if (opt_speed) {
// TODO: the speed value 0 isn't valid, wouldn't it be better to UNSET speed?
- WAYPT_SET(wpt, speed, 0);
+ wpt->set_speed(0);
}
first = false;
last_course_lat = wpt->latitude;
@@ -633,9 +633,9 @@ void TrackFilter::trackfilter_synth()
last_speed_time = wpt->GetCreationTime();
} else {
if (opt_course) {
- WAYPT_SET(wpt, course, heading_true_degrees(RAD(last_course_lat),
- RAD(last_course_lon),RAD(wpt->latitude),
- RAD(wpt->longitude)));
+ wpt->set_course(heading_true_degrees(RAD(last_course_lat),
+ RAD(last_course_lon),RAD(wpt->latitude),
+ RAD(wpt->longitude)));
last_course_lat = wpt->latitude;
last_course_lon = wpt->longitude;
}
@@ -649,17 +649,17 @@ void TrackFilter::trackfilter_synth()
// Note that points with the same time can occur because the input
// has truncated times, or because we are truncating times with
// toTime_t().
- WAYPT_SET(wpt, speed, radtometers(gcdist(
- RAD(last_speed_lat), RAD(last_speed_lon),
- RAD(wpt->latitude),
- RAD(wpt->longitude))) /
- (0.001 * std::abs(last_speed_time.msecsTo(wpt->GetCreationTime())))
- );
+ wpt->set_speed(radtometers(gcdist(
+ RAD(last_speed_lat), RAD(last_speed_lon),
+ RAD(wpt->latitude),
+ RAD(wpt->longitude))) /
+ (0.001 * std::abs(last_speed_time.msecsTo(wpt->GetCreationTime())))
+ );
last_speed_lat = wpt->latitude;
last_speed_lon = wpt->longitude;
last_speed_time = wpt->GetCreationTime();
} else {
- WAYPT_UNSET(wpt, speed);
+ wpt->reset_speed();
}
}
}
@@ -903,11 +903,11 @@ bool TrackFilter::trackfilter_points_are_same(const Waypoint* wpta, const Waypoi
std::abs(wpta->latitude - wptb->latitude) < .00001 &&
std::abs(wpta->longitude - wptb->longitude) < .00001 &&
std::abs(wpta->altitude - wptb->altitude) < 20 &&
- WAYPT_EQUAL(wpta, wptb, course) &&
- WAYPT_EQUAL(wpta, wptb, speed) &&
+ wpta->courses_equal(*wptb) &&
+ wpta->speeds_equal(*wptb) &&
(wpta->heartrate == wptb->heartrate) &&
(wpta->cadence == wptb->cadence) &&
- WAYPT_EQUAL(wpta, wptb, temperature);
+ wpta->temperatures_equal(*wptb);
}
void TrackFilter::trackfilter_segment_head(const route_head* rte)
diff --git a/unicsv.cc b/unicsv.cc
index 104406ef0..0c473e0ac 100644
--- a/unicsv.cc
+++ b/unicsv.cc
@@ -699,7 +699,7 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf)
case fld_speed:
if (parse_speed(value, &d, 1.0, MYNAME)) {
- WAYPT_SET(wpt, speed, d);
+ wpt->set_speed(d);
if (unicsv_detect) {
unicsv_data_type = trkdata;
}
@@ -707,7 +707,7 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf)
break;
case fld_course:
- WAYPT_SET(wpt, course, value.toDouble());
+ wpt->set_course(value.toDouble());
if (unicsv_detect) {
unicsv_data_type = trkdata;
}
@@ -716,14 +716,14 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf)
case fld_temperature:
d = value.toDouble();
if (fabs(d) < 999999) {
- WAYPT_SET(wpt, temperature, d);
+ wpt->set_temperature(d);
}
break;
case fld_temperature_f:
d = value.toDouble();
if (fabs(d) < 999999) {
- WAYPT_SET(wpt, temperature, FAHRENHEIT_TO_CELSIUS(d));
+ wpt->set_temperature(FAHRENHEIT_TO_CELSIUS(d));
}
break;
@@ -750,13 +750,13 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf)
case fld_proximity:
if (parse_distance(value, &d, unicsv_proximityscale, MYNAME)) {
- WAYPT_SET(wpt, proximity, d);
+ wpt->set_proximity(d);
}
break;
case fld_depth:
if (parse_distance(value, &d, unicsv_depthscale, MYNAME)) {
- WAYPT_SET(wpt, depth, d);
+ wpt->set_depth(d);
}
break;
@@ -1210,19 +1210,19 @@ UnicsvFormat::unicsv_waypt_enum_cb(const Waypoint* wpt)
}
/* "flagged" waypoint members */
- if WAYPT_HAS(wpt, course) {
+ if (wpt->course_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_course);
}
- if WAYPT_HAS(wpt, depth) {
+ if (wpt->depth_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_depth);
}
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_speed);
}
- if WAYPT_HAS(wpt, proximity) {
+ if (wpt->proximity_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_proximity);
}
- if WAYPT_HAS(wpt, temperature) {
+ if (wpt->temperature_has_value()) {
gb_setbit(&unicsv_outp_flags, fld_temperature);
}
@@ -1409,41 +1409,41 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt)
unicsv_print_str(wpt->icon_descr.isNull() ? "Waypoint" : wpt->icon_descr);
}
if FIELD_USED(fld_depth) {
- if WAYPT_HAS(wpt, depth) {
+ if (wpt->depth_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(3) << wpt->depth;
+ << qSetRealNumberPrecision(3) << wpt->depth_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_proximity) {
- if WAYPT_HAS(wpt, proximity) {
+ if (wpt->proximity_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(0) << wpt->proximity;
+ << qSetRealNumberPrecision(0) << wpt->proximity_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_temperature) {
- if WAYPT_HAS(wpt, temperature) {
+ if (wpt->temperature_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(3) << wpt->temperature;
+ << qSetRealNumberPrecision(3) << wpt->temperature_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_speed) {
- if WAYPT_HAS(wpt, speed) {
+ if (wpt->speed_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(2) << wpt->speed;
+ << qSetRealNumberPrecision(2) << wpt->speed_value();
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_course) {
- if WAYPT_HAS(wpt, course) {
+ if (wpt->course_has_value()) {
*fout << unicsv_fieldsep
- << qSetRealNumberPrecision(1) << wpt->course;
+ << qSetRealNumberPrecision(1) << wpt->course_value();
} else {
*fout << unicsv_fieldsep;
}
diff --git a/v900.cc b/v900.cc
index a815ab052..bb16a4763 100644
--- a/v900.cc
+++ b/v900.cc
@@ -316,9 +316,9 @@ v900_read()
wpt->SetCreationTime(bintime2utc(date, time));
}
- WAYPT_SET(wpt, speed, KPH_TO_MPS(xstrtoi(line.bas.common.speed, nullptr, 10)));
+ wpt->set_speed(KPH_TO_MPS(xstrtoi(line.bas.common.speed, nullptr, 10)));
- WAYPT_SET(wpt, course, xstrtoi(line.bas.common.heading, nullptr, 10));
+ wpt->set_course(xstrtoi(line.bas.common.heading, nullptr, 10));
if (is_advanced_mode) {
wpt->hdop = strtod(line.adv.hdop, nullptr);
diff --git a/waypt.cc b/waypt.cc
index 62836120b..df02d1715 100644
--- a/waypt.cc
+++ b/waypt.cc
@@ -72,8 +72,8 @@ void update_common_traits(const Waypoint* wpt)
traits.trait_heartrate |= wpt->heartrate > 0;
traits.trait_cadence |= wpt->cadence > 0;
traits.trait_power |= wpt->power > 0;
- traits.trait_depth |= WAYPT_HAS(wpt, depth);
- traits.trait_temperature |= WAYPT_HAS(wpt, temperature);
+ traits.trait_depth |= wpt->depth_has_value();
+ traits.trait_temperature |= wpt->temperature_has_value();
}
void
@@ -384,24 +384,24 @@ waypt_course(const Waypoint* A, const Waypoint* B)
}
Waypoint::Waypoint() :
- latitude(0), // These should probably use some invalid data, but
- longitude(0), // it looks like we have code that relies on them being zero.
- altitude(unknown_alt),
geoidheight(0),
depth(0),
proximity(0),
+ course(0),
+ speed(0),
+ temperature(0),
+ latitude(0), // These should probably use some invalid data, but
+ longitude(0), // it looks like we have code that relies on them being zero.
+ altitude(unknown_alt),
route_priority(0),
hdop(0),
vdop(0),
pdop(0),
- course(0),
- speed(0),
fix(fix_unknown),
sat(-1),
heartrate(0),
cadence(0),
power(0),
- temperature(0),
odometer_distance(0),
gc_data(&Waypoint::empty_gc_data),
session(curr_session()),
@@ -418,31 +418,32 @@ Waypoint::~Waypoint()
}
Waypoint::Waypoint(const Waypoint& other) :
- latitude(other.latitude),
- longitude(other.longitude),
- altitude(other.altitude),
geoidheight(other.geoidheight),
depth(other.depth),
proximity(other.proximity),
+ course(other.course),
+ speed(other.speed),
+ temperature(other.temperature),
+ opt_flags(other.opt_flags),
+ latitude(other.latitude),
+ longitude(other.longitude),
+ altitude(other.altitude),
shortname(other.shortname),
description(other.description),
notes(other.notes),
urls(other.urls),
- wpt_flags(other.wpt_flags),
icon_descr(other.icon_descr),
creation_time(other.creation_time),
+ wpt_flags(other.wpt_flags),
route_priority(other.route_priority),
hdop(other.hdop),
vdop(other.vdop),
pdop(other.pdop),
- course(other.course),
- speed(other.speed),
fix(other.fix),
sat(other.sat),
heartrate(other.heartrate),
cadence(other.cadence),
power(other.power),
- temperature(other.temperature),
odometer_distance(other.odometer_distance),
gc_data(other.gc_data),
session(other.session),
diff --git a/xcsv.cc b/xcsv.cc
index 44b38ec7e..e55f4b5e4 100644
--- a/xcsv.cc
+++ b/xcsv.cc
@@ -579,19 +579,19 @@ XcsvFormat::xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle:
/* PATH CONVERSIONS ************************************************/
case XcsvStyle::XT_PATH_SPEED:
- WAYPT_SET(wpt, speed, strtod(s, nullptr));
+ wpt->set_speed(strtod(s, nullptr));
break;
case XcsvStyle::XT_PATH_SPEED_KPH:
- WAYPT_SET(wpt, speed, KPH_TO_MPS(strtod(s, nullptr)));
+ wpt->set_speed(KPH_TO_MPS(strtod(s, nullptr)));
break;
case XcsvStyle::XT_PATH_SPEED_MPH:
- WAYPT_SET(wpt, speed, MPH_TO_MPS(strtod(s, nullptr)));
+ wpt->set_speed(MPH_TO_MPS(strtod(s, nullptr)));
break;
case XcsvStyle::XT_PATH_SPEED_KNOTS:
- WAYPT_SET(wpt, speed, KNOTS_TO_MPS(strtod(s, nullptr)));
+ wpt->set_speed(KNOTS_TO_MPS(strtod(s, nullptr)));
break;
case XcsvStyle::XT_PATH_COURSE:
- WAYPT_SET(wpt, course, strtod(s, nullptr));
+ wpt->set_course(strtod(s, nullptr));
break;
/* TIME CONVERSIONS ***************************************************/
@@ -757,10 +757,10 @@ XcsvFormat::xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle:
wpt->power = strtod(s, nullptr);
break;
case XcsvStyle::XT_TEMPERATURE:
- WAYPT_SET(wpt, temperature, strtod(s, nullptr));
+ wpt->set_temperature(strtod(s, nullptr));
break;
case XcsvStyle::XT_TEMPERATURE_F:
- WAYPT_SET(wpt, temperature, FAHRENHEIT_TO_CELSIUS(strtod(s, nullptr)));
+ wpt->set_temperature(FAHRENHEIT_TO_CELSIUS(strtod(s, nullptr)));
break;
/* GMSD ****************************************************************/
case XcsvStyle::XT_COUNTRY: {
@@ -1306,28 +1306,28 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
}
break;
case XcsvStyle::XT_PATH_SPEED:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), wpt->speed);
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), wpt->speed_value());
}
break;
case XcsvStyle::XT_PATH_SPEED_KPH:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KPH(wpt->speed));
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KPH(wpt->speed_value()));
}
break;
case XcsvStyle::XT_PATH_SPEED_MPH:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_MPH(wpt->speed));
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_MPH(wpt->speed_value()));
}
break;
case XcsvStyle::XT_PATH_SPEED_KNOTS:
- if (WAYPT_HAS(wpt, speed)) {
- buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KNOTS(wpt->speed));
+ if (wpt->speed_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), MPS_TO_KNOTS(wpt->speed_value()));
}
break;
case XcsvStyle::XT_PATH_COURSE:
- if (WAYPT_HAS(wpt, course)) {
- buff = QString::asprintf(fmp.printfc.constData(), wpt->course);
+ if (wpt->course_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), wpt->course_value());
}
break;
@@ -1350,13 +1350,13 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
}
break;
case XcsvStyle::XT_TEMPERATURE:
- if (WAYPT_HAS(wpt, temperature)) {
- buff = QString::asprintf(fmp.printfc.constData(), wpt->temperature);
+ if (wpt->temperature_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), wpt->temperature_value());
}
break;
case XcsvStyle::XT_TEMPERATURE_F:
- if (WAYPT_HAS(wpt, temperature)) {
- buff = QString::asprintf(fmp.printfc.constData(), CELSIUS_TO_FAHRENHEIT(wpt->temperature));
+ if (wpt->temperature_has_value()) {
+ buff = QString::asprintf(fmp.printfc.constData(), CELSIUS_TO_FAHRENHEIT(wpt->temperature_value()));
}
break;
/* TIME CONVERSIONS**************************************************/