Skip to main content

GeoHack ContentsQueryReplacement variablesSynchronizationsJavaScriptNice URLsSource codeSee alsoGeo-data projectsMaintainersNavigation menuVirtual GlobeMultimapMSN MapsFourmilabSwissinfoMapQuestGule SiderOpenStreetMapLive Search MapsGoogle MapsWikiMapiaMediaWiki:GeoHack.jsGeoTemplate

MMT-ToolGeo toolsMapping


map sourcesEgil Kvaleberggis extensionw:Template:GeoTemplate/sandboxHTTP refererhttp://meta.wikimedia.org/wiki/Template:GeoTemplate/osmISO 3166-1 alpha-2English WikipediaMapsMediaWiki:GeoHack.jsGeoTemplaterewrite.scriptfullurl: parser functionhttps://tools.wmflabs.org/geohack/en/52_30_N_13_23_E_type:city(3431700)?title=Berlinpagename










GeoHack


From MediaWiki.org

Jump to navigation
Jump to search


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.




Contents





  • 1 Query

    • 1.1 language


    • 1.2 pagename


    • 1.3 params


    • 1.4 project


    • 1.5 title



  • 2 Replacement variables

    • 2.1 Section codes



  • 3 Synchronizations


  • 4 JavaScript

    • 4.1 Embed maps



  • 5 Nice URLs


  • 6 Source code


  • 7 See also


  • 8 Geo-data projects


  • 9 Maintainers



Query


language


The requested language version (e.g. language.wikipedia.org), falls back to English if the template page does not exist.


pagename


The full title of the referring article. If not supplied, GeoHack will attempt to read the values from the HTTP referer.


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: a 255 byte length limit, < > [ ] | are invalid, and spaces and underscore are treated the same.


  • & causes problems if it not percent encoded in the URL.

  • Avoid non-ASCII characters as some browsers incorrectly handle copying and pasting.

  • Avoid the equal sign (=) since it causes issues with unnamed template parameters (e.g. Coord)

  • The characters & < > " are escaped in the HTML to prevent exploits

default:

Default scale: for use in templates, is overridden by dim:, scale:, type: parameters.

dim:

The size of the object in meters.

globe:

Specify a different globe, defaults to Earth. Argument value is used for the subpage name, e.g. globe:moon will load Template:GeoTemplate/moon.

page:


(disabled) Specify a subpage for map sources.

region:


(deprecated) The ISO 3166 code with an optional subdivision to highlight region specific services, see Section codes below. If not supplied GeoHack will attempt to find the region using the coordinates.

scale:

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 can vary significantly (e.g. iPhone 4) it is recommended to used the display independent dim:.

type:

The following are types GeoHack recognizes along with the calculate default scale.


TODO Provide definitions for each type.


















































































type:
ratio
m / pixel
scale
mmscale
span
altitude
zoom
osmzoom
country, satellite
1 : 10,000,000
3528
10000000
10000000
10.0
1430
1
5
state
1 : 3,000,000
1058
3000000
4000000
3.0
429
3
7
adm1st
1 : 1,000,000
353
1000000
1000000
1.0
143
4
9
adm2nd (default)
1 : 300,000
106
300000
200000
0.3
42
5
11
adm3rd, city, mountain, isle, river, waterbody
1 : 100,000
35.3
100000
100000
0.1
14
6
12
event, forest, glacier
1 : 50,000
17.6
50000
50000
0.05
7
7
13
airport
1 : 30,000
10.6
30000
25000
0.03
4
7
14
camera, edu, pass, landmark, railwaystation
1 : 10,000
3.53
10000
10000
0.01
1
8
15
zoom:


Deprecated Provided for compatibility with the Dutch maps.asp software. The scale is calibrated differently (SCALE = POWER(2, 12 - ZOOM) * 100 000, roughly equivalent to osmzoom) and conflicts with the replacement variable zoom

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


title


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


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 - Antipodes of latdegdec, londegdec


  • londegneg - The negative of londegdec


  • latdegint, londegint - Integer degrees (floored)


  • latmindec, lonmindec - Decimal minutes


  • latminint, lonminint - Integer minutes


  • latsecdec, lonsecdec - Decimal seconds


  • latsecint, lonsecint - Integer seconds


  • latNS, lonEW - Direction of absolute integer degrees

UTM Positioning
  • utmnorthing, utmeasting, utmzone

  • utm33northing, utm33easting

Ordnance Survey Grid Positioning
  • osgb36ref

  • osgb36northing, osgb36easting

CH1903 Positioning
  • ch1903northing, ch1903easting
Scaling



































name
used by
internal conversion
units
notes
scale

Virtual Globe
Use scale: or from dictionary look using type: value


mmscale

Multimap
Dictionary-like lookup


altitude

MSN Maps, Fourmilab, Swissinfo
int( scale * 143/1000000 ), [1, infinity]


zoom

MapQuest, Gule Sider
int(18.0 - log(scale)), [0,9]


osmzoom

OpenStreetMap, Live Search Maps
18 - ( round(log(scale,2) - log(1693,2)) ), [2, 18]


OSM zoom level
span

Google Maps, WikiMapia

scale * 1.0 / 1000000
degrees/nautical miles
FIXME calibration;
never is correct as span is tied to the view port size not scale
[1]
Geographical features

  • type, region, globe - The parameters from the params. 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.

  • pagename_gmaps - work around for google maps, will be replaced by pagenamee

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=

Section codes


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


<div id="GEOTEMPLATE-LOCAL"></div>

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


<div id="GEOTEMPLATE-XX">
...
</div>

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.


<div id="GEOTEMPLATE-REGIONS">
...
</div>

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 MediaWiki:GeoHack.js page. See English Wikipedia for an example.


Embed maps




GeoHack for Firenze, in Italian


Wikimedia Maps (maps.wikimedia.org) can be embedded in the tool with two edits that will not change any content or code on the source wiki: see example MediaWiki:GeoHack.js and GeoTemplate.


The Russian and Italian Wikipedias did so in November-December 2015, see example screenshot.


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.


https://tools.wmflabs.org/geohack/geohack.php?language=en&params=40.7;-74_type:city(8000000)&pagename=New_York_City
https://tools.wmflabs.org/geohack/en/40.7;-74_type:city(8000000)?pagename=New_York_City

It is also compatible with the fullurl: parser function


https://tools.wmflabs.org/geohack/en/52_30_N_13_23_E_type:city(3431700)?title=Berlin


https://tools.wmflabs.org/geohack/en/52_30_N_13_23_E_type:city(3431700)?title=Berlin


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


# URL Rewrite script for GeoHack
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


Source code


  • https://bitbucket.org/magnusmanske/geohack

  • until 2013: http://svn.toolserver.org/svnroot/geohack/ backed up to https://phabricator.wikimedia.org/diffusion/TSVN/browse/geohack/

# Clone the current version:
git clone https://bitbucket.org/magnusmanske/geohack.git

# Commit changes:
git commit -a -m "commit summary"

# Update the live installation:
become geohack
cd public_html/; git pull

See also



  • GeoHack/Replacement script, a user JavaScript that replaces links to GeoHack with another service.

Geo-data projects


  • Wikipedia-World

  • ghel

Maintainers



  • User:Dispenser (project lead)

  • User:Kolossos

  • User:Magnus Manske



Retrieved from "https://www.mediawiki.org/w/index.php?title=GeoHack&oldid=3016878"





Navigation menu



























(window.RLQ=window.RLQ||[]).push(function()mw.config.set("wgPageParseReport":"limitreport":"cputime":"0.120","walltime":"0.851","ppvisitednodes":"value":171,"limit":1000000,"ppgeneratednodes":"value":0,"limit":1500000,"postexpandincludesize":"value":2705,"limit":2097152,"templateargumentsize":"value":8,"limit":2097152,"expansiondepth":"value":8,"limit":40,"expensivefunctioncount":"value":2,"limit":500,"unstrip-depth":"value":0,"limit":20,"unstrip-size":"value":1534,"limit":5000000,"entityaccesscount":"value":0,"limit":400,"timingprofile":["100.00% 72.310 1 Template:TNT","100.00% 72.310 1 -total"," 62.23% 44.995 1 Template:Ambox"],"scribunto":"limitreport-timeusage":"value":"0.026","limit":"10.000","limitreport-memusage":"value":865826,"limit":52428800,"cachereport":"origin":"mw1330","timestamp":"20190226212051","ttl":2592000,"transientcontent":false);mw.config.set("wgBackendResponseTime":115,"wgHostname":"mw1275"););

Popular posts from this blog

Oświęcim Innehåll Historia | Källor | Externa länkar | Navigeringsmeny50°2′18″N 19°13′17″Ö / 50.03833°N 19.22139°Ö / 50.03833; 19.2213950°2′18″N 19°13′17″Ö / 50.03833°N 19.22139°Ö / 50.03833; 19.221393089658Nordisk familjebok, AuschwitzInsidan tro och existensJewish Community i OświęcimAuschwitz Jewish Center: MuseumAuschwitz Jewish Center

Valle di Casies Indice Geografia fisica | Origini del nome | Storia | Società | Amministrazione | Sport | Note | Bibliografia | Voci correlate | Altri progetti | Collegamenti esterni | Menu di navigazione46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)Sito istituzionaleAstat Censimento della popolazione 2011 - Determinazione della consistenza dei tre gruppi linguistici della Provincia Autonoma di Bolzano-Alto Adige - giugno 2012Numeri e fattiValle di CasiesDato IstatTabella dei gradi/giorno dei Comuni italiani raggruppati per Regione e Provincia26 agosto 1993, n. 412Heraldry of the World: GsiesStatistiche I.StatValCasies.comWikimedia CommonsWikimedia CommonsValle di CasiesSito ufficialeValle di CasiesMM14870458910042978-6

Typsetting diagram chases (with TikZ?) Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to define the default vertical distance between nodes?Draw edge on arcNumerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to place nodes in an absolute coordinate system in tikzCommutative diagram with curve connecting between nodesTikz with standalone: pinning tikz coordinates to page cmDrawing a Decision Diagram with Tikz and layout manager