public async Task <List <LocationLatLng> > GetPostcodeZipLatLongFromFile(string fileName)
        {
            List <LocationLatLng> fullPostcodesList = new List <LocationLatLng>();

            var allProcessedData = await File.ReadAllLinesAsync(fileName);

            foreach (var line in allProcessedData)
            {
                if (String.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                LocationLatLng p = new LocationLatLng(line);
                fullPostcodesList.Add(p);
            }

            return(fullPostcodesList);
        }
예제 #2
0
        public async Task <List <LocationLatLng> > GetVendorsCustomerCanVisit(LocationLatLng customerWithRadius)
        {
            var customerCoordinates = new Coordinate(customerWithRadius.Latitude, customerWithRadius.Longitude);

            List <LocationLatLng> vendorsWhoMatch = new List <LocationLatLng>();

            var vendors = await _vendorData.GetVendors();

            foreach (var vendor in vendors)
            {
                var vendorLocation = new Coordinate(vendor.Latitude, vendor.Longitude);

                double distance = GeoCalculator.GetDistance(customerCoordinates, vendorLocation, 0, DistanceUnit.Meters);

                if (distance < customerWithRadius.RadiusInMeters)
                {
                    vendorsWhoMatch.Add(vendor);
                }
            }

            return(vendorsWhoMatch);
        }