- Notifications
You must be signed in to change notification settings - Fork31
Precise map-matching for public transit feeds. Generates high-quality GTFS shapes from OSM data.
License
ad-freiburg/pfaedle
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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.
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.
Precise OpenStreetMap (OSM) map-matching for public transit schedules (GTFS data).First described inthis 2018 SIGSPATIAL paper.
For a quick visual inspection of the shape quality, see for example the schedule data for Germany or Switzerland in our toolTRAVIC.
cmake
gcc >= 5.0
(orclang >= 3.9
)libzip
(optional, for ZIP support)zlib
(optional, for gzip support)libbz2
(optional, for bzip2 support)
Fetch this repository and init submodules:
$ git clone --recurse-submodules https://github.com/ad-freiburg/pfaedle
$ mkdir build&&cd build$ cmake ..$ make -j
To install, type
$ make install
$ pfaedle -x<OSM FILE><GTFS INPUT FEED>
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 theinput feed. To drop all existing shapes, use the-D
flag.
For example, you may generate (and replace existing, see-D
flag) 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$ pfaedle -D -x freiburg-regbez-latest.osm.bz2 VAGFR.zip
To generate shapes for a specific mot only, use the-m
option. Possiblevalues are eithertram
,bus
,coach
,rail
,subway
,ferry
,funicular
,gondola
,all
(default) or GTFS route type codes (0, 1, 2, 3, 4, 5, 6, 7, orextended 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 withroute_type
101
(high speed rail), while-m rail
will match any rail service encoded via a standardroute_type
2
or an extendedroute_type
describing a rail service (e.g.100
,101
,102
, ...).
Multiple values can be specified (comma separated).
pfaedle
comes with the ability to filter OpenStreetMap data. If you specifythe-X
flag,pfaedle
will filter the input OSM file and output a new OSMfile which contains exactly the data needed to calculate the shapes for theinput GTFS feed and the input configuration.
This can be used to avoid parsing (for example) the entireplanet.osm
on eachrun.
You can use theDocker image by mounting the OSM & GTFS data into the container:
$ docker pull ghcr.io/ad-freiburg/pfaedle:latest$ docker run -i --rm \# mount OSM data--volume /path/to/osm/data:/osm \# mount GTFS data--volume /path/to/gtfs/data:/gtfs \# mount default output folder gtfs-out--volume /path/to/output-dir:/gtfs-out \ghcr.io/ad-freiburg/pfaedle:latest \# tell pfaedle where to find the data-x /osm/osm-data.xml.bz2 -i /gtfs/myfeed.zip
The following flags may be useful for debugging:
-T <GTFS TRIP ID>
only calculate shape for a single trip (specified via its GTFS trip id) and output it as GeoJSON to<dbg-path>/path.json
--write-graph
write the graph used for routing as GeoJSON to--write-trgraph
write the complete network graph to<dbg-path>/trgraph.json
A default configuration filepfaedle.cfg
can be found in this repo and will be installed withmake 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.
Note that theshapes.txt
produced bypfaedle
is based on OpenStreetMap data, which is licensed under ODbL 1.0 (seehere). If you copy, distribute, transmit or adapt the shapefied GTFS feed, please credit the contributors of OpenStreetMap.
About
Precise map-matching for public transit feeds. Generates high-quality GTFS shapes from OSM data.