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>(query_data_facade)); RegisterPlugin(new TimestampPlugin>(query_data_facade)); RegisterPlugin(new ViaRoutePlugin>(query_data_facade)); - RegisterPlugin(new MapsMePlugin>(query_data_facade, "../../../data/")); + RegisterPlugin(new MapsMePlugin>(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 MapsMePlugin final : public BasePlugin { - private: - std::unique_ptr> 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 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 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 MapsMePlugin final : public BasePlugin } private: + std::unique_ptr> 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(&use_shared_memory)->implicit_value(true), - "Load data from shared memory"); + "Load data from shared memory")( + "borders", + boost::program_options::value(&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 diff --git a/tools/unix/osrm_online_server_generator.sh b/tools/unix/osrm_online_server_generator.sh new file mode 100755 index 0000000000..32f14d6071 --- /dev/null +++ b/tools/unix/osrm_online_server_generator.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -u -x + +export STXXLCFG=~/.stxxl + +PLANET_FILE="$HOME/planet/planet-latest.o5m" +OSRM_PATH=~/omim/3party/osrm/osrm-backend +PROFILE="$OSRM_PATH/profiles/car.lua" +BIN_PATH="$OSRM_PATH/build" +EXTRACT="$BIN_PATH/osrm-extract" +EXTRACT_CFG="$OSRM_PATH/../extractor.ini" +PREPARE="$BIN_PATH/osrm-prepare" +PREPARE_CFG="$OSRM_PATH/../contractor.ini" + +echo Started at `date` + +"$EXTRACT" --config "$EXTRACT_CFG" --profile "$PROFILE" "\"$PLANET_FILE\"" +"$PREPARE" --config "$PREPARE_CFG" --profile "$PROFILE" "\"${PLANET_FILE/\.*/\.osrm}\"" + +echo Finished at `date`