Jump to content

Template:OSM/doc

From Wikipedia, the free encyclopedia

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

[edit]

Element types

[edit]

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

[edit]

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

[edit]
Using Nominatim
[edit]

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
[edit]

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

[edit]

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.

[edit]

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 (xjah). 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

[edit]

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

[edit]
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 (xjah) Noyo River Bridge on OpenStreetMap
{{OSM|r|9942914|Noyo Br.}} 9942914 (xjah) 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

[edit]
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:OSM in articles based on its TemplateData.

TemplateData for OSM

Display an external link to a specific data element on OpenStreetMap suitable for inline display

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Element type1

Which of the three core OSM data element types you wish to link to

Suggested values
n w r
Linesuggested
Numeric ID2

The element's numeric ID on OpenStreetMap

Example
9942914
Numbersuggested
Link text3

The text you wish to be linked to the element on OpenStreetMaps

Example
Noyo Bridge
Lineoptional
Suppress tool linkstools

Suppresses the four extra links to external tools shown by default for OSM relation entities when assigned a "falsy" value

Example
off
Booleanoptional
OSM Relation IDrelation

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
Numberoptional

See also

[edit]