carlosuc99 Posted February 2, 2013 Report Share Posted February 2, 2013 Hi, I use VB.NET How Can I obtain the distance flown? For expample. I take-off from Heatrow and I land at Chicago O`Hare. I want to obtain the distance flown in the flight. But I want to see the always the distance flown, not only when I arrival. If I am in the middle of the Atlantic I want to see the distance flown too. I want to see the distance flown anywhere. I don´t found any offset to do this. Quote Link to comment Share on other sites More sharing options...
Pete Dowson Posted February 2, 2013 Report Share Posted February 2, 2013 I use VB.NET How Can I obtain the distance flown? For expample. I take-off from Heatrow and I land at Chicago O`Hare. I want to obtain the distance flown in the flight. But I want to see the always the distance flown, not only when I arrival. If I am in the middle of the Atlantic I want to see the distance flown too. I want to see the distance flown anywhere. I don´t found any offset to do this. There isn't one, that's why. It isn't something supplied by FS You'd have to compute it by reading the latitudes and longitudes and doing the trig at regular intervals. Pete 1 Quote Link to comment Share on other sites More sharing options...
Paul Henty Posted February 2, 2013 Report Share Posted February 2, 2013 My DLL will do the trigonometry for you: Create a new fsLatLonPoint class from the current position, then get the distance from another fsLonLatPoint (the previous measured position) using one of the DistanceFrom... methods. The fsLatLonPoint takes in an fsLatitude and fsLongitude class to define the location. These two classes can be given the raw 8-byte values from the Lat and Lon offsets in FSUIPC, so you don't even need to convert them to degrees or anything. For more details and examples, see the UserGuide.pdf: "Reading and Displaying Longitudes and Latitudes" on Page 15 and "Distances and Bearings between Two Points" on Page 17 Paul 1 Quote Link to comment Share on other sites More sharing options...
carlosuc99 Posted February 3, 2013 Author Report Share Posted February 3, 2013 Ok, I read the User Guide. But, I have a problem. I want to calculate the distance flown from the start position (position when I connect with the simulator) to current position. I tryed it: Public Class MainForm 'Some Code Dim StartPoint As FsLatLonPoint ' Initialise some of the variables we will need later Public Sub New() InitializeComponent() Dim StartLat As FsLatitude = New FsLatitude(Latitude.Value) Dim StartLon As FsLongitude = New FsLongitude(Longitude.Value) StartPoint = New FsLatLonPoint(StartLat, StartLon) End Sub[/CODE]And in the timer this:[CODE]Dim Lat As FsLatitude = New FsLatitude(Latitude.Value) Dim Lon As FsLongitude = New FsLongitude(Longitude.Value) Dim Lat2 As Double = (Latitude.Value * 90.0 / (10001750.0 * 65536.0 * 65536.0)) Me.LatitudeBox.Text = Lat.ToString() Me.LongitudeBox.Text = Lon.ToString() 'Distance Flown Dim CurrentPosition As FsLatLonPoint = New FsLatLonPoint(Lat, Lon) Dim distance As Double = 0 Select Case (Me.FlownUnitsCombo.Text) Case "Nautical Miles" distance = CurrentPosition.DistanceFromInNauticalMiles(StartPoint) Case "Statute Miles" distance = CurrentPosition.DistanceFromInFeet(StartPoint) / 5280D Case "Kilometres" distance = StartPoint.DistanceFromInMetres(CurrentPosition) / 1000D End Select Me.FlownBox.Text = distance.ToString("N2")[/CODE]But, the result is my current postion to 0 postion. Because don´t read [CODE]Latitude.Value[/CODE] at the StartLatitude and [CODE]Longitude.Value[/CODE] at the StartLogintude. But, I replace that for the cordinates like EGLL in the VB EXAMPLE. Works but it shows me the distance to heatrow and not the distance flown, logical. Quote Link to comment Share on other sites More sharing options...
Paul Henty Posted February 3, 2013 Report Share Posted February 3, 2013 Public Class MainForm 'Some Code Dim StartPoint As FsLatLonPoint ' Initialise some of the variables we will need later Public Sub New() InitializeComponent() Dim StartLat As FsLatitude = New FsLatitude(Latitude.Value) Dim StartLon As FsLongitude = New FsLongitude(Longitude.Value) StartPoint = New FsLatLonPoint(StartLat, StartLon) End Sub [/CODE] But, the result is my current postion to 0 postion. Because don´t read [CODE]Latitude.Value[/CODE] at the StartLatitude and [CODE]Longitude.Value[/CODE] at the StartLogintude. You should move this code from the constructor (new()). It's too early here. The FSUIPC connection isn't even open. You should put this code after the connection is opened. Something like this: [code] FSCUIPCConnection.Open() ' Initialise start position FSUIPCConnection.Process() Dim StartLat As FsLatitude = New FsLatitude(Latitude.Value) Dim StartLon As FsLongitude = New FsLongitude(Longitude.Value) StartPoint = New FsLatLonPoint(StartLat, StartLon) Of course this means the start position is fixed to whereever the user was when they started your application. It would probably make sense to put a way of resettting the start position in your application (like a button) and calling a method: Public Sub SetStartPosition() ' set start position FSUIPCConnection.Process() Dim StartLat As FsLatitude = New FsLatitude(Latitude.Value) Dim StartLon As FsLongitude = New FsLongitude(Longitude.Value) StartPoint = New FsLatLonPoint(StartLat, StartLon) End Sub Paul Quote Link to comment Share on other sites More sharing options...
carlosuc99 Posted February 3, 2013 Author Report Share Posted February 3, 2013 Thank you, Paul. It works fun! Quote Link to comment Share on other sites More sharing options...
carlosuc99 Posted February 5, 2013 Author Report Share Posted February 5, 2013 I have another problem now. I only get the position at the start and the current position. But, I take-off and I return to the same airport. I have a problem because the position at the start and the current are near and it only shows me that I flown, for example, only 0.23NM but It´s false. I think I can fix this problem resetting the position in the timer1, and plus it than the value of the FlownTextBox. I test a lot of forms to this but doesn´t work. Paul, Do you have an idea to do this? Quote Link to comment Share on other sites More sharing options...
Pete Dowson Posted February 5, 2013 Report Share Posted February 5, 2013 I have another problem now. I only get the position at the start and the current position. But, I take-off and I return to the same airport. I have a problem because the position at the start and the current are near and it only shows me that I flown, for example, only 0.23NM but It´s false. You need to take positions at regular intervals (say once a minute for an airliner, probably more often for a small GA aircraft), and compute the small distances, adding them to a total as you go. Obviously not all flights are just one straight line! Pete Quote Link to comment Share on other sites More sharing options...
mgh Posted February 5, 2013 Report Share Posted February 5, 2013 Alternatively continuously take ground speed and multiply by the interval. Quote Link to comment Share on other sites More sharing options...
carlosuc99 Posted February 5, 2013 Author Report Share Posted February 5, 2013 Yeah!! I fix the problem. Thanks for all! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.