Skip to content
chosak edited this page Jan 30, 2012 · 8 revisions

Transit Near Me includes a local settings file template (local_settings.py.tmpl) that must be customized for each individual deployment. This file includes a number of standard Django configuration parameters along with some parameter specific to TNM.

Standard settings

See the Django documentation for information on the following standard settings:

  • DEBUG
  • TEMPLATE_DEBUG
  • SITE_ID
  • SECRET_KEY
  • DATABASES
  • ADMINS
  • MANAGERS
  • STATIC_ROOT

django-pipeline settings

TNM makes use of the django-pipeline app for optimizing included JavaScript and CSS files. See that project's documentation for information on the following settings:

  • PIPELINE
  • PIPELINE_AUTO
  • PIPELINE_VERSION

Transit API settings

The TRANSIT_APIS setting is used to configure those APIs that Transit Near Me queries to get real-time next bus/train prediction information. The setting is defined as a dictionary where each key is a descriptive name for an API and each value is a two-value tuple where the first value is the class name of the API class and the second is a list of options to pass to that class on instantiation:

TRANSIT_APIS = {
    'Name': (
        'transitapis.apis.module.ClassName',
        { 'option-name': 'option-value', }
    ),
}

Here's an example of what this entry might look like for WMATA rail and bus service:

TRANSIT_APIS = {
    'Metrorail': (
        'transitapis.apis.wmata.Metrorail',
        { 'key': 'your-api-key-here',
          'gtfs_agency': 'METRO',
          'gtfs_route_type': 1 },
    ),
    'Metrobus': (
        'transitapis.apis.wmata.Metrobus',
        { 'key': 'your-api-key-here', 
          'gtfs_agency': 'METRO',
          'gtfs_route_type': 3 },
    )
}

Note that two separate APIs are defined, one for rail service and one for bus service. Each API is defined by a separate class, and receives a dictionary of options containing a required API key (available from WMATA here). Each API is also configured with gtfs_agency and _gtfs_route_type options which specify how the real-time predictions it produces can be linked with GTFS route and stop data. See the page on data for further details on these options.

See the file tnm/transitapis/apis/_init_.py for more detailed documentation on configuring API classes.

Map tile server settings

The TILE_SERVERS and setting allows for multiple map tile servers to be configured. Configuring the tile server on the backend and passing its configuration to the frontend in a template variable allows for easier configuration and faster switching between tilesets if desired. Use TILE_SERVERS to specify server options and TILE_SERVER to refer to one in particular.

By default, TILE_SERVERS comes with sample configurations for tile servers from MapQuest and CloudMade. Make sure to refer to the licensing/attribution policies of any tile server before using it in an application.

Other Transit Near Me settings

  • TNM_COVERAGE_AREA_DISTANCE_THRESHOLD_IN_MILES

When a call is made to the TNM API to get transit near a location, there are often times that there are no nearby transit options to return. This can either be because the queried location is in a location for which there is no data in the database (say, a different city) or because the queried location just happens to be too far from any of the nearby stations (say, near a highway interchange). It may be useful to distinguish between these two cases of "no transit anywhere near here" and "no transit in this particular spot". This setting is used to distinguish between these two cases.

  • TNM_GEOCODER_KEY

A client using the TNM API may want to call to a geocoding API to translate user-entered addresses to latitude/longitude pairs. Those APIs often require user-specific keys. This setting provides a place to enter that key, if necessary.

Clone this wiki locally