Get WikiData Identifier for city by GPS location

蹲街弑〆低调 提交于 2019-12-20 03:09:52

问题


I want to get the city /settlement at a specific gps location. meaning the closest one in a given range or at best the closest.

i found some example queries in the wikimedia data examples.

I try to adopt then but i get only errors or timeouts

here is my current query:

 SELECT *
    WHERE
    {
      ?city wdt:P31/wdt:P279* wd:Q15642541 . // only settlements
       # Search by Nearest
  SERVICE wikibase:around { 
    ?place wdt:P625 ?location . 
    bd:serviceParam wikibase:center "Point(8.4024875340491 48.9993762209831)"^^geo:wktLiteral .
    bd:serviceParam wikibase:radius "1" . 
    bd:serviceParam wikibase:distance ?distance .
  }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
    } 
ORDER By ?distance

The query works when i left out the settlement condition. Butwhen i add it the query takes too long What am I doing wrong? Whats the correct syntax?


回答1:


I Found my bug.

here is the working query:

 SELECT DISTINCT *
    WHERE
    {
      ?place wdt:P31/wdt:P279* wd:Q515 .
       # Search by Nearest
  SERVICE wikibase:around { 
    ?place wdt:P625 ?location . 
    bd:serviceParam wikibase:center "Point(8.4024875340491 48.9993762209831)"^^geo:wktLiteral .
    bd:serviceParam wikibase:radius "10" . 
    bd:serviceParam wikibase:distance ?distance .
  }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
    } 

Order by  ?distance


来源:https://stackoverflow.com/questions/44718137/get-wikidata-identifier-for-city-by-gps-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!