![]() Release status: stable | |
---|---|
![]() | |
Implementation | API,Parser function |
Description | Adds geographical coordinates storage and retrieval functionality |
Author(s) | Max Semenik (MaxSemtalk) |
Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
MediaWiki | 1.25+ |
Database changes | Yes |
Tables | geo_tags |
License | WTFPL 2.0 |
Download | |
| |
Translate the GeoData extension if it is available at translatewiki.net | |
Issues | Open tasks ·Report a bug |
TheGeoData extension allows articles to specify their geographical coordinates and publishes these coordinates via the HTTPAPI.
First of all, decide which search backend to use:
GeoData
folder to yourextensions/
directory.cdextensions/gitclonehttps://gerrit.wikimedia.org/r/mediawiki/extensions/GeoData
wfLoadExtension('GeoData');
$wgGeoDataBackend='elastic';
This extension adds a newparser function,{{#coordinates:}}
, that saves coordinates to the database. Function's input format is made as compatible as possible withGeoHack.
earth
,mercury
,venus
,moon
,mars
,phobos
,deimos
,ganymede
,callisto
,io
,europa
,mimas
,enceladus
,tethys
,dione
,rhea
,titan
,hyperion
,iapetus
,phoebe
,miranda
,ariel
,umbriel
,titania
,oberon
,triton
andpluto
. Globes not mentioned in this list will be assumed to have generic characteristics: longitude range 0-360°, Eastern longitude is positive. Longitude sign for known globes is takenaccording to IAU's conventions.Function format:
{{#coordinates:latitude|longitude|[primary|][GeoHack parameters|][extra parameters]}}
||
or| |
) are always ignored.37.786971|-122.399677
, which corresponds to 37° 47′ 13.1″ N, 122° 23′ 58.84″ W.{{formatnum:}}
, to format a number of a expression.37|47.2183|-122|23.9807
or37|47|13.1|-122|23|58.84
.37.786971|N|122.399677|W
37|47.2183|N|122|23.9807|W
37|47|13.1|N|-122|23|58.84|W
type | Description | Dim |
---|---|---|
country | (e.g. "type:country") | 1,000,000 |
satellite | geo-stationary satellites | 1,000,000 |
adm1st | Administrative unit of country, 1st level (province, state), e.g. U.S. states | 1,000,000 |
adm2nd | Administrative unit of country, 2nd level, e.g. US county | 30,000 |
adm3rd | Administrative unit of country, 3rd level | 10,000 |
city(pop) | cities, towns, villages, hamlets, suburbs, subdivisions, neighborhoods, and other human settlements (including unincorporated and/or abandoned ones) with known population (optional population in braces is ignored) | 10,000 |
airport | airports and airbases | 3,000 |
mountain | peaks, mountain ranges, hills, submerged reefs, and seamounts | 10,000 |
isle | islands and isles | 10,000 |
waterbody | bays, fjords, lakes, reservoirs, ponds, lochs, loughs, meres, lagoons, estuaries, inland seas, and waterfalls | 10,000 |
forest | forests and woodlands | 5,000 |
river | rivers, canals, creeks, brooks, and streams, including intermittent ones | 10,000 |
glacier | glaciers and icecaps | 5,000 |
event | one-time or regular events and incidents that occurred at a specific location, including battles, earthquakes, festivals, and shipwrecks | 5,000 |
edu | schools, colleges, and universities | 1,000 |
pass | mountain passes | 1,000 |
railwaystation | stations, stops, and maintenance areas of railways and trains, including railroad, metro, rapid transit, underground, subway, elevated railway, etc. | 1,000 |
landmark | buildings (including churches, factories, museums, theatres, and power plants but excluding schools and railway stations), caves, cemeteries, cultural landmarks, geologic faults, headlands, intersections, mines, ranches, roads, structures (including antennas, bridges, castles, dams, lighthouses, monuments, and stadiums), tourist attractions, valleys, and other points of interest | 1,000 |
Default dim: if no type is used or the type is unknown to this extension | 1,000 |
dim:1000_type:city
). No spaces are allowed between parameter and colon or between colon and value. The parameters are the same asextra parameters above. If a parameter exists in both GeoHack parameters and extra parameters, extra parameters always have precedence. This input is needed only for compatibility with preexisting {{coord}} templates - if your wiki is only designing a geographical coordinates template, it is best if you not used raw GeoHack parameters at all.Note how extra parameters are specified:
{{#coordinates:primary|40.775114|-73.968802|type:landmark_region:US-NY|name=Loeb Central Park Boathouse}}
GeoData checks the data it receives for a number of error conditions.
The following conditions result in coordinates being outright rejected and added to tracking category (the name of it is defined byMediaWiki:Geodata-broken-tags-category):
{{#coordinates:56|04|N|190|00|E}}{{#coordinates:76|61|03|N|37|25|30|W}}
{{#coordinates:primary|-26|04|N|178|46|E}}{{#coordinates:primary|26.16|N|-178.76|E}}
{{#coordinates:primary|26|04|N|178|46|E}}{{#coordinates:primary|26|04|N|178|46|E}}
The following errors are non-fatal by default:
{{#coordinates:primary|26|04|N|178|46|E|type=New York}}{{#coordinates:primary|26|04|N|178|46|E|type:village}}
GeoData has two API modules that perform search around a given point and coordinates for a given article(s).
Searches for articles around the given point (determined either by coordinates, bounding box, or by article name).
Parameters:
earth
).primary
), secondary (secondary
) or both (all
). Default:primary
.Example:
{"batchcomplete":"","query":{"geosearch":[{"pageid":9292891,"ns":0,"title":"140 New Montgomery","lat":37.7868194444444,"lon":-122.399905555556,"dist":26.2,"primary":""},{"pageid":40377676,"ns":0,"title":"New Montgomery Street","lat":37.78729,"lon":-122.40033,"dist":67.5,"primary":""},{"pageid":1544800,"ns":0,"title":"Cartoon Art Museum","lat":37.787088,"lon":-122.40094,"dist":111.7,"primary":""},{"pageid":2183989,"ns":0,"title":"Academy of Art University","lat":37.78785,"lon":-122.40065,"dist":129.9,"primary":""},{"pageid":24801569,"ns":0,"title":"SPUR (San Francisco organization)","lat":37.78716,"lon":-122.4012,"dist":135.5,"primary":""},{"pageid":9297181,"ns":0,"title":"101 Second Street","lat":37.788139,"lon":-122.399056,"dist":140.9,"primary":""},{"pageid":40413203,"ns":0,"title":"222 Second Street","lat":37.78635,"lon":-122.39825,"dist":143.2,"primary":""},{"pageid":20004112,"ns":0,"title":"The Montgomery (San Francisco)","lat":37.78762,"lon":-122.40112,"dist":145.9,"primary":""},{"pageid":18679821,"ns":0,"title":"California Historical Society","lat":37.78684444444444,"lon":-122.40148055555557,"dist":159.1,"primary":""},{"pageid":71882190,"ns":0,"title":"St. Regis Museum Tower","lat":37.7863,"lon":-122.4013,"dist":161,"primary":""}]}}
Returns coordinates of the given page(s)
Parameters:
primary
), secondary (secondary
) or both (all
). Default:primary
.Examples:
{"batchcomplete":"","query":{"pages":{"18618509":{"pageid":18618509,"ns":0,"title":"Wikimedia Foundation","coordinates":[{"lat":37.78916667,"lon":-122.40333333,"primary":"","globe":"earth"}]}}}}
{"batchcomplete":"","query":{"pages":{"18618509":{"pageid":18618509,"ns":0,"title":"Wikimedia Foundation","coordinates":[{"lat":37.78916667,"lon":-122.40333333,"primary":"","type":"landmark","dim":"1000"}]}}}}
GeoData extends two core API modules,list=allpages
andlist=categorymembers
. The extended modules are calledgeopages
andgeopagesincategory
. It adds two mutually exclusive parameters,withcoordinates
andwithoutcoordinates
.
Setting | Type | Default | What is does |
---|---|---|---|
$wgMaxGeoSearchRadius | int | 10000 | Maximum radius for geospatial searches, in meters. Reducing this value reduces server load |
$wgMaxCoordinatesPerPage | int | 500 | Maximum number of coordinates per page, -1 means no limit |
$wgTypeToDim | array | Long array, see the sources | Conversion table type --> dim |
$wgDefaultDim | array | 1000 | Default value of dim if it is unknown |
$wgGlobes | array | Long array, see the sources | Defines parameters of every globe |
$wgGeoDataWarningLevel | array | array('unknown type'=>'none','unknown globe'=>'none','invalid region'=>'none',) | Controls what GeoData should do when it encounters some problem. Reaction type:
|
$wgGeoDataIndexGranularity | int | 10 | How many integer units per degree to use with database-only search. Influences performance. Run updateIndexGranularity.php after changing this setting. |
$wgGeoDataBackend | string | 'db' | Which backend should be used by spatial searches: 'db' or 'elastic'. Note if you're planning to change it, do so before creating the database tables. |
![]() | This extension is being used on one or moreWikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia'sCommonSettings.php andInitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki'sSpecial:Version page. |
![]() | This extension is included in the following wiki farms/hosts and/or packages:This is not an authoritative list.Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here.Always check with your wiki farms/hosts or bundle to confirm. |