Skip to content

Commit

Permalink
Make sure no empty location enters history
Browse files Browse the repository at this point in the history
Refs: #56
  • Loading branch information
orontee committed Oct 9, 2023
1 parent 4d7e832 commit 157764d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class LocationHistoryProxy {
BOOST_LOG_TRIVIAL(debug) << "Updating history";

auto &current_location = this->model->location;
if (not this->is_location_eligible_for_history(current_location)) {
BOOST_LOG_TRIVIAL(debug) << "Skipping history update for empty location";
return;
}

auto &history = this->model->location_history;
const auto found = std::find_if(history.begin(), history.end(),
[current_location](const auto &item) {
Expand Down Expand Up @@ -107,5 +112,11 @@ class LocationHistoryProxy {

private:
std::shared_ptr<Model> model;

bool is_location_eligible_for_history(const Location &location) const {
return not (std::isnan(location.longitude) or
std::isnan(location.latitude) or
location.name.empty());
}
};
} // namespace taranis

0 comments on commit 157764d

Please sign in to comment.