Zh-hant:Nominatim

From OpenStreetMap Wiki
Jump to navigation Jump to search

Nominatim(來自拉丁語,意思是“名稱”)是一個可以按名稱和地址來搜索OSM中的數據,並生成OSM點的合成地址的工具(反向地理編碼)。可用在http://nominatim.openstreetmap.org找到這個工具。Nominatim也用在OpenStreetMap首頁搜尋工具欄中,同時也為MapQuest Open Initiative, PickPoint, OpenCage Geocoder, LocationIQ, Geocoding.ai 提供搜尋支援。

本頁面提供了使用說明。要了解關於Nominatim如何工作的細節請查看發展概況以及這個FAQ。這裡還有一個關於各個國家的語言代碼各個國家地址格式的列表。

如果你在搜尋結果中發現了問題請協助提交一個測試案例透過trac上報bug。參見第2版​​的筆記。

搜尋

Nominatim為ASCII的數據集中已命名(或編號)的內容,以及其他無名的功能子集(酒吧、旅館、教堂等)進行了索引。

搜尋首先會從左至右進行,如果失敗的話會再從右到左搜尋。

這兩個搜尋都會得到結果:皮爾金頓大道,伯明翰 皮爾金頓大道,伯明翰

(逗號是可選的,但加上逗號可以降低搜尋的複雜程度並提高搜尋精度。)

門牌號碼已經被定義了的區域,可以使用:135皮爾金頓大道,伯明翰

特殊的關鍵詞

在搜尋中不同的關鍵字會被翻譯成特定OSM標籤(例如,酒吧=>市容=酒館)。這裡有一個這樣特殊短語的列表。

參數

 http://nominatim.openstreetmap.org/search?<params>
 http://nominatim.openstreetmap.org/search/<query>?<params>
 format=[html|xml|json|jsonv2]
   Output format
 json_callback=<string>
   Wrap json output in a callback function (JSONP) i.e. <string>(<json>) 
 accept-language=<browser language string>
   Preferred language order for showing search results, overrides the browser value.  
   Either uses standard rfc2616 accept-language string or 
   a simple comma separated list of language codes.
 q=<query>
   Query string to search for.  Alternatively can be entered as:
 street=<housenumber> <streetname>
 city=<city>
 county=<county>
 state=<state>
 country=<country>
 postalcode=<postalcode>
   (experimental) Alternative query string format for structured requests. 
   Structured requests are faster and require less server resources. 
   DO NOT COMBINE WITH q=<query> PARAMETER.
 countrycodes=<countrycode>[,<countrycode>][,<countrycode>]...
   Limit search results to a specific country (or a list of countries).  
   <countrycode> should be the ISO 3166-1alpha2 code, 
   e.g. gb for the United Kingdom, de for Germany, etc.
 viewbox=<left>,<top>,<right>,<bottom>
 or viewboxlbrt=<left>,<bottom>,<right>,<top>
   The preferred area to find search results
 bounded=[0|1]
   Restrict the results to only items contained with the bounding box. 
   Restricting the results to the bounding box also enables searching by amenity only. 
   For example a search query of just "[pub]" would normally be rejected
   but with bounded=1 will result in a list of items matching within the bounding box.
 polygon=[0|1]
   Output polygon outlines for items found 
   (deprecated, use one of the polygon_* parameters instead)
 addressdetails=[0|1]
   Include a breakdown of the address into elements
 email=<valid email address>
   If you are making large numbers of request please include a valid email address
   or alternatively include your email address as part of the User-Agent string.
   This information will be kept confidential and only used to contact you in the
   event of a problem, see Usage Policy for more details.
 exclude_place_ids=<place_id,[place_id],[place_id]>
   If you do not want certain openstreetmap objects to appear in the search result, 
   give a comma separated list of the place_id's you want to skip.
 limit=<integer>
   Limit the number of returned results.
 dedupe=[0|1]
   No explanation yet.
 debug=[0|1]
   No explanation yet.
 polygon_geojson=1
   Output geometry of results in geojson format.
 polygon_kml=1
   Output geometry of results in kml format.
 polygon_svg=1
   Output geometry of results in svg format.
 polygon_text=1
   Output geometry of results as a WKT.

範例

 http://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon=1&addressdetails=1
 http://nominatim.openstreetmap.org/search/135%20pilkington%20avenue,%20birmingham?format=xml&polygon=1&addressdetails=1
 http://nominatim.openstreetmap.org/search/gb/birmingham/pilkington%20avenue/135?format=xml&polygon=1&addressdetails=1
 <searchresults timestamp="Sat, 07 Nov 09 14:42:10 +0000" querystring="135 pilkington, avenue birmingham" polygon="true">
   <place 
     place_id="1620612" osm_type="node" osm_id="452010817" 
     boundingbox="52.548641204834,52.5488433837891,-1.81612110137939,-1.81592094898224" 
     polygonpoints="[['-1.81592098644987','52.5487429714954'],['-1.81592290792183','52.5487234624632'],...]" 
     lat="52.5487429714954" lon="-1.81602098644987" 
     display_name="135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom" 
     class="place" type="house">
     <house>135</house>
     <road>Pilkington Avenue</road>
     <village>Wylde Green</village>
     <town>Sutton Coldfield</town>
     <city>City of Birmingham</city>
     <county>West Midlands (county)</county>
     <postcode>B72</postcode>
     <country>United Kingdom</country>
     <country_code>gb</country_code>
   </place>
 </searchresults>

反向地理編碼/地址查詢

反向地理編碼由緯度和經度產生一個地址。可選的縮放參數指定用於顯示某信息在openlayers上顯示的合適的縮放級別。

參數

 http://nominatim.openstreetmap.org/reverse?<query>
 format=[xml|json]
   Output format
 json_callback=<string>
   Wrap json output in a callback function (JSONP) i.e. <string>(<json>) 
 accept-language=<browser language string>
   Preferred language order for showing search results, overrides the browser value.  
   Either uses standard rfc2616 accept-language string or a simple comma separated list of language codes.
 osm_type=[N|W|R]
 osm_id=<value>
   A specific osm node / way / relation to return an address for
   Please use this in preference to lat/lon where possible 
 lat=<value>
 lon=<value>
   The location to generate an address for
 zoom=[0-18]
   Level of detail required where 0 is country and 18 is house/building
 addressdetails=[0|1]
   Include a breakdown of the address into elements
 email=<valid email address>
   If you are making large numbers of request please include a valid email address
   or alternatively include your email address as part of the User-Agent string.
   This information will be kept confidential and only used to contact you in the
   event of a problem, see Usage Policy for more details.

範例

 http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1
 <reversegeocode timestamp="Fri, 06 Nov 09 16:33:54 +0000" querystring="...">
   <result place_id="1620612" osm_type="node" osm_id="452010817">
     135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom
   </result>
   <addressparts>
     <house>135</house>
     <road>Pilkington Avenue</road>
     <village>Wylde Green</village>
     <town>Sutton Coldfield</town>
     <city>City of Birmingham</city>
     <county>West Midlands (county)</county>
     <postcode>B72</postcode>
     <country>United Kingdom</country>
     <country_code>gb</country_code>
   </addressparts>   
 </reversegeocode>

詳情/地名

詳細資訊頁面(details.php)會上產生很高的服務器負載,而且僅作為調試之用途,因此目前沒有提供XML API。寫入腳本或大量的使用可能會導致IP禁令。

使用政策

關於nominatim.openstreetmap.org的使用政策,請查看Nominatim使用政策

Mapquest 也提供了一個版本的API,沒有使用限制。詳情請參閱[1]

源代碼

Nominatim是基於PostgreSQL的導入實用程式osm2pgsql使用替代地名輸出選項。索引和搜尋是使用的C,PLPGSQL和PHP相結合進行。源可以在這裡找到:

http://github.com/twain47/Nominatim

完整的安裝說明可以在Nominatim/Installation中找到。 .

Bug/錯誤報告

Nominatim由Twain維護,請使用Nominatim元件Trac報告錯誤。