Skip to content

Commit

Permalink
Add read-only vector GTFS (General Transit Feed Specification) driver
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 26, 2023
1 parent 986b841 commit bcd4ed2
Show file tree
Hide file tree
Showing 10 changed files with 924 additions and 0 deletions.
Binary file added autotest/ogr/data/gtfs/gtfs_extract.zip
Binary file not shown.
144 changes: 144 additions & 0 deletions autotest/ogr/ogr_gtfs.py

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions doc/source/drivers/vector/gtfs.rst
@@ -0,0 +1,41 @@
.. _vector.gtfs:

GTFS - General Transit Feed Specification
=========================================

.. versionadded:: 3.7

.. shortname:: GTFS

.. built_in_by_default::

This driver can read a .zip archive containing text files following the GTFS
specification.

The driver presents layers with their original structure, and:

- enhances the ``stops`` layer with Point geometries
- enhances the ``trips`` layer with LineString geometries reconstructed by
joining the ``trips`` layer with ``stops`` and ``stop_times`` layers
- expose a ``shapes_geom`` layer, if the optional ``shapes`` is present by
constructing LineString geometries.

Open syntax
-----------

The connection name can be:

- a .zip filename containing GTFS .txt files
- a directory name prefixed with ``GTFS:`` (potentially a
``/vsizip/path/to/the.zip`` filename prefixed with ``GTFS:``)

Driver capabilities
-------------------

.. supports_virtualio::


Links
-----

- `GTFS Wikipedia page <https://en.wikipedia.org/wiki/GTFS>`__
1 change: 1 addition & 0 deletions doc/source/drivers/vector/index.rst
Expand Up @@ -55,6 +55,7 @@ Vector drivers
gpsbabel
gpx
grass
gtfs
hana
idb
idrisi
Expand Down
1 change: 1 addition & 0 deletions frmts/drivers.ini
Expand Up @@ -255,6 +255,7 @@ MapML
HANA
Parquet
Arrow
GTFS

# Put TIGER and AVCBIN at end since they need poOpenInfo->GetSiblingFiles()
Tiger
Expand Down
2 changes: 2 additions & 0 deletions ogr/ogrsf_frmts/CMakeLists.txt
Expand Up @@ -96,6 +96,8 @@ ogr_dependent_driver(cad "OpenCAD" "GDAL_USE_OPENCAD OR GDAL_USE_OPENCAD_INTERNA
ogr_dependent_driver(parquet "Parquet" "GDAL_USE_PARQUET")
ogr_dependent_driver(arrow "Arrow" "GDAL_USE_ARROW")

ogr_dependent_driver(gtfs "GTFS" "OGR_ENABLE_DRIVER_CSV")

# ######################################################################################################################
# proprietary libraries
ogr_dependent_driver(oci "Oracle OCI" "GDAL_USE_ORACLE")
Expand Down
3 changes: 3 additions & 0 deletions ogr/ogrsf_frmts/generic/ogrregisterall.cpp
Expand Up @@ -254,6 +254,9 @@ void OGRRegisterAllInternal()
#ifdef ARROW_ENABLED
RegisterOGRArrow();
#endif
#ifdef GTFS_ENABLED
RegisterOGRGTFS();
#endif

// NOTE: you need to generally insert your own driver before that line.

Expand Down
6 changes: 6 additions & 0 deletions ogr/ogrsf_frmts/gtfs/CMakeLists.txt
@@ -0,0 +1,6 @@
add_gdal_driver(
TARGET ogr_GTFS
SOURCES ogrgtfsdriver.cpp
PLUGIN_CAPABLE NO_DEPS)
gdal_standard_includes(ogr_GTFS)

0 comments on commit bcd4ed2

Please sign in to comment.