Giter Club home page Giter Club logo

osrm-train-profile's Introduction

OSRM Lua profile for trains

This repo contains a profile for routing (mostly freight) trains with OSRM. This enables you to find the shortest path by train between 2 points and also do map matching with OSRM.

Note: travel time estimations are way too optimistic due to the red lights, stations and traffic not taken into account

Right now, it contains, 2 profiles :

basic.lua

A basic/naive profile that works quite well.

freight.lua

A profile optimized for freight trains:

  • Default speed is 130 km/h
  • Highspeed lines are de-prioritized
  • Has flags to completely exclude highspeed lines and/or non electrified segments
  • Rejects all gauges that are not 1435mm

Possible improvements that we might one day include :

  • Preferred left-hand driving even where OSM does not specify it (if you know how to implement it, please be in touch !)
  • Better turn restrictions/penalties
  • Speed limitation in curves
  • Time penalty for traffic lights or when passing trough stations

screenshot of the demo

Inspiration for the code taken from an old russian blog and the car profile

How to run this?

First, you will need to install the Docker daemon and osmium (osmium-tool on Ubuntu) on your machine. Then, run make all to download the OSM data, filter and combine it and finally compute the routing graph.

Last, run make serve to serve the OSRM server locally on port 5000

License

This code is under the 2-Clause BSD License.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

osrm-train-profile's People

Contributors

c4ptaincrunch avatar hannesaddec avatar huguesbrun avatar loispostula avatar pierrege avatar theperil avatar trucheromayor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osrm-train-profile's Issues

Conflicting licenses

Hi,

it is stated in README.md and LICENSE.md that this project is licensed under the 2-clause BSD license. But the lua files have an AGPL header:

-- This code was written by Nikita Marchant <[email protected]>
-- Code under the AGPL license https://www.gnu.org/licenses/agpl-3.0.html

Can you please clarify?

Osmium tags-filter might not be restrictive enough

Hi, there should be really clear note that default filter params to extract data from osm: nw/railway
is really extracting more than trains. For example this normally extract all rails (including tram lines) since this is also a rail.

I think we should be really more careful to explain and parametrize this parameter when extracting data from osm.

nw/railway="rail" would probably extract only rails (train) which is what we want.

Please let me know if this was intentional or we just should be more careful.

Thanks for really nice docker build/setup.

Subway & Tram

Hi, do you know how I could extend these profiles to subway and tram ? Thanks.

Angles and speeds at turning always zero

Originally posted by @tomvanenckevort in #6 (comment)

So I have been playing around with this a bit more and decided to have a look at the OSRM tile service to plot the various ways, speeds and angles.

But when I do that all the speeds and angles displayed at turnings seem to be set to zero:
image

I'm not really sure if that is a problem with the OSM data or the way OSRM has processed the data though?

For reference, I'm using the latest basic.lua profile from this repo and I run the following commands for OSRM:

  • docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/cheshire-latest.osm.pbf
  • docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition /data/cheshire-latest.osrm
  • docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize /data/cheshire-latest.osrm

How to avoid track changes at start of a route?

I've started playing around with OSRM and your train profile (the basic one) to use for calculating routes and distances between stations. And while that works pretty well, I have got a small issue around stations with many tracks and platforms.

If I'm trying to get a route between stations A & B I want to use the stations' central coordinates as the start and end point of the route.
But currently it seems that it starts from the track nearest to those exact coordinates and then routes it back and forth across the available tracks and points to get it onto the right track that takes it into the direction of station B.

Here is an example of such a route:
image

Is there any way to change the routing or profile parameters to avoid those initial track changes and instead start the route from the most direct track nearest to the station A coordinates?

Profile not working for great britain

Hi!
Thanks for thoses greats profiles! It really helped me a lot!

They work very fine for all continental europe, but when it comes to great britain, it seems very unstable.
For example, if I generate my osrm map with this profile (freight.lua), from the european-latest.osm.pbf (That I've filtered with osmium nw/railway), osrm is unable to compute some basics route.
Example, a route between : [-0.160675,51.187951],[-0.168915,51.220432]
(It doesn't go on the good coordinates, the road begin very far from it)

I tried to change the restriction, but nothing has effect on it.
Would you have an idea ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.