Example #1
0
        public static double distanceBetweenLocations(Places.Location locA, Places.Location locB)
        {
            double earthRadius = 6371.00; // in Km

            double lat_diff = degreesToRadians(locA.Lat - locB.Lat);
            double lng_diff = degreesToRadians(locA.Lng - locB.Lng);

            double latA_rads = degreesToRadians(locA.Lat);
            double latB_rads = degreesToRadians(locB.Lat);

            double a = Math.Pow(Math.Sin(lat_diff / 2.0), 2) + Math.Pow(Math.Sin(lng_diff / 2.0), 2) * Math.Cos(latA_rads) * Math.Cos(latB_rads);
            double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));

            return(earthRadius * c);
        }
        public void PlacesPhotos_ValidQuery()
        {
            Places.PlacesSearch placesSearch   = new Places.PlacesSearch(VALID_SETUP);
            Places.Location     VALID_LOCATION = new Places.Location(40.757870, -73.983996);

            Task <Tuple <Places.NearbySearchResultList, ResponseStatus> > searchResults =
                placesSearch.GetNearbySearchResultsRankByProminenceWithOptions(VALID_LOCATION, 10000.00, type: Places.NearbySearchTypes.MUSEUM);

            searchResults.Wait();

            Places.NearbySearchResultList resultList = searchResults.Result.Item1;

            int photoCounter = 0;

            for (int i = 0; i < resultList.Results.Count; i++)
            {
                if (resultList.Results[i].Photos != null && resultList.Results[i].Photos.Count > 0)
                {
                    List <Places.Photo> photos = resultList.Results[i].Photos;

                    for (int j = 0; j < photos.Count; j++)
                    {
                        Places.Photo photo = photos[j];

                        Task <Tuple <String, ResponseStatus> > response = placesPhotos.GetPlacesPhotos(photo.Photo_ref, EDITABLE_VALID_FILE_LOCATION + $"_{photoCounter}.jpg", maxHeight: 500);
                        response.Wait();

                        Assert.IsNotNull(response.Result.Item1);
                        Assert.AreEqual(response.Result.Item1, EDITABLE_VALID_FILE_LOCATION + $"_{photoCounter}.jpg");
                        Assert.IsTrue(System.IO.File.Exists(response.Result.Item1));

                        Assert.AreEqual(response.Result.Item2, Places.PlacesStatus.OK);

                        photoCounter++;
                    }
                }
            }

            for (int i = 0; i < photoCounter; i++)
            {
                System.IO.File.Delete(EDITABLE_VALID_FILE_LOCATION + $"_{i}.jpg");
            }
        }