Merge lp:~mandel/location-service/better-position-selection into lp:location-service/trunk

Proposed by Manuel de la Peña
Status: Merged
Approved by: Jim Hodapp
Approved revision: 202
Merged at revision: 187
Proposed branch: lp:~mandel/location-service/better-position-selection
Merge into: lp:location-service/trunk
Prerequisite: lp:~mandel/location-service/remove-pimpl
Diff against target: 494 lines (+407/-2)
8 files modified
src/location_service/com/ubuntu/location/CMakeLists.txt (+1/-0)
src/location_service/com/ubuntu/location/engine.cpp (+5/-2)
src/location_service/com/ubuntu/location/engine.h (+3/-0)
src/location_service/com/ubuntu/location/time_based_update_policy.cpp (+121/-0)
src/location_service/com/ubuntu/location/time_based_update_policy.h (+70/-0)
src/location_service/com/ubuntu/location/update_policy.h (+75/-0)
tests/CMakeLists.txt (+1/-0)
tests/time_based_update_policy_test.cpp (+131/-0)
To merge this branch: bzr merge lp:~mandel/location-service/better-position-selection
Reviewer Review Type Date Requested Status
Jim Hodapp (community) code Approve
PS Jenkins bot continuous-integration Approve
Thomas Voß (community) Needs Fixing
Review via email: mp+257037@code.launchpad.net

Commit message

Improve the selection of the bag of providers to ensure that the locations used are within a reasonable time margin.

Description of the change

Improve the selection of the bag of providers to ensure that the locations used are within a reasonable time margin.

To post a comment you must log in.
Revision history for this message
Thomas Voß (thomas-voss) wrote :

Thanks for the changes, a high-level remark first: The ProviderSelectionStrategy implementation is not the right place to add this functionality. Instead, the functionality should be added here:

  http://bazaar.launchpad.net/~phablet-team/location-service/trunk/view/head:/src/location_service/com/ubuntu/location/engine.cpp#L205

location::Engine is the central hub receiving and dispatching updates and it is meant to carry out such tasks as proposed in this MP.

Also make sure that an automated test case is added in http://bazaar.launchpad.net/~phablet-team/location-service/trunk/view/head:/tests/engine_test.cpp. I would think that introducing a location::PositionUpdateFilter interface together with a default implementation should help a lot here. You can pass the location::PositionUpdateFilter to the location::Engine constructor as a functional dependency and subsequently test if the Engine calls into that object for position updates.

Rest of my comments inline.

review: Needs Fixing
Revision history for this message
Thomas Voß (thomas-voss) wrote :

One other bit: The predominant style in the codebase is snake_style. Please change the camelCase instances accordingly.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
194. By Manuel de la Peña

Merged remove-pimpl into better-position-selection.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
195. By Manuel de la Peña

Move the heuristics to its own class to make it easier to have diff options. Move the position selection to the engine.

196. By Manuel de la Peña

Add missing files.

Revision history for this message
Thomas Voß (thomas-voss) wrote :

Looks better, but some comments inline.

review: Needs Fixing
197. By Manuel de la Peña

Made changes following the comments from the reviews.

198. By Manuel de la Peña

Add missing space.

199. By Manuel de la Peña

Merged remove-pimpl into better-position-selection.

200. By Manuel de la Peña

Remove unused var.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jim Hodapp (jhodapp) wrote :

Some suggestions inline below.

review: Needs Fixing
201. By Manuel de la Peña

Made changes following the code reviews.

202. By Manuel de la Peña

Set var to const.

Revision history for this message
Jim Hodapp (jhodapp) wrote :

Looks good

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/location_service/com/ubuntu/location/CMakeLists.txt'
--- src/location_service/com/ubuntu/location/CMakeLists.txt 2015-01-25 12:45:30 +0000
+++ src/location_service/com/ubuntu/location/CMakeLists.txt 2015-04-23 21:30:38 +0000
@@ -27,6 +27,7 @@
27 proxy_provider.cpp27 proxy_provider.cpp
28 satellite_based_positioning_state.cpp28 satellite_based_positioning_state.cpp
29 settings.cpp29 settings.cpp
30 time_based_update_policy.cpp
30 set_name_for_thread.cpp31 set_name_for_thread.cpp
31 wifi_and_cell_reporting_state.cpp32 wifi_and_cell_reporting_state.cpp
3233
3334
=== modified file 'src/location_service/com/ubuntu/location/engine.cpp'
--- src/location_service/com/ubuntu/location/engine.cpp 2015-01-25 12:44:20 +0000
+++ src/location_service/com/ubuntu/location/engine.cpp 2015-04-23 21:30:38 +0000
@@ -24,6 +24,8 @@
24#include <stdexcept>24#include <stdexcept>
25#include <unordered_map>25#include <unordered_map>
2626
27#include "time_based_update_policy.h"
28
27namespace cul = com::ubuntu::location;29namespace cul = com::ubuntu::location;
2830
29const cul::SatelliteBasedPositioningState cul::Engine::Configuration::Defaults::satellite_based_positioning_state;31const cul::SatelliteBasedPositioningState cul::Engine::Configuration::Defaults::satellite_based_positioning_state;
@@ -33,7 +35,8 @@
33cul::Engine::Engine(const cul::ProviderSelectionPolicy::Ptr& provider_selection_policy,35cul::Engine::Engine(const cul::ProviderSelectionPolicy::Ptr& provider_selection_policy,
34 const cul::Settings::Ptr& settings)36 const cul::Settings::Ptr& settings)
35 : provider_selection_policy(provider_selection_policy),37 : provider_selection_policy(provider_selection_policy),
36 settings(settings)38 settings(settings),
39 update_policy(std::make_shared<cul::TimeBasedUpdatePolicy>())
37{40{
38 if (!provider_selection_policy) throw std::runtime_error41 if (!provider_selection_policy) throw std::runtime_error
39 {42 {
@@ -204,7 +207,7 @@
204 // We should come up with a better heuristic here.207 // We should come up with a better heuristic here.
205 auto cpr = provider->updates().position.connect([this](const cul::Update<cul::Position>& src)208 auto cpr = provider->updates().position.connect([this](const cul::Update<cul::Position>& src)
206 {209 {
207 updates.reference_location = src;210 updates.reference_location = update_policy->verify_update(src);
208 });211 });
209212
210 std::lock_guard<std::mutex> lg(guard);213 std::lock_guard<std::mutex> lg(guard);
211214
=== modified file 'src/location_service/com/ubuntu/location/engine.h'
--- src/location_service/com/ubuntu/location/engine.h 2015-01-14 13:41:54 +0000
+++ src/location_service/com/ubuntu/location/engine.h 2015-04-23 21:30:38 +0000
@@ -33,6 +33,8 @@
33#include <mutex>33#include <mutex>
34#include <set>34#include <set>
3535
36#include "update_policy.h"
37
36namespace com38namespace com
37{39{
38namespace ubuntu40namespace ubuntu
@@ -193,6 +195,7 @@
193 std::map<Provider::Ptr, ProviderConnections> providers;195 std::map<Provider::Ptr, ProviderConnections> providers;
194 ProviderSelectionPolicy::Ptr provider_selection_policy;196 ProviderSelectionPolicy::Ptr provider_selection_policy;
195 Settings::Ptr settings;197 Settings::Ptr settings;
198 UpdatePolicy::Ptr update_policy;
196};199};
197200
198/** @brief Pretty prints the given status to the given stream. */201/** @brief Pretty prints the given status to the given stream. */
199202
=== added file 'src/location_service/com/ubuntu/location/time_based_update_policy.cpp'
--- src/location_service/com/ubuntu/location/time_based_update_policy.cpp 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/time_based_update_policy.cpp 2015-04-23 21:30:38 +0000
@@ -0,0 +1,121 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Manuel de la Pena <manuel.delapena@canonical.com>
17 */
18
19#include "time_based_update_policy.h"
20
21namespace com
22{
23namespace ubuntu
24{
25namespace location
26{
27
28std::chrono::minutes TimeBasedUpdatePolicy::default_timeout()
29{
30 static const std::chrono::minutes default_limit(2);
31 return default_limit;
32}
33
34TimeBasedUpdatePolicy::TimeBasedUpdatePolicy(std::chrono::minutes mins)
35 : limit(mins)
36{
37
38}
39
40const location::Update<location::Position>& TimeBasedUpdatePolicy::verify_update(const location::Update<location::Position>& update)
41{
42 std::lock_guard<std::mutex> guard(position_update_mutex);
43 bool use_new_update;
44 if (is_significantly_newer(last_position_update, update, limit))
45 {
46 use_new_update = true;
47 }
48 else if (is_significantly_older(last_position_update, update, limit))
49 {
50 use_new_update = false;
51 }
52 else
53 {
54 // if the update has happened within a reasonable amount of time we will just use it if it is more accurate
55 // that the previous one.
56 use_new_update = last_position_update.value.accuracy.horizontal && update.value.accuracy.horizontal
57 && *last_position_update.value.accuracy.horizontal >= *update.value.accuracy.horizontal;
58 }
59
60 if (use_new_update)
61 {
62 last_position_update = update;
63 return update;
64 }
65 else
66 {
67 return last_position_update;
68 }
69}
70
71
72const location::Update<location::Heading>& TimeBasedUpdatePolicy::verify_update(const location::Update<location::Heading>& update)
73{
74 std::lock_guard<std::mutex> guard(heading_update_mutex);
75 bool use_new_update;
76 if (is_significantly_newer(last_heading_update, update, limit))
77 {
78 use_new_update = true;
79 }
80 else if (is_significantly_older(last_heading_update, update, limit))
81 {
82 use_new_update = false;
83 }
84 if (use_new_update)
85 {
86 last_heading_update = update;
87 return update;
88 }
89 else
90 {
91 return last_heading_update;
92 }
93}
94
95const location::Update<location::Velocity>& TimeBasedUpdatePolicy::verify_update(const location::Update<location::Velocity>& update)
96{
97 std::lock_guard<std::mutex> guard(velocity_update_mutex);
98 bool use_new_update;
99 if (is_significantly_newer(last_velocity_update, update, limit))
100 {
101 use_new_update = true;
102 }
103 else if (is_significantly_older(last_velocity_update, update, limit))
104 {
105 use_new_update = false;
106 }
107
108 if (use_new_update)
109 {
110 last_velocity_update = update;
111 return update;
112 }
113 else
114 {
115 return last_velocity_update;
116 }
117}
118
119}
120}
121}
0\ No newline at end of file122\ No newline at end of file
1123
=== added file 'src/location_service/com/ubuntu/location/time_based_update_policy.h'
--- src/location_service/com/ubuntu/location/time_based_update_policy.h 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/time_based_update_policy.h 2015-04-23 21:30:38 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Manuel de la Pena <manuel.delapena@canonical.com>
17 */
18#ifndef LOCATION_SERVICE_UBUNTU_LOCATION_SERVICE_TIMES_BASED_UPDATE_POLICY_H_
19#define LOCATION_SERVICE_UBUNTU_LOCATION_SERVICE_TIMES_BASED_UPDATE_POLICY_H_
20
21#include <chrono>
22#include <mutex>
23
24#include "update_policy.h"
25
26namespace com
27{
28namespace ubuntu
29{
30namespace location
31{
32
33// An interface that can be implemented to add heuristics on how heading, position or velocity updates will be chosen.
34// This class ensures that the best update possible is chosen within a reasonable time bracket.
35class TimeBasedUpdatePolicy : public UpdatePolicy {
36
37 public:
38 TimeBasedUpdatePolicy(std::chrono::minutes mins=default_timeout());
39 TimeBasedUpdatePolicy(const TimeBasedUpdatePolicy&) = delete;
40 ~TimeBasedUpdatePolicy() = default;
41
42 // Return if the given position update will be verified as the new position in the engine.
43 const location::Update<location::Position>& verify_update(const location::Update<location::Position>& update) override;
44 // Return if the given heading update will be verified as the new heading in the engine.
45 const location::Update<location::Heading>& verify_update(const location::Update<location::Heading>& update) override;
46 // Return if the given velocity update will be verified as the new velocity in the engine.
47 const location::Update<location::Velocity>& verify_update(const location::Update<location::Velocity>& update) override;
48
49 static std::chrono::minutes default_timeout();
50
51 protected:
52 // not private to simplify the testing but should be private
53 location::Update<location::Position> last_position_update;
54 location::Update<location::Heading> last_heading_update;
55 location::Update<location::Velocity> last_velocity_update;
56
57 private:
58 // callbacks can happen in diff threads, make sure multi-threading will work in this class
59 std::mutex position_update_mutex;
60 std::mutex heading_update_mutex;
61 std::mutex velocity_update_mutex;
62 // used to calculate the time accepted bracket
63 std::chrono::minutes limit;
64};
65
66}
67}
68}
69
70#endif //LOCATION_SERVICE_UBUNTU_LOCATION_SERVICE_TIMES_BASED_UPDATE_POLICY_H_
071
=== added file 'src/location_service/com/ubuntu/location/update_policy.h'
--- src/location_service/com/ubuntu/location/update_policy.h 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/update_policy.h 2015-04-23 21:30:38 +0000
@@ -0,0 +1,75 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Manuel de la Pena <manuel.delapena@canonical.com>
17 */
18#ifndef LOCATION_SERVICE_UBUNTU_LOCATION_SERVICE_UPDATE_POLICY_H_
19#define LOCATION_SERVICE_UBUNTU_LOCATION_SERVICE_UPDATE_POLICY_H_
20
21#include <memory>
22
23#include <com/ubuntu/location/heading.h>
24#include <com/ubuntu/location/position.h>
25#include <com/ubuntu/location/update.h>
26#include <com/ubuntu/location/velocity.h>
27
28namespace com
29{
30namespace ubuntu
31{
32namespace location
33{
34
35// An interface that can be implemented to add heuristics on how heading, position or velocity updateswill be chosen.
36// This class allows developers to inject different heuristics in the engine to perform the update selection
37// so that the app developers can take advantage of it.
38class UpdatePolicy {
39 public:
40 typedef std::shared_ptr<UpdatePolicy> Ptr;
41
42 UpdatePolicy(const UpdatePolicy&) = delete;
43 UpdatePolicy(UpdatePolicy&&) = delete;
44 UpdatePolicy& operator=(const UpdatePolicy&) = delete;
45 virtual ~UpdatePolicy() = default;
46
47 // Return if the given position update will be verified as the new position in the engine.
48 virtual const location::Update<location::Position>& verify_update(const location::Update<location::Position>& update) = 0;
49 // Return if the given heading update will be verified as the new heading in the engine.
50 virtual const location::Update<location::Heading>& verify_update(const location::Update<location::Heading>& update) = 0;
51 // Return if the given velocity update will be verified as the new velocity in the engine.
52 virtual const location::Update<location::Velocity>& verify_update(const location::Update<location::Velocity>& update) = 0;
53 protected:
54 UpdatePolicy() = default;
55
56 template <class T> bool is_significantly_newer(const location::Update<T> last_update, const location::Update<T> update, std::chrono::minutes limit) const
57 {
58 auto delta = update.when - last_update.when;
59 return delta > limit;
60 }
61
62 template <class T> bool is_significantly_older(const location::Update<T> last_update, const location::Update<T> update, std::chrono::minutes limit) const
63 {
64 auto delta = update.when - last_update.when;
65 return delta < (-1 * limit);
66 }
67
68
69};
70}
71}
72}
73
74#endif // LOCATION_SERVICE_UBUNTU_LOCATION_SERVICE_UPDATE_POLICY_H_
75
076
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2014-11-14 11:26:45 +0000
+++ tests/CMakeLists.txt 2015-04-23 21:30:38 +0000
@@ -80,6 +80,7 @@
80LOCATION_SERVICE_ADD_TEST(engine_test engine_test.cpp)80LOCATION_SERVICE_ADD_TEST(engine_test engine_test.cpp)
81LOCATION_SERVICE_ADD_TEST(harvester_test harvester_test.cpp)81LOCATION_SERVICE_ADD_TEST(harvester_test harvester_test.cpp)
82LOCATION_SERVICE_ADD_TEST(demultiplexing_reporter_test demultiplexing_reporter_test.cpp)82LOCATION_SERVICE_ADD_TEST(demultiplexing_reporter_test demultiplexing_reporter_test.cpp)
83LOCATION_SERVICE_ADD_TEST(time_based_update_policy_test time_based_update_policy_test.cpp)
8384
84if (NET_CPP_FOUND)85if (NET_CPP_FOUND)
85 LOCATION_SERVICE_ADD_TEST(ichnaea_reporter_test ichnaea_reporter_test.cpp)86 LOCATION_SERVICE_ADD_TEST(ichnaea_reporter_test ichnaea_reporter_test.cpp)
8687
=== added file 'tests/time_based_update_policy_test.cpp'
--- tests/time_based_update_policy_test.cpp 1970-01-01 00:00:00 +0000
+++ tests/time_based_update_policy_test.cpp 2015-04-23 21:30:38 +0000
@@ -0,0 +1,131 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Manuel de la Pena <manuel.delapena@canonical.com>
17 */
18#include <com/ubuntu/location/time_based_update_policy.h>
19
20#include <gtest/gtest.h>
21
22using namespace ::testing;
23namespace cul = com::ubuntu::location;
24
25namespace
26{
27 auto timestamp = com::ubuntu::location::Clock::now();
28
29 com::ubuntu::location::Update<com::ubuntu::location::Position> reference_position_update
30 {
31 {
32 com::ubuntu::location::wgs84::Latitude{9. * com::ubuntu::location::units::Degrees},
33 com::ubuntu::location::wgs84::Longitude{53. * com::ubuntu::location::units::Degrees},
34 com::ubuntu::location::wgs84::Altitude{-2. * com::ubuntu::location::units::Meters},
35 },
36 timestamp
37 };
38}
39
40// make certain internal details public so that we can set the last update
41class PublicTimeBasedUpdatePolicy : public cul::TimeBasedUpdatePolicy {
42 public:
43 PublicTimeBasedUpdatePolicy(std::chrono::minutes mins) : cul::TimeBasedUpdatePolicy(mins) {}
44 using cul::TimeBasedUpdatePolicy::last_position_update;
45 using cul::TimeBasedUpdatePolicy::last_heading_update;
46 using cul::TimeBasedUpdatePolicy::last_velocity_update;
47};
48
49TEST(TimeBasedUpdatePolicy, policy_ignores_updates_that_are_too_old)
50{
51 auto policy = std::make_shared<PublicTimeBasedUpdatePolicy>(std::chrono::minutes(2));
52 policy->last_position_update = reference_position_update;
53
54 com::ubuntu::location::Update<com::ubuntu::location::Position> old_update
55 {
56 {
57 com::ubuntu::location::wgs84::Latitude{10. * com::ubuntu::location::units::Degrees},
58 com::ubuntu::location::wgs84::Longitude{60. * com::ubuntu::location::units::Degrees},
59 com::ubuntu::location::wgs84::Altitude{10. * com::ubuntu::location::units::Meters}
60 },
61 timestamp - std::chrono::minutes(5)
62 };
63 policy->verify_update(old_update);
64
65 ASSERT_NE(policy->last_position_update.value.latitude, old_update.value.latitude);
66 ASSERT_EQ(policy->last_position_update.value.latitude, reference_position_update.value.latitude);
67
68 ASSERT_NE(policy->last_position_update.value.longitude, old_update.value.longitude);
69 ASSERT_EQ(policy->last_position_update.value.longitude, reference_position_update.value.longitude);
70
71 ASSERT_NE(policy->last_position_update.value.altitude, old_update.value.altitude);
72 ASSERT_EQ(policy->last_position_update.value.altitude, reference_position_update.value.altitude);
73}
74
75TEST(TimeBasedUpdatePolicy, policy_uses_very_recent_updates)
76{
77 auto policy = std::make_shared<PublicTimeBasedUpdatePolicy>(std::chrono::minutes(2));
78
79 policy->last_position_update = reference_position_update;
80
81 com::ubuntu::location::Update<com::ubuntu::location::Position> new_update
82 {
83 {
84 com::ubuntu::location::wgs84::Latitude{10. * com::ubuntu::location::units::Degrees},
85 com::ubuntu::location::wgs84::Longitude{60. * com::ubuntu::location::units::Degrees},
86 com::ubuntu::location::wgs84::Altitude{10. * com::ubuntu::location::units::Meters}
87 },
88 timestamp + std::chrono::minutes(3)
89 };
90
91 policy->verify_update(new_update);
92
93 ASSERT_EQ(policy->last_position_update.value.latitude, new_update.value.latitude);
94 ASSERT_NE(policy->last_position_update.value.latitude, reference_position_update.value.latitude);
95
96 ASSERT_EQ(policy->last_position_update.value.longitude, new_update.value.longitude);
97 ASSERT_NE(policy->last_position_update.value.longitude, reference_position_update.value.longitude);
98
99 ASSERT_EQ(policy->last_position_update.value.altitude, new_update.value.altitude);
100 ASSERT_NE(policy->last_position_update.value.altitude, reference_position_update.value.altitude);
101}
102
103TEST(TimeBasedUpdatePolicy, policy_ignores_inaccurate_updates)
104{
105 auto policy = std::make_shared<PublicTimeBasedUpdatePolicy>(std::chrono::minutes(2));
106 reference_position_update.value.accuracy.horizontal = 1. * com::ubuntu::location::units::Meters;
107 policy->last_position_update = reference_position_update;
108
109 com::ubuntu::location::Update<com::ubuntu::location::Position> new_update
110 {
111 {
112 com::ubuntu::location::wgs84::Latitude{10. * com::ubuntu::location::units::Degrees},
113 com::ubuntu::location::wgs84::Longitude{60. * com::ubuntu::location::units::Degrees},
114 com::ubuntu::location::wgs84::Altitude{10. * com::ubuntu::location::units::Meters},
115 },
116 timestamp + std::chrono::minutes(1)
117 };
118 new_update.value.accuracy.horizontal = 8. * com::ubuntu::location::units::Meters;
119
120 policy->verify_update(new_update);
121 ASSERT_TRUE(*new_update.value.accuracy.horizontal > *reference_position_update.value.accuracy.horizontal);
122
123 ASSERT_NE(policy->last_position_update.value.latitude, new_update.value.latitude);
124 ASSERT_EQ(policy->last_position_update.value.latitude, reference_position_update.value.latitude);
125
126 ASSERT_NE(policy->last_position_update.value.longitude, new_update.value.longitude);
127 ASSERT_EQ(policy->last_position_update.value.longitude, reference_position_update.value.longitude);
128
129 ASSERT_NE(policy->last_position_update.value.altitude, new_update.value.altitude);
130 ASSERT_EQ(policy->last_position_update.value.altitude, reference_position_update.value.altitude);
131}

Subscribers

People subscribed via source and target branches