No luck so far converting lat/long to cartesian. Always off by a few km.
The longer description (beware, math...):
I have used the following approach:
x = r*sin(theta)*cos(phi)
y = r*sin(theta)*sin(phi)
z = r*cos(theta)
with
r = geocentrical earth radius + local elevation;
phi = longitude;
theta = 90°-latitude (standard spherical coordinates are 0° at the north pole and 90° at the equator)
The geocentrical earth radius r in this case is dependent on local latitude (and of course the polar and equatorial radius of the earth). This is due to the fact that earth is not a perfect sphere but an ellipsoid
I have initially tried the following numbers:
r1=6335439m (polar earth radius)
r2=6399594m (equatorial earth radius)
Which resulted in being off by a few kilometers in x and y and a little more in z direction compared to what FS2 does. Being off just very few km is really not all that bad, I'd exclude having messed up the obvious stuff like mixing up degrees and radians or ft and m at that point.
So I thought it is maybe just that fs2 uses a different polar and equatorial radius than the numbers I dug up. But changing them around (even in a systematical way) doesn't seem to solve the problem.
To check that I have varied both radii by about +15km and checked every combination with a stepsize of 1m. Even for combinations where x and y came out perfect, z was still off by at least 10km. (I used the airport TFFF at Martinique for testing).
If somebody notices an obvious flaw in my approach please let me know, I don't do such calculations on a regular basis. I'll check my script has other errors in the meantime. This also was just one test with one airport, so my findings are pretty vague at this point. any tipps are appreciated.
I found a pretty critical bug:
currently the program freezes and becomes unplayable when trying to import customs airports which have no elevation or runway surface info in the database.
I have made a quick hotfix (download on page one) so these airports will be skipped. I'll do an update soon with better import display and information which airports were skipped and for what reason.
I made another quick update, which adds a progress window while importing the custom airports so you can see whether everything is working as planned.
The procedure can take a minute or so if you have many custom airports. There is certainly potential to cut the import time in half, I'll probably do this eventually.
The update is available on page 1.
version 1.13 is up. (first page)
- Includes previous hotfixes.
- Importing custom airports is a lot faster now.
- New button that opens a browser with google maps and shows the selected destination on the mission table. (With all the custom airports I got a little lost when deciding where i want to fly next).
- savegames from 1.10 are fully compatible.
Note:
The "custom_airports.txt" in the download is the one I am using right now, it has bavaria, the canaries, czech republik, madrid, venice, martinique and a few other airports in it. A lot of the smallest bavarian airports will not be imported because some info is missing in the database, mostly elevation or runway length. PJ will show a detailed list during import.
Important:
In case you want to edit the airports.csv and/or runways.csv yourself to make some of the smaller airports playable, use a simple text editor, not MS excel because it can mess up the file and make it unreadable for PJ.
If in doubt, you can always download the latest database files here: http://ourairports.com/data/
After all the coding I managed to fly a bit.
One of my first missions was from Lugano to Ulrichen in Switzerland in the PA Arrow, with offers gorgeous views along the way. I recorded the landing: