Exemplo n.º 1
0
        public void GetDistanceBetweenCoordinates_SimpleTest()
        {
            double distanceCalculated = DistanceHelper.GetDistanceBetweenCoordinates(new List <double>()
            {
                0.00D, 0.00D
            }, new List <double>()
            {
                0.00D, 0.00D
            });

            Assert.AreEqual(0.00D, distanceCalculated);
        }
Exemplo n.º 2
0
        public void GetDistanceBetweenCoordinates_Compare_From_Two_Parks()
        {
            // 0.0 0.0 is our destination address
            // 1.1 1.1 is our first park
            // 1.2 1.1 is our second park
            double distanceCalculatedForFirstPark = DistanceHelper.GetDistanceBetweenCoordinates(new List <double>()
            {
                0.00D, 0.00D
            }, new List <double>()
            {
                1.1D, 1.1D
            });
            double distanceCalculatedForSecondPark = DistanceHelper.GetDistanceBetweenCoordinates(new List <double>()
            {
                0.00D, 0.00D
            }, new List <double>()
            {
                1.2D, 1.1D
            });

            Assert.AreEqual(true, distanceCalculatedForSecondPark > distanceCalculatedForFirstPark);
        }
Exemplo n.º 3
0
        public ResultParkEntity[] GetParksByAddress(string address)
        {
            // Address to coordinates
            GeoLocation destinationLocation = geoCoder.GetLocationFromAddress(address);

            // list parks
            CityCarPark[] carParks = cityParks.GetCityParks();
            // measure
            CityCarPark[] carParksOrdered = carParks.OrderBy(k => DistanceHelper.GetDistanceBetweenCoordinates(destinationLocation.results[0].geomlonlat.coordinates,
                                                                                                               new List <double>()
            {
                k.LocalisationLatitude ?? 0.0D, k.LocalisationLongitude ?? 0.0D
            })).ToArray();
            int i = 1;

            ResultParkEntity[] resultParkEntities = carParksOrdered.Select(k => new ResultParkEntity()
            {
                Id = k.Id ?? 0, Name = k.Title, FreeSlots = k.Actuel ?? 0, Rank = i++
            }).ToArray();
            // top 3
            return(resultParkEntities);
        }