Template:OSM/doc
This is a documentation subpage for Template:OSM. It may contain usage information, categories and other content that is not part of the original template page. |
Use this template for consistent linking to OpenStreetMap elements, particularly for OSM relations that represent a route or place. The basic form of the link it produces is…
- Numeric ID Name on OpenStreetMap
…with the element's numeric id shown first—linked to itself on OpenStreetMap—followed by the title of the wiki page it appears on (or, optionally, some other text) and then a link to the OpenStreetMap entry on Wikipedia.
OpenStreetMap elements
Element types
All data present in OpenStreetMap consists of three types of core data elements:
- Nodes: individual geographic positions, each with a unique and precise latitude and longitude
- Ways: two or more nodes linked serially to form lines (which can be "open," with different nodes used for its beginning and end, or "closed," where the same node is used for its start- and endpoints, to define bounded areas or objects)
- Relations: a semantic group of "member" nodes, ways and even other relations, each with assigned roles, representing logical (local) or geographic elements on the map
Numeric IDs
Each element is also assigned a numeric id (a signed 64-bit integer, specifically) which is unique only within its element type (i.e. there is both a node and a way with numeric id 100 and they are completely unrelated). They can be found either by using Nominatim or the standard OSM in-browser map interface (known as "iD").
Discovering OSM numeric IDs
Using Nominatim
Nominatim is the official debugging interface for the search engine used on the OpenStreetMap website. There you can search for the map element you wish to link to by name and upon locating it, click the Details… link to display tabular data which will list its ID number.
Using iD
iD is the name of the in-browser map interface available on the OSM home page. You can learn the numeric id of an element there by zooming in sufficiently that it fills the majority of your browser screen and then activating the 'Query features' mode by clicking the button on the right edge of the map and then clicking on the map element you wish to identify. The frame on the left will load a list of the data elements near where you clicked, and will highlight each one on the map as you hover over it with the pointer. Once you've identified the element you want, click it to load its details; the new boldface text at the top of the left frame will show the element's numeric ID (highlighted in the example below) enclosed in parentheses, following its type and name, in the format:
- Type: Name (Numeric ID)
Usage
The standard use of this template uses two or three unnamed (positional) parameters, in the form of:
{{OSM|type|numeric ID|name (optional)}}
You must specify both an element's type and numeric ID as parameters to the template. The type must be specified first, using the first letter of its English name (node: n
, way: w
, relation: r
), and the numeric ID must follow it as the second. Lastly, if you wish to use something other than the title of the transcluding page as the text that follows the link (such as a local name for the element), it may be supplied as a third parameter. Examples are provided below.
If your optional name text includes an equality symbol (=
), it must be defined instead as the value to the named |3=name
parameter. The other required parameters may likewise be assigned to |1=type
and |2=numeric ID
, though this is rarely necessary.
Links to relations
Links to OpenStreetMap relation elements are handled differently than the other two data types, as they (typically) represent larger amounts of more varied information. The default output for a relation entity will include four additional links—each consisting of a single letter—following the linked numeric ID and enclosed in parentheses as
. They are shortcuts, respectively, to:- x: the raw XML data record of the element returned by the current OpenStreetMap API v0.6
- j: the OSM JSON API version of the same data, for use with JSON-consumptive tooling
- a: the OSM Relation Analyzer which offers a human-readable format of the relation data, with some basic derived information added where possible
- h: the OSM History Browser, an analogue to Wikipedia page histories, with a record of its membership and metadata tag changes over time, if any
Alternative output modes
If a link created by this template to an OSM relation will be in a location where the additional links would not be helpful, their presence can be suppressed by passing a "falsy" Boolean value to the |tools=
parameter. This may be any case-insensitive form of:
false
off
no
n
0
Going one step further, relations also have a "bare" output format that can be invoked by supplying the relation's numeric ID as the value to a single, named |relation=numeric ID
parameter. This suppresses everything save the initial linked numeric value, relying on the editor to provide any additional context in situ.
Examples
Element type |
Wikitext | Output |
---|---|---|
Node | {{OSM|n|7530096619}}
|
7530096619 Glen Blair Junction on OpenStreetMap |
{{OSM|n|7530096619|Glen Blair}}
|
7530096619 Glen Blair on OpenStreetMap | |
Way | {{OSM|w|10273762}}
|
10273762 Fort Bragg-Sherwood Road on OpenStreetMap |
{{OSM|w|10273762|Sherwood Rd.}}
|
10273762 Sherwood Rd. on OpenStreetMap | |
Relation | {{OSM|r|9942914}}
|
9942914 Noyo River Bridge on OpenStreetMap |
{{OSM|r|9942914|Noyo Br.}}
|
9942914 Noyo Br. on OpenStreetMap | |
Alternative output formats (sans tools / bare) | ||
{{OSM|r|9942914|tools=off}}
|
9942914 Noyo River Bridge on OpenStreetMap | |
{{OSM|relation=9942914}}
|
9942914 | |
Any | With problematic custom name text | |
{{OSM|w|10273762|3=Sherwood Rd. (within city limits = E. Oak St.)}}
|
10273762 Sherwood Rd. (within city limits = E. Oak St.) on OpenStreetMap |
TemplateData
TemplateData for OSM
<templatedata>{ "description": "Display an external link to a specific data element on OpenStreetMap suitable for inline display", "format": "inline", "paramOrder": [ "1", "2", "3", "tools", "relation" ], "params": { "1": { "label": "Element type", "description": "Which of the three core OSM data element types you wish to link to", "type": "line", "suggestedvalues": [ "n", "w", "r" ], "suggested": true }, "2": { "label": "Numeric ID", "description": "The element's numeric ID on OpenStreetMap", "example": "9942914", "type": "number", "suggested": true }, "3": { "label": "Link text", "description": "The text you wish to be linked to the element on OpenStreetMaps", "example": "Noyo Bridge", "type": "line" }, "relation": { "label": "OSM Relation ID", "description": "The numeric id of the relation you wish to link to, producing a bare output format consisting of only the linked numeric ID; overrides all other parameters.", "example": "9942914", "type": "number" }, "tools": { "label": "Suppress tool links", "description": "Suppresses the four extra links to external tools shown by default for OSM relation entities when assigned a \"falsy\" value", "example": "off", "type": "boolean" } } }</templatedata>
See also
- {{Cite OpenStreetMap}}
- {{OSM location map}}
- {{OSM relation}}
- {{Osmway}}
- WikiProject OpenStreetMap