l0calhost
-
Posts
11 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Downloads
Posts posted by l0calhost
-
-
On 13/12/2014 at 2:52 PM, Paul Henty said:
Hi Ido,
Declare the offset like this:
private Offset<string> nearestICAO = new Offset<string>(0x0658, 4);
Then in your code, after the process(), read the value like this:
FSUIPCConnection.Process(); MessageBox.Show("Nearest airport is " + this.nearestICAO.Value);
Paul
Hello Paul,
i'm trying this code but in vb.net and only show icao from p3d v4. From fs9/fsx sp2/p3d v3.4 is not showing.
Is there another workaround to show on all simulators? Didnt find anything.
Can you help me with a function to get nearest airport(s) in X miles range with makerunways files like airports.fsm?
Thank you
-
I think that's it, made the same tests as before and now seems to be working, changed between some gates and all show the correct gate.
I apreciate your help, thank you very much and have a nice year.
Helder Duarte
-
1 minute ago, Paul Henty said:
Thanks. I can fix this up to work properly. Just one thing I need to know:
Do you want to always get back the closest gate even if you're a long way from it (e.g. at the end of the runway). Or do you only want to report being at a gate when you're parked at it (e.g. within 20 metres or so?).
Paul
I think is better to report always in the correct gate when i park instead the closest one.
The g5.csv have the gate radius in meters. Something like, if airplane is inside gate "radius" show gate.
Thank you Paul
-
14 minutes ago, Paul Henty said:
Assuming that your distance function is correct, you need something like this:
I don't know how you are loop though each gate so I've just put a placeholder for that.
Also I don't know what units your distance function returns so I've assumed Metres. If it's different just adjust the values.
Dim currentGate as String = "" Dim minDistanceToGate as Double = 20 'Need to be within 20 metres of the gate. (Adjust to your preference). [Loop for each gate] Dim distance As Double = distance(acLat, acLon, gateLat, gateLon, "M") If distance <= minDistanceToGate Then currentGate = strGateNumber End If [End loop for each gate] ' currentGate now contains the gate you are at. Or "" if you're not near any gate.
That's the sort of loop and logic you'll need.
If you need more help please post the exact code you are trying and I'll be able to see where it's going wrong.
Paul
Hello Paul,
this is my current code
Public Function getgate(ByVal icaocode As String) As String Using MyReader As New FileIO.TextFieldParser(Form1.fullFSpath.Value & "g5.csv") MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(",") Dim gatename As String Dim gatenumber As String Dim gatereturn As String Dim currentRow As String() Dim smallestDifference As Double = 0 While Not MyReader.EndOfData Try currentRow = MyReader.ReadFields() If currentRow(0) = icaocode Then gatename = currentRow(1) gatenumber = currentRow(2) Dim aaa As String = currentRow(3) Dim bbb As String = currentRow(4) Dim aaaa As Double = Double.Parse(aaa, CultureInfo.InvariantCulture) Dim bbbb As Double = Double.Parse(bbb, CultureInfo.InvariantCulture) Dim distance As Double = Form1.distance(Functions.getAircraftLatFS(), Functions.getAircraftLonFS(), aaaa, bbbb, "M") If distance = smallestDifference Then smallestDifference = distance gatereturn = "" + gatename + " " + gatenumber + "" Return gatereturn MyReader.Close() MyReader.Dispose() Exit Function End If End If Catch ex As FileIO.MalformedLineException 'MsgBox("Line " & ex.Message & "is not valid and will be skipped.") End Try End While MyReader.Close() MyReader.Dispose() End Using Return "" End Function
I am in LPPT on gate 104, if the distance result is 0 it show gate 104.
if i change distance = to distance <= no result show
if i change smallDiference to 20 and keep <= it will show gate 105 but i'm on 104. (105 is near but is on my left side)
the distance function i have is
'M' is statute miles (default) 'K' is kilometers 'N' is nautical miles
Public Function distance(ByVal lat1 As Double, ByVal lon1 As Double, ByVal lat2 As Double, ByVal lon2 As Double, Optional ByVal unit As Char = "M"c) As Double Dim theta As Double = lon1 - lon2 Dim dist As Double = Math.Sin(deg2rad(lat1)) * Math.Sin(deg2rad(lat2)) + Math.Cos(deg2rad(lat1)) * Math.Cos(deg2rad(lat2)) * Math.Cos(deg2rad(theta)) dist = Math.Acos(dist) dist = rad2deg(dist) dist = dist * 60 * 1.1515 If unit = "K" Then dist = dist * 1.609344 ElseIf unit = "N" Then dist = dist * 0.8684 End If Return dist End Function
Thank you for your help
-
13 minutes ago, Paul Henty said:
Do you have the lon/lat of each gate? or is that what you're stuck on?
Paul
Hello thank you for your reply.
Yes i have the plane lat/lon and all gates lat/lon from g5.csv where gate = icao. I'm stuck from here.
I try using the distance function and sometimes don't show the result, or the correct result and sometimes show the correct result.
Dim distance As Double = distance(acLat, acLon, gateLat, gateLon, "M")
If distance = smallestDifference Then
smallestDifference = distance.....
I'm not a pro coder, i think is not the correct code to calculate the current gate!
Thank you
-
Hello Paul Henty,
i'm using your FSUIPCClient DLL V3 and is working good.
I have added the Makerwys with a function getrunway copied from here and is working too.
Now i need to find how to detect the gate where the plane is, tried like function getrunway but no success.
Can you help me and post a function or some code to detect gate? I apreciate.
Sorry my english
Thank you
Cant read nearest icao in c#
in FSUIPC Client DLL for .NET
Posted
Hello Paul thank you for your reply.
I change this to get it working
to this
and now its working perfect, just what i need.
Thank you for your time and help i appreciate.
Helder