in reply to Re^4: Calculate aircraft headings from GPS data for google kml display
in thread Calculate aircraft headings from GPS data for google kml display

Without looking at the calcs in detail, I would say that you should convert the data (if size is not prohibitive) to a hash where each key is the aircraft ID and the value is an array hashes containing the other data points from each row with that aircraft ID.

You can then easily loop over the aircraft IDs. Assuming the data rows are already sorted by time it should be a relatively simple matter to step through the array items at that point calculating the deltas.

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
  • Comment on Re^5: Calculate aircraft headings from GPS data for google kml display

Replies are listed 'Best First'.
Re^6: Calculate aircraft headings from GPS data for google kml display
by hujunsimon (Sexton) on Jun 09, 2014 at 23:50 UTC

    Yes, that sounds right. definitely need to use the hash keys to step through all these items. Any chance you have an example to point me to, that would greatly appreciated !

    thank you !

    Si

      ah, i also find this perl module Geo::Calc to help me calculate the headings: https://metacpan.org/pod/Geo::Calc.

      seems i just need to step through all the data and feed the right lats and longs to this module, very promising !

      I think this approach might work. Please note that this is just "shooting-from-the-hip" psuedo-code.

      my %aircraft_ids; for my $row ( INPUT_ROWS ) { my ($row_id,$a_id,@row_fields) = split(',', $row); if ( exists( $aircraft)ids{$a_id} ) { my $prior_fields = $aircraft_ids{$a_id}; # do calcs here comparing current row data to priors } # and save these data points for the next time the ID is seen. $aircraft_ids{$a_id} = \@row_fields; }
      There are several way you can represent the row data in the array, but this should point you in the right direction.

      You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.