我正在使用DBPedia数据,我正在尝试使用多对地理坐标找到所有不同的地方。有时可能会将某个地方称为具有多个纬度或经度。我想确定这些案例。我有以下查询作为示例,但是对于只有一个坐标的地方,返回计算的是多个纬度。
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT * WHERE{
SELECT DISTINCT ?subject (?latitude) (COUNT(?latitude) as ?latitude_counter) (?longitude) (COUNT(?longitude) as ?longitude_counter)
WHERE {
?subject rdfs:label ?label ; a dbpedia-owl:Place.
?subject geo:lat ?latitude; geo:long ?longitude.
}
}
GROUP BY ?subject
HAVING (?latitude_counter > 1)
ORDER BY ?subject
LIMIT 10
这个问题的正确方法是什么?
答案 0 :(得分:0)
对于愿意执行相同任务的人,以下查询按预期检索我的结果:
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?subject,
?longitude_counter,
?latitude_counter,
(group_concat(?latitude ; separator = "||") AS ?latitude_set),
(group_concat(?longitude ; separator = "||") AS ?longitude_set)
WHERE
{
{
SELECT DISTINCT * WHERE
{
SELECT DISTINCT ?subject (COUNT(?latitude) as ?latitude_counter) (COUNT(?longitude) as ?longitude_counter)
WHERE
{
?subject geo:lat ?latitude; geo:long ?longitude .
}
}
}
?subject geo:lat ?latitude; geo:long ?longitude .
FILTER(?latitude_counter > 1 or ?longitude_counter > 1)
}
ORDER BY DESC(?longitude_counter)