libosmscout
0.1
|
#include <SimpleRoutingService.h>
Public Member Functions | |
RoutingResult | CalculateRouteViaCoords (RoutingProfile &profile, const std::vector< GeoCoord > &via, const Distance &radius, const RoutingParameter ¶meter) |
Calculate a route going through all the via points. More... | |
void | Close () |
Close the routing service. More... | |
void | DumpStatistics () |
RoutePositionResult | GetClosestRoutableNode (const GeoCoord &coord, const RoutingProfile &profile, const Distance &radius) const |
Returns the closest routable object (area or way) relative to the given coordinate. More... | |
ClosestRoutableObjectResult | GetClosestRoutableObject (const GeoCoord &location, Vehicle vehicle, const Distance &maxRadius) |
Returns the closest routeable object (area or way) relative to the given coordinate. More... | |
std::map< DatabaseId, std::string > | GetDatabaseMapping () const override |
RoutePositionResult | GetRoutableNode (const ObjectFileRef &objRef, const RoutingProfile &profile) const |
Return routable node on specific object, when this object is routable and usable by provided profile. More... | |
TypeConfigRef | GetTypeConfig () const |
Returns the type configuration of the underlying db instance. More... | |
bool | IsOpen () const |
Returns true, if the routing service has been successfully opened, else false. More... | |
bool | Open () |
Opens the routing service. More... | |
SimpleRoutingService (const DatabaseRef &database, const RouterParameter ¶meter, const std::string &filenamebase) | |
Create a new instance of the routing service. More... | |
~SimpleRoutingService () override | |
![]() | |
AbstractRoutingService (const RouterParameter ¶meter) | |
RoutingResult | CalculateRoute (RoutingProfile &state, const RoutePosition &start, const RoutePosition &target, const std::optional< osmscout::Bearing > &bearing, const RoutingParameter ¶meter) |
Calculate a route. More... | |
virtual std::map< DatabaseId, std::string > | GetDatabaseMapping () const=0 |
Get current mapping of DatabaseId to db path than be used later for lookup objects in description. More... | |
RoutePointsResult | TransformRouteDataToPoints (const RouteData &data) |
Transforms the route into a list of points. More... | |
RouteDescriptionResult | TransformRouteDataToRouteDescription (const RouteData &data) |
Transform the route into a RouteDescription. More... | |
RouteWayResult | TransformRouteDataToWay (const RouteData &data) |
Transforms the route into a Way (with empty type) More... | |
~AbstractRoutingService () override | |
![]() | |
RoutingService () | |
virtual | ~RoutingService () |
Protected Member Functions | |
bool | CanUse (const RoutingProfile &profile, DatabaseId database, const RouteNode &routeNode, size_t pathIndex) override |
bool | CanUseBackward (const RoutingProfile &profile, const DatabaseId &database, const WayRef &way) override |
bool | CanUseForward (const RoutingProfile &profile, const DatabaseId &database, const WayRef &way) override |
bool | GetAreaByOffset (const DBFileOffset &offset, AreaRef &area) override |
bool | GetAreasByOffset (const std::set< DBFileOffset > &areaOffsets, std::unordered_map< DBFileOffset, AreaRef > &areaMap) override |
double | GetCostLimit (const RoutingProfile &profile, DatabaseId database, const Distance &targetDistance) override |
double | GetCosts (const RoutingProfile &profile, DatabaseId database, const RouteNode &routeNode, size_t inPathIndex, size_t outPathIndex) override |
double | GetCosts (const RoutingProfile &profile, DatabaseId database, const WayRef &way, const Distance &wayLength) override |
std::string | GetCostString (const RoutingProfile &profile, DatabaseId database, double cost) const override |
double | GetEstimateCosts (const RoutingProfile &profile, DatabaseId database, const Distance &targetDistance) override |
std::vector< DBId > | GetNodeTwins (const RoutingProfile &state, DatabaseId database, Id id) override |
bool | GetRouteNode (const DBId &id, RouteNodeRef &node) override |
Return the route node for the given db offset. More... | |
bool | GetRouteNodes (const std::set< DBId > &routeNodeIds, std::unordered_map< DBId, RouteNodeRef > &routeNodeMap) override |
double | GetUTurnCost (const RoutingProfile &profile, const DatabaseId databaseId) override |
Vehicle | GetVehicle (const RoutingProfile &profile) override |
bool | GetWayByOffset (const DBFileOffset &offset, WayRef &way) override |
bool | GetWaysByOffset (const std::set< DBFileOffset > &wayOffsets, std::unordered_map< DBFileOffset, WayRef > &wayMap) override |
bool | ResolveRouteDataJunctions (RouteData &route) override |
![]() | |
void | AddNodes (RouteData &route, DatabaseId database, Id startNodeId, size_t startNodeIndex, const ObjectFileRef &object, size_t idCount, bool oneway, size_t targetNodeIndex) |
bool | GetRNode (const RoutingProfile &state, const RoutePosition &position, const WayRef &way, size_t routeNodeIndex, const RouteNodeRef &routeNode, const GeoCoord &startCoord, const GeoCoord &targetCoord, RNodeRef &node) |
void | GetStartBackwardRouteNode (const RoutingProfile &state, const DatabaseId &database, const WayRef &way, size_t nodeIndex, RouteNodeRef &routeNode, size_t &routeNodeIndex) |
void | GetStartForwardRouteNode (const RoutingProfile &state, const DatabaseId &database, const WayRef &way, size_t nodeIndex, RouteNodeRef &routeNode, size_t &routeNodeIndex) |
bool | GetStartNodes (const RoutingProfile &state, const RoutePosition &position, GeoCoord &startCoord, const GeoCoord &targetCoord, RouteNodeRef &forwardRouteNode, RouteNodeRef &backwardRouteNode, RNodeRef &forwardRNode, RNodeRef &backwardRNode) |
The start position is at the given position defined by an object and the index of the node within the object. More... | |
void | GetTargetBackwardRouteNode (const RoutingProfile &state, const DatabaseId &database, const WayRef &way, size_t nodeIndex, RouteNodeRef &routeNode) |
Return the route node that allows navigating to the given node in backward direction. More... | |
void | GetTargetForwardRouteNode (const RoutingProfile &state, const DatabaseId &database, const WayRef &way, size_t nodeIndex, RouteNodeRef &routeNode) |
Return the route node that allows navigating to the given node in forward direction. More... | |
bool | GetTargetNodes (const RoutingProfile &state, const RoutePosition &position, GeoCoord &targetCoord, RouteNodeRef &forwardNode, RouteNodeRef &backwardNode) |
The target position is at the given position defined by an object and the index of the node within the object. More... | |
bool | GetWayStartNodes (const RoutingProfile &state, const RoutePosition &position, GeoCoord &startCoord, const GeoCoord &targetCoord, RouteNodeRef &forwardRouteNode, RouteNodeRef &backwardRouteNode, RNodeRef &forwardRNode, RNodeRef &backwardRNode) |
The start position is at the given way and the index of the node within the object. More... | |
bool | GetWayTargetNodes (const RoutingProfile &state, const RoutePosition &position, GeoCoord &targetCoord, RouteNodeRef &forwardNode, RouteNodeRef &backwardNode) |
The target position is at the given position defined by an object and the index of the node within the object. More... | |
void | ResolveRNodeChainToList (const RNode &finalRouteNode, const ClosedSet &closedSet, std::list< VNode > &nodes) |
bool | ResolveRNodesToRouteData (const RoutingProfile &state, const std::list< VNode > &nodes, const RoutePosition &start, const RoutePosition &target, RouteData &route) |
bool | RestrictInitialUTurn (const RoutingProfile &state, const Bearing &vehicleBearing, const RoutePosition &start, RNodeRef startForwardNode, RNodeRef startBackwardNode) |
virtual bool | WalkPaths (const RoutingProfile &state, RNodeRef ¤t, RouteNodeRef ¤tRouteNode, OpenList &openList, OpenMap &openMap, ClosedSet &closedSet, RoutingResult &result, const RoutingParameter ¶meter, const GeoCoord &targetCoord, const Vehicle &vehicle, size_t &nodesIgnoredCount, Distance ¤tMaxDistance, const Distance &overallDistance, const double &costLimit) |
virtual bool | WalkToOtherDatabases (const RoutingProfile &state, RNodeRef ¤t, RouteNodeRef ¤tRouteNode, OpenList &openList, OpenMap &openMap, const ClosedSet &closedSet) |
Additional Inherited Members | |
![]() | |
static std::string | GetData2Filename (const std::string &filenamebase) |
static std::string | GetDataFilename (const std::string &filenamebase) |
static std::string | GetIndexFilename (const std::string &filenamebase) |
![]() | |
static const char *const | DEFAULT_FILENAME_BASE = "router" |
Relative filebase name for touting data as generated by default by the importer. More... | |
static const char *const | FILENAME_INTERSECTIONS_DAT = "intersections.dat" |
Relative filename of the intersection data file. More... | |
static const char *const | FILENAME_INTERSECTIONS_IDX = "intersections.idx" |
Relative filename of the intersection index file. More... | |
![]() | |
using | ClosedSet = std::unordered_set< VNode, ClosedNodeHasher > |
using | OpenList = std::set< RNodeRef, RNodeCostCompare > |
using | OpenListRef = std::set< RNodeRef, RNodeCostCompare >::iterator |
using | OpenMap = std::unordered_map< DBId, OpenListRef > |
using | RNodeRef = std::shared_ptr< RNode > |
![]() | |
bool | debugPerformance |
The RoutingService implements functionality in the context of routing. The following functions are available:
osmscout::SimpleRoutingService::SimpleRoutingService | ( | const DatabaseRef & | database, |
const RouterParameter & | parameter, | ||
const std::string & | filenamebase | ||
) |
Create a new instance of the routing service.
database | A valid reference to a db instance |
parameter | An instance to the parameter object holding further paramterization |
|
override |
References Close().
RoutingResult osmscout::SimpleRoutingService::CalculateRouteViaCoords | ( | RoutingProfile & | profile, |
const std::vector< GeoCoord > & | via, | ||
const Distance & | radius, | ||
const RoutingParameter & | parameter | ||
) |
Calculate a route going through all the via points.
profile | Profile to use |
via | A vector of via points |
radius | The maximum radius to search in from the search center |
parameter | A RoutingParamater object |
References osmscout::RouteData::Append(), osmscout::RoutingResult::AppendSectionLength(), osmscout::AbstractRoutingService< RoutingProfile >::CalculateRoute(), osmscout::RouteData::Clear(), osmscout::RoutingResult::ClearSectionLengths(), osmscout::RouteData::Entries(), GetClosestRoutableNode(), osmscout::RoutePosition::GetNodeIndex(), osmscout::RoutePosition::GetObjectFileRef(), osmscout::RoutingResult::GetRoute(), osmscout::RoutePosition::IsValid(), osmscout::RouteData::PopEntry(), and osmscout::RoutingResult::Success().
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::CanUseBackward().
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::CanUseForward().
void osmscout::SimpleRoutingService::Close | ( | ) |
Close the routing service.
References osmscout::RoutingDatabase::Close().
Referenced by ~SimpleRoutingService().
void osmscout::SimpleRoutingService::DumpStatistics | ( | ) |
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::DBFileOffset::offset.
|
overrideprotectedvirtual |
RoutePositionResult osmscout::SimpleRoutingService::GetClosestRoutableNode | ( | const GeoCoord & | coord, |
const RoutingProfile & | profile, | ||
const Distance & | radius | ||
) | const |
Returns the closest routable object (area or way) relative to the given coordinate.
The result should be use as input for the router to define routing start or end point.
coord | coordinate of the search center |
profile | Routing profile to use. It defines Vehicle to use and allowed objects. |
radius | The maximum radius to search in from the search center |
References osmscout::GeoBox::BoxByCenterAndRadius(), osmscout::RoutingProfile::CanUse(), osmscout::DistanceToSegment(), osmscout::Log::Error(), osmscout::GetEllipsoidalDistance(), osmscout::GeoCoord::GetLat(), osmscout::GeoCoord::GetLon(), osmscout::RoutingProfile::GetVehicle(), osmscout::log, and osmscout::TypeInfoSet::Set().
Referenced by CalculateRouteViaCoords().
ClosestRoutableObjectResult osmscout::SimpleRoutingService::GetClosestRoutableObject | ( | const GeoCoord & | location, |
Vehicle | vehicle, | ||
const Distance & | maxRadius | ||
) |
Returns the closest routeable object (area or way) relative to the given coordinate.
The result should be use for typical "object you are traveling on" information as used by routing applications.
coord | coordinate of the search center |
vehicle | The vehicle to use |
maxRadius | The maximum radius to search in from the search center |
References osmscout::TypeInfoSet::Empty(), osmscout::AreaRegionSearchResult::GetAreaResults(), osmscout::FeatureLabelReader< F, V >::GetLabel(), osmscout::WayRegionSearchResult::GetWayResults(), osmscout::Distance::Max(), and osmscout::TypeInfoSet::Set().
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::GetCosts().
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::GetCostString().
|
override |
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::GetCosts().
|
overrideprotectedvirtual |
RoutePositionResult osmscout::SimpleRoutingService::GetRoutableNode | ( | const ObjectFileRef & | objRef, |
const RoutingProfile & | profile | ||
) | const |
Return routable node on specific object, when this object is routable and usable by provided profile.
objRef | |
profile | Routing profile to use. It defines Vehicle to use and allowed objects. |
References osmscout::RoutingProfile::CanUse(), osmscout::Log::Error(), osmscout::ObjectFileRef::GetFileOffset(), osmscout::ObjectFileRef::GetName(), osmscout::GetSphericalDistance(), osmscout::ObjectFileRef::IsWay(), osmscout::log, and osmscout::Distance::Zero().
|
overrideprotectedvirtual |
Return the route node for the given db offset.
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingDatabase::GetRouteNode().
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingDatabase::GetRouteNodes().
TypeConfigRef osmscout::SimpleRoutingService::GetTypeConfig | ( | ) | const |
Returns the type configuration of the underlying db instance.
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::GetUTurnCost().
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::GetVehicle().
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::DBFileOffset::offset.
|
overrideprotectedvirtual |
bool osmscout::SimpleRoutingService::IsOpen | ( | ) | const |
Returns true, if the routing service has been successfully opened, else false.
bool osmscout::SimpleRoutingService::Open | ( | ) |
Opens the routing service.
This loads the routing graph for the given vehicle
References osmscout::RoutingDatabase::Open().
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RouteData::Entries(), and osmscout::RoutingDatabase::GetJunctions().