Extension:Semantic Google Maps/ParserCoordinates.php

This parser function takes coordinates in format 55.76433° N, 5.334556° E and outputs decimal longitude and latitude values (55.76433 and 5.334556).

To install copy and paste code below into a file and call this file in LocalSettings.php:

require_once( "$IP/extensions/ParserCoordinates.php" );
 * 1) parser function coordinates - http://www.mediawiki.org/wiki/Extension:Semantic_Google_Maps

setFunctionHook( 'coordinate', 'wfExampleParserFunction_Render' ); } function wfExampleParserFunction_Magic( &$magicWords, $langCode ) { # Add the magic word # The first array element is case sensitive, in this case it is not case sensitive # All remaining elements are synonyms for our parser function $magicWords['coordinate'] = array( 0, 'coordinate' ); # unless we return true, other parser functions extensions won't get loaded. return true; } function wfExampleParserFunction_Render( &$parser, $param1 = , $param2 =  ) { # The parser function itself # The input parameters are wikitext with templates expanded # The output should be wikitext too $coordinates = preg_split("/,/", $param2); switch ($param1) { case 'lat': $lat = floatval($coordinates[0]); return $lat; case 'lon': $lon = floatval($coordinates[1]); return $lon; }		} ?>
 * 1) Define a setup function
 * 1) Add a hook to initialise the magic word