Template:Coord/doc

From Zoophilia Wiki
Revision as of 01:01, 26 January 2017 by meta>ClemRutter (Inserted description if two helper functions- a proof of concept if you like, but from a developers POV I feel this should be somewhere on the page.)
Jump to navigationJump to search

Quick guide

Quick how to

To add Lua error: callParserFunction: function "#coordinates" was not found. to the top of an article, use {{Coord}}, thus:

{{Coord|57|18|22|N|4|27|32|W|display=title}}

These coordinates are in degrees, minutes, and seconds of arc.

"title" means that the coordinates will be displayed next to the article's title at the top of the page and before any other text or images.

To add Lua error: callParserFunction: function "#coordinates" was not found. to the top of an article, use either

{{Coord|44.1124|N|87.9130|W|display=title}}

(which does not require minutes or seconds but does require the user to specify north/ south and east/west) or

{{Coord|44.1124|-87.9130|display=title}}

(in which the north and east are presumed by positive values while the south and west are negative ones) These coordinates are in decimal degrees.

  • Degrees, minutes and seconds, when used, must each be separated by a pipe ("|").
  • Map datum must be WGS84 (except for off-Earth bodies).
  • Avoid excessive precision (0.0001° is <11 m, 1″ is <31 m).
  • Maintain consistency of decimal places or minutes/seconds between latitude and longitude.
  • Latitude (N/S) must appear before longitude (E/W).

Optional coordinate parameters follow the longitude and are separated by an underscore ("_"):

Other optional parameters are separated by a pipe ("|"):

  • display
    |display=inline (the default) to display in the body of the article only,
    |display=title to display at the top of the article only, or
    |display=inline,title to display in both places.
  • name
    name=X to label the place on maps (default is PAGENAME)

Thus: {{Coord|44.1172|-87.9135|dim:30_region:US-WI_type:event

|display=inline,title|name=accident site}}

Use |display=title (or |display=inline,title) once per article, for the subject of the article, where appropriate.


Purpose

{{Coord}} provides a standard notation for encoding locations by their latitude and longitude coordinates. It is primarily for specifying the WGS84 geographic coordinates of locations on Earth, at the same time emitting a machine-readable Geo microformat. However, it can also encode locations on natural satellites, dwarf planets, and planets other than Earth.

See also Wikipedia:WikiProject Geographical coordinates.

Features

Latitude and longitude may be specified (with appropriate precision) either in decimal notation or as degrees/minutes/seconds. By default, coordinates appear in the format used to specify them. However, the format= parameter can be used to force display in a particular format.

The template displays the formatted coordinates with a hyperlink to GeoHack. GeoHack displays information customized to the location, including links to external mapping services.

For terrestrial locations, a blue globe () appears to the left of the hyperlink. Clicking on the globe activates the WikiMiniAtlas (requires JavaScript).

By default, coordinates appear "in line" with the adjacent text. However, the display= parameter can be used to move the coordinates up near the page title—or display them in both places at once.

The template outputs coordinates in three formats:

  • Degree/minutes/seconds ("DMS", precision is degrees, or degrees/minutes, or degrees/minutes/seconds, based on input precision).
  • Decimal degrees (varying the number of decimal places based on input precision)
  • A machine readable Geo microformat.

Logged-in users can customize how coordinates appear in their browsers.

You can extract information from the Coord template for use in mathematical expressions. For details, see Module:Coordinates.

Caveats

The template must not be modified without prior discussion.

Tools which read Wikipedia database dumps (such as Google Earth) often ignore inline coordinates. To ensure that coordinates are seen by these tools, one set should be displayed beside the title. See How do I get my Wikipedia article to show up in the Google Earth Geographic Web layer?. However, if multiple title coordinates appear on a single page, they will overlap, making them illegible.

Superseded templates

This single template supersedes {{coor d}}, (and others in that family which have since been redirected to it), plus the Geolinks and Mapit templates. Most parameters can be used as before – see Usage.

Examples:

{{coord|10.2|N|-20.3|E|type:city}}Replaces {{coor d|10.2|N|-20.3|E|city}}
{{coord|44.4|-111.1|type:city_region:US|display=inline,title}}Replaces {{Geolinks-US-cityscale|44.4|-111.1}}
{{coord|51.01234|-1.56789|type:landmark_region:GB|display=inline,title}}Replaces {{Geolinks-UK-buildingscale|51.01234|-1.56789}}
{{coord|-35.5|150.1|type:landmark_region:AU|display=inline,title}}Replaces {{Mapit-AUS-suburbscale|lat=-35.5|long=150.1}}
{{coord|12|34|12|N|45|33|45|W|display=title}}Replaces {{CoorHeader|12|34|12|N|45|33|45|W}}

Usage

{{coord|latitude|longitude|coordinate parameters|template parameters}}
{{coord|dd|N/S|dd|E/W|coordinate parameters|template parameters}}
{{coord|dd|mm|N/S|dd|mm|E/W|coordinate parameters|template parameters}}
{{coord|dd|mm|ss|N/S|dd|mm|ss|E/W|coordinate parameters|template parameters}}

The hemisphere identifiers (N/S) and (E/W), if used, must be adjacent to the enclosing pipe "|" characters, and cannot be preceded or succeeded by spaces.

There are two kinds of parameters, all optional:

  • Coordinate parameters are parameters that {{Coord}} passes to the map server. These have the format parameter:value and are separated from each other by the underscore character ( _ ). The supported coordinate parameters are dim:, globe:, region:, scale:, source:, and type:. See coordinate parameters for details and examples.
  • Template parameters are parameters used by the {{Coord}} template. These have format parameter=value and are separated from each other by the pipe character ( | ). The supported template parameters are display=, format=, name=, and notes=.
  • display= can be one of the following:
  • display=inline – Display the coordinate inline (default)
  • display=title – Display the coordinate at the top of the article, beside the article's title (replaces {{coor title dms}} family)
    • shortcut: display=t
  • display=inline,title – Display the coordinate both inline and beside the article's title (replaces {{coor at dms}} family)
    • shortcut: display=it
  • display=title,inline has the same effect as display=inline,title
Note: the title attribute indicates that the coordinates apply to the entire article, and not just one of (perhaps many) places mentioned in it — so it should only be omitted in the latter case.
  • format= can be used to force dec or dms coordinate display.
  • format=dec reformats the coordinates to decimal degrees format.
  • format=dms reformats the coordinates to degrees | minutes | seconds format.
  • name= can be used to annotate inline coordinates for display in map services such as the WikiMiniAtlas. If omitted, the article's title (PAGENAME) is assumed.
Note: a name= parameter causes {{Coord}} to emit an hCard microformat using that name, even if used within an existing hCard. Do not use when the name is that of a person (e.g for a gravesite), as the generated hCard would be invalid. Also, do not use square brackets in names.
  • notes= specifies text to be displayed immediately following the coordinates. This is primarily intended for adding footnotes to coordinates displayed beside the title.

Helper functions

Helper functions are available to manipulate tho output from {{Coord}} when it appears in a container template such as an infobox.

To extract the latitude from a Coord template

Use:

{{#invoke:coordinates|coord2text|{{Coord|57|18|22|N|4|27|32|E}}|lat}} → 57.30611

and similarly to extract the longitude, use:

{{#invoke:coordinates|coord2text|{{Coord|57|18|22|N|4|27|32|E}}|long}} → 4.45889

Displaying all coordinate links on one map

The template {{GeoGroup}} can be used in an article with coordinates. This template creates links to mapping services which display all the coordinates on a single map, and links to other services which allow the coordinates to be used or downloaded in a variety of formats.

Examples

{{coord|43.651234|-79.383333}} Lua error: callParserFunction: function "#coordinates" was not found. Toronto – Fully decimal – western hemisphere implied by negation
{{coord|43.65|-79.38}} Lua error: callParserFunction: function "#coordinates" was not found. Toronto – low precision decimal
{{coord|43.6500|-79.3800}} Lua error: callParserFunction: function "#coordinates" was not found. Toronto – medium precision decimal with trailing zeroes
{{coord|43.653500|N|79.384000|W}} Lua error: callParserFunction: function "#coordinates" was not found. Toronto – high precision decimal with explicit hemisphere notation
{{coord|43|29|N|79|23|W}} Lua error: callParserFunction: function "#coordinates" was not found. Toronto – degrees & minutes
{{coord|43|29|13|N|79|23|02|W}} Lua error: callParserFunction: function "#coordinates" was not found. Toronto – degrees, minutes & seconds
{{coord|43|29|12.6|N|79|23|02.4|W}} Lua error: callParserFunction: function "#coordinates" was not found. Toronto – degrees, minutes, seconds & fractions of seconds
{{coord|55.752222|N|37.615556|E}} Lua error: callParserFunction: function "#coordinates" was not found. Moscow – N & E
{{coord|55.752222|N|37.615556|E|format=dms}} Lua error: callParserFunction: function "#coordinates" was not found. Convert to dms format
{{coord|39.098095|-94.587307|format=dms}} Lua error: callParserFunction: function "#coordinates" was not found. Decimal conversion without N/S/E/W
{{coord|55.752222|N|37.615556|E|format=dec|name=Moscow}} Lua error: callParserFunction: function "#coordinates" was not found. Convert to decimal and label on some maps
{{coord|33|55|S|18|25|E}} Lua error: callParserFunction: function "#coordinates" was not found. Cape Town – S & E
{{coord|35|00|N|105|00|E}} Lua error: callParserFunction: function "#coordinates" was not found. People's Republic of China
{{coord|22|54|30|S|43|14|37|W}} Lua error: callParserFunction: function "#coordinates" was not found. Rio – S & W
{{coord|22|S|43|W}} Lua error: callParserFunction: function "#coordinates" was not found. A degree confluence.
{{coord|52|28|N|1|55|W|region:GB_type:city|notes=<ref>{{cite web|url=http://www.fallingrain.com/world/UK/0/Birmingham.html|title=Birmingham}}</ref>|display=inline,title}} Lua error: callParserFunction: function "#coordinates" was not found. Birmingham – with display, notes, and parameter settings; note that these coordinates are also displayed at the top of this page.

References

  1. "Birmingham".

Coordinate parameters

The first unnamed parameter following the longitude is an optional string of coordinate parameters, separated by underscores. These parameters help GeoHack select suitable map resources, and they will become more important when Wikimaps becomes fully functional.

type:T

{{Wikipedia:WikiProject Geographical coordinates/type:}}

scale:N

{{Wikipedia:WikiProject Geographical coordinates/scale:}}

dim:D

The dim: parameter defines the diameter of a viewing circle centered on the coordinate. While the default unit of measurement is metres, the km suffix may be appended to indicate kilometres.

GeoHack uses dim: to select a map scale such that the viewing circle appears roughly 10 centimetres (4 in) in diameter on a 72 dpi computer monitor. If no dim:, type:, or scale: parameters are provided, GeoHack uses its default viewing circle of 30 kilometres (19 mi).

Samples
Subject View diameter Markup Result
Western Hemisphere 10,000 kilometres (6,200 mi) {{coord|0|N|90|W|dim:10000km}} Lua error: callParserFunction: function "#coordinates" was not found.
Ohio 400 kilometres (250 mi) {{coord|40.5|-82.5|dim:400km}} Lua error: callParserFunction: function "#coordinates" was not found.
Dresden 20,000 metres (12 mi) {{coord|51.03|13.73|dim:20000}} Lua error: callParserFunction: function "#coordinates" was not found.
Statue of Liberty 100 metres (330 ft) {{coord|40.6892|-74.0445|dim:100}} Lua error: callParserFunction: function "#coordinates" was not found.
region:R

{{Wikipedia:WikiProject Geographical coordinates/region:}}

globe:G

{{Wikipedia:WikiProject Geographical coordinates/globe:}}

source:S

{{Wikipedia:WikiProject Geographical coordinates/source:}}

Per-user display customization

To always display coordinates as DMS values, add this to your common.css: <syntaxhighlight lang="css" style="display:table; padding:0.5em; margin-left:1em; border-radius:2px"> .geo-default { display: inline } .geo-nondefault { display: inline } .geo-dec { display: none } .geo-dms { display: inline } </syntaxhighlight>

To always display coordinates as decimal values, add this to your common.css: <syntaxhighlight lang="css" style="display:table; padding:0.5em; margin-left:1em; border-radius:2px"> .geo-default { display: inline } .geo-nondefault { display: inline } .geo-dec { display: inline } .geo-dms { display: none } </syntaxhighlight>

To display coordinates in both formats, add this to your common.css: <syntaxhighlight lang="css" style="display:table; padding:0.5em; margin-left:1em; border-radius:2px"> .geo-default { display: inline } .geo-nondefault { display: inline } .geo-dec { display: inline } .geo-dms { display: inline } .geo-multi-punct { display: inline } </syntaxhighlight>

If CSS is disabled, or you have an old copy of MediaWiki:Common.css cached, you will see both formats. (You can either clear your cache or manually refresh this URL: [1].)

To disable display of the blue globe adjacent to coordinates, add this to your common.js: <syntaxhighlight lang="javascript" style="display:table; padding:0.5em; margin-left:1em; border-radius:2px"> var wma_settings = {enabled:false} </syntaxhighlight> Note that this will disable WikiMiniAtlas.

See also Wikipedia:Manual of Style (dates and numbers)#Geographical coordinates.

Incorrect uses and maintenance category

The template has some input checks built in. Most errors display a bold, red message inline and categorize the article in the hidden maintenance category Pages with malformed coordinate tags. There are currently 0 pages in that category. See the category description for further instructions.

A more thorough daily report of coordinates needing repair is at tools:~dispenser/view/File viewer#log:coord-enwiki.log.

See also: WT:GEO#To do

Internals

See Template:Coord/doc/internals and Category:Coord template.

Subtemplates

Template:Coord/sub doc

Coordinates in PDF

For generating PDF, printed books, and Open Office export format, two templates are substituted for the regular templates:

Samples are available at:

Class names

The class names geo, latitude and longitude are used to generate the microformat and MUST NOT be changed.

Template Data

This template uses overloading which does not work well with the VisualEditor/TemplateData. Consider using "Edit source" instead of the visual editor until this defect is corrected. To facilitate visual editing in the mean time, consider using {{coordDec}} for signed decimal degrees, {{coordDMS}} when degrees minutes and seconds are specified, and {{coordDM}} when just degrees and minutes are given.

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for this template in articles based on this TemplateData.

TemplateData for Coord

Encodes the latitude and longitude coordinates of a location, provides a link to map of the location. This template does not work well with the Visual Editor, consider using {{coordDec}} for signed decimal degrees, {{coordDMS}} when degrees minutes and seconds are specified {{coordDM}} when only degrees and minutes are specified. To use this template you will need to use positional parameter following one of these schemes: {{coord | D | M | S | NS | D | M | S | EW | geo | opts}}, {{coord | D | M | NS | D | M | EW | geo | opts}}, {{coord | D| NS | D| EW | geo | opts}} {{coord | sD | sD | geo | opts}} where D is degrees, M is minutes, S seconds, sD signed decimal degrees, NS is N or S, EW is E or W, opts are named parameter and geo are the coordinate parameters described on the main doc page.

Template parameters

ParameterDescriptionTypeStatus
11

Either degrees latitude or a signed decimal degrees latitude

Numberrequired
22

Either: minutes latitude, signed decimal degrees longitude or 'N' or 'S'.

Stringrequired
33

Either: second latitude, degrees longitude, 'N' or 'S' or GeoHack parameters

Stringoptional
44

Either: degrees longitude, 'N', 'S', 'E' or 'W' or GeoHack parameters

Stringoptional
55

Either: degrees longitude, minutes longitude or GeoHack parameters

Stringoptional
66

Either: minutes longitude, 'E' or 'W' or GeoHack parameters

Stringoptional
77

Either second longitude, or GeoHack parameters

Stringoptional
88

'E' or 'W'.

Stringoptional
99

GeoHack parameters. Example: dim:30_region:US-WI_type:event

Stringoptional
Displaydisplay

Where it is displayed. Can be one of: 'inline' in the body of the article, 'title' at the top of the article or 'inline,title' both

Default
inline
Stringoptional
Namename

a label to place on maps (default is PAGENAME)

Stringoptional
Notesnotes

text displayed immediately following the coordinates

Stringoptional
Formatformat

How the coordinates are displayed, either 'dec' or 'dms'

Stringoptional