Skip to content
Permalink
Browse files

Introduce a WaypointList class to define the interface to our lists …

…of waypoints. (#326)

* Introduce a WaypointList class to define the interface to our lists of waypoints.

WaypointList is backed QList, eliminating the use of legacy queues for waypoint lists.

* try to appease xcode wrt std::abs.

* clean up inheritence in WaypointList, RouteList.

also quiet clazy with igc and gpsbabel_optional::optional.
also improve includes in defs.h.

* get rid of unnecessary reinterpret_cast.

and correct pointer constness lost by auto.
  • Loading branch information...
tsteven4 committed Mar 16, 2019
1 parent 636654d commit afd089d3187b1ac40422be9aeb5234c156c6b784
Showing with 894 additions and 894 deletions.
  1. +2 −15 arcdist.cc
  2. +18 −20 bcr.cc
  3. +12 −11 bend.cc
  4. +0 −1 bend.h
  5. +105 −40 defs.h
  6. +14 −5 dmtlog.cc
  7. +12 −10 duplicate.cc
  8. +3 −7 filterdefs.h
  9. +22 −21 garmin.cc
  10. +9 −11 gdb.cc
  11. +16 −10 ggv_log.cc
  12. +12 −15 ggv_ovl.cc
  13. +26 −17 gpx.cc
  14. +60 −58 igc.cc
  15. +10 −7 interpolate.cc
  16. +38 −48 kml.cc
  17. +21 −33 lowranceusr.cc
  18. +3 −6 magproto.cc
  19. +9 −7 main.cc
  20. +15 −8 mapasia.cc
  21. +16 −9 mapsend.cc
  22. +10 −12 mapsource.cc
  23. +25 −12 mmo.cc
  24. +15 −14 netstumbler.cc
  25. +4 −6 nmea.cc
  26. +7 −4 pocketfms_fp.cc
  27. +11 −16 polygon.cc
  28. +10 −13 position.cc
  29. +1 −2 position.h
  30. +21 −13 psitrex.cc
  31. +9 −18 radius.cc
  32. +5 −4 reverse_route.cc
  33. +26 −34 route.cc
  34. +35 −37 sort.cc
  35. +4 −12 sort.h
  36. +15 −27 stackfilter.cc
  37. +2 −10 stackfilter.h
  38. +10 −15 tomtom.cc
  39. +17 −8 tpo.cc
  40. +42 −63 trackfilter.cc
  41. +2 −0 trackfilter.h
  42. +7 −8 transform.cc
  43. +193 −207 waypt.cc
@@ -42,13 +42,7 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2)
if (arcpt2 && arcpt2->latitude != BADVAL && arcpt2->longitude != BADVAL &&
(ptsopt || (arcpt1 &&
(arcpt1->latitude != BADVAL && arcpt1->longitude != BADVAL)))) {
#if NEWQ
foreach (Waypoint* waypointp, waypt_list) {
#else
queue* elem, *tmp;
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem);
#endif
foreach (Waypoint* waypointp, *global_waypoint_list) {
double dist;
extra_data* ed;
if (waypointp->extra_data) {
@@ -107,8 +101,6 @@ void ArcDistanceFilter::process()
WayptFunctor<ArcDistanceFilter> arcdist_arc_disp_wpt_cb_f(this, &ArcDistanceFilter::arcdist_arc_disp_wpt_cb);
RteHdFunctor<ArcDistanceFilter> arcdist_arc_disp_hdr_cb_f(this, &ArcDistanceFilter::arcdist_arc_disp_hdr_cb);

queue* elem, * tmp;

if (arcfileopt) {
int fileline = 0;
char* line;
@@ -154,12 +146,7 @@ void ArcDistanceFilter::process()
}

unsigned removed = 0;
#if NEWQ
foreach (Waypoint* wp, waypt_list) {
#else
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
Waypoint* wp = reinterpret_cast<Waypoint *>(elem);
#endif
foreach (Waypoint* wp, *global_waypoint_list) {
extra_data* ed = (extra_data*) wp->extra_data;
wp->extra_data = nullptr;
if (ed) {
38 bcr.cc
@@ -26,14 +26,20 @@
2007/04&14: new handling of DESCRIPTION lines
*/

#include <cmath> // for M_PI, atan, exp, log, tan
#include <cstdio> // for printf, snprintf, sscanf
#include <cstdlib> // for atof, atoi

#include <QtCore/QString> // for QString, operator+
#include <QtCore/Qt> // for CaseInsensitive
#include <QtCore/QtGlobal> // for foreach

#include "defs.h"
#include "csv_util.h"
#include "garmin_tables.h"
#include "inifile.h"
#include <QtCore/QString>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include "csv_util.h" // for csv_stringclean
#include "garmin_tables.h" // for gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, MAPSOURCE
#include "gbfile.h" // for gbfprintf, gbfclose, gbfopen, gbfile
#include "inifile.h" // for inifile_readstr, inifile_done, inifile_init, inifile_t


#define MYNAME "bcr"

@@ -201,11 +207,8 @@ bcr_rd_deinit()
static void
bcr_create_waypts_from_route(route_head* route)
{
queue* elem, *tmp;

QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
Waypoint* wpt = new Waypoint(*reinterpret_cast<Waypoint *>(elem));
waypt_add(wpt);
foreach (const Waypoint* wpt, route->waypoint_list) {
waypt_add(new Waypoint(*wpt));
}
}

@@ -350,8 +353,6 @@ static void bcr_write_line(gbfile* fout, const QString& key, const int* index, c
static void
bcr_route_header(const route_head* route)
{
queue* elem, *tmp;
Waypoint* wpt;
int north, east, nmax, emin;

curr_rte_num++;
@@ -375,8 +376,7 @@ bcr_route_header(const route_head* route)
bcr_write_line(fout, "DESCRIPTIONLINES", nullptr, "0");

int i = 0;
QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
foreach (const Waypoint* wpt, route->waypoint_list) {

i++;

@@ -392,9 +392,8 @@ bcr_route_header(const route_head* route)
int emax = nmax = -nmin;

i = 0;
QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
foreach (const Waypoint* wpt, route->waypoint_list) {
i++;
wpt = reinterpret_cast<Waypoint *>(elem);

bcr_wgs84_to_mercator(wpt->latitude, wpt->longitude, &north, &east);

@@ -418,11 +417,10 @@ bcr_route_header(const route_head* route)
bcr_write_line(fout, "[DESCRIPTION]", nullptr, nullptr); /* descr. section */

i = 0;
QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
foreach (const Waypoint* wpt, route->waypoint_list) {
QString s2;

i++;
wpt = reinterpret_cast<Waypoint *>(elem);
QString s1 = wpt->notes;
if (s1.isEmpty()) {
s1 = wpt->description;
23 bend.cc
@@ -20,13 +20,17 @@
*/

#include <cmath> // macos wants abs from here!
#include <cstdlib> // for strtod, abs

#include <QtCore/QString> // for QString
#include <QtCore/QtGlobal> // for qAsConst, QAddConst<>::Type, foreach

#include "defs.h"
#include "bend.h"
#include "filterdefs.h"
#include "grtcirc.h"
#include "bend.h"
#include "grtcirc.h" // for RAD, heading_true_degrees, gcdist, linepart, radtometers, DEG

#include <cmath>
#include <cstdlib>

#define MYNAME "bend"

@@ -90,12 +94,10 @@ int BendFilter::is_small_angle(double lat_orig, double long_orig, double lat_ori

void BendFilter::process_route(const route_head* route_orig, route_head* route_dest)
{
Waypoint* wpt_orig_prev = nullptr;
Waypoint* wpt_orig = nullptr;
const Waypoint* wpt_orig_prev = nullptr;
const Waypoint* wpt_orig = nullptr;

queue* elem, *tmp;
QUEUE_FOR_EACH(&route_orig->waypoint_list, elem, tmp) {
Waypoint* wpt_orig_next = reinterpret_cast<Waypoint *>(elem);
foreach (const Waypoint* wpt_orig_next, route_orig->waypoint_list) {

if (wpt_orig_prev == nullptr) {
if (wpt_orig != nullptr) {
@@ -158,8 +160,7 @@ void BendFilter::process_route_orig(const route_head* route_orig)

void BendFilter::process()
{
for (auto it = routes_orig->cbegin(); it != routes_orig->cend(); ++it) {
auto route_orig = reinterpret_cast<const route_head*>(*it);
for (const auto* route_orig : qAsConst(*routes_orig)) {
process_route_orig(route_orig);
}
}
1 bend.h
@@ -25,7 +25,6 @@

#include "defs.h" // for route_head (ptr only), ARGTYPE_FLOAT, ARG_NOMINMAX
#include "filter.h" // for Filter
#include "queue.h" // for queue

#if FILTERS_ENABLED

Oops, something went wrong.

0 comments on commit afd089d

Please sign in to comment.
You can’t perform that action at this time.