예제 #1
0
        public async Task <IEnumerable <Place> > GetPlaces(int offset, int quantity, Geolocation location, double distance, bool includePlaylist)
        {
            var geohashes = DistanceService.GeohashQueries(location, distance);
            var dbResult  = (await _dao.GetPlaces(offset, quantity, geohashes)).Select(p => _mapper.ToApplicationEntity(p));

            var results = dbResult.Where(p => DistanceService.Distance(p.Location, location) < distance).ToList();

            if (includePlaylist)
            {
                results.ForEach(r =>
                {
                    var p = playlistService.GetMainPlaylistFromPlace(r.Id, true, 1, int.MaxValue);
                    p.Wait();
                    r.MainPlaylist = p.Result;
                });
            }

            results.ForEach(r =>
            {
                var p = songService.GetRecognizedSongsFromPlace(r.Id);
                p.Wait();
                r.RecognizedMusic = p.Result;
            });

            return(results);
        }
        [InlineData(35.658611111111, 139.74555555556, 19.590615, -155.424133, 'M', 4048.83)] // TOKYO - HAWAI
        public void TestDistance(Double latitude1, Double longitude1, Double latitude2, Double longitude2, Char unit, double expectedDistance)
        {
            // Arrange
            DistanceService distanceService = new DistanceService();

            // Act
            double computedDistance = distanceService.Distance(latitude1, longitude1, latitude2, longitude2, unit);

            // Assert
            // Due to approximation, we roundup to the integer
            Assert.Equal((Int32)computedDistance, (Int32)expectedDistance);
        }
예제 #3
0
 public async Task <Result <Distance> > Distance(string postcodeFrom, string postcodeTo,
                                                 AccessToken accessToken = default, CancellationToken cancellationToken = default)
 {
     return(await distanceService.Distance(postcodeFrom, postcodeTo, accessToken : accessToken, cancellationToken : cancellationToken));
 }
예제 #4
0
        /// <summary>
        /// Get the distance in miles with another airport
        /// </summary>
        /// <param name="airport">Remote airport</param>
        /// <returns>Distance in miles</returns>
        public Double GetDistance(Airport airport)
        {
            var distanceService = new DistanceService();

            return(distanceService.Distance(this.Latitude, this.Longitude, airport.Latitude, airport.Longitude, 'M'));
        }