forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
3095ccf664
commit
947956059c
12 changed files with 167 additions and 139 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "generator/borders_generator.hpp"
|
||||
#include "generator/borders_loader.hpp"
|
||||
#include "generator/gen_mwm_info.hpp"
|
||||
#include "generator/utils.hpp"
|
||||
|
||||
#include "routing/osrm2feature_map.hpp"
|
||||
#include "routing/osrm_data_facade.hpp"
|
||||
|
@ -20,6 +21,7 @@
|
|||
#include "geometry/mercator.hpp"
|
||||
|
||||
#include "coding/file_container.hpp"
|
||||
#include "coding/file_name_utils.hpp"
|
||||
#include "coding/read_write_utils.hpp"
|
||||
|
||||
#include "coding/internal/file_data.hpp"
|
||||
|
@ -33,6 +35,8 @@
|
|||
using platform::CountryFile;
|
||||
using platform::LocalCountryFile;
|
||||
|
||||
using namespace generator;
|
||||
|
||||
namespace routing
|
||||
{
|
||||
using RawRouteResult = InternalRouteResult;
|
||||
|
@ -250,21 +254,12 @@ void BuildCrossRoutingIndex(std::string const & baseDir, std::string const & cou
|
|||
LOG(LINFO, ("Cross mwm routing section builder"));
|
||||
classificator::Load();
|
||||
|
||||
CountryFile countryFile(countryName);
|
||||
LocalCountryFile localFile(baseDir, countryFile, 0 /* version */);
|
||||
localFile.SyncWithDisk();
|
||||
Index index;
|
||||
auto p = index.Register(localFile);
|
||||
if (p.second != MwmSet::RegResult::Success)
|
||||
{
|
||||
LOG(LCRITICAL, ("MWM file not found"));
|
||||
return;
|
||||
}
|
||||
SingleMwmIndex singleIndex(my::JoinFoldersToPath(baseDir, countryName + DATA_FILE_EXTENSION));
|
||||
|
||||
LOG(LINFO, ("Loading indexes..."));
|
||||
osrm::NodeDataVectorT nodeData;
|
||||
gen::OsmID2FeatureID osm2ft;
|
||||
if (!LoadIndexes(localFile.GetPath(MapOptions::Map), osrmFile, nodeData, osm2ft))
|
||||
if (!LoadIndexes(singleIndex.GetPath(MapOptions::Map), osrmFile, nodeData, osm2ft))
|
||||
return;
|
||||
|
||||
LOG(LINFO, ("Loading countries borders..."));
|
||||
|
@ -274,9 +269,10 @@ void BuildCrossRoutingIndex(std::string const & baseDir, std::string const & cou
|
|||
|
||||
LOG(LINFO, ("Finding cross nodes..."));
|
||||
routing::CrossRoutingContextWriter crossContext;
|
||||
FindCrossNodes(nodeData, osm2ft, countries, countryName, index, p.first, crossContext);
|
||||
FindCrossNodes(nodeData, osm2ft, countries, countryName, singleIndex.GetIndex(),
|
||||
singleIndex.GetMwmId(), crossContext);
|
||||
|
||||
std::string const mwmPath = localFile.GetPath(MapOptions::Map);
|
||||
std::string const mwmPath = singleIndex.GetPath(MapOptions::Map);
|
||||
CalculateCrossAdjacency(mwmPath, crossContext);
|
||||
WriteCrossSection(crossContext, mwmPath);
|
||||
}
|
||||
|
@ -285,23 +281,12 @@ void BuildRoutingIndex(std::string const & baseDir, std::string const & countryN
|
|||
{
|
||||
classificator::Load();
|
||||
|
||||
CountryFile countryFile(countryName);
|
||||
|
||||
// Correct mwm version doesn't matter here - we just need access to mwm files via Index.
|
||||
LocalCountryFile localFile(baseDir, countryFile, 0 /* version */);
|
||||
localFile.SyncWithDisk();
|
||||
Index index;
|
||||
auto p = index.Register(localFile);
|
||||
if (p.second != MwmSet::RegResult::Success)
|
||||
{
|
||||
LOG(LCRITICAL, ("MWM file not found"));
|
||||
return;
|
||||
}
|
||||
ASSERT(p.first.IsAlive(), ());
|
||||
SingleMwmIndex singleIndex(my::JoinFoldersToPath(baseDir, countryName + DATA_FILE_EXTENSION));
|
||||
|
||||
osrm::NodeDataVectorT nodeData;
|
||||
gen::OsmID2FeatureID osm2ft;
|
||||
if (!LoadIndexes(localFile.GetPath(MapOptions::Map), osrmFile, nodeData, osm2ft))
|
||||
if (!LoadIndexes(singleIndex.GetPath(MapOptions::Map), osrmFile, nodeData, osm2ft))
|
||||
return;
|
||||
|
||||
OsrmFtSegMappingBuilder mapping;
|
||||
|
@ -330,7 +315,7 @@ void BuildRoutingIndex(std::string const & baseDir, std::string const & countryN
|
|||
}
|
||||
|
||||
FeatureType ft;
|
||||
Index::FeaturesLoaderGuard loader(index, p.first);
|
||||
Index::FeaturesLoaderGuard loader(singleIndex.GetIndex(), singleIndex.GetMwmId());
|
||||
if (!loader.GetFeatureByIndex(fID, ft))
|
||||
{
|
||||
LOG(LWARNING, ("Can't read feature with id:", fID, "for way:", seg.wayId));
|
||||
|
@ -460,7 +445,7 @@ void BuildRoutingIndex(std::string const & baseDir, std::string const & countryN
|
|||
|
||||
LOG(LINFO, ("Collect all data into one file..."));
|
||||
|
||||
std::string const mwmPath = localFile.GetPath(MapOptions::Map);
|
||||
std::string const mwmPath = singleIndex.GetPath(MapOptions::Map);
|
||||
std::string const mwmWithoutRoutingPath = mwmPath + NOROUTING_FILE_EXTENSION;
|
||||
|
||||
// Backup mwm file without routing.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace routing
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "generator/transit_generator.hpp"
|
||||
|
||||
#include "generator/osm_id.hpp"
|
||||
#include "generator/utils.hpp"
|
||||
|
||||
#include "traffic/traffic_cache.hpp"
|
||||
|
||||
|
@ -35,6 +36,7 @@
|
|||
|
||||
#include "3party/jansson/src/jansson.h"
|
||||
|
||||
using namespace generator;
|
||||
using namespace platform;
|
||||
using namespace routing;
|
||||
using namespace routing::transit;
|
||||
|
@ -67,26 +69,15 @@ void DeserializeFromJson(my::Json const & root, string const & key, vector<Item>
|
|||
deserializer(items, key.c_str());
|
||||
}
|
||||
|
||||
void DeserializerGatesFromJson(my::Json const & root, string const & mwmDir, string const & countryId,
|
||||
vector<Gate> & gates)
|
||||
void DeserializeGatesFromJson(my::Json const & root, string const & mwmDir, string const & countryId,
|
||||
vector<Gate> & gates)
|
||||
{
|
||||
DeserializeFromJson(root, "gates", gates);
|
||||
|
||||
// Creating IndexRouter.
|
||||
CountryFile const countryFile(countryId);
|
||||
LocalCountryFile localCountryFile(mwmDir, countryFile, 0 /* version */);
|
||||
localCountryFile.SyncWithDisk();
|
||||
CHECK_EQUAL(localCountryFile.GetFiles(), MapOptions::MapWithCarRouting,
|
||||
("No correct mwm corresponding local country file:", localCountryFile,
|
||||
". Path:", my::JoinFoldersToPath(mwmDir, countryId + DATA_FILE_EXTENSION)));
|
||||
SingleMwmIndex singleIndex(my::JoinFoldersToPath(mwmDir, countryId + DATA_FILE_EXTENSION));
|
||||
|
||||
Index index;
|
||||
pair<MwmSet::MwmId, MwmSet::RegResult> const result = index.Register(localCountryFile);
|
||||
CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ());
|
||||
|
||||
Platform platform;
|
||||
unique_ptr<storage::CountryInfoGetter> infoGetter =
|
||||
storage::CountryInfoReader::CreateCountryInfoReader(platform);
|
||||
auto infoGetter = storage::CountryInfoReader::CreateCountryInfoReader(GetPlatform());
|
||||
CHECK(infoGetter, ());
|
||||
|
||||
auto const countryFileGetter = [&infoGetter](m2::PointD const & pt) {
|
||||
|
@ -98,33 +89,39 @@ void DeserializerGatesFromJson(my::Json const & root, string const & mwmDir, str
|
|||
return infoGetter->GetLimitRectForLeaf(c);
|
||||
};
|
||||
|
||||
auto const mwmId = index.GetMwmIdByCountryFile(countryFile);
|
||||
CHECK_EQUAL(mwmId.GetInfo()->GetType(), MwmInfo::COUNTRY, ());
|
||||
CHECK_EQUAL(singleIndex.GetMwmId().GetInfo()->GetType(), MwmInfo::COUNTRY, ());
|
||||
auto numMwmIds = make_shared<NumMwmIds>();
|
||||
numMwmIds->RegisterFile(countryFile);
|
||||
numMwmIds->RegisterFile(CountryFile(countryId));
|
||||
|
||||
// Note. |indexRouter| is valid until |index| is valid.
|
||||
IndexRouter indexRouter(VehicleType::Pedestrian, false /* load altitudes */,
|
||||
CountryParentNameGetterFn(), countryFileGetter, getMwmRectByName,
|
||||
numMwmIds, MakeNumMwmTree(*numMwmIds, *infoGetter),
|
||||
traffic::TrafficCache(), index);
|
||||
unique_ptr<WorldGraph> worldGraph = indexRouter.MakeWorldGraph();
|
||||
worldGraph->SetMode(WorldGraph::Mode::SingleMwm);
|
||||
traffic::TrafficCache(), singleIndex.GetIndex());
|
||||
|
||||
// Looking for the best segment for every gate.
|
||||
bool dummy;
|
||||
for (Gate & gate : gates)
|
||||
for (auto & gate : gates)
|
||||
{
|
||||
// Note. For pedestrian routing all the segments are considered as twoway segments so
|
||||
// IndexRouter.FindBestSegment() method finds the same segment for |isOutgoing| == true
|
||||
// and |isOutgoing| == false.
|
||||
Segment bestSegment;
|
||||
if (indexRouter.FindBestSegment(gate.GetPoint(), m2::PointD::Zero() /* direction */,
|
||||
true /* isOutgoing */, *worldGraph, bestSegment, dummy))
|
||||
try
|
||||
{
|
||||
// Note. |numMwmIds| with only one mwm is used to create |indexRouter|. So |Segment::m_mwmId|
|
||||
// is not valid at |bestSegment| and is not copied to |Gate::m_bestPedestrianSegment|.
|
||||
gate.SetBestPedestrianSegment(bestSegment);
|
||||
if (indexRouter.FindBestSegmentAtSingleMwm(gate.GetPoint(),
|
||||
m2::PointD::Zero() /* direction */,
|
||||
true /* isOutgoing */, bestSegment))
|
||||
{
|
||||
CHECK_EQUAL(bestSegment.GetMwmId(), 0,
|
||||
("Best segment num mwm id ==", bestSegment.GetMwmId(), ", but should be zero"));
|
||||
gate.SetBestPedestrianSegment(SingleMwmSegment(
|
||||
bestSegment.GetFeatureId(), bestSegment.GetSegmentIdx(), bestSegment.IsForward()));
|
||||
}
|
||||
}
|
||||
catch (RootException const & e)
|
||||
{
|
||||
LOG(LDEBUG, ("Point of a gate belongs to several mwm or doesn't belong any mwm. gate:", gate,
|
||||
e.what(), e.Msg()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +200,7 @@ void BuildTransit(string const & mwmPath, string const & transitDir)
|
|||
// Note. |gates| has to be deserialized from json before to start writing transit section to mwm since
|
||||
// the mwm is used to filled |gates|.
|
||||
vector<Gate> gates;
|
||||
DeserializerGatesFromJson(root, my::GetDirectory(mwmPath), countryId, gates);
|
||||
DeserializeGatesFromJson(root, my::GetDirectory(mwmPath), countryId, gates);
|
||||
|
||||
FilesContainerW cont(mwmPath, FileWriter::OP_WRITE_EXISTING);
|
||||
FileWriter w = cont.GetWriter(TRANSIT_FILE_TAG);
|
||||
|
|
|
@ -84,9 +84,8 @@ private:
|
|||
/// as country id.
|
||||
/// \param transitDir a path to directory with json files with transit graphs.
|
||||
/// \note An mwm pointed by |mwmPath| should contain:
|
||||
/// * section which is necessary to register it at Index
|
||||
/// * feature geometry
|
||||
/// * index graph (ROUTING_FILE_TAG) and restriction sections (RESTRICTIONS_FILE_TAG)
|
||||
/// This information will be used in this method.
|
||||
void BuildTransit(std::string const & mwmPath, std::string const & transitDir);
|
||||
} // namespace transit
|
||||
} // namespace routing
|
||||
|
|
|
@ -4,8 +4,26 @@
|
|||
#include "platform/local_country_file_utils.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
namespace generator
|
||||
{
|
||||
// SingleMwmIndex ---------------------------------------------------------------------------------
|
||||
SingleMwmIndex::SingleMwmIndex(std::string const & mwmPath)
|
||||
{
|
||||
m_countryFile = platform::LocalCountryFile::MakeTemporary(mwmPath);
|
||||
m_countryFile.SyncWithDisk();
|
||||
CHECK_EQUAL(
|
||||
m_countryFile.GetFiles(), MapOptions::MapWithCarRouting,
|
||||
("No correct mwm corresponding local country file:", m_countryFile, ". Path:", mwmPath));
|
||||
|
||||
auto const result = m_index.Register(m_countryFile);
|
||||
CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ());
|
||||
CHECK(result.first.IsAlive(), ());
|
||||
m_mwmId = result.first;
|
||||
}
|
||||
|
||||
void LoadIndex(Index & index)
|
||||
{
|
||||
vector<platform::LocalCountryFile> localFiles;
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
#include "generator/gen_mwm_info.hpp"
|
||||
|
||||
#include "indexer/index.hpp"
|
||||
#include "indexer/mwm_set.hpp"
|
||||
|
||||
#include "platform/local_country_file.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "coding/file_reader.hpp"
|
||||
#include "coding/reader.hpp"
|
||||
|
@ -13,6 +18,21 @@
|
|||
|
||||
namespace generator
|
||||
{
|
||||
class SingleMwmIndex
|
||||
{
|
||||
public:
|
||||
explicit SingleMwmIndex(std::string const & mwmPath);
|
||||
|
||||
Index & GetIndex() { return m_index; }
|
||||
std::string GetPath(MapOptions file) const { return m_countryFile.GetPath(file); }
|
||||
MwmSet::MwmId const & GetMwmId() const { return m_mwmId; }
|
||||
|
||||
private:
|
||||
Index m_index;
|
||||
platform::LocalCountryFile m_countryFile;
|
||||
MwmSet::MwmId m_mwmId;
|
||||
};
|
||||
|
||||
void LoadIndex(Index & index);
|
||||
|
||||
template <typename ToDo>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "traffic/traffic_info.hpp"
|
||||
|
||||
#include "routing_common/car_model.hpp"
|
||||
#include "routing_common/num_mwm_id.hpp"
|
||||
|
||||
#include "indexer/ftypes_matcher.hpp"
|
||||
#include "indexer/index.hpp"
|
||||
|
|
|
@ -315,6 +315,16 @@ IndexRouter::IndexRouter(VehicleType vehicleType, bool loadAltitudes,
|
|||
CHECK(m_directionsEngine, ());
|
||||
}
|
||||
|
||||
bool IndexRouter::FindBestSegmentAtSingleMwm(m2::PointD const & point, m2::PointD const & direction,
|
||||
bool isOutgoing, Segment & bestSegment)
|
||||
{
|
||||
auto worldGraph = MakeWorldGraph();
|
||||
worldGraph->SetMode(WorldGraph::Mode::SingleMwm);
|
||||
bool dummy;
|
||||
return FindBestSegment(point, direction, isOutgoing, *worldGraph, bestSegment,
|
||||
dummy /* best segment is almost codirectional */);
|
||||
}
|
||||
|
||||
IRouter::ResultCode IndexRouter::CalculateRoute(Checkpoints const & checkpoints,
|
||||
m2::PointD const & startDirection,
|
||||
bool adjustToPrevRoute,
|
||||
|
@ -375,59 +385,6 @@ IRouter::ResultCode IndexRouter::CalculateRoute(Checkpoints const & checkpoints,
|
|||
}
|
||||
}
|
||||
|
||||
bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & direction,
|
||||
bool isOutgoing, WorldGraph & worldGraph, Segment & bestSegment,
|
||||
bool & bestSegmentIsAlmostCodirectional) const
|
||||
{
|
||||
auto const file = platform::CountryFile(m_countryFileFn(point));
|
||||
MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file);
|
||||
if (!handle.IsAlive())
|
||||
MYTHROW(RoutingException, ("Can't get mwm handle for", file));
|
||||
|
||||
auto const mwmId = MwmSet::MwmId(handle.GetInfo());
|
||||
NumMwmId const numMwmId = m_numMwmIds->GetId(file);
|
||||
|
||||
vector<pair<Edge, Junction>> candidates;
|
||||
m_roadGraph.FindClosestEdges(point, kMaxRoadCandidates, candidates);
|
||||
|
||||
auto const getSegmentByEdge = [&numMwmId](Edge const & edge) {
|
||||
return Segment(numMwmId, edge.GetFeatureId().m_index, edge.GetSegId(), edge.IsForward());
|
||||
};
|
||||
|
||||
// Getting rid of knowingly bad candidates.
|
||||
my::EraseIf(candidates, [&](pair<Edge, Junction> const & p){
|
||||
Edge const & edge = p.first;
|
||||
return edge.GetFeatureId().m_mwmId != mwmId || IsDeadEnd(getSegmentByEdge(edge), isOutgoing, worldGraph);
|
||||
});
|
||||
|
||||
if (candidates.empty())
|
||||
return false;
|
||||
|
||||
BestEdgeComparator bestEdgeComparator(point, direction);
|
||||
Edge bestEdge = candidates[0].first;
|
||||
for (size_t i = 1; i < candidates.size(); ++i)
|
||||
{
|
||||
Edge const & edge = candidates[i].first;
|
||||
if (bestEdgeComparator.Compare(edge, bestEdge) < 0)
|
||||
bestEdge = edge;
|
||||
}
|
||||
|
||||
bestSegmentIsAlmostCodirectional =
|
||||
bestEdgeComparator.IsDirectionValid() && bestEdgeComparator.IsAlmostCodirectional(bestEdge);
|
||||
bestSegment = getSegmentByEdge(bestEdge);
|
||||
return true;
|
||||
}
|
||||
|
||||
unique_ptr<WorldGraph> IndexRouter::MakeWorldGraph()
|
||||
{
|
||||
return make_unique<SingleVehicleWorldGraph>(
|
||||
make_unique<CrossMwmGraph>(m_numMwmIds, m_numMwmTree, m_vehicleModelFactory, m_vehicleType,
|
||||
m_countryRectFn, m_index, m_indexManager),
|
||||
IndexGraphLoader::Create(m_vehicleType, m_loadAltitudes, m_numMwmIds, m_vehicleModelFactory,
|
||||
m_estimator, m_index),
|
||||
m_estimator);
|
||||
}
|
||||
|
||||
IRouter::ResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints,
|
||||
m2::PointD const & startDirection,
|
||||
RouterDelegate const & delegate, Route & route)
|
||||
|
@ -709,6 +666,59 @@ IRouter::ResultCode IndexRouter::AdjustRoute(Checkpoints const & checkpoints,
|
|||
return IRouter::NoError;
|
||||
}
|
||||
|
||||
unique_ptr<WorldGraph> IndexRouter::MakeWorldGraph()
|
||||
{
|
||||
return make_unique<SingleVehicleWorldGraph>(
|
||||
make_unique<CrossMwmGraph>(m_numMwmIds, m_numMwmTree, m_vehicleModelFactory, m_vehicleType,
|
||||
m_countryRectFn, m_index, m_indexManager),
|
||||
IndexGraphLoader::Create(m_vehicleType, m_loadAltitudes, m_numMwmIds, m_vehicleModelFactory,
|
||||
m_estimator, m_index),
|
||||
m_estimator);
|
||||
}
|
||||
|
||||
bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & direction,
|
||||
bool isOutgoing, WorldGraph & worldGraph, Segment & bestSegment,
|
||||
bool & bestSegmentIsAlmostCodirectional) const
|
||||
{
|
||||
auto const file = platform::CountryFile(m_countryFileFn(point));
|
||||
MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file);
|
||||
if (!handle.IsAlive())
|
||||
MYTHROW(RoutingException, ("Can't get mwm handle for", file));
|
||||
|
||||
auto const mwmId = MwmSet::MwmId(handle.GetInfo());
|
||||
NumMwmId const numMwmId = m_numMwmIds->GetId(file);
|
||||
|
||||
vector<pair<Edge, Junction>> candidates;
|
||||
m_roadGraph.FindClosestEdges(point, kMaxRoadCandidates, candidates);
|
||||
|
||||
auto const getSegmentByEdge = [&numMwmId](Edge const & edge) {
|
||||
return Segment(numMwmId, edge.GetFeatureId().m_index, edge.GetSegId(), edge.IsForward());
|
||||
};
|
||||
|
||||
// Getting rid of knowingly bad candidates.
|
||||
my::EraseIf(candidates, [&](pair<Edge, Junction> const & p) {
|
||||
Edge const & edge = p.first;
|
||||
return edge.GetFeatureId().m_mwmId != mwmId || IsDeadEnd(getSegmentByEdge(edge), isOutgoing, worldGraph);
|
||||
});
|
||||
|
||||
if (candidates.empty())
|
||||
return false;
|
||||
|
||||
BestEdgeComparator bestEdgeComparator(point, direction);
|
||||
Edge bestEdge = candidates[0].first;
|
||||
for (size_t i = 1; i < candidates.size(); ++i)
|
||||
{
|
||||
Edge const & edge = candidates[i].first;
|
||||
if (bestEdgeComparator.Compare(edge, bestEdge) < 0)
|
||||
bestEdge = edge;
|
||||
}
|
||||
|
||||
bestSegmentIsAlmostCodirectional =
|
||||
bestEdgeComparator.IsDirectionValid() && bestEdgeComparator.IsAlmostCodirectional(bestEdge);
|
||||
bestSegment = getSegmentByEdge(bestEdge);
|
||||
return true;
|
||||
}
|
||||
|
||||
IRouter::ResultCode IndexRouter::ProcessLeaps(vector<Segment> const & input,
|
||||
RouterDelegate const & delegate,
|
||||
WorldGraph::Mode prevMode,
|
||||
|
|
|
@ -63,25 +63,15 @@ public:
|
|||
shared_ptr<NumMwmIds> numMwmIds, unique_ptr<m4::Tree<NumMwmId>> numMwmTree,
|
||||
traffic::TrafficCache const & trafficCache, Index & index);
|
||||
|
||||
bool FindBestSegmentAtSingleMwm(m2::PointD const & point, m2::PointD const & direction,
|
||||
bool isOutgoing, Segment & bestSegment);
|
||||
|
||||
// IRouter overrides:
|
||||
std::string GetName() const override { return m_name; }
|
||||
ResultCode CalculateRoute(Checkpoints const & checkpoints, m2::PointD const & startDirection,
|
||||
bool adjustToPrevRoute, RouterDelegate const & delegate,
|
||||
Route & route) override;
|
||||
|
||||
/// \brief Finds the best segment (edge) which may be considered as the start of the finish of the route.
|
||||
/// According to current implementation if a segment is near |point| and is almost codirectional
|
||||
/// to |direction| vector, the segment will be better than others. If there's no an an almost codirectional
|
||||
/// segment in neighbourhoods the closest segment to |point| will be chosen.
|
||||
/// \param isOutgoing == true is |point| is considered as the start of the route.
|
||||
/// isOutgoing == false is |point| is considered as the finish of the route.
|
||||
/// \param bestSegmentIsAlmostCodirectional is filled with true if |bestSegment| is chosen
|
||||
/// because vector |direction| and vector of |bestSegment| are almost equal and with false otherwise.
|
||||
bool FindBestSegment(m2::PointD const & point, m2::PointD const & direction, bool isOutgoing,
|
||||
WorldGraph & worldGraph, Segment & bestSegment,
|
||||
bool & bestSegmentIsAlmostCodirectional) const;
|
||||
std::unique_ptr<WorldGraph> MakeWorldGraph();
|
||||
|
||||
private:
|
||||
IRouter::ResultCode DoCalculateRoute(Checkpoints const & checkpoints,
|
||||
m2::PointD const & startDirection,
|
||||
|
@ -95,6 +85,21 @@ private:
|
|||
m2::PointD const & startDirection,
|
||||
RouterDelegate const & delegate, Route & route);
|
||||
|
||||
std::unique_ptr<WorldGraph> MakeWorldGraph();
|
||||
|
||||
/// \brief Finds the best segment (edge) which may be considered as the start of the finish of the route.
|
||||
/// According to current implementation if a segment is near |point| and is almost codirectional
|
||||
/// to |direction|, the segment will be better than others. If there's no an almost codirectional
|
||||
/// segment in the neighbourhood then the closest segment to |point| will be chosen.
|
||||
/// \param isOutgoing == true if |point| is considered as the start of the route.
|
||||
/// isOutgoing == false if |point| is considered as the finish of the route.
|
||||
/// \param bestSegmentIsAlmostCodirectional is filled with true if |bestSegment| is chosen
|
||||
/// because |direction| and direction of |bestSegment| are almost equal and with false otherwise.
|
||||
/// \return true if the best segment is found and false otherwise.
|
||||
bool FindBestSegment(m2::PointD const & point, m2::PointD const & direction, bool isOutgoing,
|
||||
WorldGraph & worldGraph, Segment & bestSegment,
|
||||
bool & bestSegmentIsAlmostCodirectional) const;
|
||||
|
||||
// Input route may contains 'leaps': shortcut edges from mwm border enter to exit.
|
||||
// ProcessLeaps replaces each leap with calculated route through mwm.
|
||||
IRouter::ResultCode ProcessLeaps(std::vector<Segment> const & input,
|
||||
|
|
|
@ -17,15 +17,13 @@
|
|||
|
||||
#include "indexer/index.hpp"
|
||||
|
||||
#include "geometry/distance_on_sphere.hpp"
|
||||
#include "geometry/latlon.hpp"
|
||||
|
||||
#include "platform/local_country_file.hpp"
|
||||
#include "platform/local_country_file_utils.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "platform/preferred_languages.hpp"
|
||||
|
||||
#include "geometry/distance_on_sphere.hpp"
|
||||
#include "geometry/latlon.hpp"
|
||||
|
||||
#include "std/functional.hpp"
|
||||
#include "std/limits.hpp"
|
||||
|
|
|
@ -69,10 +69,8 @@ bool Stop::IsEqualForTesting(Stop const & stop) const
|
|||
}
|
||||
|
||||
// SingleMwmSegment -------------------------------------------------------------------------------
|
||||
SingleMwmSegment::SingleMwmSegment(Segment const & segment)
|
||||
: m_featureId(segment.GetFeatureId())
|
||||
, m_segmentIdx(segment.GetSegmentIdx())
|
||||
, m_forward(segment.IsForward())
|
||||
SingleMwmSegment::SingleMwmSegment(FeatureId featureId, uint32_t segmentIdx, bool forward)
|
||||
: m_featureId(featureId), m_segmentIdx(segmentIdx), m_forward(forward)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "routing/segment.hpp"
|
||||
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include "base/visitor.hpp"
|
||||
|
@ -93,7 +91,7 @@ class SingleMwmSegment
|
|||
{
|
||||
public:
|
||||
SingleMwmSegment() = default;
|
||||
SingleMwmSegment(Segment const & segment);
|
||||
SingleMwmSegment(FeatureId featureId, uint32_t segmentIdx, bool forward);
|
||||
|
||||
FeatureId GetFeatureId() const { return m_featureId; }
|
||||
uint32_t GetSegmentIdx() const { return m_segmentIdx; }
|
||||
|
@ -103,7 +101,7 @@ public:
|
|||
visitor(m_segmentIdx, "segment_idx"),
|
||||
visitor(m_forward, "forward"))
|
||||
|
||||
private:
|
||||
private:
|
||||
FeatureId m_featureId = kInvalidFeatureId;
|
||||
uint32_t m_segmentIdx = 0;
|
||||
bool m_forward = false;
|
||||
|
@ -116,7 +114,7 @@ public:
|
|||
Gate(FeatureId featureId, bool entrance, bool exit, double weight, std::vector<StopId> const & stopIds,
|
||||
m2::PointD const & point);
|
||||
bool IsEqualForTesting(Gate const & gate) const;
|
||||
void SetBestPedestrianSegment(Segment const & s) { m_bestPedestrianSegment = SingleMwmSegment(s); }
|
||||
void SetBestPedestrianSegment(SingleMwmSegment const & s) { m_bestPedestrianSegment = s; };
|
||||
|
||||
FeatureId GetFeatureId() const { return m_featureId; }
|
||||
SingleMwmSegment const & GetBestPedestrianSegment() const { return m_bestPedestrianSegment; }
|
||||
|
@ -135,7 +133,7 @@ public:
|
|||
private:
|
||||
// |m_featureId| is feature id of a point feature which represents gates.
|
||||
FeatureId m_featureId = kInvalidFeatureId;
|
||||
// |m_bestPedestrianSegment| is a segment which can be used for pedestrian routing to leave an to enter the gate.
|
||||
// |m_bestPedestrianSegment| is a segment which can be used for pedestrian routing to leave and enter the gate.
|
||||
SingleMwmSegment m_bestPedestrianSegment;
|
||||
bool m_entrance = true;
|
||||
bool m_exit = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue