Wikivoyage:Geocoding

From Wikivoyage
Jump to: navigation, search

It's possible to encode information about the latitude and longitude of a destination into the destination guide itself. This information will then be used to make special HTML tags to show that the page is related to those lat/long coordinates; some Web spiders and bots use this information to relate a Web page to a geographic location.

Syntax[edit]

19871 of 23587 destination articles have a Geo parameter.

84.246 % complete

For a destination[edit]

The easiest way to add lat/long information to a destination guide article is to use the Geo template. To do so, add the following code to a page:

{{Geo|lat|long}}

Here, lat is the latitude and long is the longitude. Both coordinates must be in decimal form ("45.5", not "45 30 00")--see Converting from traditional format. For example, Montreal contains the code:

{{Geo|45.5|-73.6}}

which renders the map link in the upper righthand corner of that page.

Note that only one instance in a page makes sense.

For a listing[edit]

{{listing | name=Ingleside | alt= | url= | email= | address= | lat=45 | long=-75 | directions= | phone= | tollfree= | fax= | hours= | price= | content= }}

gives:

  •    Ingleside.

...with an icon linking to an OpenStreetMap via Special:Mapsources. As this allows decimal co-ordinates to be specified for every individual listing, it can be useful for pinpointing locations with no street address (such as landmarks surrounded by parkland).

Metadata[edit]

The Resource Description Framework (RDF) format is currently not enabled on Wikivoyage; information is included for historical reasons.

RDF[edit]

Behind the scenes, we used RDF to encode lat/long information into pages. It's possible to add the RDF for lat/long info directly, without using a template. For example:

<rdf>
  <> dcterms:spatial [ pos:lat "45.5" ; pos:long "-73.6" ] .
</rdf></nowiki>

Which means, roughly, "this page covers something with lat/long of 45.5/-73.6".

Results

There's special code on the Wikivoyage server to check for this kind of RDF data and to re-encode it in HTML <meta> tags when the page is shown. This is useful for some Web spiders and other tools that require that the meta tags be set. Adding the page to GeoURL, for example, will bring it up on their geographic search engine.

hCard[edit]

The hCard microformat is currently supported by the {{listing}} template. This provides (lat, long) co-ordinates for each listing in a format which can be read (and downloaded as a .kml file) by the Firefox Operator extension. It also provides a vCard-like format for contact info for each templated listing.

Limitations[edit]

Because the RDF system assigned a single geographic point to the entire destination guide, it was only suited to locations that were a) big enough to have a whole guide to themselves and b) small enough that a single point is a reasonable approximation for the location. This mostly meant that only city guides were amenable to geocoding in this way.

This functionality corresponded to the current {{geo}} tag. Wikivoyage eV now generates world maps based on these co-ordinates, for instance http://maps.wikivoyage-ev.org/w/artmap.php?lang=en which uses the geo tags in Wikivoyage:database dumps.

While it is (as of 2013) possible to assign points to individual listings in a guide using Project:Listings, there is currently no automatically-generated locator map on-site at the local (city/town destination) level. Special:Mapsources will plot one listing on an OpenStreetMap, but not all listings for a city at once on one local map.

Converting from traditional format[edit]

To convert from traditional format like lat=N45°30'0", long=W73°36'0", the following can help:

  • X°Y'Z" = X+(Y/60)+(Z/3600)
  • for S, add "-" to lat; for N, assume "+"
  • for W, add "-" to long; for E, assume "+"

For a listing item[edit]

To encode GPS information for listings in Wikivoyage, you can use the lat and long attributes in the {{listing}} tags or template. Each listing item displays an icon with a link to Special:Mapsources with the supplied decimal co-ordinates.

In future, this information may prove valuable to third-party applications for generating locator maps.

Sources for lat/longs[edit]

There are a few Web sites that provide useful lat/long information.

External links[edit]