GeoMath extension
From Tech
Contents |
License
GPL.
Usage
The GeoMath extension is part of the MapSources extension. The GeoMath extension implements the following functions:
dd2dms
- dd2dms converts degrees to degree-minute-second format. It uses the required coordinate and the optional plus, minus and precision values.
- Application:
{{#dd2dms: 14.5|plus=String for the positive cardinal direction|minus=String for the negative cardinal direction|precision=decimal places}} - Example:
{{#dd2dms: 14.58|precision=4}}gives 14° 34' 48" - Example:
{{#dd2dms: 14.58|precision=2}}gives 14° 35'
- Application:
Degree values can be both sexagesimal and decimal.
Strings for the cardial directions will be added to the dms value. They can be empty, single letters or strings and will be added at the end of the conversion result. If the original value is graeter or equal zero, the plus string is added, otherwise the minus string is used.
deg2dd
- deg2dd converts degrees to decimal-degree format.
- Application:
{{#deg2dd: 14° 23' 45''|precision=decimal places}} - Example:
{{#deg2dd: 14° 23' 45'' S|precision=3}}gives -14.396
- Application:
geoLink
The third function, geoLink, can be used to convert a complete geographic coordinate without reapplying the dd2dms function:
- geoLink replaces a string pattern with coordinates.
- Application:
{{#geoLink: pattern|lat=10.5|long=20.5|plusLat=N|plusLong=E|minusLat=S|minusLong=W|precision=decimal places}}
- Application:
The following example shows how to write a template showing a text link to a Map Sources special page:
{{#geoLink: [http://www.wikivoyage.org/w/tech/index.php?title=Special:Mapsources¶ms=$1_$2{{#if:
{{{scale|}}}|_scale:{{{scale}}}|_scale:100000}}{{#if: {{{type|}}}|_type:{{{type}}}}}{{#if:
{{{globe|}}}|_globe:{{{globe}}}}}{{#if: {{{region|}}}|_region:{{{region}}}}} $3 $4]
|lat={{{1|}}}|long={{{2|}}}
|plusLat=N
|minusLat=S
|plusLong=E
|minusLong=W
|precision={{{precision|4}}}}}
The pattern string can obtain upto four different place holders $1 ... $4.
- $1 means the latitude in Wikipedia syntax including the direction letter like 51.2323_N.
- $2 means the longitude in Wikipedia syntax including the direction letter like 51.2323_E.
- $3 means the latitude in degree, minute and second format considering the strings for the cardinal directions and the precision, see also dd2dms.
- $4 means the longitude in degree, minute and second format considering the strings for the cardinal directions and the precision, see also dd2dms.
Sexagesimal coordinate format
You can enter coordinates in the sexagesimal system in the following way:
deg[°] [min['] [sec['']]] [N|S|E|W]
deg, min, sec mean the degree, minute and second values, respectively. The designations can be omitted, but the succession must be kept.
There are alternative characters for the designations in the following way:
| Meaning | Characters |
|---|---|
| Degree | ° |
| Minute | ' ‘ ’ ′ |
| Second | " '' “ ” |
| Minus | - − |
Installing GeoMath
Donwload from svn:mediawiki/trunk/extensions/GeoMath. Copy GeoMath.php into the GeoMath folder in the extensions folder of your MediaWiki installation. Then add the following line to your LocalSettings.php file (near the end):
require_once( "$IP/extensions/GeoMath/GeoMath.php" );
Used messages
Message strings ― noted in GeoMath.i18n.php ― are available now for three languages (de, en, and pl).
<?php /** * Internationalisation file for GeoMath extension. * * @package MediaWiki * @subpackage Extensions */ $wgGeoMathMessages = array(); $wgGeoMathMessages['en'] = array( 'geoMathMissingOperand' => 'Missing operand', 'geoMathIncorrectInput' => 'Incorrect input', ); $wgGeoMathMessages['de'] = array( 'geoMathMissingOperand' => 'Fehlende(r) Parameter', 'geoMathIncorrectInput' => 'Fehlerhafte Eingabe', ); $wgGeoMathMessages['fr'] = array( 'geoMathMissingOperand' => 'Opérateur(s) manquant(s)', 'geoMathIncorrectInput' => 'Entrée erronée', ); $wgGeoMathMessages['it'] = array( 'geoMathMissingOperand' => 'Parametro mancante', 'geoMathIncorrectInput' => 'Input non corretto', ); $wgGeoMathMessages['pl'] = array( 'geoMathMissingOperand' => 'Brak parametru(ów)', 'geoMathIncorrectInput' => 'Błędne dane', ); ?>
Updates
- 2007/11/21: Polish strings added

