Skip to content
ialokim edited this page Jan 5, 2018 · 1 revision

In order to include (optional) fare information in the resulting GTFS, every city or area need to have a way to define the fares of the public transport. This page aims to define a standardized input format for this information in osm2gtfs.

It is currently only a draft, none of the information is actually supported by osm2gtfs up to now

Please refer to the discussion at #105.

Fares

To complete the GTFS with fare information, cities or areas can create a fares.json which contains all information about prizes of their public transport. It is possible to just put the fares.json in the data directory of osm2gtfs, but for various reasons it is better to publish the file somewhere publicly and define its link in the configuration:

"fares": "https://..." # Link to raw version of fares.json

One way to publish this information is creating a GitHub repository or adding it to the same one the Schedule resides in.

General information

Before starting with the actual fare information, the file needs to define some meta information about itself.

start_date

The date (ISO 8601) when the information starts to be valid. See #111 (recommended)

"start_date": "2018-01-01"

end_date

The date (ISO 8601) when the information ends to be valid. See #111 (recommended)

"end_date": "2018-12-31"

updated

The date (ISO 8601) when the information in this file was updated the last time. See #111 (recommended)

"updated": "2017-12-31"

Line information

Similar to Schedule. lines is a object with the line's ref as the key and an array of trips as the value. Each trip is an object with the following information:

from

The first stop of the trip. Has to be equal to the from tag in OSM. (required)

"from": "Hospital"

to

The last stop of the trip. Has to be equal to the to tag in OSM. (required)

"to": "El Dorado"

via

An intermediate stop of the trip. Has to be equal to the via tag in OSM. (required if present in OSM)

"via": "La Tompson"

stations

An object with all stops of the trip as keys. Should be a subset of the stop_positions present in OSM. The first one has to be equal to the from and the last one equal to the to field.

The values are strings for the fare zone used inside fares. If not all stop_position from OSM are given, osm2gtfs assumes the stops between two given stops are inside the fare zone of the first of the two stops (in the following example, the key La Pelota is thus redundant).

"stations": {
    "Hospital": "Esteli",
    "La Pelota": "Esteli",
    "La Tompson": "La Tompson",
    "El Dorado": "El Dorado"
}

Fare information

General information about fares of this GTFS. All of these keys can be overridden by the same key inside a trip.

currency_type

See the GTFS specification. The currency type (ISO 4217) of the prizes in the GTFS.

Can be overridden by an currency_type inside a trip.

"currency_type": "NIO"

payment_method

See the GTFS specification. Indicates when the fares (generally) must be paid. Valid values for this field are:

  • 0 - Fare is paid on board.
  • 1 - Fare must be paid before boarding.

Can be overridden by an payment_method inside a trip.

"payment_method": "0"

fares

An object with the following key syntax: {fare_zone_from}-{fare_zone_to}. The values are strings containing the prize information to pay for a ride from {fare_zone_from} to {fare_zone_to}, without the currency.

Can be overridden by fares inside a trip.

"fares": {
    "Esteli-Esteli": "5",
    "Esteli-La Tompson": "6",
    "Esteli-El Dorado": "10"
}

Example

Here's a complete example of a valid fares.json:

{
    "start_date": "2018-01-01",
    "end_date": "2018-12-31",
    "updated": "2017-12-31",
    "lines": {
        "10X": [
            {
                "from": "Hospital",
                "to": "El Dorado",
                "via": "La Tompson",
                "stations": {
                    "Hospital": "Esteli",
                    "La Pelota": "Esteli",
                    "La Tompson": "La Tompson",
                    "El Dorado": "El Dorado"
                },
                "fares": {
                    "Esteli-Esteli": "4"
                },
                "payment_method": "0"
            }
        ]
    },
    "currency_type": "NIO",
    "payment_method": "1",
    "fares": {
        "Esteli-Esteli": "5",
        "Esteli-La Tompson": "6",
        "Esteli-El Dorado": "10"
    }
}