Flight Historian 2.3
Automatic Distance Calculations and GPX/KML Maps
While a great deal of my flight entry work has been automated since Version 2.1, one outstanding manual entry was the distance associated with a given route between two airports. Flight Historian would automatically add a new route to my Routes table the first time I flew it, but I’d have to manually go back in and add the distance via an Edit Route page.
I decided that it would be a good idea for me to add latitude and longitude fields to my Airport model, which would then allow me to calculate distances between airport pairs. Now, when I add a new airport, I use the FlightXML API to lookup and store the airport’s coordinates in my database.
For the distance calculation itself, I used the Haversine Formula. The Haversine formula isn’t quite perfect since the Earth is not quite a perfect sphere, but since flight distances are already an estimate (planes don’t perfectly follow the great circle line), the Haversine worst-case error of 0.5% was more than acceptable for this calculation. Thus, I decided against using Vincenty’s formulae, which are more accurate but also more computationally expensive.
Flight Historian uses the Great Circle Mapper to generate its maps. However, I wanted to have the ability to create a map I could export.
GPX and KML are both XML-based geographic data formats, which I’ve already used for my GPS Logging projects. They both have the ability to specify the coordinates of points and lines on a map, which is all I really need to create flight maps.
Generating the files was a relatively straightforward task. I already had a
Map class which would accept airports, routes, and options, and create a querystring I could pass to the Great Circle Mapper. Generating this querystring already involved looping through the provided airports and routes to build a string with a specified format; I could use similar loops to generate an XML document in accordance with the GPX or KML specifications.
- Added latitudes and longitudes to airports
- Added Terminal Silhouettes to Show Airport views
- Added layover ratio to Show Trip Section views
- Added FlightXML API lookup for latitudes and longitudes when adding new airports
- Added ability to calculate route distances between two airports, using the haversine formula
Mapclass to convert airports to internally use airport IDs instead of IATA codes