| Forum | GitHub | Maps | Blog

Velocities of cars, bikes etc


How are the max velocities of vehicles defined? I am using a osm.pbf file and for example a car. Are the calculated distances and travel times equivalent to me driving according to speed limits on empty roads?


the road types come from the OSM map, but each vehicle type defines its own flagEncoder and in it a mapping from road types to velocities. Look at eg and

defaultSpeedMap.put("motorway", 100);
defaultSpeedMap.put("motorway_link", 70);
defaultSpeedMap.put("motorroad", 90);
// bundesstraße
defaultSpeedMap.put("trunk", 70);
defaultSpeedMap.put("trunk_link", 65);
// linking bigger town
defaultSpeedMap.put("primary", 65);
defaultSpeedMap.put("primary_link", 60);


Please note, that the average speed does not directly map to the maximum speed and if there is an explicit maxspeed sign it will be involved in the calculation.


but the defaultSpeedMap determines the value returned by getSpeed, right? Can’t find the code that responds to maxspeed in OSM file…

protected double getSpeed(ReaderWay way) {
        String highwayValue = way.getTag("highway");
        if (!Helper.isEmpty(highwayValue) && way.hasTag("motorroad", "yes")
                && highwayValue != "motorway" && highwayValue != "motorway_link") {
            highwayValue = "motorroad";
        Integer speed = defaultSpeedMap.get(highwayValue);
        if (speed == null)
            throw new IllegalStateException(toString() + ", no speed found for: " + highwayValue + ", tags: " + way);

        if (highwayValue.equals("track")) {
            String tt = way.getTag("tracktype");
            if (!Helper.isEmpty(tt)) {
                Integer tInt = trackTypeSpeedMap.get(tt);
                if (tInt != null)
                    speed = tInt;

        return speed;


Ups, yes. So the map is already the average speed. But can be changed due to maxspeed tags: