Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use efficient methods to delete trkpts in track filter. #1155

Merged
merged 2 commits into from
Aug 12, 2023

Conversation

tsteven4
Copy link
Collaborator

@tsteven4 tsteven4 commented Aug 11, 2023

This PR uses track_del_marked_wpts instead of track_del_wpt. track_del_marked_wpts scales with the number of points in the list, while track_del_wpt scales with the number of points in the list times the number of points deleted.

There are some intentional changes of behavior:

  1. previously in option split all existing track segment markers after the first split were removed, but those before the split were conserved. Now all pre-existing segment markers are removed, leaving only one segment per track.
  2. previously in option pack all existing track segment markers after the first track were removed, but those in the first track were conserved. Now all pre-existing segment markers are removed, leaving only one segment in the packed track. This is issue trackfilter pack handling of segments #1152.

#include <cassert> // for assert
#include <cmath> // for nan
#include <cstdio> // for printf
#include <cstdlib> // for abs
#include <cstring> // for strlen, strchr, strcmp
#include <ctime> // for gmtime, strftime
#include <ctime> // for gmtime, strftime, time_t, tm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed? We've been trying to drop ctime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strftime exposed to user in title option :(

@@ -329,11 +324,20 @@ void TrackFilter::trackfilter_pack()

route_head* master = track_list.first();

if (!master->waypoint_list.empty()) {
std::for_each(std::next(master->waypoint_list.cbegin()), master->waypoint_list.cend(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm excited that some day std::foreach can parallelize things automatically for us. Some day....

avg_dist = cur_dist;
}

if (cur_dist > 6378.14 && cur_dist > 1.2 * avg_dist) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a moment to recognize such a specific magic number. Isn't that a global (hehe) constant for us?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These magic numbers were translations of previous values with units of radians or degrees. The old comment
Latitude spacing is about 27 feet per .00001 degree
was incorrect, it is 1.11m or 3.6ft.

It seems to be arbitrary, but I though 6378 meters was easier to understand that 0.001 radians. I have a hard time imagining this specific value is generally useful.

Would it be more useful to let the user pass this limit? I' not aware of any interest, complaints or use related to this option.

kDistanceLimit seems arbitrary as well, but again 1.11 meters was easier to understand than 0.00001 degrees of latitude or longitude at the equator. There was another magic number, ktoo_close = 0.000005 radians = 31.89 meters that we used to decide if we needed to check points for being the same, this magic has been replaced by kDistanceLimit which is used both to see if we should check, and to decide if the points are the same. 1.11m seems a bit tight to decide we are sitting still.

Perhaps it makes sense, and is generally applicable, to set kDistanceLimit to something like 4.9m https://www.gps.gov/systems/gps/performance/accuracy/

We had a long email 1/10/2019 about this. The test cases referred to are not available. I created one so we have some coverage, but it certainly isn't the real data that inspired this option.

Copy link
Collaborator

@robertlipe robertlipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Algorithmically very clever. As waysl, thank you!

@GPSBabelDeveloper
Copy link
Collaborator

GPSBabelDeveloper commented Aug 11, 2023 via email

@tsteven4 tsteven4 merged commit e01a80d into GPSBabel:master Aug 12, 2023
20 checks passed
@tsteven4 tsteven4 deleted the trackefficientdelete branch August 12, 2023 11:54
robertlipe pushed a commit that referenced this pull request Aug 12, 2024
* use efficient methods to delete trkpts in track filter.

* clean up some code issues flagged by windows tools.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants