Show / Hide Table of Contents

Basic Concepts

If you want to start using Itinero as a library it's crucial to understand it's basic concepts. The most important are RouterDb, Router, Profile and RouterPoint:

  • RouterDb: Contains the routing network, all meta-data, restrictions and so on.
  • Profile: Defines vehicles and their behaviour.
  • RouterPoint: A location on the routing network to use as a start or endpoint of a route.
  • Router: The router is where you ask for routes.

How these tie together:

The Router uses the RouterDb data to calculate routes for a given Profile. It starts and ends the Route at a RouterPoint.

Example

You can see all of these in action in the following example:

// using Itinero;
// using Itinero.IO.Osm;
// using Itinero.Osm.Vehicles;

// load some routing data and build a routing network.
var routerDb = new RouterDb();
using (var stream = new FileInfo(@"/path/to/some/osmfile.osm.pbf").OpenRead())
{
    routerDb.LoadOsmData(stream, Vehicle.Car); // create the network for cars only.
}

// create a router.
var router = new Router(routerDb);

// get a profile.
var profile = Vehicle.Car.Fastest(); // the default OSM car profile.

// create a routerpoint from a location.
// snaps the given location to the nearest routable edge.
var start = router.Resolve(profile, 51.26797020271655f, 4.801905155181885f);
var end = router.Resolve(profile, 51.26797020271655f, 4.801905155181885f);

// calculate a route.
var route = router.Calculate(profile, start, end);

So this is happening in the sample, in the same order:

  1. Building a routing network from raw OSM-data.
  2. Define a profile.
  3. Snap the start and end locations of the route to het network.
  4. Ask the router for a route.

What to read next?

Learn more about the individual concepts, starting with the first step, the RouterDb.

Back to top Built by Itinero, MIT licensed.