Marc Poulhiès
13 years ago
6 changed files with 214 additions and 10 deletions
@ 0,0 +1,65 @@


Photo placement 

 



File: `igc2kmz/__init__.py` 

Function: `Flight.make_photos_folder` 



igc2kmz uses the EXIF information embedded in the photo to place at the location it was taken. If the EXIF information includes a GPS position then this is used, otherwise the tracklog is examined to find the pilot's location when the photo was taken. 



This of course assumes that the user has set the time and date on his camera correctly, which unfortunately many people do not do. Also, if they do set it, they tend to set it to local time at home, which can be quite different from local time at the time and place of the flight and is not UTC. Unfortunately the EXIF information does not record any timezone, so we don't have complete information and the photos can end up placed incorrectly. 





Thermal and glide analysis 

 



File: `igc2kmz/track.py` 

Function: `Track.analyse` 



To identify thermals and glides a simple but effective heuristic is used. The average climb rate over 20 seconds is compared with the pilot's progress. Progress is defined as the distance travelled along the track divided by the change in position over the same period. For example, when flying in a straight line the progress is close to one, but if the pilot circles then progress drops to close to zero: the pilot travels a long distance along the track without covering much distance over the ground. Experimental investigation suggests that progress values over 0.9 correspond to gliding behaviour, and values less than this correspond to thermalling or emergency descent behaviour, even in strong winds. 



Therefore we can classify the track using the following: 



* progress > 0.9 ⇒ gliding 

* progress < 0.9 and climb rate > 0 ⇒ thermalling 

* progress < 0.9 and climb rate < 0 ⇒ emergency descent 



Further refinements include ensuring that the identified features are of interest to the pilot, that is that glides are long enough, a significant amount of height is gained in a thermal, and so on. 





Average, maximum and peak climb rates and thermal efficiency 

 



File: `igc2kmz/__init__.py` 

Function: `Flight.make_analysis_folder` 



The average climb rate is the calculated for the entire thermal, that is the total height gained divided by the time taken. Maximum climb rate is the maximum climb rate on a 20 second average. Peak climb rate is the highest climb rate observed between sequential points in the track log. 



The thermal efficiency is the average climb rate divided by the maximum climb rate. A thermal efficiency of 100% corresponds to flying straight into the strongest core and staying in it until exiting the thermal. Lower values correspond to spending less time in the core or losing the thermal completely at times. This simple model assumes that the maximum climb rate is achievable from the start of the thermal to its end which is rarely the case, usually the thermal strength varies with height depending on the airmass. 



In practice, thermal efficiencies over 80% are rare, 70% or higher is very good, and anything below 50% indicates broken thermals and/or poor thermalling technique. 





Salient altitude analysis 

 



File: `igc2kmz/util.py` 

Function: `salient` 



The pilot is often interested in his maximum or minimum altitude at various points. However, highlighting every local minima and maxima leads to an overwhelming number of points. The salient algorithm uses a divide and conquer technique to find all pairs of consecutive maxima and minima where the difference between them is greater than a certain threshold. Broadly speaking it proceeds as follows: 



* for a given sequence x[i]..x[j], if the overall trend is upwards (i.e. x[i] < x[j]) then find the largest drop in the sequence, that is find (m, n) that maximises x[m]  x[n] subject to m < n 

* if the overall trend is downwards (i.e. x[i] > x[j]) then the largest climb in the sequence, i.e find (m, n) that minimises x[m]  x[n] subject to m < n 

* if the overall trend is flat (i.e. x[i] == x[j]) then compute candidate values of (m, n) using both the above and chose the value of (m, n) that maximises  x[m]  x[n]  (i.e. find both the largest drop and the largest climb and choose which ever is bigger) 

* if the magnitude of this change is less than our threshold then we are done 

* otherwise add m and n to the set of salient points and recurse with the subsequences i..m, m..n, and n..j 



In the worst case the algorithm is O(N^2), but in the normal case is O(N log N). An obvious speedup is to prefilter the sequence to remove all monotonic subsequences but this has not proved necessary with the length of sequences used in the program. 





Spherical geometric functions 

 



File: `igc2kmz/coord.py` 

Function: `Coord.initial_bearing_to`, `Coord.distance_to`, `Coord.halfway_to`, `Coord.interpolate`, `Coord.coord_at` 



All these geometric formulae are taken from this excellent page of [spherical geometry formulae](http://www.movabletype.co.uk/scripts/latlong.html). Note that all distance calculations assume that the Earth is a perfect sphere with the FAI radius (r=6371km). 
@ 0,0 +1,59 @@


igc2kmz IGC to Google Earth converter 

===================================== 



igc2kmz converts paraglider and hang glider track logs into Google Earth KML format with lots of features, notably: 



* track colored by altitude, climb rate and ground speed 

* shadow feature makes it easier to judge the track's altitude by eye 

* animation of the flight 

* photos automatically placed where they were taken and with an optional comment 

* XC optimisation output 

* altitude graph and high and low points labelled 

* thermal and glide analysis 

* time marks 



It's used by the following XC league servers: 



* [Leonardo](http://www.paraglidingforum.com/leonardo) 

* [UK National XC League](http://www.uknxcl.org.uk/) 



Just upload your flight to one of these and you can download your flight in Google Earth format without having to install any extra software on your computer. 



It is designed to run on XC league servers, and as such is not designed to be directly used by pilots. 





Requirements 

 



* [Python](http://www.python.org/) version 2.5 or 2.6, not version 3.0 





Get the code 

 



Download either the [zip archive](http://github.com/twpayne/igc2kmz/zipball/master) or the [tar.gz archive](http://github.com/twpayne/igc2kmz/tarball/master). 



Unpack this archive somewhere. 



If you want to track development then you can checkout the source code with [git](http://git.or.cz/) instead of downloading an archive: 



git clone git://github.com/twpayne/igc2kmz.git 





Run it 

 



Change to the directory where you unpacked the archive and run: 



bin/igc2kmz.py i <inputfilename>.igc o <outputfilename>.kmz 





Customise it 

 



You can set various parameters via the command line, including the time zone offset in hours relative to UTC. For example, use `z 2` for Central European Time during the summer. For individual flights you can override the pilot name and glider type (otherwise they are taken from the IGC file), set the line color and width, add optimized XC information and photos with comments. Run `bin/igc2kmz.py help` for a full list of options. For example use, look at the Makefile. 



Rebuild the examples 

 



You can rebuild the example files with the command `make examples`. This will build the `olc2002` flight optimizer, optimize a number of flights, and create the KMZ files in the examples/ subdirectory. Be warned that the flight optimization step can take a long time (30 minutes on a 2.4GHz Core 2 Duo). 
@ 0,0 +1,32 @@


# igc2kmz waypoint functions 

# Copyright (C) 2010 Tom Payne 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the GNU General Public License 

# along with this program. If not, see <http://www.gnu.org/licenses/>. 





from math import pi 



from coord import Coord 





class Waypoint(Coord): 



def __init__(self, name, lat, lon, ele, description=None): 

Coord.__init__(self, lat, lon, ele) 

self.name = name 

self.description = description 



@classmethod 

def deg(cls, name, lat, lon, ele, description=None): 

return cls(name, pi * lat / 180.0, pi * lon / 180.0, ele, description) 
Loading…
Reference in new issue