Flickrからgeotag検索

前の記事で改造してtagsとmachine_tagsが読めるようになったNet::Flickrを使う。
machine_tag検索で、geo:lat=とgeo:lon=が入っている写真を検索すればいい。
あとややこしいが、flickrはgeotagと別にSony GPS CS1K等で埋め込まれたgeoDataというのがあるので
getWithGeoDataで検索してやらないと網羅できない。 http://flickr.com/services/api/flickr.photos.getWithGeoData.html

#!/usr/bin/ruby
require 'rubygems'
require 'net/flickr'

flickr = Net::Flickr.new('your-api-key')

flickr.photos.search('machine_tags' => 'geo:lat=,geo:lon=',
                     'machine_tag_mode' => 'all',
                     'extras' => 'tags,machine_tags',
                     'per_page' => 5).each{|photo|
  puts photo.title
  puts photo.page_url
  puts photo.source_url(:medium)
  puts 'tags=>' << photo.tags
  puts 'machine_tags=>' << photo.machine_tags
  puts '---'
}

結果

Marco
http://www.flickr.com/photos/53755594@N00/2328043661
http://farm4.static.flickr.com/3199/2328043661_2863feac4d.jpg
tags=>cameraphone roma celltagged geotagged demo italia bluetagged teamlife carlolicciardi massimovalla peopletagged cell:mnc=1 cell:mcc=222 geo:source=cgi people:fn=carlolicciardi people:fn=massimovalla address:city=roma geo:range=380 address:country=italia cell:lac=61502 cell:cellid=98442050 cell:cgi=22216150298442050 geo:lat=41818933 geo:lon=12416226 address:street=vialeparcodemedici
machine_tags=>cell:mcc=222 cell:mnc=1 cell:lac=61502 cell:cellid=98442050 cell:cgi=22216150298442050 geo:source=cgi geo:lat=41818933 geo:lon=12416226 geo:range=380 address:street=vialeparcodemedici address:city=roma address:country=italia people:fn=carlolicciardi people:fn=massimovalla
    • -
Bellver de Cerdanya (IV) http://www.flickr.com/photos/53552950@N00/2328858444 http://farm3.static.flickr.com/2370/2328858444_eae2afe5ba.jpg tags=>street houses windows sky clouds canon geotagged alley europe doors village pavement decay facades catalonia powershot stonewall catalunya walls lleida bellverdecerdanya a640 tonivc estiu2007 geo:lat=42376807 geo:lon=1763306 machine_tags=>geo:lat=42376807 geo:lon=1763306
    • -
12032008177 http://www.flickr.com/photos/14111604@N06/2328858358 http://farm4.static.flickr.com/3082/2328858358_1581ff1760.jpg tags=>shozu geotagged geo:lat=5365031 geo:lon=298275 machine_tags=>geo:lon=298275 geo:lat=5365031
    • -
2008-03-08 Open-air museum of contemporary art http://www.flickr.com/photos/43144679@N00/2328025075 http://farm3.static.flickr.com/2392/2328025075_e4ab50c0ba.jpg tags=>pictures trash canon germany geotagged 350d junk market sale painted row frame rubbish land nrw multicultural 2008 wuppertal bergisches bergischesland nordrheinwestfalen henning jumble schlock elberfeld brokers northrhinewestfalia shlock ragfair mühlinghaus bergishland wuppertalelberfeld geo:lat=5127029110 geo:lon=715996385 machine_tags=>geo:lat=5127029110 geo:lon=715996385
    • -
Lord's http://www.flickr.com/photos/42358423@N00/2328843942 http://farm3.static.flickr.com/2181/2328843942_2d414c7ec0.jpg tags=>shozu geotagged geo:lon=016922 geo:lat=5153007 machine_tags=>geo:lon=016922 geo:lat=5153007
    • -