|
libosmscout 0.1
|
Abstract algorithms for routing. More...
#include <AbstractRoutingService.h>
Public Member Functions | |
| AbstractRoutingService (const RouterParameter ¶meter) | |
| RoutingResult | CalculateRoute (RoutingState &state, const RoutePosition &start, const RoutePosition &target, const std::optional< osmscout::Bearing > &bearing, const RoutingParameter ¶meter) |
| Calculate a route. | |
| 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. | |
| RoutePointsResult | TransformRouteDataToPoints (const RouteData &data) |
| Transforms the route into a list of points. | |
| RouteDescriptionResult | TransformRouteDataToRouteDescription (const RouteData &data) |
| Transform the route into a RouteDescription. | |
| RouteWayResult | TransformRouteDataToWay (const RouteData &data) |
| Transforms the route into a Way (with empty type). | |
| ~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< DBId > | GetNodeTwins (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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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 ¤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 RoutingState &state, RNodeRef ¤t, RouteNodeRef ¤tRouteNode, 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. | |
| static const char *const | FILENAME_INTERSECTIONS_DAT = "intersections.dat" |
| Relative filename of the intersection data file. | |
| static const char *const | FILENAME_INTERSECTIONS_IDX = "intersections.idx" |
| Relative filename of the intersection index file. | |
| 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> |
Abstract algorithms for routing.
|
explicit |
References debugPerformance.
Referenced by GetNodeTwins().
|
override |
|
protected |
References osmscout::RouteData::AddEntry().
Referenced by GetNodeTwins(), and ResolveRNodesToRouteData().
| 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.
| state | State to use |
| start | Start of the route |
| target | Target of teh route |
| bearing | Initial vehicle bearing, route will start by the way in specified direction. When possible. |
| progress | Optional callback for handling routing progress |
| route | The route object holding the resulting route on success |
References osmscout::Aborted, osmscout::Distance::As(), osmscout::DataFailure, debugPerformance, osmscout::debugRouting, osmscout::RoutingParameter::GetBreaker(), osmscout::RouteNode::GetCoord(), GetCostLimit(), GetCostString(), osmscout::RoutePosition::GetDatabaseId(), osmscout::GeoCoord::GetDisplayText(), GetEstimateCosts(), osmscout::RouteNode::GetFileOffset(), osmscout::RouteNode::GetId(), osmscout::ObjectFileRef::GetName(), osmscout::RoutePosition::GetNodeIndex(), osmscout::RoutePosition::GetObjectFileRef(), osmscout::RoutingResult::GetRoute(), osmscout::GetSphericalDistance(), GetStartNodes(), GetTargetNodes(), GetVehicle(), osmscout::Breaker::IsAborted(), osmscout::log, osmscout::NoRouteFound, osmscout::NoStartNode, osmscout::NoTargetNode, ResolveRNodeChainToList(), ResolveRNodesToRouteData(), ResolveRouteDataJunctions(), RestrictInitialUTurn(), osmscout::RoutingResult::SetCurrentMaxDistance(), osmscout::RoutingResult::SetError(), osmscout::RoutingResult::SetOverallDistance(), osmscout::StopClock::Stop(), WalkPaths(), and WalkToOtherDatabases().
Referenced by osmscout::MultiDBRoutingService::CalculateRoute(), and GetNodeTwins().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by WalkPaths().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by GetStartBackwardRouteNode(), GetTargetBackwardRouteNode(), ResolveRNodesToRouteData(), and RestrictInitialUTurn().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by GetStartForwardRouteNode(), GetTargetForwardRouteNode(), and RestrictInitialUTurn().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by TransformRouteDataToPoints().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
References ResolveRNodeChainToList().
Referenced by ResolveRNodesToRouteData().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by CalculateRoute().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by GetRNode(), and WalkPaths().
|
protectedpure virtual |
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by CalculateRoute().
|
pure virtual |
Get current mapping of DatabaseId to db path than be used later for lookup objects in description.
Implemented in osmscout::MultiDBRoutingService, and osmscout::SimpleRoutingService.
Referenced by TransformRouteDataToRouteDescription().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by CalculateRoute(), GetRNode(), and WalkPaths().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
References AbstractRoutingService(), AddNodes(), CalculateRoute(), GetRNode(), GetStartBackwardRouteNode(), GetStartForwardRouteNode(), GetStartNodes(), GetTargetBackwardRouteNode(), GetTargetForwardRouteNode(), GetTargetNodes(), GetWayStartNodes(), GetWayTargetNodes(), ResolveRNodesToRouteData(), RestrictInitialUTurn(), TransformRouteDataToPoints(), TransformRouteDataToRouteDescription(), TransformRouteDataToWay(), WalkPaths(), and WalkToOtherDatabases().
Referenced by WalkToOtherDatabases().
|
protected |
|
protectedpure virtual |
Return the route node for the given db offset.
Implemented in osmscout::SimpleRoutingService.
Referenced by GetStartBackwardRouteNode(), GetStartForwardRouteNode(), GetTargetBackwardRouteNode(), GetTargetForwardRouteNode(), GetWayStartNodes(), WalkPaths(), and WalkToOtherDatabases().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by ResolveRNodesToRouteData().
|
protected |
References CanUseBackward(), osmscout::Way::GetId(), GetRouteNode(), and osmscout::Way::nodes.
Referenced by GetNodeTwins().
|
protected |
References CanUseForward(), osmscout::Way::GetId(), GetRouteNode(), and osmscout::Way::nodes.
Referenced by GetNodeTwins().
|
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.
| state | The routing state |
| position | The start position |
| startCoord | The coordinate of the start position |
| targetCoord | The coordinate of the target position |
| forwardRouteNode | Optional route node in the forward direction |
| backwardRouteNode | Optional route node in the backward direction |
| forwardRNode | Optional prefilled routing node for the forward direction to be used as part of the routing process |
| backwardRNode | Optional prefilled routing node for the backward direction to be used as part of the routing process |
Referenced by CalculateRoute(), and GetNodeTwins().
|
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.
References CanUseBackward(), osmscout::Way::GetId(), GetRouteNode(), and osmscout::Way::nodes.
Referenced by GetNodeTwins().
|
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.
References CanUseForward(), osmscout::Way::GetId(), GetRouteNode(), and osmscout::Way::nodes.
Referenced by GetNodeTwins().
|
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.
| state | The routing state |
| position | The start position |
| targetCoord | The coordinate of the target position |
| forwardRouteNode | Optional route node in the forward direction |
| backwardRouteNode | Optional route node in the backward direction |
References osmscout::RoutePosition::GetObjectFileRef(), osmscout::ObjectFileRef::GetType(), osmscout::ObjectFileRef::GetTypeName(), GetWayTargetNodes(), osmscout::log, and osmscout::refWay.
Referenced by CalculateRoute(), and GetNodeTwins().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by RestrictInitialUTurn().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by CalculateRoute().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by GetWayStartNodes(), RestrictInitialUTurn(), and TransformRouteDataToPoints().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by ResolveRNodesToRouteData().
|
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.
| state | The routing state |
| position | The start position |
| startCoord | The coordinate of the start position |
| targetCoord | The coordinate of the target position |
| forwardRouteNode | Optional route node in the forward direction |
| backwardRouteNode | Optional route node in the backward direction |
| forwardRNode | Optional prefilled routing node for the forward direction to be used as part of the routing process |
| backwardRNode | Optional prefilled routing node for the backward direction to be used as part of the routing process |
References osmscout::RoutePosition::GetDatabaseId(), osmscout::ObjectFileRef::GetFileOffset(), osmscout::Way::GetId(), osmscout::RoutePosition::GetNodeIndex(), osmscout::RoutePosition::GetObjectFileRef(), GetRouteNode(), osmscout::ObjectFileRef::GetType(), GetWayByOffset(), osmscout::log, osmscout::Way::nodes, and osmscout::refWay.
Referenced by GetNodeTwins().
|
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.
| state | The routing state |
| position | The start position |
| targetCoord | The coordinate of the target position |
| forwardRouteNode | Optional route node in the forward direction |
| backwardRouteNode | Optional route node in the backward direction |
Referenced by GetNodeTwins(), and GetTargetNodes().
|
protected |
References osmscout::debugRouting, osmscout::RoutingService::RNode::id, and osmscout::RoutingService::RNode::restricted.
Referenced by CalculateRoute(), and GetAreasByOffset().
|
protected |
References osmscout::RouteData::AddEntry(), AddNodes(), CanUseBackward(), GetAreasByOffset(), osmscout::RoutePosition::GetDatabaseId(), osmscout::ObjectFileRef::GetFileOffset(), osmscout::RouteNode::GetId(), osmscout::RoutePosition::GetNodeIndex(), osmscout::RoutePosition::GetObjectFileRef(), GetRouteNodes(), osmscout::ObjectFileRef::GetType(), GetWaysByOffset(), osmscout::log, osmscout::refArea, and osmscout::refWay.
Referenced by CalculateRoute(), and GetNodeTwins().
|
protectedpure virtual |
Implemented in osmscout::SimpleRoutingService.
Referenced by CalculateRoute().
|
protected |
References CanUseBackward(), CanUseForward(), osmscout::debugRouting, osmscout::Bearing::Degrees(), osmscout::RoutePosition::GetDatabaseId(), osmscout::ObjectFileRef::GetFileOffset(), osmscout::RoutePosition::GetNodeIndex(), osmscout::RoutePosition::GetObjectFileRef(), osmscout::GetSphericalBearingInitial(), osmscout::ObjectFileRef::GetType(), GetUTurnCost(), GetWayByOffset(), osmscout::log, osmscout::Way::nodes, and osmscout::refWay.
Referenced by CalculateRoute(), and GetNodeTwins().
| RoutePointsResult osmscout::AbstractRoutingService< RoutingState >::TransformRouteDataToPoints | ( | const RouteData & | data | ) |
Transforms the route into a list of points.
| data | Route data |
| points | A list of the points holding route nodes |
References osmscout::RouteData::Entries(), GetAreaByOffset(), osmscout::Way::GetPoint(), GetWayByOffset(), osmscout::log, osmscout::refArea, osmscout::refWay, and osmscout::Area::rings.
Referenced by GetNodeTwins(), osmscout::MultiDBRoutingService::TransformRouteDataToPoints(), and TransformRouteDataToWay().
| 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.
| data | Route data |
| description | An initialized description on success |
References osmscout::RouteDescription::AddNode(), osmscout::RouteData::Entries(), GetDatabaseMapping(), and osmscout::RouteDescription::SetDatabaseMapping().
Referenced by GetNodeTwins(), and osmscout::MultiDBRoutingService::TransformRouteDataToRouteDescription().
| RouteWayResult osmscout::AbstractRoutingService< RoutingState >::TransformRouteDataToWay | ( | const RouteData & | data | ) |
Transforms the route into a Way (with empty type).
References osmscout::RoutePointsResult::GetPoints(), osmscout::Way::nodes, osmscout::RoutePoints::points, osmscout::RoutePointsResult::Success(), and TransformRouteDataToPoints().
Referenced by GetNodeTwins(), and osmscout::MultiDBRoutingService::TransformRouteDataToWay().
|
protectedvirtual |
References CanUse(), osmscout::debugRouting, osmscout::RouteNode::excludes, osmscout::RouteNode::GetCoord(), GetCosts(), GetEstimateCosts(), osmscout::RouteNode::GetId(), osmscout::RoutingParameter::GetProgress(), GetRouteNode(), osmscout::GetSphericalDistance(), osmscout::log, osmscout::Distance::Max(), osmscout::RouteNode::objects, osmscout::RouteNode::paths, osmscout::RoutingProgress::Progress(), and osmscout::RoutingResult::SetCurrentMaxDistance().
Referenced by CalculateRoute(), and GetNodeTwins().
|
protectedvirtual |
References osmscout::debugRouting, osmscout::RouteNode::GetId(), GetNodeTwins(), and GetRouteNode().
Referenced by CalculateRoute(), and GetNodeTwins().
|
protected |
Referenced by AbstractRoutingService(), and CalculateRoute().