Beispiel #1
0
        private Location Parse(string input)
        {
            string[] tokens = Regex.Split(input.Substring(1, input.Length - 2), CsvPattern);

            var address = tokens[0];
            var latitude = double.Parse(tokens[1]);
            var longitude = double.Parse(tokens[2]);

            var geoCoodinate = new GeoCoordinate(latitude, longitude);

            return new Location { Address = address, Coordinates = geoCoodinate };
        }
Beispiel #2
0
        /// <summary>
        /// Calculates the distance between this geoCoordinate and another one, in meters.
        /// </summary>
        public double CalculateDistance(GeoCoordinate geoCoordinate)
        {
            var rlat1 = Math.PI * Latitude / 180;
            var rlat2 = Math.PI * geoCoordinate.Latitude / 180;
            var rlon1 = Math.PI * Longitude / 180;
            var rlon2 = Math.PI * geoCoordinate.Longitude / 180;
            var theta = Longitude - geoCoordinate.Longitude;
            var rtheta = Math.PI * theta / 180;
            var dist = Math.Sin(rlat1) * Math.Sin(rlat2) + Math.Cos(rlat1) * Math.Cos(rlat2) * Math.Cos(rtheta);
            dist = Math.Acos(dist);
            dist = dist * 180 / Math.PI;
            dist = dist * 60 * 1.1515;

            return dist * 1609.344;
        }
Beispiel #3
0
 public SpatialDocument(ISpatialDocument entity)
 {
     _id = entity.Id;
     _coordinates = entity.Coordinates;
 }