MapSources extension

From Tech

Jump to: navigation, search

This extension shall give access to several data and mapping sources.

Contents

License

GPL.

Test Examples

Installing MapSources

Download the MapSources extension from the SVN repository. It contains and requires the GeoMath extension.

Copy GeoMath.php, GeoMath.i18n.php (decimal and sexagesimal input and conversion), GeoTransform.php (conversion from decimal to the Universal Transverse Mercator projection), MapSources.php, MapSources.class.php and MapSources.i18n.php (Map Sources special page) 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/MapSources.php" );

Customization

Map Sources special page uses the Project:Map Sources as a master copy. It uses place holders as described below. The name of this project page is taken from the mapsources message string of the content language.

  • English wikis: Project:Map Sources
  • French wikis: Project:Sources de cartes
  • German wikis: Project:Karten- und Datenquellen
  • Italian wikis: Project:Fonte della mappa
  • Polish wikis: Project:Mapy

The text language will not be changed by the user language, it depends only on the content language. Therefore, you must have only one project page per wiki.

URL and search parameters

Two different types of input parameter sets are accepted:

  • The Wikipedia Georeference code like
    • 51.5_N_0.125_W_scale:10000_region:UK
  • A comma- or semicolon-separated list of latitude, langitude, and parameters. Latitude and langitude can be written in decimal or sexagesimal forms, ie deg[°] [min['] [sec['']]] [N|S|E|W]. The parameters must be separated by spaces or underscores. The parameter name and its value are separated by a colon “:” or an equal sign “=”. Example:
    • 51.5,-0.125,scale:10000 region=UK

Parameters

scale:N

Sets the desired map scale as 1:N. This will override the default scale 1:100.000 or the type.

type:T

Sets the type of this location, which will be used for the reverse mapping of the points. Will also set the default map scale. Types are:

Type Description Scale
country (e.g. "type:country") 1:10,000,000
state Where applicable 1:3,000,000
adm1st Administrative unit of country, 1st level (province, county) 1:1,000,000
adm2nd Administrative unit of country, 2nd level 1:300,000
city City, town or village, unspecified population. Will be treated as a minor city. 1:100,000
mountain peaks, mountain passes 1:100,000
isle 1:100,000
waterbody Bays, fjords, lakes, glaciers, inland seas... 1:100,000
airport 1:30,000
landmark Cultural landmark, building of special interest, tourist attraction and other points of interest. 1:10,000

dim:D

Specifies the size of a location by meters. Not yet supported.

region:R

Sets the preferred map region of coverage, used in selecting appropriate map resources for the area. The region should be supplied as either a two character ISO 3166-1 alpha-2 country code, or an ISO 3166-2 region code. Examples:

  • US
  • DE
  • DE-BB (Brandenburg state in Germany)

globe:G

Specifies other worlds than earth. Such as Moon or other planets.

precision:P

Specifies the number of valid decimal places of the coordinate. Default value is 6.

Place Holders

Type Description
{latdegdec} Decimal value of the latitude like -0.125 or 51.5.
{latdegabs} Unsigned value of the latitude like 0.125 or 51.5.
{latdegint} Integer value of the latitude like 0 or 51.
{latmindec} Decimal value of the latitude's minute like 30.0 or 7.5.
{latminint} Integer value of the latitude's minute like 30 or 7.
{latsecdec} Decimal value of the latitude's second like 30.0 or 7.5.
{latsecint} Integer value of the latitude's second like 30 or 7.
{latNS} Latitude direction N or S.
{londegdec} Decimal value of the longitude like -0.125 or 51.5.
{londegabs} Unsigned value of the longitude like 0.125 or 51.5.
{londegneg} Negative decimal value of the longitude like 0.125 or -51.5.
{londegint} Integer value of the longitude like 0 or 51.
{lonmindec} Decimal value of the longitude's minute like 30.0 or 7.5.
{lonminint} Integer value of the longitude's minute like 30 or 7.
{lonsecdec} Decimal value of the longitude's second like 30.0 or 7.5.
{lonsecint} Integer value of the longitude's second like 30 or 7.
{lonEW} Longitude direction E or W
{scale} Scale
{mmscale} Multimap fixed scales
{altitude} MSN altitude = scale * 143/1000000
{zoom} Mapquest zoom 0 ... 9, 9 is approximately 1:6,000, 5 (default) is approximately 1:333,000, 2 is approximately 1:8,570,000
{span} Google and Tiger span = scale/1000000
{osmzoom} OSM zoom 0 ... 18, osmzoom = round (ld (5E8 / scale))
{osmzoommap} osmzoom - 1
{type} Location type (see above)
{region} Region code (see above)
{globe} Globe type (see above)
{params} Wikipedia Georeference parameter, for instance used by Geohack
{utmzone} Universal Transverse Mercator coordinate system using the WGS84 ellipsoid
UTM zone
{utmnorthing} UTM northing
{utmeasting} UTM easting
{utmerror} UTM out-of-range error message
{utm33northing} UTM for zone 33
UTM northing
{utm33easting} UTM easting
{utm33error} UTM out-of-range error message
{osgb36ref} OSGB36, British national grid reference system using the Airy 1830 ellipsoid
UK Ordnance Survey reference
{osgb36northing} OSGB36 northing
{osgb36easting} OSGB36 easting
{osgb36error} OSGB36 out-of-range error message
{ch1903northing} CH1903, Swiss coordinate system (Swiss grid) using the 1841 Bessel ellipsoid
CH1903 northing
{ch1903easting} CH1903 easting
{ch1903error} CH1903 out-of-range error message
{nztmnorthing} New Zealand NZTM2000, New Zealand coordinate system using the WGS84 ellipsoid
NZTM2000 northing
{nztmeasting} NZTM2000 easting
{nztmerror} NZTM2000 out-of-range error message

Used messages

Message strings ― noted in Mapsources.i18n.php ― are available now for two languages (de and en).

<?php
/**
 * Internationalisation file for MapSources extension.
 *
 * @package MediaWiki
 * @subpackage Extensions
*/
 
$MapsourcesMessages = array();
 
$MapsourcesMessages['en'] = array(
	'mapsources'                 => 'Map Sources',
	'mapsources-summary'         => 'This page allows users to search for multiple sources for a location given by its coordinate.',
	'mapsources-search-legend'   => 'Search for data and map sources',
	'mapsources-coordinate'      => 'Coordinate:',
	'mapsources-go'              => 'Go',
	'mapsources-errormsgs'       => 'Error Messages',
	'mapsources-noparams'        => 'No parameters given',
	'mapsources-incorrectparams' => 'Incorrect parameters given',
	'mapsources-incorrectlat'    => 'Incorrect latitude',
	'mapsources-incorrectlong'   => 'Incorrect longitude',
	'mapsources-nopage'          => 'No project page [[Project:$1]] available',
	'mapsources-outofrange'      => 'Coordinate out of range',
);
 
$MapsourcesMessages['de'] = array(
	'mapsources'                 => 'Karten- und Datenquellen',
	'mapsources-summary'         => 'Auf dieser Spezialseite können Sie eine Koordinate eingeben und erhalten dann eine Liste mit Informations- und Bezugsmöglichkeiten von Karten und geografischen Angaben.',
	'mapsources-search-legend'   => 'Suche nach Daten- und Kartenquellen',
	'mapsources-coordinate'      => 'Koordinate:',
	'mapsources-go'              => 'Suche',
	'mapsources-errormsgs'       => 'Fehlermeldungen',
	'mapsources-noparams'        => 'Keine Parameter angegeben',
	'mapsources-incorrectparams' => 'Fehlerhafte Parameter angegeben',
	'mapsources-incorrectlat'    => 'Fehlerhafte Breitenangabe',
	'mapsources-incorrectlong'   => 'Fehlerhafte Längenangabe',
	'mapsources-nopage'          => 'Keine Projektseite [[Project:$1]] verfügbar',
	'mapsources-outofrange'      => 'Ungültige Koordinate',
);
 
$MapsourcesMessages['fr'] = array(
	'mapsources'                 => 'Sources de cartes',
	'mapsources-summary'         => 'Cette page permet aux utilisateurs de rechercher des sources multiples pour un lieu en donnant ses coordonées.',
	'mapsources-search-legend'   => 'Rechercher des sources de cartes et données',
	'mapsources-coordinate'      => 'Coordonées:',
	'mapsources-go'              => 'Rechercher',
	'mapsources-errormsgs'       => 'Messages d’erreur',
	'mapsources-noparams'        => 'Paramètres manquants',
	'mapsources-incorrectparams' => 'Paramètres erronés',
	'mapsources-incorrectlat'    => 'Latitude erronée',
	'mapsources-incorrectlong'   => 'Longitude erronée',
	'mapsources-nopage'          => 'Pas de page de projet [[Project:$1]] disponible',
	'mapsources-outofrange'      => 'Coordonées invalides',
);
 
$MapsourcesMessages['it'] = array(
	'mapsources'                 => 'Fonte della mappa',
	'mapsources-summary'         => 'Questa pagina speciale permette che gli utenti cerchino le fonti multiple per una posizione data dalla relativa coordinata.',
	'mapsources-search-legend'   => 'Cerca per dati e fonti delle mappe',
	'mapsources-coordinate'      => 'Coordinate:',
	'mapsources-go'              => 'Cerca',
	'mapsources-errormsgs'       => 'Messaggio di errore',
	'mapsources-noparams'        => 'Parametri mancanti',
	'mapsources-incorrectparams' => 'Parametri non corretti',
	'mapsources-incorrectlat'    => 'Latitudine non corretta',
	'mapsources-incorrectlong'   => 'Longitudine non corretta',
	'mapsources-nopage'          => 'Pagine del progetto [[Project:$1]] non disponibili',
	'mapsources-outofrange'      => 'Coordinate non valide',
);
 
$MapsourcesMessages['pl'] = array(
	'mapsources'                 => 'Mapy',
	'mapsources-summary'         => 'Na tej stronie można odnaleźć łącza do map przedstawiających miejsce o podanych współrzędnych.',
	'mapsources-search-legend'   => 'Wyszukaj mapy i odwzorowania terenu',
	'mapsources-coordinate'      => 'Współrzędne:',
	'mapsources-go'              => 'Przejdź',
	'mapsources-errormsgs'       => 'Komunikaty błędów',
	'mapsources-noparams'        => 'Brak parametrów',
	'mapsources-incorrectparams' => 'Błędne parametry',
	'mapsources-incorrectlat'    => 'Błędna szerokość',
	'mapsources-incorrectlong'   => 'Błędna długość',
	'mapsources-nopage'          => 'Brak adresu [[Project:$1]] źródła',
	'mapsources-outofrange'      => 'Współrzędne poza zakresem',
);
 
?>

Approximation of the Universal Transverse Mercator conversion

This program uses Redfearn’s formulae to convert a given latitude and longitude into the equivalent Transverse Mercator (TM) coordinates.

Meridian Distance

The Meridian Distance m from the equator is given approximately by:

\begin{align} m &= r \left( \left( 1 - \frac{e^2}{4} - \frac{3}{64}e^4 - \frac{5}{256}e^6  \right) \varphi
- \left( \frac{3}{8}e^2 + \frac{3}{32}e^4 + \frac{45}{1024}e^6 \right) \sin(2 \varphi) \right. \\
&+ \left. \left( \frac{15}{256}e^4  + \frac{45}{1024}e^6 \right) \sin(4 \varphi)
- \left( \frac{35}{3072}e^6 \right) \sin(6 \varphi) \right) \end{align}

where are

  • r the size of the major semi axis
  • e the eccentricity of the reference ellipsoid
  • φ the latitude in radian

Calculation of Northing and Easting

Weblinks

References

  • Redfearn’s formulae
    Redfearn, J.C.B. : Transverse Mercator Formulae. In: Empire Survey Review <London> 9,69 (July 1948), pp. 318 ‒ 322.
  • Approximation using power series
    Hofmann-Wellenhof, Bernhard ; Lichtenegger, Herbert ; Collins, James : Global positioning system : theory and practice. – Wien [u.a.] : Springer, 2001.
Personal tools