Search images in particular area

Topics: Developer Forum
Jul 1, 2010 at 10:21 AM

Hi there:

I want to get all images geo-located in a particular area (a coordinate as a center and a distance as a radius). I write the following code to do this job:

            PhotoSearchOptions options = new PhotoSearchOptions();
            options.PerPage = 500; // 100 is the default anyway
            options.Extras = PhotoSearchExtras.All;
            options.SortOrder= PhotoSearchSortOrder.InterestingnessDescending;

            options.Latitude = 39.51;
            options.Longitude = 116.25;
            options.Radius = 25;
            options.RadiusUnits = RadiusUnit.Kilometers;


The question is:
Is it a correct way to use options.Latitude, options.Longitude, options.Radius, options.RadiusUnits above? If wrong, please show me a example of  get all images geo-located in a particular area (a coordinate as a center and a distance as a radius).

Thanks!!!

Jul 1, 2010 at 10:26 AM

Because above code just gather  few images for me ( there exits large mounts of images in that area with the options.BoundaryBox method), so i am wondering whether my code is correct. 

Coordinator
Jul 1, 2010 at 10:29 AM
Edited Jul 1, 2010 at 10:35 AM
You might want to try setting the Accuracy setting as well and see if that has any affect.

Also, I always set the HasGeo = true - I don't know if this makes any difference though.

Finally - I would assume that a circle with a particular diameter, and the square that fits around that circle would return different results, as the square would cover a larger area. I don't know if this accounts for the difference you are seeing.

Sam
Jul 1, 2010 at 10:35 AM

Can you tell more details about the Accuracy setting? I am a noob, sorry.

Jul 1, 2010 at 10:37 AM

            List photos = new List();
            PhotoSearchOptions options = new PhotoSearchOptions();
            options.PerPage = 500; // 100 is the default anyway
            options.Extras = PhotoSearchExtras.All;
            options.SortOrder= PhotoSearchSortOrder.InterestingnessDescending;
            options.HasGeo = true;
            options.a


            options.Latitude = 39.5413;
            options.Longitude = 116.2329;
            options.Radius = 25;
            options.RadiusUnits = RadiusUnit.Kilometers;

            //options.BoundaryBox = new BoundaryBox(116.01, 39.40, 116.46, 40.06);
            options.Tags = "tiananmen";
            options.Page = 1; // page 1 is the default if Page is not set
            PhotoCollection firstSet = flickr.PhotosSearch(options);
            photos.AddRange(firstSet);
            if(firstSet.Count>200)
            {
                options.Page = 2;
                PhotoCollection secondSet = flickr.PhotosSearch(options);
                photos.AddRange(secondSet);
            }
This is my code above, BoundaryBox can return many results but options.Radius return noon.

Jul 1, 2010 at 10:39 AM

options.Accuracy = FlickrNet.GeoAccuracy.City;

have noon efforts, noon result return!

Coordinator
Jul 1, 2010 at 10:44 AM
If I change the Latitude to 39.92 and the Longitude to 116.40 then it
returns results. It might be that your 25km circle is in the wrong
place to fully capture the photos you are looking for.

Sam
Jul 1, 2010 at 10:53 AM

Thanks!

Another question: 

When i get the first page of the return images, if result contains less than 500 images, is that mean i have no need to gather the second page because these is no more result?

Coordinator
Jul 1, 2010 at 11:00 AM
Correct. The Pages property will tell you how many pages of results
there are available. If this is 1 then there are no more pages.
Jul 1, 2010 at 11:01 AM

Thanks very much! Best Wishes for you : )

PS:  Unlike standard photo queries, geo (or bounding box) queries will only return 250 results per page.