public double Distance(Location destination) { var aLatRad=this.Latitude*Math.PI/180; var aLonRad=this.Longitude*Math.PI/180; var bLatRad = destination.Latitude * Math.PI / 180; var bLonRad = destination.Longitude * Math.PI / 180; return 20000 / Math.PI * Math.Acos(Math.Sin(aLatRad) * Math.Sin(bLatRad) + Math.Cos(aLatRad) * Math.Cos(bLatRad)* Math.Cos(bLonRad-aLonRad)); }
public City(Country country, System.Xml.Linq.XElement xCity, System.Xml.Linq.XDocument xDoc) { this.ID = xCity.Attribute("id").Value; this.Name = xCity.Element("name").Value; var xPop = xCity.Element("population"); if (xPop != null) this.Population = int.Parse(xPop.Value); var xLat = xCity.Element("latitude"); if (xLat == null) { //Debug.WriteLine(this.Name + " ohne Positionsangabe"); } else { Location = new Location() { Latitude = double.Parse(xCity.Element("latitude").Value, CultureInfo.InvariantCulture), Longitude = double.Parse(xCity.Element("longitude").Value, CultureInfo.InvariantCulture) }; } this.Country = country; }