user2747385
user2747385

Reputation: 31

Flickr 4 Java - How do you find pictures / metadata from a certain region? e.g. Vienna

Best

Goal : Receiving geographic data(coordinates), time-stamps... . "From pictures taken in Vienna."

My question: How can i do this in Java? (using flickrapi-1.2.jar)

What did i already found out? : Give me the 500 most recent pictures - url's ... :s

public static void main(String[] args) throws FlickrException, IOException,
        SAXException {

    String apiKey = "123456789abcdefghijklmnopqrstvwuxz";

    Flickr f = new Flickr(apiKey);

    PhotosInterface photosInterface = f.getPhotosInterface();
    Collection photosCollection = null;
    photosCollection = photosInterface.getRecent(500, 0);

    int i = 0;

    Photo photo = null;
    Iterator photoIterator = photosCollection.iterator();
    while (photoIterator.hasNext()) {
        i++;
        photo = (Photo) photoIterator.next();
        System.out.println(i + " - Description: " + photo.getSmallUrl());

    }
}

Option : Good Examples or a decent manual is welkom, because i don't know exactly how this API works...

Kind regards

Upvotes: 3

Views: 2757

Answers (1)

Itai Hay
Itai Hay

Reputation: 355

You need to call the flickr.photos.search API method.

With Flickr4Java it would look like this:

    String apikey;
    String secret;

    // Create a Flickr instance with your data. No need to authenticate
    Flickr flickr = new Flickr(apikey, secret, new REST());

    // Set the wanted search parameters (I'm not using real variables in the example)
    SearchParameters searchParameters = new SearchParameters();
    searchParameters.setAccuracy(accuracyLevel);
    searchParameters.setBBox(minimum_longitude, 
                                 minimum_latitude, 
                                 maximum_longitude, 
                                 maximum_latitude);

    PhotoList<Photo> list = flickr.getPhotosInterface().search(searchParameters, 0, 0);

    // Do something with the list

Upvotes: 3

Related Questions