XQuery/Flickr GoogleEarth

Flickr photos which are geo-coded can be used to generate a GoogleEarth overlay.

[** API not functional on this server yet **]

Select Photos

The code for the Flickr Api to kml transformation. $flickrKey is my Flickr API key (not shown).

declare option exist:serialize "method=xhtml media-type=application/vnd.google-earth.kml+xml";

declare function local:callFlickr($method,$params){ doc(concat("http://api.flickr.com/services/rest/?method=",$method,"&amp;api_key={$flickrKey}", string-join($params,"&amp;"))) };

let $username := request:request-parameter("username","") let $tags := string-join(request:request-parameter("tags",""),",")

let $user := string(local:callFlickr("flickr.people.findByUsername",concat("username=",$username))//user/@id) return  Places for {$username} tagged {$tags} { for $photo in local:callFlickr("flickr.photos.search",(concat("user_id=",$user),concat("tags=",$tags)))//photo let $photo_id := string($photo/@id) let $details := local:callFlickr("flickr.photos.getInfo",concat("photo_id=",$photo_id))//photo where exists($details/location) return  {string($details/title)} {let $url := string(local:callFlickr("flickr.photos.getSizes",concat("photo_id=",$photo_id))//size[@label="Small"]/@source) return util:serialize(  ,) }     {string($details/description)}  {string($details/location/@longitude)},{string($details/location/@latitude)},0   } 