diff options
author | Mikhail Gorbushin <m.gorbushin@corp.mail.ru> | 2018-09-10 14:24:35 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2018-09-17 12:49:53 +0300 |
commit | 48deff91e538716eaa06204167101eb48fe3bdbd (patch) | |
tree | 23726c83920ce805a62d876161ca11f6cb09695b /map | |
parent | 5dff287f0dbd6960bdf2bd08918e560a512db604 (diff) |
[routing] add routing part of speed cameras and tests for it.
Diffstat (limited to 'map')
-rw-r--r-- | map/extrapolation/extrapolator.cpp | 2 | ||||
-rw-r--r-- | map/framework.cpp | 12 | ||||
-rw-r--r-- | map/framework.hpp | 3 | ||||
-rw-r--r-- | map/gps_track_filter.cpp | 2 | ||||
-rw-r--r-- | map/gps_track_storage.cpp | 4 | ||||
-rw-r--r-- | map/map_tests/extrapolator_tests.cpp | 12 | ||||
-rw-r--r-- | map/map_tests/gps_track_storage_test.cpp | 10 | ||||
-rw-r--r-- | map/map_tests/gps_track_test.cpp | 10 | ||||
-rw-r--r-- | map/routing_manager.cpp | 5 |
9 files changed, 36 insertions, 24 deletions
diff --git a/map/extrapolation/extrapolator.cpp b/map/extrapolation/extrapolator.cpp index d0463e2c90..e860e17c3a 100644 --- a/map/extrapolation/extrapolator.cpp +++ b/map/extrapolation/extrapolator.cpp @@ -76,7 +76,7 @@ location::GpsInfo LinearExtrapolation(location::GpsInfo const & gpsInfo1, // look nice when the road changes its direction. if (gpsInfo1.HasSpeed() && gpsInfo2.HasSpeed()) - result.m_speed = e.Extrapolate(gpsInfo1.m_speed, gpsInfo2.m_speed); + result.m_speedMpS = e.Extrapolate(gpsInfo1.m_speedMpS, gpsInfo2.m_speedMpS); return result; } diff --git a/map/framework.cpp b/map/framework.cpp index d5d7a6533d..4fc6b6af22 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2809,6 +2809,16 @@ bool Framework::ParseEditorDebugCommand(search::SearchParams const & params) return false; } +bool Framework::ParseRoutingDebugCommand(search::SearchParams const & params) +{ + if (params.m_query == "?speedcams") + { + GetRoutingManager().RoutingSession().ToggleSpeedCameras(true /* enable */); + return true; + } + return false; +} + namespace { WARN_UNUSED_RESULT bool LocalizeStreet(DataSource const & dataSource, FeatureID const & fid, @@ -3374,6 +3384,8 @@ bool Framework::ParseSearchQueryCommand(search::SearchParams const & params) return true; if (ParseEditorDebugCommand(params)) return true; + if (ParseRoutingDebugCommand(params)) + return true; return false; } diff --git a/map/framework.hpp b/map/framework.hpp index 61a31ce196..8710e76ad8 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -659,9 +659,12 @@ private: //void GetLocality(m2::PointD const & pt, search::AddressInfo & info) const; /// @returns true if command was handled by editor. bool ParseEditorDebugCommand(search::SearchParams const & params); + /// @returns true if command was handled by drape. bool ParseDrapeDebugCommand(string const & query); + bool ParseRoutingDebugCommand(search::SearchParams const & params); + void FillFeatureInfo(FeatureID const & fid, place_page::Info & info) const; /// @param customTitle, if not empty, overrides any other calculated name. void FillPointInfo(m2::PointD const & mercator, string const & customTitle, place_page::Info & info) const; diff --git a/map/gps_track_filter.cpp b/map/gps_track_filter.cpp index 1ce1ffd57b..762afe0046 100644 --- a/map/gps_track_filter.cpp +++ b/map/gps_track_filter.cpp @@ -147,7 +147,7 @@ bool GpsTrackFilter::IsGoodPoint(location::GpsInfo const & info) const double const speedFromLast = distanceFromLast / timeFromLast; // Filter by acceleration: skip point if it jumps too far in short time - double const accelerationFromLast = (speedFromLast - lastInfo.m_speed) / timeFromLast; + double const accelerationFromLast = (speedFromLast - lastInfo.m_speedMpS) / timeFromLast; if (accelerationFromLast > kMaxAcceptableAcceleration) return false; diff --git a/map/gps_track_storage.cpp b/map/gps_track_storage.cpp index 9d63dccf5d..8e9063b9b0 100644 --- a/map/gps_track_storage.cpp +++ b/map/gps_track_storage.cpp @@ -50,7 +50,7 @@ void Pack(char * p, location::GpsInfo const & info) MemWrite<double>(p + 1 * sizeof(double), info.m_latitude); MemWrite<double>(p + 2 * sizeof(double), info.m_longitude); MemWrite<double>(p + 3 * sizeof(double), info.m_altitude); - MemWrite<double>(p + 4 * sizeof(double), info.m_speed); + MemWrite<double>(p + 4 * sizeof(double), info.m_speedMpS); MemWrite<double>(p + 5 * sizeof(double), info.m_bearing); MemWrite<double>(p + 6 * sizeof(double), info.m_horizontalAccuracy); MemWrite<double>(p + 7 * sizeof(double), info.m_verticalAccuracy); @@ -65,7 +65,7 @@ void Unpack(char const * p, location::GpsInfo & info) info.m_latitude = MemRead<double>(p + 1 * sizeof(double)); info.m_longitude = MemRead<double>(p + 2 * sizeof(double)); info.m_altitude = MemRead<double>(p + 3 * sizeof(double)); - info.m_speed = MemRead<double>(p + 4 * sizeof(double)); + info.m_speedMpS = MemRead<double>(p + 4 * sizeof(double)); info.m_bearing = MemRead<double>(p + 5 * sizeof(double)); info.m_horizontalAccuracy = MemRead<double>(p + 6 * sizeof(double)); info.m_verticalAccuracy = MemRead<double>(p + 7 * sizeof(double)); diff --git a/map/map_tests/extrapolator_tests.cpp b/map/map_tests/extrapolator_tests.cpp index 5d9dffd733..6fce9625ef 100644 --- a/map/map_tests/extrapolator_tests.cpp +++ b/map/map_tests/extrapolator_tests.cpp @@ -22,7 +22,7 @@ void TestGpsInfo(GpsInfo const & tested, GpsInfo const & expected) TEST(my::AlmostEqualAbs(tested.m_altitude, expected.m_altitude, kEpsilon), ()); TEST(my::AlmostEqualAbs(tested.m_verticalAccuracy, expected.m_verticalAccuracy, kEpsilon), ()); TEST(my::AlmostEqualAbs(tested.m_bearing, expected.m_bearing, kEpsilon), ()); - TEST(my::AlmostEqualAbs(tested.m_speed, expected.m_speed, kEpsilon), ()); + TEST(my::AlmostEqualAbs(tested.m_speedMpS, expected.m_speedMpS, kEpsilon), ()); } GpsInfo GetGpsInfo(double timestampS, double lat, double lon, double altitude, double speed) @@ -41,9 +41,9 @@ GpsInfo GetGpsInfo(double timestampS, double lat, double lon, double altitude, d UNIT_TEST(LinearExtrapolation) { GpsInfo const loc1 = GetGpsInfo(0.0 /* timestampS */, 1.0 /* m_latitude */, 1.0 /* m_longitude */, - 1.0 /* m_altitude */, 10.0 /* m_speed */); + 1.0 /* m_altitude */, 10.0 /* m_speedMpS */); GpsInfo const loc2 = GetGpsInfo(1.0 /* timestampS */, 1.01 /* m_latitude */, 1.01 /* m_longitude */, - 2.0 /* m_altitude */, 12.0 /* m_speed */); + 2.0 /* m_altitude */, 12.0 /* m_speedMpS */); // 0 ms after |point2|. TestGpsInfo(LinearExtrapolation(loc1, loc2, 0 /* timeAfterPoint2Ms */), loc2); @@ -51,21 +51,21 @@ UNIT_TEST(LinearExtrapolation) // 100 ms after |point2|. { GpsInfo const expected = GetGpsInfo(1.1 /* timestampS */, 1.011 /* m_latitude */, - 1.011 /* m_longitude */, 2.1 /* m_altitude */, 12.2 /* m_speed */); + 1.011 /* m_longitude */, 2.1 /* m_altitude */, 12.2 /* m_speedMpS */); TestGpsInfo(LinearExtrapolation(loc1, loc2, 100 /* timeAfterPoint2Ms */), expected); } // 200 ms after |point2|. { GpsInfo const expected = GetGpsInfo(1.2 /* timestampS */, 1.012 /* m_latitude */, - 1.012 /* m_longitude */, 2.2 /* m_altitude */, 12.4 /* m_speed */); + 1.012 /* m_longitude */, 2.2 /* m_altitude */, 12.4 /* m_speedMpS */); TestGpsInfo(LinearExtrapolation(loc1, loc2, 200 /* timeAfterPoint2Ms */), expected); } // 1000 ms after |point2|. { GpsInfo const expected = GetGpsInfo(2.0 /* timestampS */, 1.02 /* m_latitude */, - 1.02 /* m_longitude */, 3.0 /* m_altitude */, 14.0 /* m_speed */); + 1.02 /* m_longitude */, 3.0 /* m_altitude */, 14.0 /* m_speedMpS */); TestGpsInfo(LinearExtrapolation(loc1, loc2, 1000 /* timeAfterPoint2Ms */), expected); } } diff --git a/map/map_tests/gps_track_storage_test.cpp b/map/map_tests/gps_track_storage_test.cpp index e24efd521a..9da8e2e07d 100644 --- a/map/map_tests/gps_track_storage_test.cpp +++ b/map/map_tests/gps_track_storage_test.cpp @@ -21,7 +21,7 @@ location::GpsInfo Make(double timestamp, ms::LatLon const & ll, double speed) { location::GpsInfo info; info.m_timestamp = timestamp; - info.m_speed = speed; + info.m_speedMpS = speed; info.m_latitude = ll.lat; info.m_longitude = ll.lon; info.m_source = location::EAndroidNative; @@ -64,7 +64,7 @@ UNIT_TEST(GpsTrackStorage_WriteReadWithoutTrunc) TEST_EQUAL(point.m_latitude, points[i].m_latitude, ()); TEST_EQUAL(point.m_longitude, points[i].m_longitude, ()); TEST_EQUAL(point.m_timestamp, points[i].m_timestamp, ()); - TEST_EQUAL(point.m_speed, points[i].m_speed, ()); + TEST_EQUAL(point.m_speed, points[i].m_speedMpS, ()); ++i; return true; }); @@ -81,7 +81,7 @@ UNIT_TEST(GpsTrackStorage_WriteReadWithoutTrunc) TEST_EQUAL(point.m_latitude, points[i].m_latitude, ()); TEST_EQUAL(point.m_longitude, points[i].m_longitude, ()); TEST_EQUAL(point.m_timestamp, points[i].m_timestamp, ()); - TEST_EQUAL(point.m_speed, points[i].m_speed, ()); + TEST_EQUAL(point.m_speed, points[i].m_speedMpS, ()); ++i; return true; }); @@ -157,14 +157,14 @@ UNIT_TEST(GpsTrackStorage_WriteReadWithTrunc) TEST_EQUAL(point.m_latitude, points2[fileMaxItemCount/2 + i].m_latitude, ()); TEST_EQUAL(point.m_longitude, points2[fileMaxItemCount/2 + i].m_longitude, ()); TEST_EQUAL(point.m_timestamp, points2[fileMaxItemCount/2 + i].m_timestamp, ()); - TEST_EQUAL(point.m_speed, points2[fileMaxItemCount/2 + i].m_speed, ()); + TEST_EQUAL(point.m_speedMpS, points2[fileMaxItemCount/2 + i].m_speedMpS, ()); } else { TEST_EQUAL(point.m_latitude, points3[i - fileMaxItemCount/2].m_latitude, ()); TEST_EQUAL(point.m_longitude, points3[i - fileMaxItemCount/2].m_longitude, ()); TEST_EQUAL(point.m_timestamp, points3[i - fileMaxItemCount/2].m_timestamp, ()); - TEST_EQUAL(point.m_speed, points3[i - fileMaxItemCount/2].m_speed, ()); + TEST_EQUAL(point.m_speedMpS, points3[i - fileMaxItemCount/2].m_speedMpS, ()); } ++i; return true; diff --git a/map/map_tests/gps_track_test.cpp b/map/map_tests/gps_track_test.cpp index 33ef98af4f..206264f3a6 100644 --- a/map/map_tests/gps_track_test.cpp +++ b/map/map_tests/gps_track_test.cpp @@ -22,7 +22,7 @@ inline location::GpsInfo Make(double timestamp, ms::LatLon const & ll, double sp { location::GpsInfo info; info.m_timestamp = timestamp; - info.m_speed = speed; + info.m_speedMpS = speed; info.m_latitude = ll.lat; info.m_longitude = ll.lon; info.m_horizontalAccuracy = 15; @@ -117,7 +117,7 @@ UNIT_TEST(GpsTrack_Simple) { TEST_EQUAL(i, callback.m_toAdd[i].first, ()); TEST_EQUAL(points[i].m_timestamp, callback.m_toAdd[i].second.m_timestamp, ()); - TEST_EQUAL(points[i].m_speed, callback.m_toAdd[i].second.m_speed, ()); + TEST_EQUAL(points[i].m_speedMpS, callback.m_toAdd[i].second.m_speed, ()); TEST_EQUAL(points[i].m_latitude, callback.m_toAdd[i].second.m_latitude, ()); TEST_EQUAL(points[i].m_longitude, callback.m_toAdd[i].second.m_longitude, ()); } @@ -140,7 +140,7 @@ UNIT_TEST(GpsTrack_Simple) { TEST_EQUAL(i, callback.m_toAdd[i].first, ()); TEST_EQUAL(points[i].m_timestamp, callback.m_toAdd[i].second.m_timestamp, ()); - TEST_EQUAL(points[i].m_speed, callback.m_toAdd[i].second.m_speed, ()); + TEST_EQUAL(points[i].m_speedMpS, callback.m_toAdd[i].second.m_speed, ()); TEST_EQUAL(points[i].m_latitude, callback.m_toAdd[i].second.m_latitude, ()); TEST_EQUAL(points[i].m_longitude, callback.m_toAdd[i].second.m_longitude, ()); } @@ -173,7 +173,7 @@ UNIT_TEST(GpsTrack_EvictedByAdd) TEST_EQUAL(1, callback.m_toAdd.size(), ()); TEST_EQUAL(0, callback.m_toAdd[0].first, ()); TEST_EQUAL(pt1.m_timestamp, callback.m_toAdd[0].second.m_timestamp, ()); - TEST_EQUAL(pt1.m_speed, callback.m_toAdd[0].second.m_speed, ()); + TEST_EQUAL(pt1.m_speedMpS, callback.m_toAdd[0].second.m_speed, ()); TEST_EQUAL(pt1.m_latitude, callback.m_toAdd[0].second.m_latitude, ()); TEST_EQUAL(pt1.m_longitude, callback.m_toAdd[0].second.m_longitude, ()); // and nothing was evicted @@ -190,7 +190,7 @@ UNIT_TEST(GpsTrack_EvictedByAdd) TEST_EQUAL(1, callback.m_toAdd.size(), ()); TEST_EQUAL(1, callback.m_toAdd[0].first, ()); TEST_EQUAL(pt2.m_timestamp, callback.m_toAdd[0].second.m_timestamp, ()); - TEST_EQUAL(pt2.m_speed, callback.m_toAdd[0].second.m_speed, ()); + TEST_EQUAL(pt2.m_speedMpS, callback.m_toAdd[0].second.m_speed, ()); TEST_EQUAL(pt2.m_latitude, callback.m_toAdd[0].second.m_latitude, ()); TEST_EQUAL(pt2.m_longitude, callback.m_toAdd[0].second.m_longitude, ()); // and pt1 was evicted as old diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index 5d70420190..4dd5af1d88 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -922,10 +922,7 @@ void RoutingManager::CheckLocationForRouting(location::GpsInfo const & info) if (!IsRoutingActive()) return; - auto const featureDataSourceGetterFn = m_callbacks.m_dataSourceGetter; - ASSERT(featureDataSourceGetterFn, ()); - RoutingSession::State const state = - m_routingSession.OnLocationPositionChanged(info, featureDataSourceGetterFn()); + RoutingSession::State const state = m_routingSession.OnLocationPositionChanged(info); if (state == RoutingSession::RouteNeedRebuild) { m_routingSession.RebuildRoute( |