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

Enhance Data Retrieval Accuracy with MatchType in TimeseriesRef #969

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

salmagro
Copy link
Contributor

This MR introduces the MatchType enumeration to TimeseriesRef, providing the option to choose between exact and nearest time matching. Changes include updates to the atTime and getRawIndexAtTime methods to support this new functionality.

For a detailed problem description see: #968

@facontidavide
Copy link
Owner

look at CI...

- Added an enumeration MatchType with options Exact and Nearest.
- Modified atTime and getRawIndexAtTime in TimeseriesRef to support MatchType, allowing callers to specify whether they need an exact timestamp match or the nearest available match.
- Adjusted the atTime method to throw an error when an exact match is required but not found, enhancing error handling for strict match requirements.
@salmagro
Copy link
Contributor Author

I have resolved the compilation issues. However, I have a question regarding the proposal to pass an enum class MatchType to the atTime method.
Do we need to make any modifications when exposing this to Lua in this line https://github.com/facontidavide/PlotJuggler/blob/main/plotjuggler_base/src/reactive_function.cpp#L116?
How should the enum class MatchType be defined from Lua?

if (match_type == MatchType::Exact)
{
auto it = std::find_if(_plot_data->begin(), _plot_data->end(),
[t](const auto& point) { return point.x == t; });

Check notice

Code scanning / CodeQL

Equality test on floating-point values Note

Equality checks on floating point values can yield unexpected results.
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.

None yet

2 participants