libosmscout  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups
osmscout::RoutingService Class Reference

The RoutingService implements functionality in the context of routing. More...

#include <RoutingService.h>

Public Member Functions

RoutingResult CalculateRoute (const RoutingProfile &profile, const RoutePosition &start, const RoutePosition &target, const RoutingParameter &parameter)
 Calculate a route. More...
 
RoutingResult CalculateRoute (const RoutingProfile &profile, std::vector< GeoCoord > via, double radius, const RoutingParameter &parameter)
 
void Close ()
 Close the routing service. More...
 
void DumpStatistics ()
 
RoutePosition GetClosestRoutableNode (const GeoCoord &coord, const RoutingProfile &profile, double radius) const
 Returns the closed routeable object (area or way) relative to the given coordinate. More...
 
TypeConfigRef GetTypeConfig () const
 Returns the type configuration of the underlying database 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...
 
 RoutingService (const DatabaseRef &database, const RouterParameter &parameter, const std::string &filenamebase)
 Create a new instance of the routing service. More...
 
bool TransformRouteDataToPoints (const RouteData &data, std::list< Point > &points)
 Transforms the route into a list of points. More...
 
bool TransformRouteDataToRouteDescription (const RouteData &data, RouteDescription &description)
 Transform the route into a RouteDescription. More...
 
bool TransformRouteDataToWay (const RouteData &data, Way &way)
 Transforms the route into a Way. More...
 
virtual ~RoutingService ()
 

Static Public Attributes

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...
 

Detailed Description

The RoutingService implements functionality in the context of routing.

The following functions are available:

  • Calculation of a route from a start node to a target node
  • Transformation of the resulting route to a Way
  • Transformation of the resulting route to a simple list of points
  • Transformation of the resulting route to a routing description with is the base for further transformations to a textual or visual description of the route
  • Returning the closest routeable node to given geolocation

Constructor & Destructor Documentation

osmscout::RoutingService::RoutingService ( const DatabaseRef database,
const RouterParameter &  parameter,
const std::string &  filenamebase 
)

Create a new instance of the routing service.

Parameters
databaseA valid reference to a database instance
parameterAn instance to the parameter object holding further paramterization
vehicleThe vehicle to route for (this results in loading a routing network for the given vehicle).
osmscout::RoutingService::~RoutingService ( )
virtual

References Close().

Member Function Documentation

RoutingResult osmscout::RoutingService::CalculateRoute ( const RoutingProfile profile,
const RoutePosition &  start,
const RoutePosition &  target,
const RoutingParameter &  parameter 
)

Calculate a route.

Parameters
profileProfile to use
startStart of the route
targetTarget of teh route
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

References osmscout::RoutingProfile::CanUse(), osmscout::Log::Error(), osmscout::RoutingProfile::GetCostLimitDistance(), osmscout::RoutingProfile::GetCostLimitFactor(), osmscout::RoutingProfile::GetCosts(), osmscout::ObjectVariantDataFile::GetData(), osmscout::GetSphericalDistance(), osmscout::RoutingProfile::GetVehicle(), and osmscout::log.

RoutingResult osmscout::RoutingService::CalculateRoute ( const RoutingProfile profile,
std::vector< GeoCoord >  via,
double  radius,
const RoutingParameter &  parameter 
)
void osmscout::RoutingService::Close ( )

Close the routing service.

Referenced by ~RoutingService().

void osmscout::RoutingService::DumpStatistics ( )
RoutePosition osmscout::RoutingService::GetClosestRoutableNode ( const GeoCoord &  coord,
const RoutingProfile profile,
double  radius 
) const

Returns the closed routeable object (area or way) relative to the given coordinate.

Note
The returned node may in fact not be routable, it is just the closest node to the given position on a routable way or area.
The actual object may not be within the given radius due to internal search index resolution.
Parameters
coordcoordinate of the search center
profileRouting profile to use
vehicleVehicle to use (may differ from the vehicle the router was initialized but tin this case the route will not return a valid route based on this object).
radiusThe maximum radius to search in from the search center in meter
objectThe resulting object if one was found
nodeIndexThe index of the closed node to the search center.
Returns

References osmscout::RoutingProfile::CanUse(), osmscout::Log::Error(), osmscout::RoutingProfile::GetVehicle(), and osmscout::log.

TypeConfigRef osmscout::RoutingService::GetTypeConfig ( ) const

Returns the type configuration of the underlying database instance.

Returns
A valid type configuration or null if the database is not valid
bool osmscout::RoutingService::IsOpen ( ) const

Returns true, if the routing service has been successfully opened, else false.

Returns
True, if the routing service has been successfully opened
bool osmscout::RoutingService::Open ( )

Opens the routing service.

This loads the routing graph for the given vehicle

Returns
false on error, else true

References osmscout::AppendFileToDir(), osmscout::Log::Debug(), osmscout::Log::Error(), osmscout::ObjectVariantDataFile::Load(), and osmscout::log.

bool osmscout::RoutingService::TransformRouteDataToPoints ( const RouteData data,
std::list< Point > &  points 
)

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

References osmscout::RouteData::Entries(), osmscout::Log::Error(), osmscout::log, osmscout::refArea, and osmscout::refWay.

bool osmscout::RoutingService::TransformRouteDataToRouteDescription ( const RouteData data,
RouteDescription description 
)

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

References osmscout::RouteDescription::AddNode(), osmscout::RouteDescription::Clear(), and osmscout::RouteData::Entries().

bool osmscout::RoutingService::TransformRouteDataToWay ( const RouteData data,
Way &  way 
)

Transforms the route into a Way.

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

References osmscout::RouteData::Entries(), osmscout::refArea, and osmscout::refWay.

Member Data Documentation

const char *const osmscout::RoutingService::DEFAULT_FILENAME_BASE = "router"
static

Relative filebase name for touting data as generated by default by the importer.

Referenced by DBInstance::AssureRouter().

const char *const osmscout::RoutingService::FILENAME_INTERSECTIONS_DAT = "intersections.dat"
static

Relative filename of the intersection data file.

const char *const osmscout::RoutingService::FILENAME_INTERSECTIONS_IDX = "intersections.idx"
static

Relative filename of the intersection index file.


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