开发者

freebase get buildings and geolocation

I need to get all the buildings with "church" function that are far 100km from a specified point (lat, lng). I made in this way:

[{
"id":            null,
"name":          null,
"typ开发者_JAVA百科e":          "/architecture/building",
"building_function" : [{"name" : 'church'}],
"/location/location/geolocation" : {"latitude" : 45.1603653, "longitude" : 10.7976976}
"/location/location/area" : 100
}]​

but I alway get an empty response

code: "/api/status/ok"
result: []
status: "200 OK"
transaction_id: "cache;cache03.p01.sjc1:8101;2011-04-16T12:32:45Z;0035"

What am I missing? Thanks


An area isn't a distance and you probably don't want an exact match to the value "100" anyway. You've asked for things which are precisely at that long/lat and have exactly that area.

Are you looking for churches which are less than a certain distance, more than a certain distance, or exactly the given distance? You probably want to look at the Geosearch API http://api.freebase.com/api/service/geosearch?help (although it's not a long term solution since it's been deprecated)


The /location/location/area property is used to query locations which cover a certain amount of area. So your query looks for buildings centered at (45.1603653, 10.7976976) which cover an area of 100km. Naturally there are no results that match.

Searching for topics within 100km of a those coordinates takes a little more work. You'll need to use the Geosearch service which is still in alpha. The following query should give you the results that you're looking for:

http://www.freebase.com/api/service/geosearch?location={%22type%22:%22Point%22,%22coordinates%22:[10.7976976,45.1603653]}&type=/architecture/building&within=100&indent=1

Once you have that list of buildings, you can query the MQL Read API to find out which ones are churches like this:

[{
  "id": null,
  "name": null,
  "type": "/architecture/building",
  "building_function" : [{"name" : 'church'}],
  "filter:id|=":[
    "/en/verona_arena",
    "/en/basilica_palladiana",
    "/en/teatro_olimpico",
    "/en/palazzo_del_te",
    "/en/villa_capra_la_rotonda",
    "/en/villa_badoer",
    "/en/san_petronio_basilica",
    "/en/palazzo_schifanoia",
    "/en/palazzo_chiericati",
    "/en/basilica_di_santandrea_di_mantova",
    "/en/basilica_of_san_domenico",
    "/en/castello_estense",
    "/en/palazzo_dei_diamanti",
    "/en/villa_verdi",
    "/en/cathedral_of_cremona",
    "/en/monte_berico",
    "/en/villa_pojana",
    "/en/san_sebastiano",
    "/en/cremona_baptistery",
    "/en/palazzo_della_pilotta"
  ]
}]​

Right now its only matching 2 results so you'll probably need to edit some of those topics to mark them as churches.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜