我正在使用Wikidata API从名人那里获取出生位置,然后使用Google Maps API显示该位置。这是我使用的Wikidata请求:
SELECT DISTINCT ?item ?itemLabel ?birthLocation ?birthLocationLabel WHERE {
?item (wdt:P31|wdt:P101|wdt:P106)/wdt:P279* wd:Q482980 ;
rdfs:label "Mary Wollstonecraft"@en ;
wdt:P19 ?birthLocation
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
然后,我使用Google地理编码器从birthLocationLabel获取纬度,并将其显示在地图上,但是有时地理编码器找不到位置(也许该地点不再存在),所以我是否想知道是否可以从Wikidata查询中获取坐标?我知道出生位置具有“坐标位置”属性,但是我不知道如何访问它。
的链接答案 0 :(得分:2)
这对我有效?birthLocation wdt:P625 ?coordinates
,因此整个查询将是:
SELECT DISTINCT ?item ?itemLabel ?coordinates ?birthLocation ?birthLocationLabel
WHERE {
?item ((wdt:P31|wdt:P101|wdt:P106)/(wdt:P279*)) wd:Q482980;
rdfs:label "Mary Wollstonecraft"@en;
wdt:P19 ?birthLocation.
?birthLocation wdt:P625 ?coordinates.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
这将返回:
[{
"item": "http://www.wikidata.org/entity/Q101638",
"itemLabel": "Mary Wollstonecraft",
"coordinates": "Point(-0.075 51.5166)",
"birthLocation": "http://www.wikidata.org/entity/Q123219",
"birthLocationLabel": "Spitalfields"
}]