/// <summary>
        /// Converts a location type name into something more readable.
        /// </summary>
        public static void ConvertPlaceType(this HtmlHelper htmlHelper, PlaceType placeType)
        {
            switch (placeType)
            {
            case PlaceType.Country:
                htmlHelper.ViewContext.Writer.Write("Country");
                break;

            case PlaceType.AdministrativeAreaLevel1:
                htmlHelper.ViewContext.Writer.Write("State");
                break;

            case PlaceType.AdministrativeAreaLevel2:
                htmlHelper.ViewContext.Writer.Write("City / County");
                break;

            case PlaceType.Route:
                htmlHelper.ViewContext.Writer.Write("Road");
                break;

            default:
                htmlHelper.ViewContext.Writer.Write(placeType.ToString());
                break;
            }
        }
Esempio n. 2
0
        public static string From(PlaceType type)
        {
            List <char> letters = new List <char>();
            var         name    = type.ToString();

            for (int i = 0; i < name.Length; i++)
            {
                char letter = name[i];

                if (char.IsUpper(letter))
                {
                    if (i != 0)
                    {
                        letters.Add('_');
                    }
                    letters.Add(Char.ToLower(letter));
                }
                else
                {
                    letters.Add(letter);
                }
            }

            return(new string(letters.ToArray()));
        }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        /// <param name="client"></param>
        /// <param name="query"></param>
        /// <param name="region">https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains</param>
        /// <param name="returnFields"></param>
        /// <returns></returns>
        public async Task <Response <Place> > FindBusiness(HttpClient client, string query, double?lat = null, double?lng = null, int?radiusInMeters = 50000, string region = null, string language = null, string pageToken = null, PlaceType?type = null, string[] returnFields = null)
        {
            var location = lat.HasValue && lng.HasValue ? $"{lat},{lng}" : string.Empty;

            var uri = "";

            if (string.IsNullOrWhiteSpace(pageToken))
            {
                uri = GetPlacesQueryString(
                    "textsearch",
                    ("query", query),
                    ("type", type?.ToString()),
                    ("location", location),
                    ("radius", radiusInMeters?.ToString()),
                    ("region", region),
                    ("language", language),
                    ("fields", string.Join(",", returnFields ?? GoogleApiBase.SearchFieldsBasic.Concat(GoogleApiBase.SearchFieldsContact).Concat(GoogleApiBase.SearchFieldsAtmosphere)))
                    );
            }
            else
            {
                uri = $"{GeoPlacesUrl}textsearch/json?pagetoken={pageToken}&key={GoogleApiKey}";
            }

            return(await MakeRequest(client, uri));
        }
Esempio n. 4
0
        public IActionResult NewNonNetworkItem(string placeId, PlaceType placeType,
                                               string name, string type, int count)
        {
            NonNetworkItem item;

            if (placeType == PlaceType.Room)
            {
                item = new NonNetworkRoomItem {
                    Type = Enum.Parse <NonNetworkRoomItem.NonNetworkRoomItemType>(type)
                }
            }
            ;
            else if (placeType == PlaceType.Rack)
            {
                item = new NonNetworkRackItem {
                    Type = Enum.Parse <NonNetworkRackItem.NonNetworkRackItemType>(type)
                }
            }
            ;
            else
            {
                throw new NotImplementedException();
            }

            item.Place = placeId;
            item.Name  = name;
            item.Count = count;

            db.Save(item);
            return(RedirectToAction(nameof(Item), new { type = placeType.ToString(), id = placeId.ToString() }));
        }
        /// <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="threshold">The minimum number of photos that a place type must have to be included.
        /// If the number of photos is lowered then the parent place type for that place will be used.</param>
        /// <param name="tags">A list of tags. Photos with one or more of the tags listed will be returned.</param>
        /// <param name="tagMode">Either 'any' for an OR combination of tags, or 'all' for an AND combination.
        /// Defaults to 'any' if not specified.</param>
        /// <param name="machineTags"></param>
        /// <param name="machineTagMode"></param>
        /// <param name="minUploadDate">Minimum upload date.</param>
        /// <param name="maxUploadDate">Maximum upload date.</param>
        /// <param name="minTakenDate">Minimum taken date.</param>
        /// <param name="maxTakenDate">Maximum taken date.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PlacesPlacesForTagsAsync(PlaceType placeType, string woeId, string placeId, int threshold,
                                             string[] tags, TagMode tagMode, string[] machineTags,
                                             MachineTagMode machineTagMode, DateTime minUploadDate,
                                             DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate,
                                             Action <FlickrResult <PlaceCollection> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.placesForTags");

            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);
            }
            if (threshold > 0)
            {
                parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (tags != null && tags.Length > 0)
            {
                parameters.Add("tags", String.Join(",", tags));
            }
            if (tagMode != TagMode.None)
            {
                parameters.Add("tag_mode", UtilityMethods.TagModeToString(tagMode));
            }
            if (machineTags != null && machineTags.Length > 0)
            {
                parameters.Add("machine_tags", String.Join(",", machineTags));
            }
            if (machineTagMode != MachineTagMode.None)
            {
                parameters.Add("machine_tag_mode", UtilityMethods.MachineTagModeToString(machineTagMode));
            }
            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 (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }

            GetResponseAsync <PlaceCollection>(parameters, callback);
        }
Esempio n. 6
0
        private Place InstantiatePlace(PlaceType baseType)
        {
            Place baseResult = Instantiate <Place>(basePrefab);

            baseResult.transform.parent = gameObject.transform;
            baseResult.name             = baseType.ToString();

            return(baseResult);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets PlaceTypeDescriptionAttribute associated with PlaceType value.
        /// </summary>
        /// <param name="value">Type of place.</param>
        /// <returns>Attributes associated with PlaceType value.</returns>
        private static PlaceTypeDescriptionAttribute GetPlaceDescriptionAttribute(PlaceType value)
        {
            if (!(value.GetType().GetField(value.ToString()) is FieldInfo fieldInfo))
            {
                return(null);
            }

            if (!(fieldInfo.GetCustomAttribute(typeof(PlaceTypeDescriptionAttribute))
                  is PlaceTypeDescriptionAttribute placeAttribute))
            {
                return(null);
            }

            return(placeAttribute);
        }
        /// <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="threshold">The minimum number of photos that a place type must have to be included.
        /// If the number of photos is lowered then the parent place type for that place will be used.</param>
        /// <param name="contactType">The type of contacts to return places for. Either all, or friends and family only.</param>
        /// <param name="minUploadDate">Minimum upload date.</param>
        /// <param name="maxUploadDate">Maximum upload date.</param>
        /// <param name="minTakenDate">Minimum taken date.</param>
        /// <param name="maxTakenDate">Maximum taken date.</param>
        /// <returns></returns>
        public PlaceCollection PlacesPlacesForContacts(PlaceType placeType, string woeId, string placeId, int threshold,
                                                       ContactSearch contactType, DateTime minUploadDate,
                                                       DateTime maxUploadDate, DateTime minTakenDate,
                                                       DateTime maxTakenDate)
        {
            CheckRequiresAuthentication();

            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.placesForContacts");

            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);
            }
            if (threshold > 0)
            {
                parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (contactType != ContactSearch.None)
            {
                parameters.Add("contacts", (contactType == ContactSearch.AllContacts ? "all" : "ff"));
            }
            if (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }
            if (minTakenDate != DateTime.MinValue)
            {
                parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            }
            if (maxTakenDate != DateTime.MinValue)
            {
                parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));
            }

            return(GetResponseCache <PlaceCollection>(parameters));
        }
Esempio n. 9
0
        public void PlacesGetPlaceTypes()
        {
            var pts = TestData.GetInstance().PlacesGetPlaceTypes();

            Assert.IsNotNull(pts);
            Assert.IsTrue(pts.Count > 1, "Count should be greater than one. Count = " + pts.Count + ".");

            foreach (var kp in pts)
            {
                Assert.AreNotEqual(0, kp.Id, "Key should not be zero.");
                Assert.IsNotNull(kp.Name, "Value should not be null.");

                Assert.IsTrue(Enum.IsDefined(typeof(PlaceType), kp.Id), "PlaceType with ID " + kp.Id + " and Value '" + kp.Name + "' not defined in PlaceType enum.");
                PlaceType type = (PlaceType)kp.Id;
                Assert.AreEqual(type.ToString("G").ToLower(), kp.Name, "Name of enum should match.");
            }
        }
Esempio n. 10
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 async Task <FlickrResult <PlaceCollection> > PlacesPlacesForBoundingBoxAsync(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(await GetResponseAsync <PlaceCollection>(parameters));
        }
Esempio n. 11
0
        /// <summary>
        /// Gets the places of a particular type that the authenticated user has geotagged photos.
        /// </summary>
        /// <param name="placeType">The type of places to return.</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="threshold">The minimum number of photos that a place type must have to be included.
        /// If the number of photos is lowered then the parent place type for that place will be used.
        /// For example if you only have 3 photos taken in the locality of Montreal (WOE ID 3534)
        /// but your threshold is set to 5 then those photos will be "rolled up"
        /// and included instead with a place record for the region of Quebec (WOE ID 2344924).</param>
        /// <param name="minUploadDate">Minimum upload date. Photos with an upload date greater than or equal to this value will be returned.</param>
        /// <param name="maxUploadDate">Maximum upload date. Photos with an upload date less than or equal to this value will be returned. </param>
        /// <param name="minTakenDate">Minimum taken date. Photos with an taken date greater than or equal to this value will be returned. </param>
        /// <param name="maxTakenDate">Maximum taken date. Photos with an taken date less than or equal to this value will be returned. </param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PlacesPlacesForUserAsync(PlaceType placeType, string woeId, string placeId, int threshold,
                                             DateTime minUploadDate, DateTime maxUploadDate, DateTime minTakenDate,
                                             DateTime maxTakenDate, Action <FlickrResult <PlaceCollection> > callback)
        {
            CheckRequiresAuthentication();

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.placesForUser");

            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);
            }
            if (threshold > 0)
            {
                parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            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 (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }

            GetResponseAsync <PlaceCollection>(parameters, callback);
        }
        /// <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)
        {
            var 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 <TwentyThreeResult <PlaceCollection> > callback)
        {
            var 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);
        }
Esempio n. 14
0
        /// <summary>
        /// Return the top 100 most geotagged places for a day.
        /// </summary>
        /// <param name="placeType">The type for a specific place type to cluster photos by. </param>
        /// <param name="date">A valid date. The default is yesterday.</param>
        /// <param name="placeId">Limit your query to only those top places belonging to a specific Flickr Places identifier.</param>
        /// <param name="woeId">Limit your query to only those top places belonging to a specific Where on Earth (WOE) identifier.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public async Task <FlickrResult <PlaceCollection> > PlacesGetTopPlacesListAsync(PlaceType placeType, DateTime date, string placeId, string woeId)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.getTopPlacesList");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (date != DateTime.MinValue)
            {
                parameters.Add("date", date.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo));
            }
            if (!String.IsNullOrEmpty(placeId))
            {
                parameters.Add("place_id", placeId);
            }
            if (!String.IsNullOrEmpty(woeId))
            {
                parameters.Add("woe_id", woeId);
            }

            return(await GetResponseAsync <PlaceCollection>(parameters));
        }
        /// <summary>
        /// Return the top 100 most geotagged places for a day.
        /// </summary>
        /// <param name="placeType">The type for a specific place type to cluster photos by. </param>
        /// <param name="date">A valid date. The default is yesterday.</param>
        /// <param name="placeId">Limit your query to only those top places belonging to a specific Flickr Places identifier.</param>
        /// <param name="woeId">Limit your query to only those top places belonging to a specific Where on Earth (WOE) identifier.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PlacesGetTopPlacesListAsync(PlaceType placeType, DateTime date, string placeId, string woeId,
                                                Action <TwentyThreeResult <PlaceCollection> > callback)
        {
            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.getTopPlacesList");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (date != DateTime.MinValue)
            {
                parameters.Add("date",
                               date.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo));
            }
            if (!string.IsNullOrEmpty(placeId))
            {
                parameters.Add("place_id", placeId);
            }
            if (!string.IsNullOrEmpty(woeId))
            {
                parameters.Add("woe_id", woeId);
            }

            GetResponseAsync <PlaceCollection>(parameters, callback);
        }
Esempio n. 16
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);
        }
 private NameValueCollection BuildGeoParameters(double latitude, double longitude, PlaceType? granularity, string accuracy, string query)
 {
     NameValueCollection nameValueCollection = new NameValueCollection();
     nameValueCollection.Add("lat", latitude.ToString((IFormatProvider) CultureInfo.InvariantCulture));
     nameValueCollection.Add("long", longitude.ToString((IFormatProvider) CultureInfo.InvariantCulture));
     if (granularity.HasValue)
     {
         nameValueCollection.Add("granularity", granularity.ToString().ToLower());
     }
     if (accuracy != null)
     {
         nameValueCollection.Add("accuracy", accuracy);
     }
     if (query != null)
     {
         nameValueCollection.Add("query", query);
     }
     return nameValueCollection;
 }
Esempio n. 18
0
 private string TranslatePlaceType(PlaceType t)
 {
     return(_specialTypeTranslations.ContainsKey(t)
                         ? _specialTypeTranslations[t]
                         : t.ToString().ToSnakeCase());
 }
Esempio n. 19
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="threshold">The minimum number of photos that a place type must have to be included. 
        /// If the number of photos is lowered then the parent place type for that place will be used.</param>
        /// <param name="contactType">The type of contacts to return places for. Either all, or friends and family only.</param>
        /// <param name="minUploadDate">Minimum upload date.</param>
        /// <param name="maxUploadDate">Maximum upload date.</param>
        /// <param name="minTakenDate">Minimum taken date.</param>
        /// <param name="maxTakenDate">Maximum taken date.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PlacesPlacesForContactsAsync(PlaceType placeType, string woeId, string placeId, int threshold,
            ContactSearch contactType, DateTime minUploadDate,
            DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate,
            Action<FlickrResult<PlaceCollection>> callback)
        {
            CheckRequiresAuthentication();

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.places.placesForContacts");

            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);
            if (threshold > 0)
                parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            if (contactType != ContactSearch.None)
                parameters.Add("contacts", (contactType == ContactSearch.AllContacts ? "all" : "ff"));
            if (minUploadDate != DateTime.MinValue)
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            if (maxUploadDate != DateTime.MinValue)
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            if (minTakenDate != DateTime.MinValue)
                parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            if (maxTakenDate != DateTime.MinValue)
                parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));

            GetResponseAsync<PlaceCollection>(parameters, callback);
        }
Esempio n. 20
0
        /// <summary>
        /// Return the top 100 most geotagged places for a day.
        /// </summary>
        /// <param name="placeType">The type for a specific place type to cluster photos by. </param>
        /// <param name="date">A valid date. The default is yesterday.</param>
        /// <param name="placeId">Limit your query to only those top places belonging to a specific Flickr Places identifier.</param>
        /// <param name="woeId">Limit your query to only those top places belonging to a specific Where on Earth (WOE) identifier.</param>
        /// <returns></returns>
        public PlaceCollection PlacesGetTopPlacesList(PlaceType placeType, DateTime date, string placeId, string woeId)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.places.getTopPlacesList");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (date != DateTime.MinValue) parameters.Add("date", date.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo));
            if (!String.IsNullOrEmpty(placeId)) parameters.Add("place_id", placeId);
            if (!String.IsNullOrEmpty(woeId)) parameters.Add("woe_id", woeId);

            return GetResponseCache<PlaceCollection>(parameters);
        }
Esempio n. 21
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="threshold">The minimum number of photos that a place type must have to be included. If the number of photos is lowered then the parent place type for that place will be used.</param>
        /// <param name="tags">A list of tags. Photos with one or more of the tags listed will be returned.</param>
        /// <param name="tagMode">Either 'any' for an OR combination of tags, or 'all' for an AND combination. Defaults to 'any' if not specified.</param>
        /// <param name="machineTags"></param>
        /// <param name="machineTagMode"></param>
        /// <param name="minUploadDate">Minimum upload date.</param>
        /// <param name="maxUploadDate">Maximum upload date.</param>
        /// <param name="minTakenDate">Minimum taken date.</param>
        /// <param name="maxTakenDate">Maximum taken date.</param>
        /// <returns></returns>
        public PlaceCollection PlacesPlacesForTags(PlaceType placeType, string woeId, string placeId, int threshold, string[] tags, TagMode tagMode, string[] machineTags, MachineTagMode machineTagMode, DateTime minUploadDate, DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.places.placesForTags");

            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);
            if (threshold > 0) parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            if (tags != null && tags.Length > 0) parameters.Add("tags", String.Join(",", tags));
            if (tagMode != TagMode.None) parameters.Add("tag_mode", UtilityMethods.TagModeToString(tagMode));
            if (machineTags != null && machineTags.Length > 0) parameters.Add("machine_tags", String.Join(",", machineTags));
            if (machineTagMode != MachineTagMode.None) parameters.Add("machine_tag_mode", UtilityMethods.MachineTagModeToString(machineTagMode));
            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 (minUploadDate != DateTime.MinValue) parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            if (maxUploadDate != DateTime.MinValue) parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));

            return GetResponseCache<PlaceCollection>(parameters);
        }
 public PlaceCollection PlacesPlacesForUser(PlaceType placeTypeId, string placeType, string woeId, string placeId, int? threshold, DateTime? minUploadDate, DateTime? maxUploadDate, DateTime? minTakenDate, DateTime? maxTakenDate)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.places.placesForUser");
     if (placeTypeId != PlaceType.None) dictionary.Add("place_type_id", placeTypeId.ToString().ToLower());
     if (placeType != null) dictionary.Add("place_type", placeType);
     if (woeId != null) dictionary.Add("woe_id", woeId);
     if (placeId != null) dictionary.Add("place_id", placeId);
     if (threshold != null) dictionary.Add("threshold", threshold.ToString().ToLower());
     if (minUploadDate != null) dictionary.Add("min_upload_date", minUploadDate.Value.ToUnixTimestamp());
     if (maxUploadDate != null) dictionary.Add("max_upload_date", maxUploadDate.Value.ToUnixTimestamp());
     if (minTakenDate != null) dictionary.Add("min_taken_date", minTakenDate.Value.ToUnixTimestamp());
     if (maxTakenDate != null) dictionary.Add("max_taken_date", maxTakenDate.Value.ToUnixTimestamp());
     return GetResponse<PlaceCollection>(dictionary);
 }
 public PlaceCollection PlacesPlacesForTags(PlaceType placeTypeId, string woeId, string placeId, int? threshold, IEnumerable<string> tags, TagMode tagMode, IEnumerable<string> machineTags, MachineTagMode machineTagMode, DateTime? minUploadDate, DateTime? maxUploadDate, DateTime? minTakenDate, DateTime? maxTakenDate)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.places.placesForTags");
     if (placeTypeId != PlaceType.None) dictionary.Add("place_type_id", placeTypeId.ToString().ToLower());
     if (woeId != null) dictionary.Add("woe_id", woeId);
     if (placeId != null) dictionary.Add("place_id", placeId);
     if (threshold != null) dictionary.Add("threshold", threshold.ToString().ToLower());
     if (tags != null) dictionary.Add("tags", tags == null ? String.Empty : String.Join(",", tags.ToArray()));
     if (tagMode != TagMode.None) dictionary.Add("tag_mode", tagMode.ToString().ToLower());
     if (machineTags != null) dictionary.Add("machine_tags", machineTags == null ? String.Empty : String.Join(",", machineTags.ToArray()));
     if (machineTagMode != MachineTagMode.None) dictionary.Add("machine_tag_mode", machineTagMode.ToString().ToLower());
     if (minUploadDate != null) dictionary.Add("min_upload_date", minUploadDate.Value.ToUnixTimestamp());
     if (maxUploadDate != null) dictionary.Add("max_upload_date", maxUploadDate.Value.ToUnixTimestamp());
     if (minTakenDate != null) dictionary.Add("min_taken_date", minTakenDate.Value.ToUnixTimestamp());
     if (maxTakenDate != null) dictionary.Add("max_taken_date", maxTakenDate.Value.ToUnixTimestamp());
     return GetResponse<PlaceCollection>(dictionary);
 }
 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);
 }
 public PlaceCollection PlacesGetTopPlacesList(PlaceType placeTypeId, DateTime? date, string placeId, string woeId)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.places.getTopPlacesList");
     dictionary.Add("place_type_id", placeTypeId.ToString().ToLower());
     if (date != null) dictionary.Add("date", date.Value.ToUnixTimestamp());
     if (placeId != null) dictionary.Add("place_id", placeId);
     if (woeId != null) dictionary.Add("woe_id", woeId);
     return GetResponse<PlaceCollection>(dictionary);
 }
Esempio n. 26
0
        public static List <Place> UpdateNearbyPlaces(string apiKey, Location location, int radius, PlaceType type, List <Place> setOfNearbyPlaces)
        {
            try
            {
                string constructedUrl = GOOGLE_BASE_URL + string.Format(PLACE_SEARCH, location.lat.ToString().Replace(",", "."), location.lng.ToString().Replace(",", "."), radius, type.ToString(), apiKey);

                PlaceJson placesJson = HttpRequest.GetNearbyPlaceResponse(constructedUrl);
                return(GetListOfPlaces(apiKey, placesJson, location, setOfNearbyPlaces));
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Call the google api to get the places
        /// </summary>
        /// <param name="miles"></param>
        /// <param name="baseLocation"></param>
        /// <param name="placeType"></param>
        /// <param name="apiKey"></param>
        /// <returns></returns>
        public static List <CoolPlace> GetCoolPlacesFromGoogle(int miles, string baseLocation, PlaceType placeType, string apiKey)
        {
            List <CoolPlace> coolPlaces = new List <CoolPlace>();
            //https://developers.google.com/places/web-service/search#find-place-examples

            string baseUrl = "https://maps.googleapis.com/maps/api/place/";
            //string apiKey = "&key=AIzaSyCM0J-Drb3xKzY96XecL7khAfs33zM4Uac";
            string outputType = "/json?";

            //int miles = 10;
            int metersPerMile = 1609;
            int radius        = miles * metersPerMile;

            string searchFunction = "nearbysearch";
            // string baseLocation = "location=-33.8670522,151.1957362";
            string radiusParm = "&radius=" + radius.ToString();

            //string searchParms = "&types=food";
            //string searchParms = "&type=restaurant";
            string searchParms = "&type=" + placeType.ToString();

            string parms = baseLocation + radiusParm + searchParms;

            //The 'using' will help to prevent memory leaks.
            //Create a new instance of HttpClient
            string apiCall = baseUrl + searchFunction + outputType + parms + apiKey;

            while (apiCall != string.Empty)
            {
                using (HttpClient client = new HttpClient())
                {
                    var response = client.GetAsync(apiCall).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        var responseContent = response.Content;

                        // by calling .Result you are synchronously reading the result
                        string responseString = responseContent.ReadAsStringAsync().Result;

                        dynamic responseData = JsonConvert.DeserializeObject(responseString);

                        int docCount = (int)responseData.results.Count;

                        for (int i = 0; i < docCount; i++)
                        {
                            CoolPlace place = new CoolPlace();
                            place.Name     = responseData.results[i].name;
                            place.ID       = responseData.results[i].id;
                            place.PlaceID  = responseData.results[i].place_id;
                            place.Icon     = responseData.results[i].icon;
                            place.Rating   = responseData.results[i].rating;
                            place.Location = responseData.results[i].vicinity;
                            if (responseData.results[i].photos.Count > 0)
                            {
                                CoolPlacePhoto photo = new CoolPlacePhoto();
                                photo.PhotoReference = responseData.results[i].photos[0].photo_reference;
                                photo.Height         = responseData.results[i].photos[0].height;
                                photo.Width          = responseData.results[i].photos[0].width;
                                place.Photo          = photo;
                            }

                            coolPlaces.Add(place);
                        }

                        // see if we need to get more results
                        string pagetoken = responseData.next_page_token;
                        apiCall = string.Empty;
                        if (pagetoken != null)
                        {
                            string parmsNext = "pagetoken=" + pagetoken;
                            apiCall = baseUrl + searchFunction + outputType + parmsNext + apiKey;
                        }
                    }
                }
            }

            return(coolPlaces);
        }
Esempio n. 28
0
        /// <summary>
        /// Return the top 100 most geotagged places for a day.
        /// </summary>
        /// <param name="placeType">The type for a specific place type to cluster photos by. </param>
        /// <param name="date">A valid date. The default is yesterday.</param>
        /// <param name="placeId">Limit your query to only those top places belonging to a specific Flickr Places identifier.</param>
        /// <param name="woeId">Limit your query to only those top places belonging to a specific Where on Earth (WOE) identifier.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PlacesGetTopPlacesListAsync(PlaceType placeType, DateTime date, string placeId, string woeId,
            Action<FlickrResult<PlaceCollection>> callback)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.places.getTopPlacesList");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (date != DateTime.MinValue)
                parameters.Add("date",
                               date.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo));
            if (!String.IsNullOrEmpty(placeId)) parameters.Add("place_id", placeId);
            if (!String.IsNullOrEmpty(woeId)) parameters.Add("woe_id", woeId);

            GetResponseAsync<PlaceCollection>(parameters, callback);
        }
Esempio n. 29
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>
        /// <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);
        }
Esempio n. 30
0
        /// <summary>
        /// Gets the places of a particular type that the authenticated user has geotagged photos.
        /// </summary>
        /// <param name="placeType">The type of places to return.</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="threshold">The minimum number of photos that a place type must have to be included. If the number of photos is lowered then the parent place type for that place will be used.
        /// For example if you only have 3 photos taken in the locality of Montreal (WOE ID 3534) but your threshold is set to 5 then those photos will be "rolled up" and included instead with a place record for the region of Quebec (WOE ID 2344924).</param>
        /// <param name="minUploadDate">Minimum upload date. Photos with an upload date greater than or equal to this value will be returned.</param>
        /// <param name="maxUploadDate">Maximum upload date. Photos with an upload date less than or equal to this value will be returned. </param>
        /// <param name="minTakenDate">Minimum taken date. Photos with an taken date greater than or equal to this value will be returned. </param>
        /// <param name="maxTakenDate">Maximum taken date. Photos with an taken date less than or equal to this value will be returned. </param>
        /// <returns>The list of places of that type.</returns>
        public PlaceCollection PlacesPlacesForUser(PlaceType placeType, string woeId, string placeId, int threshold, DateTime minUploadDate, DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate)
        {
            CheckRequiresAuthentication();

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.places.placesForUser");

            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);
            if (threshold > 0) parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            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 (minUploadDate != DateTime.MinValue) parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            if (maxUploadDate != DateTime.MinValue) parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));

            return GetResponseCache<PlaceCollection>(parameters);
        }