diff options
author | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-02-16 19:26:39 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:45:05 +0300 |
commit | ef44d75c14d003df2131d99b01a4f0fe13cf6ba3 (patch) | |
tree | 47ee2364319af4d3844685440ab7af7377324ace /3party/osrm | |
parent | 62000bcacea4a8ce4737371d567c9ec8d96f7f62 (diff) |
online routing plugin fixes + osrm planet preparing scripting
Diffstat (limited to '3party/osrm')
-rw-r--r-- | 3party/osrm/osrm-backend/Library/OSRM_impl.cpp | 2 | ||||
-rw-r--r-- | 3party/osrm/osrm-backend/Plugins/MapsMePlugin.h | 53 | ||||
-rw-r--r-- | 3party/osrm/osrm-backend/Util/ProgramOptions.h | 5 | ||||
-rw-r--r-- | 3party/osrm/server.ini | 3 |
4 files changed, 23 insertions, 40 deletions
diff --git a/3party/osrm/osrm-backend/Library/OSRM_impl.cpp b/3party/osrm/osrm-backend/Library/OSRM_impl.cpp index 00bbabcec7..ade38e9987 100644 --- a/3party/osrm/osrm-backend/Library/OSRM_impl.cpp +++ b/3party/osrm/osrm-backend/Library/OSRM_impl.cpp @@ -80,7 +80,7 @@ OSRM_impl::OSRM_impl(ServerPaths server_paths, const bool use_shared_memory) RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade)); RegisterPlugin(new TimestampPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade)); RegisterPlugin(new ViaRoutePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade)); - RegisterPlugin(new MapsMePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade, "../../../data/")); + RegisterPlugin(new MapsMePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade, server_paths["borders"].string())); } OSRM_impl::~OSRM_impl() diff --git a/3party/osrm/osrm-backend/Plugins/MapsMePlugin.h b/3party/osrm/osrm-backend/Plugins/MapsMePlugin.h index b4038a5f88..5a9eea6cfd 100644 --- a/3party/osrm/osrm-backend/Plugins/MapsMePlugin.h +++ b/3party/osrm/osrm-backend/Plugins/MapsMePlugin.h @@ -22,41 +22,8 @@ #include "../../../../generator/country_loader.hpp" #include "../../../../indexer/mercator.hpp" -class GetMWMNameByPoint -{ - class CheckPointInBorder - { - m2::PointD const & m_point; - bool & m_inside; - public: - CheckPointInBorder(m2::PointD const & point, bool & inside) : m_point(point), m_inside(inside) {m_inside=false;} - void operator()(m2::RegionD const & region) - { - if (region.Contains(m_point)) - m_inside=true; - } - }; - - string & m_name; - m2::PointD const & m_point; -public: - GetMWMNameByPoint(string & name, m2::PointD const & point) : m_name(name), m_point(point) {} - void operator() (borders::CountryPolygons const & c) - { - bool inside; - CheckPointInBorder getter(m_point, inside); - c.m_regions.ForEachInRect(m2::RectD(m_point, m_point), getter); - if (inside) - m_name = c.m_name; - } -}; - template <class DataFacadeT> class MapsMePlugin final : public BasePlugin { - private: - std::unique_ptr<SearchEngine<DataFacadeT>> search_engine_ptr; - borders::CountriesContainerT m_countries; - public: explicit MapsMePlugin(DataFacadeT *facade, std::string const & baseDir) : descriptor_string("mapsme"), facade(facade) { @@ -124,8 +91,7 @@ template <class DataFacadeT> class MapsMePlugin final : public BasePlugin raw_route.segment_end_coordinates.emplace_back(current_phantom_node_pair); } - search_engine_ptr->shortest_path( - raw_route.segment_end_coordinates, route_parameters.uturns, raw_route); + search_engine_ptr->alternative_path(raw_route.segment_end_coordinates.front(), raw_route); if (INVALID_EDGE_WEIGHT == raw_route.shortest_path_length) { @@ -144,9 +110,18 @@ template <class DataFacadeT> class MapsMePlugin final : public BasePlugin PathData const & path_data = raw_route.unpacked_path_segments[i][j]; FixedPointCoordinate const coord = facade->GetCoordinateOfNode(path_data.node); string mwmName; - m2::PointD mercatorPoint(MercatorBounds::LonToX(coord.lon), MercatorBounds::LatToY(coord.lat)); - GetMWMNameByPoint getter(mwmName, mercatorPoint); - m_countries.ForEachInRect(m2::RectD(mercatorPoint, mercatorPoint), getter); + m2::PointD mercatorPoint(MercatorBounds::LonToX(coord.lon/1000000.0), MercatorBounds::LatToY(coord.lat/1000000.0)); + m_countries.ForEachInRect(m2::RectD(mercatorPoint, mercatorPoint), [&](borders::CountryPolygons const & c) + { + bool inside = false; + c.m_regions.ForEachInRect(m2::RectD(mercatorPoint, mercatorPoint), [&](m2::RegionD const & region) + { + if (region.Contains(mercatorPoint)) + inside = true; + }); + if (inside) + mwmName = c.m_name; + }); usedMwms.insert(mwmName); } } @@ -159,6 +134,8 @@ template <class DataFacadeT> class MapsMePlugin final : public BasePlugin } private: + std::unique_ptr<SearchEngine<DataFacadeT>> search_engine_ptr; + borders::CountriesContainerT m_countries; std::string descriptor_string; DataFacadeT *facade; }; diff --git a/3party/osrm/osrm-backend/Util/ProgramOptions.h b/3party/osrm/osrm-backend/Util/ProgramOptions.h index bde9766a65..4023f32229 100644 --- a/3party/osrm/osrm-backend/Util/ProgramOptions.h +++ b/3party/osrm/osrm-backend/Util/ProgramOptions.h @@ -198,7 +198,10 @@ inline unsigned GenerateServerProgramOptions(const int argc, "Number of threads to use")( "sharedmemory,s", boost::program_options::value<bool>(&use_shared_memory)->implicit_value(true), - "Load data from shared memory"); + "Load data from shared memory")( + "borders", + boost::program_options::value<boost::filesystem::path>(&paths["borders"]), + "Borders folder"); // hidden options, will be allowed both on command line and in config // file, but will not be shown to the user diff --git a/3party/osrm/server.ini b/3party/osrm/server.ini new file mode 100644 index 0000000000..b1b1b04819 --- /dev/null +++ b/3party/osrm/server.ini @@ -0,0 +1,3 @@ +Threads = 4 +IP = 0.0.0.0 +Port = 5000 |