|
libosmscout 0.1
|
The RoutingService implements functionality in the context of routing. More...
#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. | |
| void | Close () |
| Close the routing service. | |
| 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. | |
| RoutePositionResult | GetClosestRoutableNode (const GeoCoord &coord, const RoutingProfile &profile, const Distance &radius, RouteEndpoint endpoint) const |
| The closest routable way the position can be attached to for the given end of a route. | |
| ClosestRoutableObjectResult | GetClosestRoutableObject (const GeoCoord &location, Vehicle vehicle, const Distance &maxRadius) |
| Returns the closest routeable object (area or way) relative to the given coordinate. | |
| std::map< DatabaseId, std::string > | GetDatabaseMapping () const override |
| Get current mapping of DatabaseId to db path than be used later for lookup objects in description. | |
| 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. | |
| TypeConfigRef | GetTypeConfig () const |
| Returns the type configuration of the underlying db instance. | |
| bool | IsOpen () const |
| Returns true, if the routing service has been successfully opened, else false. | |
| bool | Open () |
| Opens the routing service. | |
| SimpleRoutingService (const DatabaseRef &database, const RouterParameter ¶meter, const std::string &filenamebase) | |
| Create a new instance of the routing service. | |
| ~SimpleRoutingService () override | |
| Public Member Functions inherited from osmscout::AbstractRoutingService< RoutingProfile > | |
| 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. | |
| 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 | |
| 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. | |
| 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 | IsEndpointAttachable (const RoutingProfile &profile, const WayRef &way, size_t nodeIndex, RouteEndpoint endpoint) const |
| Whether a position at nodeIndex of way can be attached to the routing network for endpoint. | |
| bool | ResolveRouteDataJunctions (RouteData &route) override |
| Protected Member Functions inherited from osmscout::AbstractRoutingService< RoutingProfile > | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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 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> |
| Protected Attributes inherited from osmscout::AbstractRoutingService< RoutingProfile > | |
| 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 |
References osmscout::AbstractRoutingService< RoutingProfile >::AbstractRoutingService(), and GetTypeConfig().
|
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 |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::CanUse().
|
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.
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 GetClosestRoutableNode(), and osmscout::Unspecified.
Referenced by CalculateRouteViaCoords(), and GetClosestRoutableNode().
| RoutePositionResult osmscout::SimpleRoutingService::GetClosestRoutableNode | ( | const GeoCoord & | coord, |
| const RoutingProfile & | profile, | ||
| const Distance & | radius, | ||
| RouteEndpoint | endpoint ) const |
The closest routable way the position can be attached to for the given end of a route.
A way is only taken when IsEndpointAttachable holds for it, so a way the position cannot be attached to is skipped in favour of the next one within the same radius instead of failing the whole calculation (see that function). RouteEndpoint::Unspecified applies no end-specific restriction and therefore selects exactly what the overload above selects.
References osmscout::GeoBox::BoxByCenterAndRadius(), osmscout::RoutingProfile::CanUse(), osmscout::DistanceToSegment(), osmscout::GetEllipsoidalDistance(), osmscout::GeoCoord::GetLat(), osmscout::GeoCoord::GetLon(), osmscout::RoutingProfile::GetVehicle(), IsEndpointAttachable(), osmscout::log, and osmscout::TypeInfoSet::Set().
| 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 |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::GetCosts().
|
overrideprotected |
References osmscout::RoutingProfile::GetCosts().
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RoutingProfile::GetCostString().
|
overridevirtual |
Get current mapping of DatabaseId to db path than be used later for lookup objects in description.
Implements osmscout::AbstractRoutingService< RoutingProfile >.
|
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::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 >.
|
overrideprotectedvirtual |
| TypeConfigRef osmscout::SimpleRoutingService::GetTypeConfig | ( | ) | const |
Returns the type configuration of the underlying db instance.
Referenced by SimpleRoutingService().
|
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 |
|
protected |
Whether a position at nodeIndex of way can be attached to the routing network for endpoint.
GetWayStartNodes and GetWayTargetNodes attach a position by looking for a route node on the position's way: the attach index itself first, then along the way in the direction(s) the profile permits for that end. The two ends search opposite halves of the way – the start forward from the attach index, the target backward from it – so a position can attach as one end of a route and not as the other on a direction-restricted way (a one-way street, a slip road). A way the position cannot be attached to cannot carry it: taking it as the closest routable way makes the whole calculation fail in GetWayStartNodes / GetWayTargetNodes, although a way a little further away can carry the position.
The gates and the index ranges are the ones of the four search functions in AbstractRoutingService (GetStartForwardRouteNode, GetStartBackwardRouteNode, GetTargetForwardRouteNode, GetTargetBackwardRouteNode). Those are not const and this selection is, so the route node is read through RoutingDatabase::GetRouteNode rather than through the service's own lookup. Keep the ranges in step with those four functions.
References osmscout::RoutingProfile::CanUseBackward(), osmscout::RoutingProfile::CanUseForward(), osmscout::Start, and osmscout::Unspecified.
Referenced by GetClosestRoutableNode().
| 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
|
overrideprotectedvirtual |
Implements osmscout::AbstractRoutingService< RoutingProfile >.
References osmscout::RouteData::Entries().