AirFlow
-
Posts
3 -
Joined
-
Last visited
-
Days Won
1
Content Type
Profiles
Forums
Events
Gallery
Downloads
Posts posted by AirFlow
-
-
Hey Team,
I have been racking my brain for the past 2 days trying to deep dive into programming an accurate and effective ETA system.
Using VB.net and the harvestine theory formula to calculate the remaining time until destination. I am pulling the user's current Position (latitude and longitude) via a timer then inputting that into the following:
Public Sub CalculateAndDisplayETA() Dim xmlFile As String = My.Settings.ApplicationDirectory + "\Routes\" + IFETabletLrg.DepartureLbl.Text + IFETabletLrg.ArrivalLbl.Text + ".xml" ' Load the XML file that contains route information Dim xmlDoc As New XmlDocument() xmlDoc.Load(xmlFile) ' Find the <destination> element Dim destinationNode As XmlNode = xmlDoc.SelectSingleNode("/OFP/destination") ' Check if the <destination> elements exist If destinationNode IsNot Nothing Then ' Extract the values from the <destination> element Dim destinationAirportLat As Double = Double.Parse(destinationNode.SelectSingleNode("pos_lat").InnerText) Dim destinationAirportLon As Double = Double.Parse(destinationNode.SelectSingleNode("pos_long").InnerText) Dim startLat As Double = IFETabletLrg.UserPosLat ' Formula Start latitude in degrees (Current User's A/C Lat) Dim startLon As Double = IFETabletLrg.userPosLng ' Formula Start longitude in degrees (Current User's A/C Long) Dim endLat As Double = destinationAirportLat ' Destination latitude in degrees Dim endLon As Double = destinationAirportLon ' Destination longitude in degrees Dim speed As Double = ((gspeed.Value / 33714.6311111111) * 1.852) ' User's Groundspeed ' Calculate the distance using the Haversine formula Dim distanceNM As Double = HaversineDistance(startLat, startLon, endLat, endLon) ' Convert distance to nautical miles to kilometers Dim distanceKm As Double = distanceNM * 1.852 ' Calculate the ETA in hours Dim timeHours As Double = distanceKm / speed ' Calculate hours and minutes from the total hours (timeHours) Dim hours As Integer = CInt(Math.Floor(timeHours)) Dim minutes As Integer = CInt(Math.Round((timeHours - hours) * 60)) ' Format the ETA as "hh'h mm'm" Dim formattedETA As String = $"{hours:00}h {minutes:00}m" ' Display the formatted ETA in the label IFETabletLrg.ETALbl.Text = formattedETA End If End Sub Private Function HaversineDistance(startLat As Double, startLon As Double, endLat As Double, endLon As Double) As Double ' Convert degrees to radians Dim startLatRad As Double = startLat * Math.PI / 180.0 Dim startLonRad As Double = startLon * Math.PI / 180.0 Dim endLatRad As Double = endLat * Math.PI / 180.0 Dim endLonRad As Double = endLon * Math.PI / 180.0 ' Earth's radius in nautical miles Const EarthRadiusNM As Double = 3443.8445 ' Haversine formula Dim dLat As Double = endLatRad - startLatRad Dim dLon As Double = endLonRad - startLonRad Dim a As Double = Math.Sin(dLat / 2.0) * Math.Sin(dLat / 2.0) + Math.Cos(startLatRad) * Math.Cos(endLatRad) * Math.Sin(dLon / 2.0) * Math.Sin(dLon / 2.0) Dim c As Double = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)) Dim distanceNM As Double = EarthRadiusNM * c Return distanceNM End Function
This is returning a result however it seems to be inaccurate when compared to other software such as SmartCars. It is slower by a range of 30 minutes to 90 minutes.
Any ideas?
- 1
-
Hey Team,
I downloaded the example code project however found that it will not connect to MSFS. I tested it with P3D V5 and seems to work fine. I then downloaded the MSFSVariableService project and was able to successfully connect to MSFS and read/write.
I am wanting to read information such as IAS, HDG, ALT, etc from MSFS and display it in my own VB.NET application, any ideas on why I cant connect using the original Example project?
Extract User Information
in FSUIPC7 MSFS
Posted
Hi Team,
I have been attempting to extract some aircraft data from the current user but am unable to find any offsets or systems that work. The information I require is:
AC MAX PASSENGERS
AC MTOW
AC MAXFUEL
AC ZFW
AC TAS
AC MAX CRUISING ALT
any ideas on how I can pull this from the sim?