2018-08-17 14:11:10 +00:00
[![Left: station-to-station path of a single train through Switzerland obtained from schedule timetable data. Right: path of the same train map-matched by pfaedle. ](geo/schweiz_ex_res.png?raw=true )](geo/schweiz_ex.png?raw=true)
2018-08-17 14:11:50 +00:00
*Left: station-to-station path of a single train through Switzerland obtained from official schedule data. Right: path of the same train map-matched by pfaedle.*
2018-08-17 14:11:10 +00:00
[![Left: station-to-station path of a single bus through Stuttgart obtained from official schedule data. Right: path of the same bus map-matched by pfaedle. ](geo/stuttgart_ex_res.png?raw=true )](geo/stuttgart_ex.png?raw=true)
2018-08-17 14:11:50 +00:00
*Left: station-to-station path of a single bus through Stuttgart obtained from official schedule data. Right: path of the same bus map-matched by pfaedle.*
2018-06-09 15:15:05 +00:00
2018-07-22 16:42:10 +00:00
[![Build
Status](https://travis-ci.org/ad-freiburg/pfaedle.svg?branch=master)](https://travis-ci.org/ad-freiburg/pfaedle)
2018-06-09 15:15:05 +00:00
# pfaedle
2019-02-04 15:46:56 +00:00
Precise OpenStreetMap (OSM) map-matching for public transit schedules ([GTFS](https://developers.google.com/transit/gtfs/reference/) data).
2019-02-04 15:43:32 +00:00
Implementation and evaluation code for our paper [Sparse Map-Matching in Public Transit Networks with Turn Restrictions ](http://ad-publications.informatik.uni-freiburg.de/SIGSPATIAL_Sparse%20map%20matching%202018.pdf ).
2018-06-09 15:15:05 +00:00
## Requirements
* `cmake`
2019-01-12 00:04:38 +00:00
* `gcc >= 4.9` (or `clang >= 5.0` )
2018-06-09 15:15:05 +00:00
## Building and Installation
Fetch this repository and init submodules:
```
2018-06-09 15:22:37 +00:00
git clone --recurse-submodules https://github.com/ad-freiburg/pfaedle
2018-06-09 15:15:05 +00:00
```
```
mkdir build & & cd build
cmake ..
make -j
```
To install, type
```
make install
```
# General Usage
2018-06-12 10:52:43 +00:00
## Generating shapes for a GTFS feed
2018-06-09 15:15:05 +00:00
```
2019-01-10 15:52:59 +00:00
pfaedle -x < OSM FILE > < GTFS INPUT FOLDER >
2018-06-09 15:15:05 +00:00
```
A shape'd version of the input GTFS feed will be written to `./gtfs-out` .
By default, shapes are only calculated for trips that don't have a shape in the
input feed. To drop all existing shapes, use the `-D` flag.
2018-07-22 15:17:53 +00:00
For example, you may generate (and replace existing, see -D parameter) shapes for the GTFS dataset for Freiburg like this:
```
2019-01-10 15:52:59 +00:00
$ wget https://fritz.freiburg.de/csv_Downloads/VAGFR.zip & & unzip VAGFR.zip
$ wget http://download.geofabrik.de/europe/germany/baden-wuerttemberg/freiburg-regbez-latest.osm.bz2 & & bunzip2 freiburg-regbez-latest.osm.bz2
$ pfaedle -D -x freiburg-regbez-latest.osm .
2018-07-22 15:17:53 +00:00
```
2018-06-12 10:52:43 +00:00
## Generating shapes for a specific MOT
2018-06-09 15:15:05 +00:00
2019-02-04 15:43:32 +00:00
To generate shapes for a specific mot only, use the `-m` option. Possible
2019-01-10 15:52:59 +00:00
values are either `tram` , `bus` , `coach` , `rail` , `subway` , `ferry` , `funicular` ,
2018-07-25 18:18:42 +00:00
`gondola` , `all` (default) or GTFS vehicle type codes (0, 1, 2, 3, 4, 5, 6, 7).
2018-06-09 15:15:05 +00:00
Multiple values can be specified (comma separated).
## OSM filtering
`pfaedle` comes with the ability to filter OpenStreetMap data. If you specify
2018-06-12 10:52:43 +00:00
the `-X` flag, `pfaedle` will filter the input OSM file and output a new OSM
2019-01-10 15:52:59 +00:00
file which contains exactly the data needed to calculate the shapes for the
2018-06-09 15:15:05 +00:00
input GTFS feed and the input configuration.
2019-02-04 15:43:32 +00:00
This can be used to avoid parsing (for example) the entire `planet.osm` on each
2018-06-09 15:15:05 +00:00
run.
2020-12-02 16:53:31 +00:00
## via Docker
2021-06-27 10:20:15 +00:00
You can use the [`adfreiburg/pfaedle` Docker image ](https://hub.docker.com/r/adfreiburg/pfaedle ) by mounting the OSM & GTFS data into the container:
2020-12-02 16:53:31 +00:00
```shell
docker run -i --rm \
# mount OSM data
--volume /path/to/osm/data:/osm \
# mount GTFS data
--volume /path/to/gtfs/data:/gtfs \
# tell pfaedle where to find the data
pfaedle -x /osm/osm-data.xml -i /gtfs
```
2018-06-09 15:15:05 +00:00
## Debugging
The following flags may be useful for debugging:
2018-06-12 10:52:43 +00:00
* `-T <GTFS TRIP ID>` only calculate shape for a single trip (specified via its GTFS trip id) and output it as GeoJSON to
2018-06-09 15:15:05 +00:00
`<dbg-path>/path.json`
* `--write-graph` write the graph used for routing as GeoJSON to
`<dbg-path>/graph.json`
* `--write-cgraph` if `-T` is set, write the combination graph used for
routing as GeoJSON to `<dbg-path>/combgraph.json`
2018-07-25 18:18:42 +00:00
* `--write-trgraph` write the complete network graph to `<dbg-path>/trgraph.json`
2018-06-09 15:15:05 +00:00
# Configuration
2019-01-10 15:52:59 +00:00
A default configuration file `pfaedle.cfg` can be found in this repo and will be installed with `make install` . Custom configuration files can be specified with the `-c` flag. If no `-c` flag is set, `pfaedle` will parse and merge the following cfg files in the given order (if present): `<install prefix>/etc/pfaedle/pfaedle.cfg` , `$HOME/.config/pfaedle/pfaedle.cfg` , `<CWD>/pfaedle.cfg` . Values given in later files will overwrite earlier defined values.
2018-06-09 15:15:05 +00:00
# Evaluation
2018-06-12 10:52:43 +00:00
You may run an entire evaluation of our testing datasets Vitoria-Gasteiz, Paris, Switzerland and
2018-06-09 15:15:05 +00:00
Stuttgart with
```
mkdir build & & cd build
cmake ..
make -j
make eval
```
2018-08-09 16:41:52 +00:00
*Notes:*
2019-02-04 15:43:32 +00:00
* this will download, and filter, the entire OSM files for Spain and the
2018-06-09 15:15:05 +00:00
Stuttgart region. Make sure you have enough space left on your hard drive.
2018-08-09 16:41:52 +00:00
* in evaluation mode, pfaedle needs significantly more time, because the
calculation of the similarity measurements between shapes are expensive
* if you are only interested in the end results of a single dataset, run
`make <dataset>.lighteval` in `/eval` . For example, `make paris.lighteval`
generates a shaped version of the paris dataset, without doing extensive
comparisons to the ground truth.
* similarily, if you want to run the extensive evaluation for a single dataset,
run `make <dataset>.eval` in `/eval` .
2018-06-09 15:15:05 +00:00
## Evaluation requirements
* zlib
On Debianesque systems, type
```
sudo apt-get install zlib1g-dev
```
2018-07-03 17:27:20 +00:00
to install the dependencies.