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

feat(track): allow track truncation by time / age out #1243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bradh
Copy link
Collaborator

@bradh bradh commented Apr 15, 2021

os.track supports truncation to a specified number of track points. I need something similar, but by age of the points.

That is, old points in the track will be removed if they "age out" beyond a specified time.

The PR includes some minor refactoring and jsdoc fixes.

var timeNow = Date.now();
var pointsToKeep = 0;
if (coords) {
coords.reverse().forEach(function(c) {
Copy link
Contributor

Choose a reason for hiding this comment

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

os.track.getTimeIndex will get the closest index to a specified timestamp using binary search, so it may be more performant to:

  • Get the closest index to the age-off timestamp.
  • Splice the flat coordinates array from the index to the end.
  • Do the same for metadata.

This would avoid the getCoordinates call which reconstitutes the flat coordinates (unnecessary GC of all those arrays), and reversing/iterating over the entire array.

os.track.prunePointsAt_(track, geometry, numCoords);
};

os.track.prunePointsAt_ = function(track, geometry, numCoords) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing JSDoc for this new function.

@schmidtk
Copy link
Contributor

@bradh FYI Travis stopped building OpenSphere, so you'll have to merge this branch with master to pick up the GH Actions builds.

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.

2 participants