Skip to content
Peter Johnson a.k.a. insertcoffee edited this page Dec 5, 2015 · 16 revisions

What is a geocoder and why do I want one?

The OTP journey planning API only understands latitude and longitude coordinates and internal stop IDs from GTFS feeds as start and end points. In order to support place names, an OTP client must use an external web service called a geocoder which converts text into geographic coordinates. The client then uses those coordinates when talking to the OTP trip planning API.

Setting up your OTP server to use a geocoder

Configuring the geocoder servlet (needed for all clients)

You need to deploy an additional servlet called otp-geocoder (opentripplanner-geocoder in the older module layout). That servlet is configured (via its application-context.xml) with the url of the geocoding service you want to use. The OTP client talks to otp-geocoder (usually hosted on the same servlet container as the OTP trip planning API) and otp-geocoder in turn talks to the main geocoding service.

  1. Add the module otp-geocoder (opentriplanner-geocoder in the old module layout) to your servlet container (e.g. Tomcat).

  2. Optional: in src/main/resources/org/opentripplanner/geocoder/application-context.xml , you can change the geocoder that is used by changing the property on line 84 to geocoderUSCSV or geocoderGoogle or geocoderYahoo (the three other geocoders that are supported so far). By default it uses Nominatim.

Configuring the openlayers client to use a geocoder

These instructions are for the older openlayers-based OTP client located in the module otp-openlayers-client (opentripplanner-webapp in the old module layout).

  1. In src/main/webapp/js/otp/config.js file, around line 37, change the property of the geocoder enabled from false to true

  2. Double check the url parameter (line 38) in config.js. It should be set to "otp-geocoder/geocode" (or "/opentripplanner-geocoder/geocode" in the old module layout).

  3. You have to comment the line 41 'fromToOverride...' in config.js so that the text boxes to input the addresses appear in the form.

Configuring the Leaflet client to use a geocoder

These instructions are for the newer leaflet-based OTP client located in the module otp-leaflet-client (opentripplanner-leaflet-client in the old module layout). Edit the geocoders section of /otp-leaflet-client/src/main/webapp/js/otp/config.js to tell the client about your geocoder servlet:

geocoders : [
    {
        'name': 'geocoder',
        'className': 'otp.core.Geocoder',
        'url': '/otp-geocoder/geocode',
        'addressParam': 'address'
    }
]

The url in config.js refers to the local url of the OTP geocoder module, so if you're serving locally a master branch build, that should be: http://localhost:8080/otp-geocoder/geocode

If you are using the stable branch (old module layout), then the geocoder would be at: http://localhost:8080/opentripplanner-geocoder/geocode

You should be able to test it out with a query, like: http://localhost:8080/otp-geocoder/geocode?address=city%20hall

or something like that, if your addressParam is 'address'.

The url for the Nominatim server you're using is set in the geocoder's application-context.xml, which unless it's been changed, should be the MapQuest server's address.

A list of other geocoder services out there

Pelias Geocoder by Mapzen

https://mapzen.com/documentation/search/

Their API is available at https://search.mapzen.com/v1, it requires signing up for a free API key which provides generous rate-limits.

OSM Nominatim

http://nominatim.openstreetmap.org

http://nominatim.openstreetmap.org/search?q=834+SE+Lambert+St

http://wiki.openstreetmap.org/wiki/Nominatim

OSM Gazetteer

http://gazetteer.openstreetmap.org/namefinder/ OSM

http://gazetteer.openstreetmap.org/namefinder/?find=834+SE+Lambert+St


OSS GeoCoder using OSM & geonames data (Java/Solr/PostGIS/Mvn)

http://www.gisgraphy.com/


"Simple OSM Geocoder"

http://github.com/brianw/osmgeocode


**J Spatial **

http://www.ibm.com/developerworks/opensource/library/j-spatial/index.html

Open Data

GeoNames (services: http://www.geonames.org/export/ws-overview.html)

http://wiki.osgeo.org/wiki/Public_Geospatial_Data_Project


Misc

http://dogg.ie/read/simple-osm-geocoder

http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/gazetteer/

http://www.geocoder.com.uy/geocoder_servicios.php

The documentation on this wiki is outdated and should not be used

unless you are intentionally working with legacy versions of OpenTripPlanner. Please consult the current documentation at readthedocs

Clone this wiki locally