Jump to content
The simFlight Network Forums

Converting nm to FS Format

Recommended Posts

Hi there!


I'm working at the moment on a little tool which positions (or should) your plane 4nm away from the runway. I already got it working setting the altitude and speed, but when it comes to longitude and latitude i have a problem.


As said i want to position the aircracft 4 nautical miles away from the runway. I thought it should work with picking the runway coordinates and adding values to the latitude and longitude (Offsets 0560, 0568). I was able to calculate with the law of sines the the values i have to add. But those values are in nautical miles (because I used the 4nm as  my hypotenuse for my calculation)... so how do I convert them into FS Values?


Thanks in advance



Link to comment
Share on other sites

Pete's away at the moment so I'll tell you how I did this in my .NET Client DLL for FSUIPC. It has a helper class for calculating the very thing you describe. I assume you're not using .NET and so can't use these facilities, so here's what's 'under the hood':


What I suggest is not converting the NM distances into FS Units, but rather use them to calculate new Lon/Lat positions, then convert these to FS Units in the normal way. Converting Lon/Lat to FS Units for 0560 and 0568 is well documented and fairly easy. Trying to convert NM distances into these units is not documented and more difficult.


Adding/subtracting NM distances to Lon/Lat coordinates is easy for Latitude and a bit more cumbersome for Longitude. The following calculations all assume the Lon/Lat is in pure degrees and fractions of a degree (e.g. you're working with a value of 50.5 degrees representing 50 Degrees 30 Minutes)




1 Nautical Mile = 1/60th of 1 degree of Latitude, or

1 Degree of Latitude = 60 NM.

Therefore the number of degrees (or fraction of degrees) to add for distance d in NM = d / 60.


e.g. Adding 30NM to latitude 50.454:


50.454 + (30 / 60) = 50.954





A bit more tricky because the length of 1 degree of longitude varies depending on the latitude because the circles of longitude are smaller towards the pole than at the equator.


The first step is to figure out the length of a degree of longitude at the latitude of the point. This is given by:


cosine(latitude) * circumference of FS equator / 360


The circumference of the FS Equator is 40,075km = 21,638.7689 NM


So at 49.882 degrees latitude, one degree of longitude (in FS at least) is:


cos(49.882) * 21638.7689 / 360 = 38.73 NM


(Assume the cos function above takes degrees to keep this simple. Most programming languages have trig functions that take radians).


The next step is to calculate the number of degrees of longitude to add for the given distance (same as latitude but using the value from step 1 instead of the fixed 60 value)


e.g. Adding 30mn to 2.33 degrees longitude at latitude 49.882:


2.33 + (30 / 38.73) = 3.10


Once you have the new Lon/Lat you can just do the normal conversion to FS units to write to the offsets you mentioned.



Nothing in this post should be used for real-world navigation :smile:



Link to comment
Share on other sites

Many Thanks Paul!


Very well explained. Now I'm a big step further in "developing" my little tool ;)




I assume you're not using .NET and so can't use these facilities, so here's what's 'under the hood':


Actually I'm using Visual Studio and working with .NET  :smile:



Thanks a lot






I just realized that you added an example project to the FSUIPC Client DLL Package  :oops: . I took the code for positioning the plane on the runway and edited it a bit(the distance, the heading, and the start position):

        Dim latFS As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H560)
        Dim lonFS As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H568)        

        slewMode.Value = 1
        CMD_PAUSE.Value = 1

        Dim lon As FsLongitude = New FsLongitude(lonFS.Value)
        Dim lat As FsLatitude = New FsLatitude(latFS.Value)
        Dim newPos As FsLatLonPoint = New FsLatLonPoint(lat, lon)
        Dim rwyTrueHeading As Double = 161.18D

        newPos = newPos.OffsetByNauticalMiles(rwyTrueHeading, 4)
        latFS.Value = newPos.Latitude.ToFSUnits8()
        lonFS.Value = newPos.Longitude.ToFSUnits8()
        speed.Value = 180 * 128
        alt.Value = 1870 / 3.28

        slewMode.Value = 0


It works quite well and everything seems logical, BUT: The plane is positioned 4nm away from the runway edge but not infront of it. It's a bit aside(see at the attached picture).


What did I wrong?


Thanks again :)


Link to comment
Share on other sites

The runway heading you used (161) seems to be the Magnetic heading. You need to use True headings when working with Lon/Lat positions.


The True heading of this runway is about 164.


If you don't have the true headings for the runways you can derive them from the magnetic headings by adding the magnetic variation. This can be found is offset 02A0, but only gives the value for the current position of the player.



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.