反向维基百科地理标记查找 [英] Reverse wikipedia geotagging lookup

查看:38
本文介绍了反向维基百科地理标记查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

维基百科是地理标记 一个很多 文章.(在页面右上角查看.)

Wikipedia is geotagging a lot of its articles. (Look in the top right corner of the page.)

是否有任何 API 可以查询指定半径范围内的所有 地理标记页面地理位置?

Is there any API for querying all geotagged pages within a specified radius of a geographical position?

好的,所以基于lost-theory的答案,我尝试了这个(在DBpedia查询浏览器上):

Okay, so based on lost-theory's answer I tried this (on DBpedia query explorer):

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?subject ?label ?lat ?long WHERE {
    ?subject geo:lat ?lat.
    ?subject geo:long ?long.
    ?subject rdfs:label ?label.
    FILTER(xsd:float(?lat) - 57.03185 <= 0.05 && 57.03185 - xsd:float(?lat) <= 0.05
        && xsd:float(?long) - 9.94513 <= 0.05 && 9.94513 - xsd:float(?long) <= 0.05
        && lang(?label) = "en"
    ).
} LIMIT 20

这与我想要的非常接近,除了它在 (local) 围绕该点的正方形而不是圆形.另外,我希望结果是否根据与该点的距离进行排序.(如果可能.)

This is very close to what I want, except it returns results within a (local) square around the point and not a circle. Also I would like if the results where sorted based on the distance from the point. (If possible.)

我试图将欧几里得距离确定为真实距离的近似值,但在 SPARQL 中对数字求平方时遇到了问题.(问题在此处打开.)当我得到有用的东西时,我会更新问题,但与此同时,我将不胜感激关于替代方法的任何建议.

I am trying to determine the euclidean distance as an approximation of the true distance, But I am having trouble on squaring a number in SPARQL. (Question opened here.) When I get something useful I will update the question, but in the meantime I will appreciate any suggestions on alternative approaches.

最后更新.我放弃了通过 DBpedia 使用 SPARQL.我编写了一个简单的解析器,它获取 Wikipedia 文章文本每晚数据库转储并解析所有文章以进行地理编码.它工作得相当好,它允许我随意存储有关带有地理标记的文章的信息.

A final update. I gave up on using SPARQL through DBpedia. I have written a simple parser which fetches the Wikipedia article text nightly database dump and parses all articles for geocodes. It works rather nicely and it allows me to store information about geotagged articles however I wish.

这可能是我将继续使用的解决方案,如果我能够为它创建一个很好的接口,我可能会考虑允许公共 API 访问和/或将源发布到解析器.

This is probably the solution I will continue using, and if I get around to create a nice interface to it I might consider allowing public API access and/or publishing the source to the parser.

推荐答案

dbpedia 端点使用的 OpenLink Virtuoso 服务器具有多个查询功能.我在 http://docs.openlinksw.com/virtuoso/rdfsparqlgeospat.html 对类似问题很有用.

The OpenLink Virtuoso server used by the dbpedia endpoint has several query features. I found the information on http://docs.openlinksw.com/virtuoso/rdfsparqlgeospat.html useful for a similar problem.

我最终得到了这样的查询:

I ended up with a query such as this:

SELECT ?page ?lat ?long (bif:st_distance(?geo, bif:st_point(15.560278, 58.394167)))
WHERE{
    ?m foaf:page ?page.
    ?m geo:geometry ?geo.
    ?m geo:lat ?lat.
    ?m geo:long ?long.
    FILTER (bif:st_intersects (?geo, bif:st_point(15.560278, 58.394167), 30))
}
ORDER BY ASC 4 LIMIT 15

此示例检索距原点位置 30 公里范围内的地理标记位置.

This example retrieves the geotagged locations within 30 km from the origin position.

这篇关于反向维基百科地理标记查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆