Extension:GeoData/ru

The GeoData extension allows articles to specify their geographical coordinates and publishes these coordinates via the HTTP.

Search backends
First of all, decide which search backend to use:


 * MySQL (default): suitable for small to medium installs. Requires zero configuration. It does not use MySQL's built-in spatial indexes because when the extension was being developed, SPATIAL was supported only by MyISAM storage engine, which is worse than nothing. Instead, it uses 0.1x0.1 degree tiles for search, which results in a slightly higher I/O, but faster updates.
 * ElasticSearch is a powerful search engine. When using ElasticSearch as a backend, GeoData works as a plugin for which adds ES text search to the wiki.

Process

 * Download and place the file(s) in a directory called GeoData in your  directory.
 * Add the following code at the bottom of your LocalSettings.php:


 * If you're about to use GeoData with ElasticSearch, then add   to LocalSettings.php, below the GeoData loading.
 * to create the  database table.
 * Done! Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage
This extension adds a new, , that saves coordinates to the database. Function's input format is made as compatible as possible with GeoHack.

Glossary

 * Coordinates - see here
 * Globe - terrestrial body on which the coordinate resides. By default, Earth is assumed. Internally, globe is represented as lowercase strings. The following globes are supported:,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,   and  . 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 taken according to IAU's conventions.
 * dim - approximate size of an object. Used by GeoData to restrict search and by GeoHack for determining appropriate map zoom. The default unit of measurement is metres, although the km suffix may be appended to indicate kilometres.
 * Primary vs. secondary coordinates: primary coordinates define article subject's location, while secondary coordinates are other coordinates mentioned in the article. There can be only one primary coordinate per article, but as many secondaries as you like barring technical restrictions.

Parser function
Function format:




 * latitude and longitude can be specified in several formats:
 * Direct signed input in degrees, e.g., which corresponds to 37° 47′ 13.1″ N, 122° 23′ 58.84″ W.
 * As formatted number in the content language. Use, to format a number of a expression.
 * Degrees/minutes or degrees/minutes/seconds, e.g.  or.
 * Either of the above, but with sign specified by N/E/S/W letters:


 * primary keyword specifies that these coordinates are primary (see ).
 * Extra parameters are any combination of the following named parameters:
 * dim: approximate size of the object.
 * scale: Scale of map display for this object, e.g. scale of 300 is 1:300. Gets converted into dim internally using formula dim = scale / 10. If both scale and dim are set, dim has precedence.
 * globe, see.
 * name: name of this point, up to 255 bytes (UTF-8).
 * region: ISO 3166-1 alpha-2 country code (e.g. US or RU) or an ISO 3166-2 region code (e.g. US-FL or RU-MOS). This parameter is always capitalised internally.
 * type: type of object with these coordinates, can be one of the following: country, satellite, state, adm1st, adm2nd, adm3rd, city, isle, mountain, river, waterbody, event, forest, glacier, airport, railwaystation, edu, pass, camera, landmark.


 * GeoHack parameters: one or more pairs in format parameter:value, delimited by underscores (_) or spaces (e.g. ). No spaces are allowed between parameter and colon or between colon and value. The parameters are the same as extra 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  templates - if your wiki is only designing a geographical coordinates template, it is best if you not used raw GeoHack parameters at all.

Examples
Note how extra parameters are specified:

Error conditions
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 by MediaWiki:Geodata-broken-tags-category):


 * Coordinates out of range:
 * Mixing coordinate signs and hemisphere letters:
 * More than one primary coordinate on page:
 * Too many coordinates on page: by default 500, 2000 on WMF.

The following errors are non-fatal by default:


 * Unrecognised coordinate type:

API
GeoData has two API modules that perform search around a given point and coordinates for a given article(s).

list=geosearch
Searches for articles around the given point (determined either by coordinates, bounding box, or by article name).

Parameters:


 * gscoord: Coordinate around which to search: two floating-point values separated by pipe (|)
 * gsradius:Search radius in meters (10-10000). This parameter is required with the use of gscoord.
 * gsbbox:Bounding box to search in: pipe ( | ) separated coordinates of the corners in top|left|bottom|right order.
 * gspage: Title of page around which to search
 * gsmaxdim: Restrict search to objects no larger than this, in meters
 * gslimit: Maximum number of pages to return. No more than 500 (5000 for bots) allowed. Default: 10.
 * gsglobe: Globe to search on (by default ).
 * gsnamespace: Namespace(s) to search. Default: main namespace.
 * gsprop: What additional coordinate properties to return. Values (separate with '|'): type, name, country, region.
 * gsprimary: Whether to return only primary coordinates, secondary or both . Default:.

Example:


 * Search around the point with coordinates 37° 47′ 13.1″ N, 122° 23′ 58.84″ W:
 * |-122.399677 api.php?action=query&list=geosearch&gsradius=10000&gscoord=37.786971|-122.399677

prop=coordinates
Returns coordinates of the given page(s)

Parameters:


 * colimit: How many coordinates to return.
 * cocontinue: When more results are available, use this to continue.
 * coprop: What additional coordinate properties to return. Values (separate with '|'): type, name, dim, country, region.
 * coprimary: Whether to return only primary coordinates, secondary or both . Default:.

Examples:


 * Get a list of coordinates of the Wikimedia Foundation article:
 * api.php?action=query&prop=coordinates&titles=Wikimedia%20Foundation


 * More qualified results (this is the query that Pywikibot uses.):
 * |name|dim|country|region&coprimary=all api.php?action=query&prop=coordinates&titles=Wikimedia%20Foundation&coprop=type|name|dim|country|region&coprimary=all

Enumerating pages with or without coordinates
GeoData extends two core API modules,  and. The extended modules are called  and. It adds two mutually exclusive parameters,  and.