### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

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

#### winni

• Hero Member
• Posts: 1893
##### Re: Problems with time and Distance Help Please
« Reply #30 on: July 04, 2020, 11:55:14 am »

A mile is about 1.6 KM so if that 2346.44922 {KM} is your distance between Osaka and Amsterdam expressed in KiloMetres then there seems to be something off.

@JLWEST

I told you not to work with miles. Now you do the same as the NASA did: Miss your destiniation.
Osaka plus 2346 km west you'll arrive in the endless dark Sibiria.
Not so nice.

Winni

#### wp

• Hero Member
• Posts: 7618
##### Re: Problems with time and Distance Help Please
« Reply #31 on: July 04, 2020, 12:10:11 pm »
[...] 42 KM longer than my original  5699 miles.  [...]
Over such large distances it should matter that the earth is not a sphere but an ellipsoid. Does you distance calculation take care of that? And how is that officially handled?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### winni

• Hero Member
• Posts: 1893
##### Re: Problems with time and Distance Help Please
« Reply #32 on: July 04, 2020, 12:44:42 pm »
Hi!

The deviation from the mean earth radius is

-14 km at the Poles
+7 km at the Equator

In percent this is -0.2% and +0.1%

How do you officially handle if the beer in the pub is suddenly 0.1% more expensive?

There are hundreds of factors that are more significant for the flight buisiness.

Winni

#### wp

• Hero Member
• Posts: 7618
##### Re: Problems with time and Distance Help Please
« Reply #33 on: July 04, 2020, 05:01:19 pm »
JLWest is worried about a distance in the calculation by 41 km. I have no idea what he is doing, maybe incorrect conversion between miles and kilometers. I only wanted to point to the error source due to the elliptical shape of the earth. Since I do not have any idea how many km this would be I used the distance calculation from LazMapViewer (which is based on a spherical shape) and that of https://forum.lazarus.freepascal.org/index.php/topic,46737.msg333796.html#msg333796 (whch is based on an elliptical shape) and calculated the distance between the geo locations mentioned further up in the text:

- spherical surface: 9251 km
- elliptical surface: 9264 km

A difference of 13 km. The same order of magnitude observed by JLWest, but only a third of the value. Therefore his error must be somewhere else.

My question about the "official" handling of distance calculation: i picked another example: a flight from Munich (MUC) to San Francisco (SFO). According to https://www.airmilescalculator.com/distance/muc-to-sfo/ the flight distance is 9461 km. The calculation with the spherical surface yields 9448 km, the elliptical surface 9461 km - exactly the result of the airmilecalculator. Therefore, I'd conclude that flight distances are calculated based on the elliptical shape of out planet.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### JLWest

• Hero Member
• Posts: 877
##### Re: Problems with time and Distance Help Please
« Reply #34 on: July 04, 2020, 05:23:16 pm »
@WP That's interesting.

I'm not that concerned about the 41 Km difference. I just need a reasonable approximation of the distance, flight times and local times at the start and finish.

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

#### wp

• Hero Member
• Posts: 7618
##### Re: Problems with time and Distance Help Please
« Reply #35 on: July 04, 2020, 05:59:23 pm »
I just need a reasonable approximation of the distance [...]
In this case forget my post. The calculation based on the spherical surface does in fact provide a "reasonable" distance value for most practical means. Except, maybe, for a very ambitious frequent flyer who could feel cheated if the airline company would calculate flight miles based on the spherical model.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### winni

• Hero Member
• Posts: 1893
##### Re: Problems with time and Distance Help Please
« Reply #36 on: July 04, 2020, 06:44:25 pm »
Hi!

The exact distance is not so import between two airports.

The main order is: save fuel, save fuel, save fuel! That's where the money is.

If you can fetch a good jet stream and fly some extra kilometers -  do it: That save fuel.
If you let the passengers pay for the bagage like RyanAir: Less weight saves fuel.
And try to get a clean free slot at the desination: every holding pattern burns fuel!

And as some german students develop a "shark skin" that could save fuel,  it is just tested by Airbus. A 0.1 millimeter high structure on the wings.

Winni

#### JLWest

• Hero Member
• Posts: 877
##### Re: Problems with time and Distance Help Please
« Reply #37 on: July 04, 2020, 07:19:17 pm »
Save fuel is what the airline piolits get rated on. It's all buried in scheduling but the bottom line is fuel.

So I have tried a different shorter route. Phx to KME:

PHX Fri 03-Jul-2020 05:14PM MST to   MKE Fri 03-Jul-2020 10:42PM CDT
Actial Flight Time  3 hrs 28 min posted by the airline. This was in a Boeing 737 Cruise 523

It's 1458 miles div 8.71 = 167.393799 min or about  180 min / 3 hours. Factor in Taxi and decent and it's pretty close to the actual.

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: 1893
##### Re: Problems with time and Distance Help Please
« Reply #38 on: July 04, 2020, 11:45:59 pm »

So I have tried a different shorter route. Phx to KME:

Nice typo:

KME is Kamembe in Ruanda. Now inside the USA?

Sorry - I could not resist.
Good flight to Milwaukee!

Winni

#### JLWest

• Hero Member
• Posts: 877
##### Re: Problems with time and Distance Help Please
« Reply #39 on: July 05, 2020, 04:11:51 am »
No not a good flight.

This doesn't add up. The distance between PHX and KME is right on but the times don't make sence unless I'm doing something wrong.

The difference in this is the flight has landed in PHX, so the time of the airplane is  UTC Phoenix. but the departure time is wrong.
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

#### jamie

• Hero Member
• Posts: 3637
##### Re: Problems with time and Distance Help Please
« Reply #40 on: July 05, 2020, 02:23:13 pm »
This thread is starting to remind me of the satellite tracking software I did years ago where I had to account for magnetic north , true north, elliptic arcs, LON,LAT, Accel etc..

The only true wisdom is knowing you know nothing

#### winni

• Hero Member
• Posts: 1893
##### Re: Problems with time and Distance Help Please
« Reply #41 on: July 05, 2020, 03:02:59 pm »

PHX Fri 03-Jul-2020 05:14PM MST to   MKE Fri 03-Jul-2020 10:42PM CDT
Actial Flight Time  3 hrs 28 min posted by the airline. This was in a Boeing 737 Cruise 523

It's 1458 miles div 8.71 = 167.393799 min or about  180 min / 3 hours. Factor in Taxi and decent and it's pretty close to the actual.

Don't believe the airline.
Allways the better solution:

MKE Arr:   10:42
- PHX Dep   05:14
=                 05:28

The time offset between MST and CDT is -1.

So the real flight time is

04:28 hours

Same old story:
Calculating time with different time zones often confuses people.

Winni

#### JLWest

• Hero Member
• Posts: 877
##### Re: Problems with time and Distance Help Please
« Reply #42 on: July 05, 2020, 08:34:24 pm »
@winni
Often - It always confuses me.
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: 1893
##### Re: Problems with time and Distance Help Please
« Reply #43 on: July 05, 2020, 10:28:58 pm »
Hi!

USA confuses me:

Phoenix has Mountain Standard Time (UTC−7)
Milwaukee has  Central Time (UTC−6/−5)

So: Milwaukee has now daylight saving.
And Phoenix has NOT.

So the time difference is -2 hours.

And so the flight time is

3:28 hours

Complicated America ...

Winni

#### JLWest

• Hero Member
• Posts: 877
##### Re: Problems with time and Distance Help Please
« Reply #44 on: July 05, 2020, 11:36:54 pm »
Ok - Hopefully this is correct. Needs verification Please.

Plane flew from KMKE to LPHX and landed. Over the ADS-B it transmuted it's locaton with a UTC time stamp of 1592610243.

So for PHX time convert  1592610243 to TDateTime and then to local time of 13:44:03.

The distance is 1458 miles or 11476 min. / 688560 seconds. Subtract 688560 from 1592610243 = 1591921683.

Convert the  1591921683 to TDateTime and then to Local time and I get:

MKE Local Time:    17:08:03
PHX Local Time:     13:44:03

Flight Time 3 Hrs and 44 min.

It close to what the SWA flight was?

JPeg and program attached.

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