B4A Library ICOSWorldForecast 3.50

View attachment 14755 View attachment 14754 View attachment 16846 Hi guys, ICOSWorldForecast is here.


It's a pleasure to introduce the new library of weather forecast.

The zip include:

The library, and the demo

INSTALLATION:

Copy the Library in your Basic For Android Library.

Copy the folder weathericon is located in files in the demo. In your one.


RENAME:
ICOSWorldForecast2.71.part1.zip and ICOSWorldForecast2.71.part2.zip

TO:
ICOSWorldForecast2.71.part1.rar and ICOSWorldForecast2.71.part1.rar

In this version I add WeatherUrl and 2 more days forecast.

You can use your own icons, instead of my icons.

For this new version 2.71 you need the new key.

You must register to obtain the new key, otherwise you will get error.

Use the address below to register.

World Weather Online - Welcome to the World Weather Online Developer Network!

don't forget to replace the ApiKey="XXXXXXXXXXXXXX" with your private key

This demos, I made with my galaxy tab 7 600x1024

any question or bugs please report to me.

big Thx to warwound for is fantastic auto-generated reference.


ICOSWorldForecast
Author:
Giuseppe Salvi
Version: 2.81
  • ICOSWorldForecast
    Methods:
    • FCDate (index As Int) As String
      Return Date for which the weather is forecasted
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCDate(0)
    • FCIcon (index As Int) As Bitmap
      Return Weather symbol image
      example:
      Dim a As ICOSWorldForecast
      Image1.SetBackgroundImage=a.FCWeatherIcon(0)
    • FCIconUrl (index As Int) As String
      Return URLIcon For Forecast Condition
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCIconUrl(0)
    • FCPrecipitationMM (index As Int) As String
      Return Precipitation amount in millimeter
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCPrecipitationMM(0)
    • FCTempMaxCelsius (index As Int) As String
      Return Day and night max temperature in Celcius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMaxCelsius(0)
    • FCTempMaxFahrenheit (index As Int) As String
      Return Day and night max temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMaxFahrenheit(0)
    • FCTempMinCelsius (index As Int) As String
      Return Day and night min temperature in Celcius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMinCelsius(0)
    • FCTempMinFahrenheit (index As Int) As String
      Return Day and night max temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCTempMinFahrenheit(0)
    • FCWeatherCode (index As Int) As String
      Return Weather Code
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWeatherCode(0)
    • FCWeatherDesc (index As Int) As String
      Return Weather description
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWeatherDesc(0)
    • FCWinddir16Point (index As Int) As String
      Return 16-Point compass wind direction
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddir16Point(0)
    • FCWinddirDegree (index As Int) As String
      Return Wind direction in degree
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddirDegree(0)
    • FCWinddirection (index As Int) As String
      Return Compass Wind direction
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWinddirection(0)
    • FCWindspeedKmph (index As Int) As String
      Return Wind speed in kilometer per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWindspeedKmph(0)
    • FCWindspeedMiles (index As Int) As String
      Return Wind speed in Miles per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.FCWindspeedMiles(0)
    • FindLatAndLong As String
      Retrieve accurate latitude and longitude from GPS or network services
    • FindLocation As String
      Retrieve accurate location from GPS or network services
    • Full7DayName (day As Int) As String
      Return Full name of the day ( Monday )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Full7DayName(0) ' 0 = today - 1 = tomorrow etc etc
    • GetList (mCity As String) As ArrayList
      Set the City Name you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      Dim l As List
      Dim lv1 As ListView
      l = a.GetList("Los Angeles")
      For n = 0 To l.Size-1
      lv1.AddSingleLine(l.Get(n))
      Next
      Sub lv1_ItemClick (Position As Int, Value As Object)ics.CityName = lv1.GetItem(Position)
      lv1.Clear
      End Sub
    • Initialize (EventName As String)
      Initilize the object
    • Short7DayName (day As Int) As String
      Return Short name of the day ( Mon )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Short7DayName(0) ' 0 = today - 1 = tomorrow etc etc
    • StringFormat (format As String, object As Object, object1 As Object) As String
      Return Formatted String
      example:
      Label1.Text=StringFormat("Lat: %1$s - Long: %2$s ",Latitude,Longitude)
    • isWiFiConnected As Boolean
      Check if WiFi is Connected
    Permissions:
    • android.permission.ACCESS_ASSISTED_GPS
    • android.permission.ACCESS_COARSE_LOCATION
    • android.permission.ACCESS_FINE_LOCATION
    • android.permission.ACCESS_GPS
    • android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
    • android.permission.ACCESS_NETWORK_STATE
    • android.permission.ACCESS_WIFI_STATE
    • android.permission.CONTROL_LOCATION_UPDATES
    • android.permission.INTERNET
    Properties:
    • ApiKey As String [write only]
      Set your personal ApiKey
      example:
      Dim a As ICOSWorldForecast
      a.ApiKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    • AreaName As String [read only]
      Return Name of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.AreaName
    • CCCloudCover As String [read only]
      Return Cloud Cover in %
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCCloudCover
    • CCHumidity As String [read only]
      Return Humidity in %
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCHumidity
    • CCIcon As Bitmap [read only]
      Return Weather symbol image
      example:
      Dim a As ICOSWorldForecast
      Image1.SetBackgroundImage=a.CCWeatherIcon
    • CCIconUrl As String [read only]
      Return URLIcon For Current Condition
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCIconUrl
    • CCLocalObsDateTime As String [read only]
      Return Local Observation date and time
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCLocalObsDateTime
    • CCObservationTime As String [read only]
      Return Observation time (UTC)
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCObservationTime
    • CCPrecipitationMM As String [read only]
      Return Precipitation Amount in Millimeter
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.PrecipitationMM
    • CCPressure As String [read only]
      Return Atmospheric pressure in Milibars
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCPressure
    • CCTempCelsius As String [read only]
      Return Temperature in Celsius
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCTempCelsius
    • CCTempFahrenheit As String [read only]
      Return Temperature in Fahrenheit
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCTempFahrenheit
    • CCVisibility As String [read only]
      Return Visibility kilometers per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCVisibility
    • CCWeatherCode As String [read only]
      Return Weather Code
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWeatherCode
    • CCWeatherDescription As String [read only]
      Return Weather Description
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWeatherDescription
    • CCWinddir16Point As String [read only]
      Return 16-Point wind direction compass
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWinddir16Point
    • CCWinddirDegree As String [read only]
      Return Wind direction in degree
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWinddirDegree
    • CCWindspeedKmph As String [read only]
      Return Wind speed in kilometer per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWindspeedKmph
    • CCWindspeedMiles As String [read only]
      Return Wind speed in Miles per hour
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CCWindspeedMiles
    • CityName As String [write only]
      Set City you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      a.CityName="New York"
    • Country As String [read only]
      Return Name of the Country
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Country
    • CurrentDate As String [read only]
      Return Current Day,Month,Year ( Friday, 28 September, 2012 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CurrentDate
    • CurrentTime As String [read only]
      Return Current time ( 02.09 PM )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.CurrentTime
    • DstOffset As String [read only]
      Return DstOffset = ( GMT +2 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.DstOffset
    • GmtOffset As String [read only]
      Return GmtOffset = ( GMT +1 )
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.GmtOffset
    • LatAndLong As String [write only]
      Set Lat and Long you wish to get the weather
      example:
      Dim a As ICOSWorldForecast
      a.LatAndLong="40.714,-74.006"
    • Latitude As Object [read only]
      Return Latitude of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Latitude
    • Longitude As Object [read only]
      Return Longitude of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Longitude
    • Population As String [read only]
      Return Population of the city
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Population
    • Region As String [read only]
      Return Name of the Region
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Region
    • Sunrise As String [read only]
      Return Sunrise = 06:04
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Sunrise
    • Sunset As String [read only]
      Return Sunset = 19:36
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.Sunset
    • TimeZoneID As String [read only]
      Return TimeZoneID = Europe/Rome
      example:
      Dim a As ICOSWorldForecast
      Label1.Text=a.TimeZoneID
    • Version As Double [read only]
      Return the version of this library
    • WeatherUrl As String [read only]
      Return url of the city [ http://www.worldweatheronline.com/London-weather/City-of-London-Greater-London/GB.aspx ]
      example:
      Dim Webview1 As Webview
      Webview1.LoadUrl(a.WeatherUrl)
 

Attachments

  • ICOSWorldForecast_DEMO.part1.zip
    293 KB · Views: 982
  • ICOSWorldForecast_DEMO.part2.zip
    167.1 KB · Views: 786
  • Main.png
    Main.png
    86.8 KB · Views: 935
  • Widget.jpg
    Widget.jpg
    81.8 KB · Views: 921
  • ICOSWorldForecast.png
    ICOSWorldForecast.png
    156.3 KB · Views: 982
  • ICOSWorldForecastFree_v3.50_lib_fix.zip
    53.9 KB · Views: 531
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Gusieppe,

That's nice, and i thank you.

Unfortunately it still a mistake. That seems be between time zone of the request and time zone of the place of the weather.
Look the screen shot i have put, for play with i put far away place, but that's eight hours difference with here, and one more day, hu ho :)

It's pity, that means again to work on it. Maybe it's because you reference time of the weather's request, or the time zone of user ?
A precision, my local time is French time, because i test my AHLocale xml files on the example also.

I know i'm a bit weird, i do the same with my currencies converter, always try to get some rate of currency from the other side of earth or try weird things like that ;)

Best regards
hi Laurent it´s not a mistake,

the 23 Juin - 8.18 PM is the time in france.

the 24 - Juin - 2013 4:18 AM is the weather time.
 

Laurent95

Active Member
Licensed User
Longtime User
hi Laurent it´s not a mistake,

the 23 Juin - 8.18 PM is the time in france.

the 24 - Juin - 2013 4:18 AM is the weather time.

Hi Giuseppe,

I don't talk about the date, i mean the weekday of the translation in the library.
As far as i know, my wife's family have the same day of us in Euro zone, even they have six hours more in summer and seven hours in winter.

That's why i put the screen shot where we can see monday, june 25. That's not possible the june 25 is all around the world a tuesday not a monday :)

Best regards
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Giuseppe,

I don't talk about the date, i mean the weekday of the translation in the library.
As far as i know, my wife's family have the same day of us in Euro zone, even they have six hours more in summer and seven hours in winter.

That's why i put the screen shot where we can see monday, june 25. That's not possible the june 25 is all around the world a tuesday not a monday :)

Best regards
Hi Laurent u r right,

I´ll fix soon thx u.
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent u r right,

I´ll fix soon thx u.

Hi,
No need to thank, that's normal, I use your library, then I can participate.
Take your time, your library is still be a very good job, even with this.
I have does a little adaptation in my example code for now.

Regards, Laurent
 

Laurent95

Active Member
Licensed User
Longtime User
Great job

Hi Laurent95,

as i promised i fixed the the weekday.

Sorry for the time you have waited.

Hi Giuseppe,
No need to be sorry.
That will be a great help for my next project, a big thank you:)
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Giuseppe,

Currently I fetch the weather by calling:

B4X:
Weather.LatAndLong = lat & "," & lon

Which 9 times out of 10 is great. On occasion there is a delay - a very noticeable delay. Is there anyway to get the weather asynchronously?

Hi gadgetmonster,


the delay is from the provider but u give me good idea.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi guys, here is the fix for Full7DayName and Short7DayName


I addede:



FindLocation ( Retrieve accurate location from GPS or network services )


FindLatAndLong (Retrieve accurate latitude and longitude from GPS or network services )


I hope this fix will help.


Exaple:

If a.FindLocation.Length > 0 Then
a.CityName=a.FindLocation
StartActivity(Forecast)
CallSub(Forecast,mGetList)
End If


If a.FindLatAndLong.Length > 0 Then
a.LatAndLong = a.FindLatAndLong
StartActivity(Forecast)
CallSub(Forecast,mGetList)
End If
 

Laurent95

Active Member
Licensed User
Longtime User
Hi paulchatwin, I just saw your donation a big thanks.
I started to create the library premium for the weather with many new.

Hello Giuseppe,
Any news about the "premium" library ?
I 'm still interested by with the widget that i program, thanks.

Another question, had you the project to give us the possibility to have return from the event passed in the initialize command ? For example to have the callback of request.
That would be interesting to have the results into event and have the possibility to manage data from several places.
For now if i do it, that's make me have more than 2 requests by minute and i get errors.
If you haven't time for, i will keep the datas in a list.

Best regards.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Laurent I'm trying to finish this library but i´ve not much time, just now i arrived from work.

But in september it will be finisched.

About the second question, u can get it just in premium if i underrstand good.


Now work good the library about the Full7DayName please let me know.
 

Laurent95

Active Member
Licensed User
Longtime User
Hi Giuseppe,

Thank you for your quick response.
No worries for the premium, i'm also a bit busy since a while. We can wait september :)

For the second question let that, there are many ways to manage the data.

For the full7dayname it's perfect :cool:, see below the screenshots, i can use the library in the code now. Sorry for the late reply but i need to wait the good time to test it.

Best regard.
 

Attachments

  • screenshot19-08.png
    screenshot19-08.png
    160.4 KB · Views: 150
  • screenshot-code19-08.png
    screenshot-code19-08.png
    34.6 KB · Views: 153

Laurent95

Active Member
Licensed User
Longtime User
Hi Laurent I'm trying to finish this library but i´ve not much time, just now i arrived from work.

Now work good the library about the Full7DayName please let me know.

Hi Giuseppe,For the full7dayname it's perfect :cool:, see below the screenshots, i can use the library in the code now. Sorry for the late reply but i need to wait the good time to test it.

Best regard.

Hello Giuseppe,

Sorry for so quick reply, but it stays a little bug in the library about the 'full7dayname' coding.
It seems that in the code the date have "1 " (with a space after) and not numeric 1 only for the first day of month.
That does an error when you try to parse the date in the library for the days names.
The sceenchot of my widget and the log give you the indications.

Best regards, Laurent.
 

Attachments

  • screenshot-1-09-2013.png
    screenshot-1-09-2013.png
    87.3 KB · Views: 137
  • log-1-09-2013.txt
    8.4 KB · Views: 166

lonleystar

Well-Known Member
Licensed User
Longtime User
Hello Giuseppe,

Sorry for so quick reply, but it stays a little bug in the library about the 'full7dayname' coding.
It seems that in the code the date have "1 " (with a space after) and not numeric 1 only for the first day of month.
That does an error when you try to parse the date in the library for the days names.
The sceenchot of my widget and the log give you the indications.

Best regards, Laurent.



Hi Laurent with the Italian language I couldn't see this error

but Thx to report this bug, I´ll fix soon .
 

GMan

Well-Known Member
Licensed User
Longtime User
Replaced my old lib - all works fine :)
 
Top