Recent

Author Topic: Problems with time and Distance Help Please  (Read 4262 times)

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problems with time and Distance Help Please
« Reply #45 on: July 06, 2020, 12:22:00 am »
quick summary (by approximation):
flight time: 3 hours, 21 minutes
gate to gate: 3 hours, 44 minutes
speed 500 mph: 2 hours, 56 minutes
take off and landing: 30 minutes
distance: 1,464 miles = 2 357 km

current time (minus a few minutes, for me to post)):
time Milwaukee, Wisconsin:   5:16 PM on Sunday, Jul 5, 2020
time Phoenix, Arizona:   3:16 PM on Sunday, Jul 5, 2020
time-diff: 2 hours

so yes, you seem to be heading into the right direction  :D

winni

  • Hero Member
  • *****
  • Posts: 1795
Re: Problems with time and Distance Help Please
« Reply #46 on: July 06, 2020, 12:28:41 am »
Hi !

No - I dont look into your code.
Airplane is landing before start time?

Start thinking!

Epoch time 1592610243 is 19.06.2020 23:44 :03
Then it was

-6 17:44:03 in Milwaukee
-7 16:44:03 in Phoenix

Winni

« Last Edit: July 06, 2020, 12:33:28 am by winni »

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problems with time and Distance Help Please
« Reply #47 on: July 06, 2020, 12:31:02 am »
Airplane is landing before start time?
Oh, my  :-[

Glad that at least someone is awake... I completely overlooked that part :-[

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: Problems with time and Distance Help Please
« Reply #48 on: July 06, 2020, 12:31:58 am »
I don't get it ? Oh Yea I see it.

Well why isn't that working?
« Last Edit: July 06, 2020, 12:34:15 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

winni

  • Hero Member
  • *****
  • Posts: 1795
Re: Problems with time and Distance Help Please
« Reply #49 on: July 06, 2020, 12:37:34 am »
Airplane is landing before start time?
Oh, my  :-[

Glad that at least someone is awake... I completely overlooked that part :-[

Hi!

Or we start that funny old discussion:

Is the speed of light a constant?
And is it related to the time?

Leaving with Warp  2:

Winni

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problems with time and Distance Help Please
« Reply #50 on: July 06, 2020, 12:42:08 am »
@winni:
Thank you for that ROFLMAO :)

edit: (you made me phase out of sync in such a way that I even spelled your name wrong, apologies).
« Last Edit: July 06, 2020, 01:06:54 am by TRon »

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: Problems with time and Distance Help Please
« Reply #51 on: July 06, 2020, 12:43:46 am »
I think I have the wrong offsets at both airports. Rechecking now.

Well to arrive before you leave would require a speed greater than the speed of light.

Yea I have the wrong offsets at both airports. However, after changing KMKE to -300 and KPHX to -400 I have the local time at KMKE at 19:28:03 and the local time in KPHX at 16:14:03.

The right elapsed time but arrival before leaving.

I don't know how to do this. Is there another way of solving the problem like a table lookup or something?

« Last Edit: July 06, 2020, 12:58:55 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problems with time and Distance Help Please
« Reply #52 on: July 06, 2020, 01:45:33 am »
I don't know how to do this. Is there another way of solving the problem like a table lookup or something?
I'm just a quick visitor of this thread (haven't read everything), you mean like a timezone database where you are able to look up the local time offsets ?

I had a quick look at what you posted a couple of message ago, and tbh I have not the faintest idea what you are trying to do there with all those static numbers.

As far as I was able to understand from your questions so far your inputs are:
- a lan/lat of an airport (obtained by airport callsign ?) where a departure of a plane takes place
- a lan/lat of an airport (obtained by airport callsign ?) where an arrival of a place takes place (preferably the same plane that departured in the previous item, otherwise we are already in trouble)
- you know the type of plane, therefor are able to obtain its (hypothetical) speed

Given those input parameters, you wish to:
- calculate the distance between the departure and arrival location
- calculate the (hypothetical) duration of the flight
- given either the arrival or departure time, calculate the departure or arrival time, both in their respective local time(zone), taking into account daylight saving time.

Is that what you are currently trying to accomplish ? or did I miss something there or expressed things wrongly ?

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: Problems with time and Distance Help Please
« Reply #53 on: July 06, 2020, 02:13:56 am »
Yes TRon I think you got it right.

To be precise this is satellite tracking data. Several different providers sell subscription for live flights data (flights in the air).

What you get is the following:
opr  Dept  Arrv   Plane  EPOCH time    Lat         Lon         CallSign
AAL KMKE KPHX B787 1592610243   33.4333 -111.999  AA2164

That's it. The epoch time is for the Lat and Lon of the aircraft not for an airport.

There are two problems.  The aircraft may be en-route or landed.

What I need to do is determine the Local time at the departure airport and the local time at the arrival airport regardless of the position of the aircraft.

I have a file of 45,000 airports with the lat/lon timezone offset. In addition I have the FAA Aircraft designated table with all the airplanes of the world and there cruising speed.

The reason I hard codded all the figures was to post the data in a presentable form showing the calculations.

But, yes what you said is basically correct.


 The data comes from the ADS-B system


« Last Edit: July 06, 2020, 02:49:32 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problems with time and Distance Help Please
« Reply #54 on: July 06, 2020, 03:19:23 am »
Ok JLWest, then let's analyse what kind of information we've got so far (and I apologise in case it is perhaps obvious for you, but for good communication it is necessary)

What you get is the following:
opr  Dept  Arrv   Plane  EPOCH time    Lat         Lon
AAL KMKE KPHX B787 1592610243   33.4333 -111.999
No idea what "opr" is but, that is not important for us right now.

1) You have a call-sign (airport) for departure and arrival,
2) you have a lat/lon for the plane (wherever it might be located in the universe.. uhm.. I meant earth  ;) ).
3) to that lat/lon location of the plane, there is an associated epoch time.

Quote
What I need to do is determine the Local time at the departure airport and the local time at the arrival airport regardless of the position of the aircraft.
(*1)

Quote
I have a file of 45,000 airports with the lat/lon timezone offset.
That is an important piece of information on which things can be build.

Please correct me if wrong:
- For all 45,000 airports you have their respective latitude and longitude coordinates and additionally their timezone offset.
- I assume you are able to lookup this information, by using the callsign of the airport that you were given.
- That would mean you are able to determine lat/lon for departure as well as arrival location, complemented with their respective timezone offset.

That also means that you are able to approx. determine where the plane is situated (near departure or arrival location). But, we have to take into account that this means nothing, as a plain could f.e. fly its flight in the opposite direction of what you would expect (I have currently no idea how you would be able to detect that, as there seems a vital piece of information missing to be able to determine that. Feel free to express your thoughts on that).

Quote
In addition I have the FAA Aircraft designated table with all the airplanes of the world and there cruising speed.
As you already discovered with regards to your questions on the forum, you can calculate the approx duration of a flight by using that information, based on the lat/lon of the departure/arrival locations (again keep in mind flights flying in opposite direction is a possibility).

Assuming a flight always takes the shortest route (straight line) from departure to arrival location, you are then able to determine the direction of the flight (west to east, east to west, south to north, north to south and all in between).

Do take note that a plane flying a straight line is a myth, especially with countries/regions where there are airspace restrictions (and there are many of those, also in western peaceful countries).

Now, that poses a bit of a problem (at least for me) as I have no idea how you would determine, in case your data was taken when the plane was mid-air, when exactly the plane departured. It is simply imprecise without additional information. I expect you would comment on that...

(*1)
Have you taken notice of what winni tried to hammer into your ... uhm by lack of better wording, skull ?
1. convert plane epoch to UTC
2. use plane lat-lon to determine how long we've been flying since departure (lat/lon departure location, i.c.w. plane speed & taking into account other time-wasters during departure).
3. you subtract that time (2) from (1) to calculate UTC departure time.
4. you would then be able to calculate UTC arrival time

At this point you have all necessary data, only in UTC time and not in local time, for that we need the timezones (actually their offsets to UTC), and you would need to know if daylight saving time is active or not at the departure and arrival locations.
Local time = UTC time + timezone offset + DST (when active)

i.o.w. you use universal time as an absolute measurement, and after you're done calculating convert those universal times to their corresponding local times.

Does that make sense to you ?

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: Problems with time and Distance Help Please
« Reply #55 on: July 06, 2020, 04:34:19 am »
"No idea what "opr" is but, that is not important for us right now."

OPR is the Carrier/Airline and it's not germane to the problem.

"I assume you are able to lookup this information, by using the callsign of the airport that you were given."

It's the Dept and Arr positions in the record.  Called IACO.

 " to that lat/lon location of the plane, there is an associated epoch time."
Yes
"- That would mean you are able to determine lat/lon for departure as well as arrival location, complemented with their respective timezone offset.
"

YES
"That also means that you are able to approx. determine where the plane is situated (near departure or arrival location). But, we have to take into account that this means nothing, as a plain could f.e. fly its flight in the opposite direction of what you would expect (I have currently no idea how you would be able to detect that, as there seems a vital piece of information missing to be able to determine that. Feel free to express your thoughts on that)."

These are scheduled airline flights and the fly from departure ICAO to Arrival ICAO. They are required to have a ADS-3 transponder encoded transmitter. It produces the EPOCH Time and Lat/Lon and the status (en-route, landed,started,unknown)

The information is picked up by a ADS-3 receiver located all over the world, thousands of them. They are a small Raspberry pie computer connected to a network. If the plane transmits a location that doesn't make sence it goes into unknown.

"Now, that poses a bit of a problem (at least for me) as I have no idea how you would determine, in case your data was taken when the plane was mid-air, when exactly the plane departured. It is simply imprecise without additional information. I expect you would comment on that..."

The end product doesn't have to be precise approximation is all that is required for the end use.  The end product will look like:

AAL KMEK KPHX B737 0950 AAL7854 N7456AA 2 1521  and this can be interpreted as American Airlines departing KMEK at 0950 local time to KPHX in a B737 flight AAL7854 FAA registration  number N7456AA on Tuesday at 1521 local PHX time.

This data will be used by a Flight Simulator X-Plane 11 to produce traffic en-route, parked at airports gates, taxing to and from gates and taking off based on the status of landed, en-route and started. The unknown are not processed (figure that one out and we could find MD-370 and Amelia Earhart)

Maybe 10,000 to 15,000  records will be produced. If some are completely wrong it's not that big of a deal.

Real-world airline schedules are computed  using approximate date. They add 10 min. for taxi out, 7 to 11 min to climb out, and maybe 15 min to descent and landing. Each carrier has their own standards.


"At this point you have all necessary data, only in UTC time and not in local time, for that we need the timezones (actually their offsets to UTC), and you would need to know if daylight saving time is active or not at the departure and arrival locations.
Local time = UTC time + timezone offset + DST (when active)

i.o.w. you use universal time as an absolute measurement, and after you're done calculating convert those universal times to their corresponding local times.

Does that make sense to you ?"

The airport offset is provided in the 45K airport file along with the Lat/Lon of the airport.

And I think I'm using UTC time throught the process except for the UniversialTimetoLocal function and DateTimeToString. PHX offset is -420

For  PHX I use UnisToDateTime to turn the EPOCH time into a TDateTime. At Phoenix all I have to do is turn the EPOCH time number into Local time UniversalTimeLocal then DateTimeToString.

For KMKE it's PHX EPOCH time 1592610243 - 688500
UnixtoDateTime then UniversalTimetoLocal and then DateTimeToStr. The offset of KMKE is -300.











FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

winni

  • Hero Member
  • *****
  • Posts: 1795
Re: Problems with time and Distance Help Please
« Reply #56 on: July 06, 2020, 09:19:32 am »
"No idea what "opr" is but, that is not important for us right now."
...
 The offset of KMKE is -300.

* OPR is the abreviation for OPERATOR

* MKE is only in summertime time offset -300. In the wintertime it is -360. Daylight saving!!

Winni



TRon

  • Hero Member
  • *****
  • Posts: 536
Re: Problems with time and Distance Help Please
« Reply #57 on: July 07, 2020, 05:47:39 pm »
Sorry for the delay.

Thanks for the additional information, also @winni.

Real-world airline schedules are computed  using approximate date. They add 10 min. for taxi out, 7 to 11 min to climb out, and maybe 15 min to descent and landing. Each carrier has their own standards.
I have left out the additional time 'wasters' for convenience (they can easily be added to the equation). Take that into account when looking at the results, e.g. earlier for departure later for arrival.

I quote myself
Quote
"At this point you have all necessary data, only in UTC time and not in local time, for that we need the timezones (actually their offsets to UTC), and you would need to know if daylight saving time is active or not at the departure and arrival locations.
Local time = UTC time + timezone offset + DST (when active)

i.o.w. you use universal time as an absolute measurement, and after you're done calculating convert those universal times to their corresponding local times.

Then, I quote you again:
Quote
And I think I'm using UTC time throught the process except for the UniversialTimetoLocal function and DateTimeToString. PHX offset is -420
I think you're not exactly doing that...

Quote
For  PHX I use UnisToDateTime to turn the EPOCH time into a TDateTime. At Phoenix all I have to do is turn the EPOCH time number into Local time UniversalTimeLocal then DateTimeToString.
You should not be using EPOCH time for PHX, e.g. it is not UTC. I believe that is where things go wrong with regards to your calculations.

Quote
For KMKE it's PHX EPOCH time 1592610243 - 688500
UnixtoDateTime then UniversalTimetoLocal and then DateTimeToStr. The offset of KMKE is -300.
... and again, EPOCH....

The problem is that the epoch time is not absolute with regards to the airports.

Try attached zip file, I believe that is what you would need in order to make the right calculations (I might be wrong though, so feel free to correct).

In case you wish to test it quickly using Lazarus then open a new project, with a form and place a memo onto that together with a button. Then copy-paste my code (minus the program header etc) and invoke procedure FlyingHigh() from a ButtonClick event. Don't forget to correct my code to use your memo. Or, compile the code using Free Pascal and start it from a shell/terminal.

Unfortunately I had only 2 items to test with (those that you posted in this thread), as I lack additional ADS records.

output:
Code: [Select]
Takeoff
Departure
    ICAO : KMKE
    name : General Mitchell International Airport
 lat,lon : 42.94720000,-87.89659800

Arrival
    ICAO : KPHX
    name : Phoenix Sky Harbor International Airport
 lat,lon : 33.43429900,-112.01200100

Flight
    ICAO : B787
    name : AAL AA2164
 lat,lon : 33.43330000,-111.99900000

Distance
 KMKE <--> B787 : 2345.584727 km (1457.546350 miles)
 B787 <--> KPHX : 1.211528 km (0.752843 miles)
 KMKE <--> KPHX : 2346.524925 km (1458.130588 miles)

Duration
 KMKE <--> B787 : 174.90 min (2.91 hour)
 B787 <--> KPHX : 0.09 min (0.00 hour)
 KMKE <--> KPHX : 174.97 min (2.92 hour)

Timetable
 Location   ICAO        UTC                     Local                   UTC+  DST+
 Departure  KMKE        2020-06-19 20:49:09     2020-06-19 15:49:09     -360    60
    Flight  B787        2020-06-19 23:44:03     -                          0     0
   Arrival  KPHX        2020-06-19 23:44:08     2020-06-19 16:44:08     -420     0
========================================
Departure
    ICAO : RJBB
    name : Kansai International Airport
 lat,lon : 34.42729900,135.24400300

Arrival
    ICAO : EHAM
    name : Amsterdam Airport Schiphol
 lat,lon : 52.30860100,4.76389000

Flight
    ICAO : B77W
    name : ??? ??????
 lat,lon : 63.62000000,38.28000000

Distance
 RJBB <--> B77W : 6947.509362 km (4317.182318 miles)
 B77W <--> EHAM : 2302.411254 km (1430.718353 miles)
 RJBB <--> EHAM : 9241.280512 km (5742.531710 miles)

Duration
 RJBB <--> B77W : 456.82 min (7.61 hour)
 B77W <--> EHAM : 151.39 min (2.52 hour)
 RJBB <--> EHAM : 607.65 min (10.13 hour)

Timetable
 Location   ICAO        UTC                     Local                   UTC+  DST+
 Departure  RJBB        2020-06-19 16:17:02     2020-06-20 01:17:02      540     0
    Flight  B77W        2020-06-19 23:53:52     -                          0     0
   Arrival  EHAM        2020-06-20 02:25:15     2020-06-20 04:25:15       60    60
Landing
« Last Edit: July 07, 2020, 05:51:17 pm by TRon »

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: Problems with time and Distance Help Please
« Reply #58 on: July 07, 2020, 06:50:02 pm »
@TRon

Thanks, I'll Work the code up in a demo to see if it matches what I now have.
My offsets were reversed and the seconds were wrong along with miles per min.

But I can't trust the results. This is on the flight from KMEK to KPHX.

I'm departing at 15:23:30 and arriving at 16:44:03. It's about an hour and 16 difference. But then there is 2 hours difference between KMEK and KPHX. So then I'm wondering.

 "// JLW: The only time I have to work with is the Unix EPOCH 1592610832 at 63.62 Lat / 38.28 Lon.
  // JLW: The provider says the time is an Uniz/EPOCH time and is GMT, however it's really UTC. I think."

That's the only time I get is a Lat/Lon and a Unix/GMT but I suspect the time is actually UTC. However, that why I posted at the bottom of the form EGLL's (Heathrow) Offset. Heathrow is in the GMT timezone.







 
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

winni

  • Hero Member
  • *****
  • Posts: 1795
Re: Problems with time and Distance Help Please
« Reply #59 on: July 07, 2020, 07:11:41 pm »
Hi!

Dont forget: There is summer on the northern hemisphere.

So London (Heathrow) is NOT UTC +-0 but with daylight saving UTC + 1!!!!!


Winni

 

TinyPortal © 2005-2018