Pl:OpenRailwayMap/API

From OpenStreetMap Wiki
Jump to: navigation, search

Terms of use

OpenRailwayMap is a non-commercial project, financed by donations and run by volunteers. Our infrastructure has a limited capacity, therefore we allow using the API and the tiles under the following conditions:

  • Small scale applications with few or relatively small requests are allowed to use the API and tiles free and without charge.
  • Generally there is no differentiation between commercial and non-commercial applications; however, financial support is highly appreciated.
  • Applications have to send an unique User-Agent (name and website URL) with their requests in order to be able to contact the maintainers them if there are any problems.
  • Users sending large scale API queries or tile requests will be blocked and - if identifiable - contacted.
  • If your application was blocked, we either give you tips on how the required functionality can be set up on your own server, or would allow a further use of our services in exchange for financial support.
  • Most API requests should normally took no longer than 3 seconds. In any case, you should write your application so that it will time out requests after ca. 5 seconds. If multiple requests fail in a row, your application should assume that the service is not available and slow down the rate of attempts.
  • The API limits the rate of requests to a sensible level. The limits are designed to protect the API from too heavy load, and to protect the database contents from harvesting. If your application hits the limits and you'd like to have a larger quota, please get in touch and describe your application's needs in detail.
  • The application may only request data or tiles when it is actively needed by the end-user. If you want to perform bulk requests, add some delays to let your bulk request behave like a human users. And generally try to use as much caching as possible to reduce the load.
  • The availability is generally very good, but there are no guarantees. Remind that this is a free service offered by a non-commercial community project. If you need a full reliable service, you should set up your own instance of this API or tile server.

The OpenRailwayMap data, which comes from from the OpenStreetMap database, is available under the Open Data Commons Open Database License (ODbL). The OpenRailwayMap tiles are available under Creative-Commons license Attribution-ShareAlike 2.0 (CC-BY-SA 2.0).

Using the OpenRailwayMap tiles requires this attribution:

Data <a href="http://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, Style: <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a> <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a>

Using also standard OpenStreetMap tiles as a background map, which is the case if you are including the OpenRailwayMap slippy map into your website, requires this attribution:

Data <a href="http://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, Style: <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a> <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> and OpenStreetMap

If data is requested by using our API, the following attribution is required:

Data <a href="http://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, Service by <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a>

Attributions with text color equal to the background color, very small font sizes, full or partly hidden text and disabled links do not count.

Tiles

The bitmap tiles have a size of 512 x 512 pixels and are in PNG format. The usable resolution is 256 x 256 pixels because the tiles are rendered in "retina" resolution. They can be accessed under this URL:

http://${s}.tiles.openrailwaymap.org/${style}/${z}/${x}/${y}.png

The placeholder ${s} can be replaced by a, b or c to create different domains for faster loading. This domain prefix can also be omitted.

The placeholder ${style} has to be replaced by the name of a rendering style. Currently there are the following styles:

Value Description
standard Default railway layer visualizing infrastructure such as tracks, stations, line numbers, switches, etc.
signals Visualization of railway signals and train protection systems
maxspeed Visualization of railway line maxspeeds and speed signals

Usage in OpenLayers

var openrailwaymap = new OpenLayers.Layer.XYZ("OpenRailwayMap", ["http://a.tiles.openrailwaymap.org/standard/${z}/${x}/${y}.png","http://b.tiles.openrailwaymap.org/standard/${z}/${x}/${y}.png","http://c.tiles.openrailwaymap.org/standard/${z}/${x}/${y}.png"],
{
	sphericalMercator: true,
	opacity: 1,
	visibility: false,
	transparent: true,
	noOpaq: true,
	isBaseLayer: false,
	attribution: "<a href="http://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, Style: <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a> <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> and OpenStreetMap"
});
map.addLayer(openrailwaymap);

Usage in Leaflet

var openrailwaymap = new L.TileLayer('http://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png',
{
	attribution: "<a href="http://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, Style: <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a> <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> and OpenStreetMap",
	minZoom: 2,
	maxZoom: 19,
	tileSize: 256
}).addTo(map);

Usage in OsmAnd

A layer of maxspeeds (downloaded live from the OpenRailwayMap database), based on a pre-installed offline map in OsmAnd 2.0

It only takes a few easy steps to display online OpenRailwayMap tiles on top of a offline OsmAnd map.

In order to perform the following steps, the "Online maps" plugin needs to be enabled. The list of plugins can be accessed via the square symbol in the lower left corner of the main menu (you might have to scroll down a bit and enable "Show all" in the "Plugins" section.

  1. With the Online maps plugin enabled, select the layer symbol in the upper left corner of the main menu.
  2. In the "Configure map" dialog, scroll down to "Overlay map..." or "Underlay map..."
  3. Choose "Install more...", scroll down and you will select the OpenRailwayMap layers desired (OpenRailwayMap, OpenRailwayMap maxspeed, OpenRailwayMap signalling).

Now, you can choose those layers in the overlay/underlay menus.

Hint: With default settings, overlay maps might appear a bit pale. Map transparency can be altered in two days:

  • There is a small scroll bar in the lower mid section of the main screen.
  • You can access the settings menu of the Online map plugin via the square symbol in the lower left corner. Press "Online maps", then choose "Settings", scroll down and select "Overlay transparency" or "Base map transparency".

A full offline usability of OpenRailwayMap in OsmAnd isn't possible yet. The project has not enough resources to offer ready-to-use offline data for downloading. It is possible to generate offline maps yourself, but the necessary stylesheet for OsmAnd has not been written yet. Further details can be found in the OpenRailwayMap repository.


Usage in QGIS

It is possible to use OpenRailwayMap tile overlays in QGIS using the Tile Map Scale Levels plugin and the following XML configuration. The placeholder ${style} has to be replaced by the name of a rendering style. Have a look at the table above for the available style names.

<GDAL_WMS>
	<Service name="TMS">
		<ServerUrl>http://tiles.openrailwaymap.org/${style}/${z}/${x}/${y}.png</ServerUrl>
	</Service>
	<DataWindow>
		<UpperLeftX>-20037508.34</UpperLeftX>
		<UpperLeftY>20037508.34</UpperLeftY>
		<LowerRightX>20037508.34</LowerRightX>
		<LowerRightY>-20037508.34</LowerRightY>
		<TileLevel>19</TileLevel>
		<TileCountX>1</TileCountX>
		<TileCountY>1</TileCountY>
		<YOrigin>top</YOrigin>
	</DataWindow>
	<Projection>EPSG:3857</Projection>
	<BlockSizeX>512</BlockSizeX>
	<BlockSizeY>512</BlockSizeY>
	<BandsCount>4</BandsCount>
	<Cache>
		<Path>/tmp/cache_osm_rail</Path>
	</Cache>
</GDAL_WMS>

API

The OpenRailwayMap provides a RESTful HTTP API which makes it easy to request railway data in OpenStreetMap. Requests are received via GET, the results are returned as JSON data.

The API supports Cross-Origin Resource Sharing (CORS), by sending Access-Control-Allow-Origin: * in the header for each response.

URL parameters and iframes