Tue 12 Feb 2013 10:44:15 CET
owmClient library - get weather status and forecast
owmClient library - get weather status and forecast
Just published a new library to interface with the services from OpenWeatherMap (OWM). License is Apache v2 and you can get to the source code by going to:
It's not complete (doesn't yet support all the services OWM does) but it it already makes it easy to get to know the weather status and forecast.
An example of getting the current weather status for the city of London, UK:
1: OwmClient owm = new OwmClient (); 2: WeatherStatusResponse currentWeather = owm.currentWeatherAtCity ("london", "UK"); 3: 4: /* Let's see if it's raining... */ 5: if (currentWeather.hasWeatherStatus ()) { 6: WeatherData weather = currentWeather.getWeatherStatus ().get (0); 7: if (weather.hasRain ()) { 8: Precipitation rain = weather.getRain (); 9: if (rain.hasToday ()) { 10: if (rain.getToday () == 0) 11: System.out.println ("No reports of rain in London"); 12: else 13: System.out.println ("Another report of rain in London"); 14: } 15: } else { 16: System.out.println ("No rain information in London"); 17: } 18: }