Home
>
GIS > Weather Info using WebServices.Net
Weather Info using WebServices.Net
September 5th, 2009
admin
Private Sub WeatherInfo(ByVal country As String)
Try
Dim reader As XmlNodeReader = Nothing
Dim WeatherInfo As String = ""
Dim weatherws As New WeatherWS.GlobalWeather
WeatherInfo = weatherws.GetWeather("", country)
Dim time As String = ""
Dim wind As String = ""
Dim Visibility As String = ""
Dim Sky As String = ""
Dim Humidity As String = ""
Dim Pressure As String = ""
Dim tempstr As String
Dim temp As Integer
Dim notes As String
Try
Dim doc As New XmlDocument
doc.LoadXml(WeatherInfo)
reader = New XmlNodeReader(doc)
reader.MoveToContent()
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
If reader.Name = "Time" Then
time = reader.ReadInnerXml
End If
If reader.Name = "Wind" Then
wind = reader.ReadInnerXml()
End If
If reader.Name = "Visibility" Then
Visibility = reader.ReadInnerXml()
End If
If reader.Name = "SkyConditions" Then
Sky = reader.ReadInnerXml()
End If
If reader.Name = "Temperature" Then
Temperature = reader.ReadInnerXml()
End If
If reader.Name = "RelativeHumidity" Then
Humidity = reader.ReadInnerXml()
End If
If reader.Name = "Pressure" Then
Pressure = reader.ReadInnerXml()
End If
End Select
End While
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
notes = "Time:" + time + vbCrLf
notes += "Temperature: " + Temperature + vbCrLf
notes += "Visibility: " + Visibility + vbCrLf + "Sky: " + Sky + vbCrLf
notes += "Wind: " + wind + vbCrLf
notes += "Humidity: " + Humidity + vbCrLf
notes += "Pressure: " + Pressure + vbCrLf
tempstr = Temperature.Split("(")(1)
tempstr = tempstr.Substring(0, 2)
temp = Integer.Parse(tempstr)
Me.btn_NearBeach.Visible = False
If temp >= 30 Then
notes += "Ideal Temperature for Swimming " + vbCrLf
notes += "Click to find the nearest beach " + vbCrLf
Me.btn_NearBeach.Visible = True
End If
Me.lbl_Weather.Text = notes
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub