libosmscout  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
osmscout::AbstractRoutingService< RoutingState > Class Template Referenceabstract

#include <AbstractRoutingService.h>

+ Inheritance diagram for osmscout::AbstractRoutingService< RoutingState >:

Public Member Functions

 AbstractRoutingService (const RouterParameter &parameter)
 
RoutingResult CalculateRoute (RoutingState &state, const RoutePosition &start, const RoutePosition &target, const std::optional< osmscout::Bearing > &bearing, const RoutingParameter &parameter)
 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
 
- Public Member Functions inherited from osmscout::RoutingService
 RoutingService ()
 
virtual ~RoutingService ()
 

Protected Member Functions

void AddNodes (RouteData &route, DatabaseId database, Id startNodeId, size_t startNodeIndex, const ObjectFileRef &object, size_t idCount, bool oneway, size_t targetNodeIndex)
 
virtual bool CanUse (const RoutingState &state, DatabaseId database, const RouteNode &routeNode, size_t pathIndex)=0
 
virtual bool CanUseBackward (const RoutingState &state, const DatabaseId &database, const WayRef &way)=0
 
virtual bool CanUseForward (const RoutingState &state, const DatabaseId &database, const WayRef &way)=0
 
virtual bool GetAreaByOffset (const DBFileOffset &offset, AreaRef &area)=0
 
virtual bool GetAreasByOffset (const std::set< DBFileOffset > &areaOffsets, std::unordered_map< DBFileOffset, AreaRef > &areaMap)=0
 
virtual double GetCostLimit (const RoutingState &state, DatabaseId database, const Distance &targetDistance)=0
 
virtual double GetCosts (const RoutingState &state, DatabaseId database, const RouteNode &routeNode, size_t inPathIndex, size_t outPathIndex)=0
 
virtual double GetCosts (const RoutingState &state, DatabaseId database, const WayRef &way, const Distance &wayLength)=0
 
virtual std::string GetCostString (const RoutingState &state, DatabaseId database, double cost) const =0
 
virtual double GetEstimateCosts (const RoutingState &state, DatabaseId database, const Distance &targetDistance)=0
 
virtual std::vector< DBIdGetNodeTwins (const RoutingState &state, DatabaseId database, Id id)=0
 
bool GetRNode (const RoutingState &state, const RoutePosition &position, const WayRef &way, size_t routeNodeIndex, const RouteNodeRef &routeNode, const GeoCoord &startCoord, const GeoCoord &targetCoord, RNodeRef &node)
 
virtual bool GetRouteNode (const DBId &id, RouteNodeRef &node)=0
 Return the route node for the given db offset. More...
 
virtual bool GetRouteNodes (const std::set< DBId > &routeNodeIds, std::unordered_map< DBId, RouteNodeRef > &routeNodeMap)=0
 
void GetStartBackwardRouteNode (const RoutingState &state, const DatabaseId &database, const WayRef &way, size_t nodeIndex, RouteNodeRef &routeNode, size_t &routeNodeIndex)
 
void GetStartForwardRouteNode (const RoutingState &state, const DatabaseId &database, const WayRef &way, size_t nodeIndex, RouteNodeRef &routeNode, size_t &routeNodeIndex)
 
bool GetStartNodes (const RoutingState &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 RoutingState &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 RoutingState &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 RoutingState &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...
 
virtual double GetUTurnCost (const RoutingState &state, const DatabaseId databaseId)=0
 
virtual Vehicle GetVehicle (const RoutingState &state)=0
 
virtual bool GetWayByOffset (const DBFileOffset &offset, WayRef &way)=0
 
virtual bool GetWaysByOffset (const std::set< DBFileOffset > &wayOffsets, std::unordered_map< DBFileOffset, WayRef > &wayMap)=0
 
bool GetWayStartNodes (const RoutingState &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 RoutingState &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 RoutingState &state, const std::list< VNode > &nodes, const RoutePosition &start, const RoutePosition &target, RouteData &route)
 
virtual bool ResolveRouteDataJunctions (RouteData &route)=0
 
bool RestrictInitialUTurn (const RoutingState &state, const Bearing &vehicleBearing, const RoutePosition &start, RNodeRef startForwardNode, RNodeRef startBackwardNode)
 
virtual bool WalkPaths (const RoutingState &state, RNodeRef &current, RouteNodeRef &currentRouteNode, OpenList &openList, OpenMap &openMap, ClosedSet &closedSet, RoutingResult &result, const RoutingParameter &parameter, const GeoCoord &targetCoord, const Vehicle &vehicle, size_t &nodesIgnoredCount, Distance &currentMaxDistance, const Distance &overallDistance, const double &costLimit)
 
virtual bool WalkToOtherDatabases (const RoutingState &state, RNodeRef &current, RouteNodeRef &currentRouteNode, OpenList &openList, OpenMap &openMap, const ClosedSet &closedSet)
 

Protected Attributes

bool debugPerformance
 

Additional Inherited Members

- Static Public Member Functions inherited from osmscout::RoutingService
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 Public Attributes inherited from osmscout::RoutingService
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...
 
- Protected Types inherited from osmscout::RoutingService
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 >
 

Detailed Description

template<class RoutingState>
class osmscout::AbstractRoutingService< RoutingState >

Abstract algorithms for routing

Constructor & Destructor Documentation

◆ AbstractRoutingService()

template<class RoutingState >
osmscout::AbstractRoutingService< RoutingState >::AbstractRoutingService ( const RouterParameter parameter)
explicit

◆ ~AbstractRoutingService()

template<class RoutingState >
osmscout::AbstractRoutingService< RoutingState >::~AbstractRoutingService
override

Member Function Documentation

◆ AddNodes()

template<class RoutingState >
void osmscout::AbstractRoutingService< RoutingState >::AddNodes ( RouteData route,
DatabaseId  database,
Id  startNodeId,
size_t  startNodeIndex,
const ObjectFileRef object,
size_t  idCount,
bool  oneway,
size_t  targetNodeIndex 
)
protected

◆ CalculateRoute()

template<class RoutingState >
RoutingResult osmscout::AbstractRoutingService< RoutingState >::CalculateRoute ( RoutingState &  state,
const RoutePosition start,
const RoutePosition target,
const std::optional< osmscout::Bearing > &  bearing,
const RoutingParameter parameter 
)

Calculate a route.

Parameters
stateState to use
startStart of the route
targetTarget of teh route
bearingInitial vehicle bearing, route will start by the way in specified direction. When possible.
progressOptional callback for handling routing progress
routeThe route object holding the resulting route on success
Returns
True, if the engine was able to find a route, else false

Referenced by osmscout::MultiDBRoutingService::CalculateRoute().

◆ CanUse()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::CanUse ( const RoutingState &  state,
DatabaseId  database,
const RouteNode routeNode,
size_t  pathIndex 
)
protectedpure virtual

◆ CanUseBackward()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::CanUseBackward ( const RoutingState &  state,
const DatabaseId database,
const WayRef way 
)
protectedpure virtual

◆ CanUseForward()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::CanUseForward ( const RoutingState &  state,
const DatabaseId database,
const WayRef way 
)
protectedpure virtual

◆ GetAreaByOffset()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::GetAreaByOffset ( const DBFileOffset offset,
AreaRef area 
)
protectedpure virtual

◆ GetAreasByOffset()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::GetAreasByOffset ( const std::set< DBFileOffset > &  areaOffsets,
std::unordered_map< DBFileOffset, AreaRef > &  areaMap 
)
protectedpure virtual

◆ GetCostLimit()

template<class RoutingState >
virtual double osmscout::AbstractRoutingService< RoutingState >::GetCostLimit ( const RoutingState &  state,
DatabaseId  database,
const Distance targetDistance 
)
protectedpure virtual

◆ GetCosts() [1/2]

template<class RoutingState >
virtual double osmscout::AbstractRoutingService< RoutingState >::GetCosts ( const RoutingState &  state,
DatabaseId  database,
const RouteNode routeNode,
size_t  inPathIndex,
size_t  outPathIndex 
)
protectedpure virtual

◆ GetCosts() [2/2]

template<class RoutingState >
virtual double osmscout::AbstractRoutingService< RoutingState >::GetCosts ( const RoutingState &  state,
DatabaseId  database,
const WayRef way,
const Distance wayLength 
)
protectedpure virtual

◆ GetCostString()

template<class RoutingState >
virtual std::string osmscout::AbstractRoutingService< RoutingState >::GetCostString ( const RoutingState &  state,
DatabaseId  database,
double  cost 
) const
protectedpure virtual

◆ GetDatabaseMapping()

template<class RoutingState >
virtual std::map<DatabaseId, std::string> osmscout::AbstractRoutingService< RoutingState >::GetDatabaseMapping ( ) const
pure virtual

Get current mapping of DatabaseId to db path than be used later for lookup objects in description.

Returns

◆ GetEstimateCosts()

template<class RoutingState >
virtual double osmscout::AbstractRoutingService< RoutingState >::GetEstimateCosts ( const RoutingState &  state,
DatabaseId  database,
const Distance targetDistance 
)
protectedpure virtual

◆ GetNodeTwins()

template<class RoutingState >
virtual std::vector<DBId> osmscout::AbstractRoutingService< RoutingState >::GetNodeTwins ( const RoutingState &  state,
DatabaseId  database,
Id  id 
)
protectedpure virtual

◆ GetRNode()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::GetRNode ( const RoutingState &  state,
const RoutePosition position,
const WayRef way,
size_t  routeNodeIndex,
const RouteNodeRef routeNode,
const GeoCoord startCoord,
const GeoCoord targetCoord,
RNodeRef node 
)
protected

◆ GetRouteNode()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::GetRouteNode ( const DBId id,
RouteNodeRef node 
)
protectedpure virtual

Return the route node for the given db offset.

Parameters
idDatabase and Offset in given db
nodeNode instance to write the result back
Returns
True, if the node could be loaded, else false

Implemented in osmscout::SimpleRoutingService.

◆ GetRouteNodes()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::GetRouteNodes ( const std::set< DBId > &  routeNodeIds,
std::unordered_map< DBId, RouteNodeRef > &  routeNodeMap 
)
protectedpure virtual

◆ GetStartBackwardRouteNode()

template<class RoutingState >
void osmscout::AbstractRoutingService< RoutingState >::GetStartBackwardRouteNode ( const RoutingState &  state,
const DatabaseId database,
const WayRef way,
size_t  nodeIndex,
RouteNodeRef routeNode,
size_t &  routeNodeIndex 
)
protected

◆ GetStartForwardRouteNode()

template<class RoutingState >
void osmscout::AbstractRoutingService< RoutingState >::GetStartForwardRouteNode ( const RoutingState &  state,
const DatabaseId database,
const WayRef way,
size_t  nodeIndex,
RouteNodeRef routeNode,
size_t &  routeNodeIndex 
)
protected

◆ GetStartNodes()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::GetStartNodes ( const RoutingState &  state,
const RoutePosition position,
GeoCoord startCoord,
const GeoCoord targetCoord,
RouteNodeRef forwardRouteNode,
RouteNodeRef backwardRouteNode,
RNodeRef forwardRNode,
RNodeRef backwardRNode 
)
protected

The start position is at the given position defined by an object and the index of the node within the object.

Return the closest route node and routing node either in the forward or backward direction or both.

Parameters
stateThe routing state
positionThe start position
startCoordThe coordinate of the start position
targetCoordThe coordinate of the target position
forwardRouteNodeOptional route node in the forward direction
backwardRouteNodeOptional route node in the backward direction
forwardRNodeOptional prefilled routing node for the forward direction to be used as part of the routing process
backwardRNodeOptional prefilled routing node for the backward direction to be used as part of the routing process
Returns
True, if at least one route node was found. If not or in case of technical errors false is returned.

◆ GetTargetBackwardRouteNode()

template<class RoutingState >
void osmscout::AbstractRoutingService< RoutingState >::GetTargetBackwardRouteNode ( const RoutingState &  state,
const DatabaseId database,
const WayRef way,
size_t  nodeIndex,
RouteNodeRef routeNode 
)
protected

Return the route node that allows navigating to the given node in backward direction.

In result the returned routing node will have a bigger or equal index then the given node index.

◆ GetTargetForwardRouteNode()

template<class RoutingState >
void osmscout::AbstractRoutingService< RoutingState >::GetTargetForwardRouteNode ( const RoutingState &  state,
const DatabaseId database,
const WayRef way,
size_t  nodeIndex,
RouteNodeRef routeNode 
)
protected

Return the route node that allows navigating to the given node in forward direction.

In result the returned routing node will have a smaller index then the given node index.

◆ GetTargetNodes()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::GetTargetNodes ( const RoutingState &  state,
const RoutePosition position,
GeoCoord targetCoord,
RouteNodeRef forwardNode,
RouteNodeRef backwardNode 
)
protected

The target position is at the given position defined by an object and the index of the node within the object.

Return the closest route node and routing node either in the forward or backward direction or both.

Parameters
stateThe routing state
positionThe start position
targetCoordThe coordinate of the target position
forwardRouteNodeOptional route node in the forward direction
backwardRouteNodeOptional route node in the backward direction
Returns
True, if at least one route node was found. If not or in case of technical errors false is returned.

◆ GetUTurnCost()

template<class RoutingState >
virtual double osmscout::AbstractRoutingService< RoutingState >::GetUTurnCost ( const RoutingState &  state,
const DatabaseId  databaseId 
)
protectedpure virtual

◆ GetVehicle()

template<class RoutingState >
virtual Vehicle osmscout::AbstractRoutingService< RoutingState >::GetVehicle ( const RoutingState &  state)
protectedpure virtual

◆ GetWayByOffset()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::GetWayByOffset ( const DBFileOffset offset,
WayRef way 
)
protectedpure virtual

◆ GetWaysByOffset()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::GetWaysByOffset ( const std::set< DBFileOffset > &  wayOffsets,
std::unordered_map< DBFileOffset, WayRef > &  wayMap 
)
protectedpure virtual

◆ GetWayStartNodes()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::GetWayStartNodes ( const RoutingState &  state,
const RoutePosition position,
GeoCoord startCoord,
const GeoCoord targetCoord,
RouteNodeRef forwardRouteNode,
RouteNodeRef backwardRouteNode,
RNodeRef forwardRNode,
RNodeRef backwardRNode 
)
protected

The start position is at the given way and the index of the node within the object.

Return the closest route node and routing node either in the forward or backward direction or both.

Parameters
stateThe routing state
positionThe start position
startCoordThe coordinate of the start position
targetCoordThe coordinate of the target position
forwardRouteNodeOptional route node in the forward direction
backwardRouteNodeOptional route node in the backward direction
forwardRNodeOptional prefilled routing node for the forward direction to be used as part of the routing process
backwardRNodeOptional prefilled routing node for the backward direction to be used as part of the routing process
Returns
True, if at least one route node was found. If not or in case of technical errors false is returned.

◆ GetWayTargetNodes()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::GetWayTargetNodes ( const RoutingState &  state,
const RoutePosition position,
GeoCoord targetCoord,
RouteNodeRef forwardNode,
RouteNodeRef backwardNode 
)
protected

The target position is at the given position defined by an object and the index of the node within the object.

Return the closest route node and routing node either in the forward or backward direction or both.

Parameters
stateThe routing state
positionThe start position
targetCoordThe coordinate of the target position
forwardRouteNodeOptional route node in the forward direction
backwardRouteNodeOptional route node in the backward direction
Returns
True, if at least one route node was found. If not or in case of technical errors false is returned.

◆ ResolveRNodeChainToList()

template<class RoutingState >
void osmscout::AbstractRoutingService< RoutingState >::ResolveRNodeChainToList ( const RNode finalRouteNode,
const ClosedSet closedSet,
std::list< VNode > &  nodes 
)
protected

◆ ResolveRNodesToRouteData()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::ResolveRNodesToRouteData ( const RoutingState &  state,
const std::list< VNode > &  nodes,
const RoutePosition start,
const RoutePosition target,
RouteData route 
)
protected

◆ ResolveRouteDataJunctions()

template<class RoutingState >
virtual bool osmscout::AbstractRoutingService< RoutingState >::ResolveRouteDataJunctions ( RouteData route)
protectedpure virtual

◆ RestrictInitialUTurn()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::RestrictInitialUTurn ( const RoutingState &  state,
const Bearing vehicleBearing,
const RoutePosition start,
RNodeRef  startForwardNode,
RNodeRef  startBackwardNode 
)
protected

◆ TransformRouteDataToPoints()

template<class RoutingState >
RoutePointsResult osmscout::AbstractRoutingService< RoutingState >::TransformRouteDataToPoints ( const RouteData data)

Transforms the route into a list of points.

Parameters
dataRoute data
pointsA list of the points holding route nodes
Returns
True, if the way could be build, else false

Referenced by osmscout::MultiDBRoutingService::TransformRouteDataToPoints().

◆ TransformRouteDataToRouteDescription()

template<class RoutingState >
RouteDescriptionResult osmscout::AbstractRoutingService< RoutingState >::TransformRouteDataToRouteDescription ( const RouteData data)

Transform the route into a RouteDescription.

The RouteDescription can be further transformed to enhanced textual and/or visual description of the route containing additional information.

Parameters
dataRoute data
descriptionAn initialized description on success
Returns
True on success, else false

Referenced by osmscout::MultiDBRoutingService::TransformRouteDataToRouteDescription().

◆ TransformRouteDataToWay()

template<class RoutingState >
RouteWayResult osmscout::AbstractRoutingService< RoutingState >::TransformRouteDataToWay ( const RouteData data)

Transforms the route into a Way (with empty type)

Parameters
dataRoute data
wayWay to get initialized to the route on success
Returns
True, if the way could be build, else false

Referenced by osmscout::MultiDBRoutingService::TransformRouteDataToWay().

◆ WalkPaths()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::WalkPaths ( const RoutingState &  state,
RNodeRef current,
RouteNodeRef currentRouteNode,
OpenList openList,
OpenMap openMap,
ClosedSet closedSet,
RoutingResult result,
const RoutingParameter parameter,
const GeoCoord targetCoord,
const Vehicle vehicle,
size_t &  nodesIgnoredCount,
Distance currentMaxDistance,
const Distance overallDistance,
const double &  costLimit 
)
protectedvirtual

◆ WalkToOtherDatabases()

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::WalkToOtherDatabases ( const RoutingState &  state,
RNodeRef current,
RouteNodeRef currentRouteNode,
OpenList openList,
OpenMap openMap,
const ClosedSet closedSet 
)
protectedvirtual

Member Data Documentation

◆ debugPerformance

template<class RoutingState >
bool osmscout::AbstractRoutingService< RoutingState >::debugPerformance
protected

The documentation for this class was generated from the following files: