Jump to content
The simFlight Network Forums

Draw Wind - Detect gate via G5.CSv


Recommended Posts

Hello Paul,

What's the way to catch Wind & speed and draw in realtime an Arrow to a form, for my acars system reports in vb.net ?

I'm looking for a function you to do that.

 

 

Public Function getrunaway(ByVal icaocode As String) As String
        Dim lon As FsLongitude = New FsLongitude(playerLongitude.Value)
        Dim lat As FsLatitude = New FsLatitude(playerLatitude.Value)
        ' Get the point for the current plane position
        Dim currentPosition As FsLatLonPoint = New FsLatLonPoint(lat, lon)
        Dim pathto As String = My.Application.Info.DirectoryPath
        Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(pathto & "\runways.csv")
            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")
            Dim runawayst As String
            Dim runawaynum As String
            Dim runawaydes1 As String
            Dim runawaydes2 As String = ""
            Dim runawayreturn As String
            Dim currentRow As String()
            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    If currentRow(0) = icaocode Then
                        runawayst = currentRow(1)
                        runawaynum = runawayst.Substring(1, 2)
                        runawaydes1 = runawayst.Substring(3, 1)
                        If runawaydes1 = "0" Then runawaydes2 = ""
                        If runawaydes1 = "1" Then runawaydes2 = "L"
                        If runawaydes1 = "2" Then runawaydes2 = "R"
                        If runawaydes1 = "3" Then runawaydes2 = "C"
                        If runawaydes1 = "4" Then runawaydes2 = "W"
                        Dim aaa As String = currentRow(2)
                        Dim bbb As String = currentRow(3)
                        Dim aaaa As Double
                        Dim bbbb As Double
                        aaaa = System.Convert.ToDouble(aaa)
                        bbbb = System.Convert.ToDouble(bbb)
                        Dim rwyThresholdLat As FsLatitude = New FsLatitude(aaaa)
                        Dim rwyThresholdLon As FsLongitude = New FsLongitude(bbbb)
                        Dim rwyMagHeading As Double = CDbl(currentRow(5))
                        Dim rwyMagVariation As Double = 0
                        Dim rwyLength As Double = CDbl(currentRow(6)) / 2
                        Dim rwyWidth As Double = 254D

                        Dim thresholdCentre As FsLatLonPoint = New FsLatLonPoint(rwyThresholdLat, rwyThresholdLon)
                        Dim trueHeading As Double = rwyMagHeading + rwyMagVariation
                        runwayQuad = FsLatLonQuadrilateral.ForRunway(thresholdCentre, trueHeading, rwyWidth, rwyLength)
                        If runwayQuad.ContainsPoint(currentPosition) = True Then
                            runawayreturn = runawaynum & runawaydes2
                            Return runawayreturn
                            MyReader.Close()
                            MyReader.Dispose()
                            Exit Function
                        End If
                    End If
                Catch ex As Microsoft.VisualBasic.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

 Public Function getWindDirectionFromMETAR(metar As String)
        Dim heading As Integer = 0
        Try

            Dim endPos As Integer = metar.IndexOf("KT")
            If endPos >= 0 Then
                Dim startPos As Double = metar.LastIndexOf(" ", endPos)
                If startPos >= 0 Then
                    heading = metar.Substring(startPos + 1, 3)
                End If
            End If

        Catch ex As Exception

        End Try
        Return heading
    End Function

Thanks Regards Fred

Link to comment
Share on other sites

Just function To draw in real time with values of wind component.

I have already offset and formation to receive values. I try now rotate arrow depending of where come from wind.

Here the code :

 Function Rotation(ByVal AngleDegre As Integer)

        Dim G As Graphics
        'on mémorise la longueur de l'image
        'je pars de l'hypothèse que j'utilise une image carré
        Dim Largeur As Integer = FrmMain.Windirimg.Image.Width
        Dim Hauteur As Integer = FrmMain.Windirimg.Image.Height

        'on mémorise l'image présente dans la picture box
        Dim IMG = FrmMain.Windirimg.Image

        'définition de la picturebox comme espace de dessin
        G = FrmMain.Windirimg.CreateGraphics()

        'on efface 
        G.Clear(FrmMain.BackColor)

        'on transforme l'angle en radians
        Dim Angle As Double = AngleDegre / 180 * Math.PI

        'on calcule les nouvelles coord X et Y de l'image 
        Dim PosX As Single = Math.Sqrt(2) * (Largeur) * Math.Sin(Angle / 2) * Math.Cos(Math.PI / 4 + Angle / 2)
        Dim PosY As Single = -Math.Sqrt(2) * (Largeur) * Math.Sin(Angle / 2) * Math.Cos(Math.PI / 4 - Angle / 2)

        'on fait la rotation
        G.RotateTransform(AngleDegre)

        'on dessine l'image rotée aux nouvelles coordonnées
        G.DrawImage(IMG, PosX, PosY, Largeur, Hauteur)

        'on libère !
        G.Dispose()
    End Function

 

Trying also to find runways in use by METAR and if AI Trafic are in use works with AI Trafic and not by METAR

Regards Fred

592ab1f9d20b1_2017-05-2812_52_49-SKYDreamTracker.png.f3b26d742c81e25db746a6804b31a9b7.png

 

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.