in reply to Re: Calculate aircraft headings from GPS data for google kml display
in thread Calculate aircraft headings from GPS data for google kml display
Thank you for all the comments. But my main problem is still how to loop around all these big dataset and calculate the headings. i think the logic should be something like this:
for ($aircraft_id){ $current_point_x = $latitude $current_point_y = $longitude $waypoint_x = $latitude_next $waypoint_y = $longitude_next //do some calculations on calculate headings ! //output headings }
Any ideas to parse through all these data and do calculations, the data is organised in a way that there are different aircraft in the dataset, but it can be identified by aircraft_id, and they are ordered by gps_time column, how could i get my two continuous points and calculate the heading. In Python, i could use dictionary to do that, as to perl, i don't know. help please !
thank you!
Si
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Calculate aircraft headings from GPS data for google kml display
by BrowserUk (Patriarch) on Jun 10, 2014 at 06:01 UTC | |
In Python, i could use dictionary to do that In Perl, a "dictionary" is called a hash. As you have multiple aircraft, you cannot use the rowids to determine consecutive coordinates for a given aircraft (unless there are always and only 2), so I've used a hash of arrays of hashes to accumulate the data in:
This print the headings for each aircraft as it reads the data:
Would've been nice if the sample contained some heading changes, and I'm somewhat suspicious of the exact 90° difference in the aircraft headings, so check the math. but this should get you started:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by hujunsimon (Sexton) on Jun 10, 2014 at 15:49 UTC | |
Awesome man, thanks for the tips, that's very helpful ! However, i have few more questions regarding your clever code, :-)! first, what does following few lines of code do ? i think the first one is to trim the raw data and put it into array, but i never saw lots of expressions you put there before, can you give a bit hint, especially the # at the end, :-)!
second, i understand the key method is to get it into a hash dictionary, by using:
But this does not seem to pick up the right number, i did a printf to check, it seems always 0. third, for the heading calculations, i think the math is fine, because the data represents the aircrafts at the take-off or landing stage, so most of heading should be 90 or 180 degree. also i don't need it to be that accurate, it's only for display purpose on the google earth. i did a check on one pair of coordinates by using your formula, it seems work fine.
I also upload more data here, in case you want to check ! _Data_
| [reply] [d/l] [select] |
by BrowserUk (Patriarch) on Jun 10, 2014 at 21:20 UTC | |
can you give a bit hint, especially the # at the end, :-)! A couple of corrections and a couple of tweaks:
With the extended dataset (still no course changes!), produces:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by hujunsimon (Sexton) on Jun 11, 2014 at 00:23 UTC | |
by BrowserUk (Patriarch) on Jun 11, 2014 at 02:10 UTC | |
| |
|
Re^3: Calculate aircraft headings from GPS data for google kml display
by boftx (Deacon) on Jun 09, 2014 at 23:25 UTC | |
DOH!
You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
| [reply] |
by hujunsimon (Sexton) on Jun 09, 2014 at 23:28 UTC | |
Hi boftx, the data sample is in my original post, let me knwo if it's not clear enough ! | [reply] |
by boftx (Deacon) on Jun 09, 2014 at 23:40 UTC | |
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.
| [reply] |
by hujunsimon (Sexton) on Jun 09, 2014 at 23:50 UTC | |
by hujunsimon (Sexton) on Jun 09, 2014 at 23:53 UTC | |
by boftx (Deacon) on Jun 10, 2014 at 00:17 UTC | |