Flight Historian 2.3: Automatic Distance Calculations and GPX/KML Maps

Automatic Distance Calculations

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.

GPX and KML Maps

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.

Google Earth, showing a trip from CMH-DFW-TUS-SFO-YVR-YYZ-CMH.
KML map files can be opened in Google Earth.

Changelog

Added

  • Latitudes and longitudes to the Airport model.
  • FlightXML API lookup for latitudes and longitudes when adding new airports.
  • Automatic distance calculation for new Routes, using the Haversine formula.
  • Terminal silhouettes to Show Airport views.
  • Layover ratios to Show Trip Section views with more than one flight.
  • Map.gpx and Map.kml methods for generating GPX and KML maps.

Changed

  • Map class now uses airport IDs instead of IATA codes.
  • Renamed Map.draw to Map.gcmap.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s