Ejemplo n.º 1
0
		public bool Equals(Location coor)
		{
			if (coor == null)
				return false;

			return (this.Latitude == coor.Latitude && this.Longitude == coor.Longitude);
		}
		public static Task<IEnumerable<Address>> ReverseGeocodeAsync(this IAsyncGeocoder geoCoder, Location location)
		{
			if (location == null)
				throw new ArgumentNullException("location");

			return geoCoder.ReverseGeocodeAsync(location.Latitude, location.Longitude);
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Given a coordinate, and a search radius search for results closest to a particular coordinate.
        /// </summary>
        /// <param name="coordinate"></param>
        /// <param name="searchRadius"></param>
        /// <param name="maxResults"></param>
        /// <returns></returns>
        public List <SpatialSearchResultItem> GetSpatialResultsByDistance(Geocoding.Location coordinate, double searchRadius, int maxResults = 50)
        {
            IEnumerable <SpatialSearchResultItem> results = GetComputedByCoordinate <SpatialSearchResultItem>(coordinate, searchRadius, maxResults);

            List <SpatialSearchResultItem> distanceResults = new List <SpatialSearchResultItem>();

            foreach (var spatialResult in results)
            {
                spatialResult.Distance = this._distanceCalculator.CalculateDistanceGps(coordinate, new Geocoding.Location(spatialResult.GeoLocation.Coordinates[1], spatialResult.GeoLocation.Coordinates[0]));
                distanceResults.Add(spatialResult);
            }
            return(distanceResults);
        }
Ejemplo n.º 4
0
		public Bounds(Location southWest, Location northEast)
		{
			if (southWest == null)
				throw new ArgumentNullException("southWest");

			if (northEast == null)
				throw new ArgumentNullException("northEast");

			if (southWest.Latitude > northEast.Latitude)
				throw new ArgumentException("southWest latitude cannot be greater than northEast latitude");

			this.southWest = southWest;
			this.northEast = northEast;
		}
Ejemplo n.º 5
0
		public virtual Distance DistanceBetween(Location location, DistanceUnits units)
		{
			double earthRadius = (units == DistanceUnits.Miles) ? Distance.EarthRadiusInMiles : Distance.EarthRadiusInKilometers;

			double latRadian = ToRadian(location.Latitude - this.Latitude);
			double longRadian = ToRadian(location.Longitude - this.Longitude);

			double a = Math.Pow(Math.Sin(latRadian / 2.0), 2) +
				Math.Cos(ToRadian(this.Latitude)) *
				Math.Cos(ToRadian(location.Latitude)) *
				Math.Pow(Math.Sin(longRadian / 2.0), 2);

			double c = 2.0 * Math.Asin(Math.Min(1, Math.Sqrt(a)));

			double distance = earthRadius * c;
			return new Distance(distance, units);
		}
Ejemplo n.º 6
0
		public Address(string formattedAddress, Location coordinates, string provider)
		{
			formattedAddress = (formattedAddress ?? "").Trim();

			if (String.IsNullOrEmpty(formattedAddress))
				throw new ArgumentNullException("formattedAddress");

			if (coordinates == null)
				throw new ArgumentNullException("coordinates");

			if (provider == null)
				throw new ArgumentNullException("provider");

			this.formattedAddress = formattedAddress;
			this.coordinates = coordinates;
			this.provider = provider;
		}
Ejemplo n.º 7
0
		public virtual Distance DistanceBetween(Location location)
		{
			return DistanceBetween(location, DistanceUnits.Miles);
		}
Ejemplo n.º 8
0
		public ParsedAddress(string formattedAddress, Location coordinates, string provider)
			: base(formattedAddress, coordinates, provider)
		{
		}
Ejemplo n.º 9
0
		public Address(string formattedAddress, Location coordinates, string provider)
		{
			FormattedAddress = formattedAddress;
			Coordinates = coordinates;
			Provider = provider;
		}