GeoHack

GeoHack is a modified version of map sources from Egil Kvaleberg's gis extension. It is designed to do simple HTML replacements of a template on Wikipedia and serve it to the client. It is used by Wikipedia to provide links to various mapping services, when a user clicks on a link with geographical coordinates.

Different layout designs for GeoHack are listed on w:Template:GeoTemplate/sandbox.

Query

 * language
 * Set the sub-domain for the request,


 * pagename
 * Name of the article on Wikipedia. If not supplied will attempt to read the values from the HTTP referer.


 * params
 * See params below.


 * title
 * Set this if the page is a not an appropriate title, such as when referring to a location in the article.


 * project
 * Request for a different project. If requesting the OpenStreetMaps (project=osm) page it will retrieve it from a template on meta: http://meta.wikimedia.org/wiki/Template:GeoTemplate/osm

params
The D_M_S_N_D_M_S_E, D_M_N_D_M_E, D_N_D_E, or D;D where D is degrees, M is minutes, S is seconds, and NS/EWO are the directions


 * TODO Document me: boxed range syntax D_N_D_E_to_D_N_D_E
 * Restrictions
 * Should be compatible with MediaWiki titles. This means observing a 255 byte limit,  are considered invalid, and spaces and underscore are treated the same.
 * causes problems if it not percent encoded in the URL.
 * The characters  are escaped in the HTML to prevent exploits.  This could cause problems in older user agents but really shouldn't.
 * Generally avoid using non-ASCII characters here as some browser incorrectly handle copying and pasting.
 * The equal sign has inputting in template using unnamed parameters.


 * default&#58;
 * default scale: for use in templates, is overridden by dim:, scale:, type: parameters.


 * dim&#58;
 * specify the size of the object in meters. The value is converted into a scale: with an assumed view port 10 cm by 10 cm.


 * globe&#58;
 * Specify globe other than earth, argument value is used as the subpage name, for example globe:moon will call w:Template:GeoTemplate/moon


 * page&#58;
 * (disabled) specify a subpage for map sources


 * region&#58;
 * ... If not supplied GeoHack will attempt to find the region using the coordinates.


 * scale&#58;
 * Set the relative map scale as 1:N. The OGC's "standard rendering pixel size" of 0.28mm × 0.28mm (90.7 dpi) is assumed and derived for all size calculations.  Since the actually value varies non-insignificantly it is recommended to used the display independent dim:.


 * type&#58;
 * The following are types GeoHack recognizes along with the calculate default scale.


 * zoom&#58;
 * Unimplemented since the typically meaning assigned to it (roughly equivalent to {osmzoom}) conflicts with the replacement variable {zoom}

Replacement variables

 * WGS84 Positioning
 * {latdegdec}, {londegdec} - Decimal degrees
 * {latdegdecabs}, {londegdecabs} - Absolute decimal degrees (no negative)
 * {latdeground}, {londeground} - Rounded integer degrees
 * {latdegroundabs}, {londegroundabs} - Rounded absolute
 * {latdeg_outer_abs}, {londeg_outer_abs} - Absolute integer degrees rounded up
 * {latdegabs}, {londegabs} - Absolute integer degrees


 * {latantipodes}, {longantipodes}</tt> - Antipodes of {latdegdec}, {londegdec}
 * {londegneg}</tt> - The negative of {londegdec}
 * {latdegint}, {londegint}</tt> - Integer degrees (floored)
 * {latmindec}, {lonmindec}</tt> - Decimal minutes
 * {latminint}, {lonminint}</tt> - Integer minutes
 * {latsecdec}, {lonsecdec}</tt> - Decimal seconds
 * {latsecint}, {lonsecint}</tt> - Integer seconds
 * {latNS}, {lonEW}</tt> - Direction of absolute integer degrees
 * UTM Positioning
 * {utmnorthing}, {utmeasting}, {utmzone}</tt>
 * {utm33northing}, {utm33easting}</tt>
 * Ordnance Survey Grid Positioning
 * {osgb36ref}</tt>
 * {osgb36northing}, {osgb36easting}</tt>
 * CH1903 Positioning
 * {ch1903northing}, {ch1903easting}</tt>


 * Scaling


 * Geographical features
 * {type}, {region}, {globe}</tt> - The parameters from the . Globe is deprecated with the implementation of subpages for bodies.


 * Coordinate title
 * {pagename} - Underscore page name, as given by the pagename or determined by the HTTP referrer.
 * {title} - Title of the location as given by title, if not specified then falls back to {pagename} with the underscore replaced with spaces.


 * Misc./Not fully implemented
 * {page} - Deprecated
 * {geocountry} - same as region:
 * {geoa1} - Characters 4 to 8 of region; Uppercased
 * {lang} -likely to change
 * {params} - content from params=
 * {pagename_gmaps} work around for google maps

Section codes
If the region is supplied or determined then GeoHack moves the section to the placeholder:

The region sections are wrapped in the divs where XX of the id is the ISO 3166-1 alpha-2 code:

A surrounding div can style this section or the local div can provide only local links. To save bandwidth and simplify the REGIONS div will be removed if a local section is found.

Synchronizations
Due to issues affecting the squid server implementation on WMF servers, pages are cached longer than they should. This worked around requesting a different URL every hour.

JavaScript
For user modifications and development, JavaScript is loaded from the local language's  page. See English Wikipedia for an example.

Nice URLs
A URL rewrite script has been installed to allow shortening of URL. The example below illustrates the parts that are changed or removed. http://toolserver.org/~geohack/ geohack.php?language=en&params=40.7;-74_type:city(8000000)&pagename=New_York_City http://toolserver.org/~geohack/ en/40.7;-74_type:city(8000000)?pagename=New_York_City

It is also compatible with the {&#123;fullurl:}} parser function

Note it is not necessary to supply  and this can often be derived from the referer, see  above.

match URL into $ with ^/~geohack/([a-z-]{2,12})/([^=]*)([&?]([a-z]+=.*)$|$) if matched then set URL = /~geohack/geohack.php?language=$1&params=$2&$4 endif Note, for compatibility reason "?" must be followed by "=" for it to be read as a CGI parameter
 * 1) URL Rewrite script for GeoHack

SVN
Download the current version: svn checkout http://svn.toolserver.org/svnroot/geohack/

Save changes using Subversion: svn commit -m "commit summary"

Update the live installation: $ become geohack geohack@willow:~$ cd public_html/ geohack@willow:~/public_html$ svn update

Maintainers

 * User:Dispenser (project lead)
 * User:Kolossos
 * User:Magnus Manske