示例#1
0
        public Dictionary <int, double> CountDistancesFromPackageToCouriers(List <User> couriers, Package package)
        {
            var distances = new Dictionary <int, double>();

            var packageLocationCoordinates = new LocationCoordinates()
            {
                Lat = package.Sender.lat,
                Lon = package.Sender.lon
            };

            foreach (var courier in couriers)
            {
                var courierLocationCoordinates = new LocationCoordinates()
                {
                    Lat = courier.lat,
                    Lon = courier.lon
                };

                var distance = GetDistanceBetweenTwoPlaces(packageLocationCoordinates, courierLocationCoordinates);

                distances[courier.Id] = distance;
            }

            return(distances);
        }
示例#2
0
        public LocationCoordinates ChangeLocationToCoordinates(string city, string postCode, string street, string streetNumber)
        {
            var location     = GetCoordinatesForAddress("Polska", city, postCode, street, streetNumber);
            var locationData = _jsonSerializer.DeserializeLocation(location);

            var locationCoordinates = new LocationCoordinates()
            {
                Lat = locationData[0].lat,
                Lon = locationData[0].lon,
            };

            return(locationCoordinates);
        }
示例#3
0
        public LocationCoordinates ChangeLocationToCoordinates(User user)
        {
            var location     = GetCoordinatesForAddress("Polska", user.City, user.PostCode, user.Street, user.StreetNumber);
            var locationData = _jsonSerializer.DeserializeLocation(location);

            var locationCoordinates = new LocationCoordinates()
            {
                Lat = locationData[0].lat,
                Lon = locationData[0].lon,
            };

            return(locationCoordinates);
        }
示例#4
0
        public double GetDistanceBetweenTwoPlaces(LocationCoordinates originLocation, LocationCoordinates destinationLocation)
        {
            Coordinate origin = new Coordinate()
            {
                Latitude = originLocation.Lat, Longitude = originLocation.Lon
            };
            Coordinate destination = new Coordinate()
            {
                Latitude = destinationLocation.Lat, Longitude = destinationLocation.Lon
            };

            double distance = GeoCalculator.GetDistance(origin, destination, 1, DistanceUnit.Kilometers);

            return(distance);
        }