Extension:GeoData
GeoData リリースの状態: 安定 |
|
---|---|
実装 | API , パーサー関数 |
説明 | 地理座標の保存・検索機能を追加 |
作者 | Max Semenik (MaxSemトーク) |
互換性の方針 | MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。 |
MediaWiki | 1.25+ |
データベースの変更 | はい |
テーブル | geo_tags |
ライセンス | WTFPL 2.0 |
ダウンロード | |
|
|
四半期ごとのダウンロード数 | 63 (Ranked 79th) |
translatewiki.net で翻訳を利用できる場合は、GeoData 拡張機能の翻訳にご協力ください | |
問題点 | 未解決のタスク · バグを報告 |
GeoData拡張機能は、記事の地理的な座標を指定し、HTTP API 経由でその座標を公開することを可能にします。
インストール
検索バックエンド
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 CirrusSearch which adds ES text search to the wiki.
プロセス
- ダウンロードして、ファイルを
extensions/
フォルダー内のGeoData
という名前のディレクトリ内に配置します。
開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GeoData - 以下のコードを LocalSettings.php ファイルの末尾に追加します:
wfLoadExtension( 'GeoData' );
- 更新スクリプトを実行します。このスクリプトは、この拡張機能が必要とするデータベーステーブルを自動的に作成します。
- If you're about to use GeoData with ElasticSearch, install CirrusSearch then add to LocalSettings.php, below the GeoData loading.
$wgGeoDataBackend = 'elastic';
- 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
使用法
This extension adds a new parser function , {{#coordinates:}}
, that saves coordinates to the database. Function's input format is made as compatible as possible with GeoHack.
用語集
- Coordinates - see w:geographical coordinates
- 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:
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 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.
パーサー関数
Function format:
{{#coordinates:latitude|longitude|[primary|][GeoHack parameters|][extra parameters]}}
||
or | |
) are always ignored.- latitude and longitude can be specified in several formats:
- Direct signed input in degrees, e.g.
37.786971|-122.399677
, which corresponds to 37° 47′ 13.1″ N, 122° 23′ 58.84″ W.- As formatted number in the content language. Use
{{formatnum:}}
, to format a number of a expression.
- As formatted number in the content language. Use
- Degrees/minutes or degrees/minutes/seconds, e.g.
37|47.2183|-122|23.9807
or37|47|13.1|-122|23|58.84
. - Either of the above, but with sign specified by N/E/S/W letters:
37.786971|N|122.399677|W
37|47.2183|N|122|23.9807|W
37|47|13.1|N|-122|23|58.84|W
- Direct signed input in degrees, e.g.
- primary keyword specifies that these coordinates are primary (see #Glossary).
- 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 #Glossary.
- 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.
タイプ | 説明 | 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 |
- GeoHack parameters: one or more pairs in format parameter:value, delimited by underscores (_) or spaces (e.g.
dim:1000_type:city
). 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 {{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 by MediaWiki:Geodata-broken-tags-category):
- Coordinates out of range:
{{#coordinates:56|04|N|190|00|E}} {{#coordinates:76|61|03|N|37|25|30|W}}
- Mixing coordinate signs and hemisphere letters:
{{#coordinates:primary|-26|04|N|178|46|E}} {{#coordinates:primary|26.16|N|-178.76|E}}
- More than one primary coordinate on page:
{{#coordinates:primary|26|04|N|178|46|E}}{{#coordinates:primary|26|04|N|178|46|E}}
- Too many coordinates on page: by default 500, 2000 on WMF.
The following errors are non-fatal by default:
- Unrecognised coordinate type:
{{#coordinates:primary|26|04|N|178|46|E|type=New York}} {{#coordinates:primary|26|04|N|178|46|E|type:village}}
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
earth
). - 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 (
primary
), secondary (secondary
) or both (all
). Default:primary
.
Example:
- Search around the point with coordinates 37° 47′ 13.1″ N, 122° 23′ 58.84″ W:
{
"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": ""
}
]
}
}
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 (
primary
), secondary (secondary
) or both (all
). Default:primary
.
Examples:
- Get a list of coordinates of the Wikimedia Foundation article:
{
"batchcomplete": "",
"query": {
"pages": {
"18618509": {
"pageid": 18618509,
"ns": 0,
"title": "Wikimedia Foundation",
"coordinates": [
{
"lat": 37.78916667,
"lon": -122.40333333,
"primary": "",
"globe": "earth"
}
]
}
}
}
}
- More qualified results (this is the query that Pywikibot uses.):
{
"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
and list=categorymembers
. The extended modules are called geopages
and geopagesincategory
. It adds two mutually exclusive parameters, withcoordinates
and withoutcoordinates
.
設定
設定 | タイプ | 既定 | 説明 |
---|---|---|---|
$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. |
この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |
この拡張機能は以下のウィキ ファーム/ウィキ ホスト/パッケージに含まれています: これは正式な一覧ではありません。 一部のウィキ ファーム/ウィキ ホスト/パッケージは、ここに記載されていなくてもこの拡張機能を含んでいる場合があります。 必ずご利用のウィキ ファーム、ウィキ ホスト、バンドルで確認してください。 |