我正在尝试编写一个只返回一个村庄,城镇或城市的脚本。我正在使用以下YQL查询,但console的结果太具体了,它们首先给了我邻居。
select * from flickr.places where lat=51.558418 and lon=-1.781985 and api_key=YOU_FLICKR_API_KEY
以下是我从控制台查询的结果。
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="1" yahoo:created="2011-10-25T09:35:50Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="1" execution-stop-time="123" execution-time="122"><![CDATA[http://api.flickr.com/services/rest/?method=flickr.places.findByLatLon&lat=51.558418&lon=-1.781985]]></url>
<user-time>124</user-time>
<service-time>122</service-time>
<build-version>22535</build-version>
</diagnostics>
<results>
<places accuracy="16" latitude="51.558418" longitude="-1.781985" total="1">
<place latitude="51.547" longitude="-1.802"
name="West Leaze, Swindon, England, GB, United Kingdom"
place_id="sddCvK9SW703gg" place_type="neighbourhood"
place_type_id="22"
place_url="/United+Kingdom/England/Swindon/West+Leaze"
timezone="Europe/London" woeid="39722"/>
</places>
</results>
</query>
我希望能够更改查询中的place_type_id。我知道我可以使用正则表达式来隔离信息,但我不确定这是否适用于所有位置,因此我更倾向于让API返回我想要的结果。
答案 0 :(得分:2)
Flickr的flickr.places.findByLatLon
方法(由YQL查询在后台调用)接受accuracy
密钥。
accuracy
(可选)记录位置信息的准确度。世界水平为1,国家为~3,区域为~6,城市为~11,街道为~16。目前的范围是1-16。默认值为16。
请参阅»Flickr docs for flickr.places.FindByLatLon
。
使用它就像在accuracy =
子句中提供n
where
一样简单。大约10的值看起来与您正在寻找的准确性有关,但要试验看看哪种是最好的。
select * from flickr.places where
lat=51.558418 and lon=-1.781985 and api_key=API_KEY_HERE
and accuracy=10
<强>除了强>
通常可以通过查看表格描述来获取YQL表使用的数据源/服务的文档。
desc flickr.places
这提供了大量信息,通常包括至少一个指向文档页面的链接。有关meta
项目,请参阅documentationURL
部分。