generate-shapes/README.md

106 lines
4.8 KiB
Markdown
Raw Normal View History

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
2022-08-29 13:25:29 +00:00
[![Build](https://github.com/ad-freiburg/pfaedle/actions/workflows/build.yml/badge.svg)](https://github.com/ad-freiburg/pfaedle/actions/workflows/build.yml)
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).
2022-10-12 10:08:52 +00:00
First described in [this 2018 SIGSPATIAL paper](http://ad-publications.informatik.uni-freiburg.de/SIGSPATIAL_Sparse%20map%20matching%202018.pdf).
2022-04-11 10:38:22 +00:00
For a quick visual inspection of the shape quality, see for example the schedule data for Germany or Switzerland in our tool [TRAVIC](https://travic.app/?z=7&x=1261608.6&y=6430601.6).
2018-06-09 15:15:05 +00:00
## Requirements
* `cmake`
2022-04-11 10:38:22 +00:00
* `gcc >= 5.0` (or `clang >= 3.9`)
2022-10-12 10:08:52 +00:00
* `libzip` (optional, for ZIP support)
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
```
pfaedle -x <OSM FILE> <GTFS INPUT FEED>
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:
```
$ wget https://fritz.freiburg.de/csv_Downloads/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 VAGFR.zip
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
values are either `tram`, `bus`, `coach`, `rail`, `subway`, `ferry`, `funicular`,
2023-04-04 11:49:29 +00:00
`gondola`, `all` (default) or GTFS route type codes (0, 1, 2, 3, 4, 5, 6, 7, or [extended route types](https://developers.google.com/transit/gtfs/reference/extended-route-types)). Integer codes will only match the specific route type, while string codes will match classes of route types. For example, `-m 101` will only match routes with `route_type` `101` (high speed rail), while `-m rail` will match any rail service encoded via a standard `route_type` `2` or an extended `route_type` describing a rail service (e.g. `100`, `101`, `102`, ...).
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
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
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
adfreiburg/pfaedle -x /osm/osm-data.xml -i /gtfs
2020-12-02 16:53:31 +00:00
```
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
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
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.