public void BoundaryBoxCalculateSizesFrankfurtToBerlin() { BoundaryBox b = new BoundaryBox(8.68194, 50.11222, 13.29750, 52.52222); double e = b.DiagonalDistanceInMiles(); Assert.IsTrue(259.9 < e && e < 260.0); }
/// <summary> /// Return a list of the top 100 unique places clustered by a given placetype for set of tags or machine tags. /// </summary> /// <param name="placeType">The ID for a specific place type to cluster photos by. </param> /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. </param> /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param> /// <param name="boundaryBox">The boundary box to search for places in.</param> /// <param name="callback">Callback method to call upon return of the response from Flickr.</param> public void PlacesPlacesForBoundingBoxAsync(PlaceType placeType, string woeId, string placeId, BoundaryBox boundaryBox, Action <FlickrResult <PlaceCollection> > callback) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("method", "flickr.places.placesForBoundingBox"); parameters.Add("place_type_id", placeType.ToString("D")); if (!String.IsNullOrEmpty(woeId)) { parameters.Add("woe_id", woeId); } if (!String.IsNullOrEmpty(placeId)) { parameters.Add("place_id", placeId); } parameters.Add("bbox", boundaryBox.ToString()); GetResponseAsync <PlaceCollection>(parameters, callback); }
public void PhotosSearchPhotoSearchBoundaryBox() { var b = new BoundaryBox(103.675997, 1.339811, 103.689456, 1.357764, GeoAccuracy.World); var o = new PhotoSearchOptions { HasGeo = true, BoundaryBox = b, Accuracy = b.Accuracy, MinUploadDate = DateTime.Now.AddYears(-1), MaxUploadDate = DateTime.Now, Extras = PhotoSearchExtras.Geo | PhotoSearchExtras.PathAlias, Tags = "colorful" }; var ps = Instance.PhotosSearch(o); foreach (var p in ps) { // Annoying, but sometimes Flickr doesn't return the geo properties for a photo even for this type of search. if (Math.Abs(p.Latitude - 0) < 1e-8 && Math.Abs(p.Longitude - 0) < 1e-8) continue; Assert.IsTrue(p.Latitude > b.MinimumLatitude && b.MaximumLatitude > p.Latitude, "Latitude is not within the boundary box. {0} outside {1} and {2} for photo {3}", p.Latitude, b.MinimumLatitude, b.MaximumLatitude, p.WebUrl); Assert.IsTrue(p.Longitude > b.MinimumLongitude && b.MaximumLongitude > p.Longitude, "Longitude is not within the boundary box. {0} outside {1} and {2} for photo {3}", p.Longitude, b.MinimumLongitude, b.MaximumLongitude, p.WebUrl); } }
/// <summary> /// Takes the various properties of this instance and adds them to a <see cref="Dictionary{K,V}"/> instanced passed in, ready for sending to Flickr. /// </summary> /// <param name="parameters">The <see cref="Dictionary{K,V}"/> to add the options to.</param> public void AddToDictionary(Dictionary <string, string> parameters) { if (!string.IsNullOrEmpty(UserId)) { parameters.Add("user_id", UserId); } if (!string.IsNullOrEmpty(GroupId)) { parameters.Add("group_id", GroupId); } if (!string.IsNullOrEmpty(Text)) { parameters.Add("text", Text); } if (!string.IsNullOrEmpty(Tags)) { parameters.Add("tags", Tags); } if (TagMode != TagMode.None) { parameters.Add("tag_mode", UtilityMethods.TagModeToString(TagMode)); } if (!string.IsNullOrEmpty(MachineTags)) { parameters.Add("machine_tags", MachineTags); } if (MachineTagMode != MachineTagMode.None) { parameters.Add("machine_tag_mode", UtilityMethods.MachineTagModeToString(MachineTagMode)); } if (MinUploadDate != DateTime.MinValue) { parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(MinUploadDate).ToString()); } if (MaxUploadDate != DateTime.MinValue) { parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(MaxUploadDate).ToString()); } if (MinTakenDate != DateTime.MinValue) { parameters.Add("min_taken_date", UtilityMethods.DateToMySql(MinTakenDate)); } if (MaxTakenDate != DateTime.MinValue) { parameters.Add("max_taken_date", UtilityMethods.DateToMySql(MaxTakenDate)); } if (Licenses.Count != 0) { var licenseArray = new List <string>(); foreach (var license in Licenses) { licenseArray.Add(license.ToString("d")); } parameters.Add("license", String.Join(",", licenseArray.ToArray())); } if (PerPage != 0) { parameters.Add("per_page", PerPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Page != 0) { parameters.Add("page", Page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Extras != PhotoSearchExtras.None) { parameters.Add("extras", ExtrasString); } if (SortOrder != PhotoSearchSortOrder.None) { parameters.Add("sort", SortOrderString); } if (PrivacyFilter != PrivacyFilter.None) { parameters.Add("privacy_filter", PrivacyFilter.ToString("d")); } if (BoundaryBox != null && BoundaryBox.IsSet) { parameters.Add("bbox", BoundaryBox.ToString()); } if (Accuracy != GeoAccuracy.None) { parameters.Add("accuracy", Accuracy.ToString("d")); } if (SafeSearch != SafetyLevel.None) { parameters.Add("safe_search", SafeSearch.ToString("d")); } if (ContentType != ContentTypeSearch.None) { parameters.Add("content_type", ContentType.ToString("d")); } if (HasGeo != null) { parameters.Add("has_geo", HasGeo.Value ? "1" : "0"); } if (Latitude != null) { parameters.Add("lat", Latitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Longitude != null) { parameters.Add("lon", Longitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); } if (Radius != null) { parameters.Add("radius", Radius.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo)); } if (RadiusUnits != RadiusUnit.None) { parameters.Add("radius_units", (RadiusUnits == RadiusUnit.Miles ? "mi" : "km")); } if (Contacts != ContactSearch.None) { parameters.Add("contacts", (Contacts == ContactSearch.AllContacts ? "all" : "ff")); } if (WoeId != null) { parameters.Add("woe_id", WoeId); } if (PlaceId != null) { parameters.Add("place_id", PlaceId); } if (IsCommons) { parameters.Add("is_commons", "1"); } if (InGallery) { parameters.Add("in_gallery", "1"); } if (IsGetty) { parameters.Add("is_getty", "1"); } if (MediaType != MediaType.None) { parameters.Add("media", UtilityMethods.MediaTypeToString(MediaType)); } if (GeoContext != GeoContext.NotDefined) { parameters.Add("geo_context", GeoContext.ToString("d")); } if (Faves) { parameters.Add("faves", "1"); } if (PersonId != null) { parameters.Add("person_id", PersonId); } if (Camera != null) { parameters.Add("camera", Camera); } if (JumpTo != null) { parameters.Add("jump_to", JumpTo); } }
public PlaceCollection PlacesPlacesForBoundingBox(BoundaryBox bbox) { return PlacesPlacesForBoundingBox(bbox, PlaceType.None, null, null); }
public PlaceCollection PlacesPlacesForBoundingBox(BoundaryBox bbox, PlaceType placeType, int? placeTypeId, bool? recursive) { var dictionary = new Dictionary<string, string>(); dictionary.Add("method", "flickr.places.placesForBoundingBox"); dictionary.Add("bbox", bbox.ToString().ToLower()); if (placeType != PlaceType.None) dictionary.Add("place_type", placeType.ToString().ToLower()); if (placeTypeId != null) dictionary.Add("place_type_id", placeTypeId.ToString().ToLower()); if (recursive != null) dictionary.Add("recursive", recursive.Value ? "1" : "0"); return GetResponse<PlaceCollection>(dictionary); }
/// <summary> /// Return a list of the top 100 unique places clustered by a given placetype for set of tags or machine tags. /// </summary> /// <param name="placeType">The ID for a specific place type to cluster photos by. </param> /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. </param> /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param> /// <param name="boundaryBox">The boundary box to search for places in.</param> /// <returns></returns> public PlaceCollection PlacesPlacesForBoundingBox(PlaceType placeType, string woeId, string placeId, BoundaryBox boundaryBox) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("method", "flickr.places.placesForBoundingBox"); parameters.Add("place_type_id", placeType.ToString("D")); if (!String.IsNullOrEmpty(woeId)) { parameters.Add("woe_id", woeId); } if (!String.IsNullOrEmpty(placeId)) { parameters.Add("place_id", placeId); } parameters.Add("bbox", boundaryBox.ToString()); return(GetResponseCache <PlaceCollection>(parameters)); }
/// <summary> /// Return a list of the top 100 unique places clustered by a given placetype for set of tags or machine tags. /// </summary> /// <param name="placeType">The ID for a specific place type to cluster photos by. </param> /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. </param> /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param> /// <param name="boundaryBox">The boundary box to search for places in.</param> /// <returns></returns> public PlaceCollection PlacesPlacesForBoundingBox(PlaceType placeType, string woeId, string placeId, BoundaryBox boundaryBox) { Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("method", "flickr.places.placesForBoundingBox"); parameters.Add("place_type_id", placeType.ToString("D")); if (!String.IsNullOrEmpty(woeId)) parameters.Add("woe_id", woeId); if (!String.IsNullOrEmpty(placeId)) parameters.Add("place_id", placeId); parameters.Add("bbox", boundaryBox.ToString()); return GetResponseCache<PlaceCollection>(parameters); }
/// <summary> /// Return a list of the top 100 unique places clustered by a given placetype for set of tags or machine tags. /// </summary> /// <param name="placeType">The ID for a specific place type to cluster photos by. </param> /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. </param> /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param> /// <param name="boundaryBox">The boundary box to search for places in.</param> /// <param name="callback">Callback method to call upon return of the response from Flickr.</param> public void PlacesPlacesForBoundingBoxAsync(PlaceType placeType, string woeId, string placeId, BoundaryBox boundaryBox, Action<FlickrResult<PlaceCollection>> callback) { Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("method", "flickr.places.placesForBoundingBox"); parameters.Add("place_type_id", placeType.ToString("D")); if (!String.IsNullOrEmpty(woeId)) parameters.Add("woe_id", woeId); if (!String.IsNullOrEmpty(placeId)) parameters.Add("place_id", placeId); parameters.Add("bbox", boundaryBox.ToString()); GetResponseAsync<PlaceCollection>(parameters, callback); }
public void PhotosSearchPhotoSearchBoundaryBox() { BoundaryBox b = new BoundaryBox(103.675997, 1.339811, 103.689456, 1.357764, GeoAccuracy.World); PhotoSearchOptions o = new PhotoSearchOptions(); o.HasGeo = true; o.BoundaryBox = b; o.Accuracy = b.Accuracy; o.MinUploadDate = DateTime.Now.AddYears(-1); o.MaxUploadDate = DateTime.Now; o.Extras = PhotoSearchExtras.Geo; PhotoCollection ps = f.PhotosSearch(o); foreach (Photo p in ps) { // Annoying, but sometimes Flickr doesn't return the geo properties for a photo even for this type of search. if (p.Latitude == 0 && p.Longitude == 0) continue; Assert.IsTrue(p.Latitude > b.MinimumLatitude && b.MaximumLatitude > p.Latitude, "Latitude is not within the boundary box."); Assert.IsTrue(p.Longitude > b.MinimumLongitude && b.MaximumLongitude > p.Longitude, "Longitude is not within the boundary box."); } }
public void BoundaryBoxWithValidPointStringSetCorrectly() { var b = new BoundaryBox("1,2,3,4"); Assert.That(b.MinimumLongitude, Is.EqualTo(1M)); Assert.That(b.MinimumLatitude, Is.EqualTo(2M)); Assert.That(b.MaximumLongitude, Is.EqualTo(3M)); Assert.That(b.MaximumLatitude, Is.EqualTo(4M)); }
public PointLayer GetPointLayerByBounds(double neLat, double neLng, double swLat, double swLng, int page = 1, string[] ds = null, string[] tags = null) { PhotoSearchOptions searchOptions = new PhotoSearchOptions(); searchOptions.Licenses.Add(LicenseType.AttributionCC); searchOptions.Licenses.Add(LicenseType.AttributionShareAlikeCC); searchOptions.Licenses.Add(LicenseType.AttributionNoDerivativesCC); searchOptions.Licenses.Add(LicenseType.NoKnownCopyrightRestrictions); BoundaryBox bndry = new BoundaryBox(); if (neLat > swLat) { bndry.MinimumLatitude = swLat; bndry.MaximumLatitude = neLat; } else { bndry.MinimumLatitude = neLat; bndry.MaximumLatitude = swLat; } if (neLng > swLng) { bndry.MinimumLongitude = swLng; bndry.MaximumLongitude = neLng; } else { bndry.MinimumLongitude = neLng; bndry.MaximumLongitude = swLng; } searchOptions.BoundaryBox = bndry; if (!(tags == null || tags.Length < 1)) { searchOptions.Tags = string.Join(",", tags); searchOptions.TagMode = TagMode.AllTags; } searchOptions.Accuracy = GeoAccuracy.Street; searchOptions.PerPage = pageSize; searchOptions.SortOrder = PhotoSearchSortOrder.InterestingnessDescending; searchOptions.Extras |= PhotoSearchExtras.Geo; searchOptions.Extras |= PhotoSearchExtras.OwnerName; searchOptions.Extras |= PhotoSearchExtras.CountFaves; searchOptions.Extras |= PhotoSearchExtras.DateTaken; searchOptions.Extras |= PhotoSearchExtras.Description; searchOptions.Extras |= PhotoSearchExtras.Tags; searchOptions.Extras |= PhotoSearchExtras.SquareUrl; searchOptions.Page = page; PhotoCollection flickrPhotos = api.PhotosSearch(searchOptions); PointLayer result = new PointLayer(); result.DataSource = this.DataSource; result.TotalResults = flickrPhotos.Total; result.Page = flickrPhotos.Page; result.PageCount = flickrPhotos.Pages; result.Points = PointsFromPhotoCollection(flickrPhotos); result.PageSize = pageSize; return result; }
public PlaceCollection PlacesPlacesForBoundingBox(PlaceType placeType, string woeId, string placeId, BoundaryBox boundaryBox);