Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2019-02-18 13:29:51 +0300
committerVlad Mihaylenko <vxmihaylenko@gmail.com>2019-02-20 13:25:42 +0300
commit61f3a3626cc1ac29107dc146842b4ac479a0f2cd (patch)
tree684c3e3d070aa50deee83931a0885797143f70e2 /routing
parent3a6ee0bc9a45b7d6421a70fb7778272e6a8f7bf2 (diff)
Adding methods for getting info if route crosses mwm where warnings about speedcams are prohibited.
Diffstat (limited to 'routing')
-rw-r--r--routing/CMakeLists.txt2
-rw-r--r--routing/index_router.cpp28
-rw-r--r--routing/index_router.hpp8
-rw-r--r--routing/route.cpp15
-rw-r--r--routing/route.hpp16
-rw-r--r--routing/speed_camera_prohibition.cpp46
-rw-r--r--routing/speed_camera_prohibition.hpp12
7 files changed, 124 insertions, 3 deletions
diff --git a/routing/CMakeLists.txt b/routing/CMakeLists.txt
index 4605e5ab92..a45f433be0 100644
--- a/routing/CMakeLists.txt
+++ b/routing/CMakeLists.txt
@@ -119,6 +119,8 @@ set(
speed_camera.hpp
speed_camera_manager.cpp
speed_camera_manager.hpp
+ speed_camera_prohibition.cpp
+ speed_camera_prohibition.hpp
speed_camera_ser_des.cpp
speed_camera_ser_des.hpp
traffic_stash.cpp
diff --git a/routing/index_router.cpp b/routing/index_router.cpp
index 13cbab4575..67b996939e 100644
--- a/routing/index_router.cpp
+++ b/routing/index_router.cpp
@@ -15,6 +15,7 @@
#include "routing/routing_exceptions.hpp"
#include "routing/routing_helpers.hpp"
#include "routing/single_vehicle_world_graph.hpp"
+#include "routing/speed_camera_prohibition.hpp"
#include "routing/transit_info.hpp"
#include "routing/transit_world_graph.hpp"
#include "routing/turns_generator.hpp"
@@ -29,13 +30,13 @@
#include "indexer/data_source.hpp"
#include "indexer/feature_altitude.hpp"
+#include "platform/mwm_traits.hpp"
+
#include "geometry/mercator.hpp"
#include "geometry/parametrized_segment.hpp"
#include "geometry/point2d.hpp"
-#include "platform/country_file.hpp"
-#include "platform/mwm_traits.hpp"
-
+#include "base/assert.hpp"
#include "base/exception.hpp"
#include "base/logging.hpp"
#include "base/stl_helpers.hpp"
@@ -963,6 +964,10 @@ RouterResultCode IndexRouter::RedressRoute(vector<Segment> const & segments,
routeSegment.SetSpeedCameraInfo(worldGraph.GetSpeedCamInfo(routeSegment.GetSegment()));
}
+ vector<platform::CountryFile> speedcamProhibited;
+ FillsSpeedcamProhibitedMwms(segments, speedcamProhibited);
+ route.StealSpeedcamProhibited(move(speedcamProhibited));
+
if (delegate.IsCancelled())
return RouterResultCode::Cancelled;
@@ -1016,4 +1021,21 @@ RouterResultCode IndexRouter::ConvertTransitResult(set<NumMwmId> const & mwmIds,
return RouterResultCode::TransitRouteNotFoundTooLongPedestrian;
}
+
+void IndexRouter::FillsSpeedcamProhibitedMwms(vector<Segment> const & segments,
+ vector<platform::CountryFile> & speedcamProhibitedMwms) const
+{
+ CHECK(m_numMwmIds, ());
+
+ set<NumMwmId> mwmIds;
+ for (auto const & s : segments)
+ mwmIds.insert(s.GetMwmId());
+
+ for (auto const id : mwmIds)
+ {
+ auto const & country = m_numMwmIds->GetFile(id);
+ if (ShouldWarnAboutSpeedcam(country))
+ speedcamProhibitedMwms.push_back(country);
+ }
+}
} // namespace routing
diff --git a/routing/index_router.hpp b/routing/index_router.hpp
index 22d07d75e9..351ae7ea1d 100644
--- a/routing/index_router.hpp
+++ b/routing/index_router.hpp
@@ -12,6 +12,7 @@
#include "routing/joint.hpp"
#include "routing/router.hpp"
#include "routing/routing_callbacks.hpp"
+#include "routing/segment.hpp"
#include "routing/segmented_route.hpp"
#include "routing/world_graph.hpp"
@@ -20,6 +21,8 @@
#include "indexer/mwm_set.hpp"
+#include "platform/country_file.hpp"
+
#include "geometry/tree4d.hpp"
#include "std/unique_ptr.hpp"
@@ -121,6 +124,11 @@ private:
RouterResultCode ConvertTransitResult(std::set<NumMwmId> const & mwmIds,
RouterResultCode resultCode) const;
+ /// \brief Fills |speedcamProhibitedMwms| with mwms which are crossed by |segments|
+ /// where speed cameras are prohibited.
+ void FillsSpeedcamProhibitedMwms(std::vector<Segment> const & segments,
+ std::vector<platform::CountryFile> & speedcamProhibitedMwms) const;
+
template <typename Graph>
RouterResultCode ConvertResult(typename AStarAlgorithm<Graph>::Result result) const
{
diff --git a/routing/route.cpp b/routing/route.cpp
index 7c838ba8b4..99e35eee66 100644
--- a/routing/route.cpp
+++ b/routing/route.cpp
@@ -368,6 +368,21 @@ double Route::GetSegLenMeters(size_t segIdx) const
(segIdx == 0 ? 0.0 : m_routeSegments[segIdx - 1].GetDistFromBeginningMeters());
}
+void Route::StealSpeedcamProhibited(vector<platform::CountryFile> && speedcamProhibited)
+{
+ m_speedcamProhibited = move(speedcamProhibited);
+}
+
+bool Route::CrossSpeedcomProhibited() const
+{
+ return m_speedcamProhibited.empty();
+}
+
+std::vector<platform::CountryFile> const & Route::GetSpeedcamProhibited() const
+{
+ return m_speedcamProhibited;
+}
+
double Route::GetETAToLastPassedPointSec() const
{
CHECK(IsValid(), ());
diff --git a/routing/route.hpp b/routing/route.hpp
index cdd06b472e..60b3cd8237 100644
--- a/routing/route.hpp
+++ b/routing/route.hpp
@@ -12,6 +12,8 @@
#include "indexer/feature_altitude.hpp"
+#include "platform/country_file.hpp"
+
#include "geometry/polyline2d.hpp"
#include "base/assert.hpp"
@@ -372,6 +374,17 @@ public:
/// \returns Length of the route segment with |segIdx| in meters.
double GetSegLenMeters(size_t segIdx) const;
+ /// \brief Moves |speedcamProhibited| to |m_speedcamProhibited|.
+ void StealSpeedcamProhibited(std::vector<platform::CountryFile> && speedcamProhibited);
+
+ /// \returns true if the route crosses at lease one mwm where there are restrictions on warning
+ /// about speed cameras.
+ bool CrossSpeedcomProhibited() const;
+
+ /// \returns mwm list which is crossed by the route and where there are restrictions on warning
+ /// about speed cameras.
+ std::vector<platform::CountryFile> const & GetSpeedcamProhibited() const;
+
private:
friend std::string DebugPrint(Route const & r);
@@ -402,5 +415,8 @@ private:
std::vector<SubrouteAttrs> m_subrouteAttrs;
// Route identifier. It's unique within single program session.
uint64_t m_routeId = 0;
+
+ // Mwms which are crossed by the route where speed cameras are prohibited.
+ std::vector<platform::CountryFile> m_speedcamProhibited;
};
} // namespace routing
diff --git a/routing/speed_camera_prohibition.cpp b/routing/speed_camera_prohibition.cpp
new file mode 100644
index 0000000000..03b7915f3a
--- /dev/null
+++ b/routing/speed_camera_prohibition.cpp
@@ -0,0 +1,46 @@
+#include "routing/speed_camera_prohibition.hpp"
+
+#include "base/string_utils.hpp"
+
+#include <vector>
+
+namespace
+{
+// List of country names where mwm should be generated without speedcameras.
+std::vector<std::string> kCountryBlockListForMapGeneration = {
+ "Cyprus",
+ "Macedonia",
+ "Switzerland",
+ "Turkey",
+};
+
+// List of country names where an end user should be warned about speedcameras.
+std::vector<std::string> kCountryWarnList = {
+ "France",
+ "Germany",
+};
+
+bool IsMwmContained(platform::CountryFile const & mwm, std::vector<std::string> const & countryList)
+{
+ for (auto const & country : countryList)
+ {
+ if (strings::StartsWith(mwm.GetName(), country))
+ return true;
+ }
+
+ return false;
+}
+} // namespace
+
+namespace routing
+{
+bool ShouldRemoveSpeedcamWhileMapGeneration(platform::CountryFile const & mwm)
+{
+ return IsMwmContained(mwm, kCountryBlockListForMapGeneration);
+}
+
+bool ShouldWarnAboutSpeedcam(platform::CountryFile const & mwm)
+{
+ return ShouldRemoveSpeedcamWhileMapGeneration(mwm) || IsMwmContained(mwm, kCountryWarnList);
+}
+} // namespace routing
diff --git a/routing/speed_camera_prohibition.hpp b/routing/speed_camera_prohibition.hpp
new file mode 100644
index 0000000000..297b628310
--- /dev/null
+++ b/routing/speed_camera_prohibition.hpp
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "platform/country_file.hpp"
+
+namespace routing
+{
+/// \returns true if any information about speed cameras is prohibited in |mwm|.
+bool ShouldRemoveSpeedcamWhileMapGeneration(platform::CountryFile const & mwm);
+
+/// \returns true if any information about speed cameras is prohibited or partly prohibited in |mwm|.
+bool ShouldWarnAboutSpeedcam(platform::CountryFile const & mwm);
+} // namespace routing