dlat = lat2 - lat1 dlon = lon2 - lon1 y = sin(lon2-lon1)*cos(lat2) x = cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1) if y > 0 then if x > 0 then tc1 = arctan(y/x) if x < 0 then tc1 = 180 - arctan(-y/x) if x = 0 then tc1 = 90 if y < 0 then if x > 0 then tc1 = -arctan(-y/x) if x < 0 then tc1 = arctan(y/x)-180 if x = 0 then tc1 = 270 if y = 0 then if x > 0 then tc1 = 0 if x < 0 then tc1 = 180 if x = 0 then [the 2 points are the same] #### #!/usr/bin/perl use POSIX qw(ceil floor); open(INPUT, $infile); @lines = ; close(INPUT); open(OUTPUT, ">$outfile"); sub trim($); $timeCounter = 0; $seconds = 0; $minutes = 0; $hours = 0; $comma = ","; $space = " "; print OUTPUT ""."\n"; print OUTPUT ""."\n"; print OUTPUT ""."\n"; foreach $currentLine(@lines) { @lineBuffer = split($delimiter,$currentLine); #--- At this point, we have the data from the current line. #--- Get all the elements $rowid = trim(@lineBuffer[0]); $aircraftid = trim(@lineBuffer[1]); $actual_date_time = trim(@lineBuffer[2]); #$end_time = trim(@lineBuffer[3]); $latitude = trim(@lineBuffer[3]); $longitude = trim(@lineBuffer[4]); $radio_altitude = trim(@lineBuffer[5]); $ground_speed = trim(@lineBuffer[6]); $thrust_engine_1 = trim(@lineBuffer[7]); $thrust_engine_2 = trim(@lineBuffer[8]); #--- Now, convert start and end times into UTC @timeString = split($space,$actual_date_time); $actual_date_time = @timeString[0]."T".@timeString[1]; #--- Determine the bearing $icon = "./blue_plane.png"; print OUTPUT ""; print OUTPUT $longitude.$comma.$latitude.$comma.$radio_altitude; print OUTPUT "relativeToGround"; print OUTPUT "$actual_date_time"; print OUTPUT ""."ID:".$rowid."
"."time:".$actual_date_time."
"."Ground_speed:".$ground_speed."
"."Thrust_engine_1:".$thrust_engine_1."
"."thrust_engine_2:".$thrust_engine_2."
"."nox_total:".$nox_total."
"."co_total:".$co_total."
"."longitude:".$longitude."
"."latitude:".$latitude."
"."radio_altitude:".$radio_altitude."
"; print OUTPUT "
"."\n"; } print OUTPUT "
"; ##
## "rowid","aircraft_id","actual_date_time","latitude","longitude","radio_altitude","ground_speed","thrust_engine_1","thrust_engine_2" 3828994,599,2012-11-04 14:00:00,51.47592545,-0.437049866,-9.0,2.0,0.044653355,0.041778761,1.74208527619370935228499282740898271690901934191164070390564,15.22092881857486030932218666006017736321211426212568671811012 3828995,591,2012-11-04 14:00:00,51.47598267,-0.435331702,-0.875,0.0,0.066208174,0.068682498,0.91309579395343765782284643054122415908645386540627114668956,4.89409068988509446645508839697462129412344644649063483492349 3828996,599,2012-11-04 14:00:01,51.47592545,-0.437049866,-9.0,2.0,0.044653355,0.041778761,1.74208527619370935228499282740898271690901934191164070390564,15.22092881857486030932218666006017736321211426212568671811012 3828997,591,2012-11-04 14:00:01,51.47598267,-0.435331702,-0.75,0.0,0.064970428,0.068682498,0.90550603857151443957938619839883126906356038703789731965392,4.92096836684002218971971504299700119099094370033875757916224 3828998,599,2012-11-04 14:00:02,51.47592545,-0.437049866,-9.0,2.0,0.044653355,0.041778761,1.74208527619370935228499282740898271690901934191164070390564,15.22092881857486030932218666006017736321211426212568671811012 3828999,591,2012-11-04 14:00:02,51.47598267,-0.435331702,-0.625,0.0,0.066208174,0.068682498,0.91309579395343765782284643054122415908645386540627114668956,4.89409068988509446645508839697462129412344644649063483492349 3829000,599,2012-11-04 14:00:03,51.47592545,-0.437049866,-9.0,2.0,0.044653355,0.041