eigan / yr-php-library

Small php library for the norwegian weather service Yr.
18 stars 4 forks source link

Bug in xml for towns out of Norway #2

Closed franko108 closed 9 years ago

franko108 commented 9 years ago

Hi there, I like your library, but if you put in current_forecast.php the following line: $yr = Yr\Yr::create("Croatia/Istria/Medulin/", "/tmp"); There are notice and warnings like this:

Notice: Trying to get property of non-object in /var/www/tester/yr-php-library/Yr/Yr.php on line 138 Warning: Invalid argument supplied for foreach() in /var/www/tester/yr-php-library/Yr/Yr.php on line 148

Line 138 in Yr.php is: foreach($xml_hourly->forecast->text->location->time as $forecast) { which expects to have forecast->text while on several xml data (tried to put Berlin, Gothenburg, Pula) there is no <forecast><text> in forecast.xml but <forecast><tabular>

Also, there is no <observations> at the end of same xml, as demand the weather_stations section. xml for Norway cities aren't completely the same as for another countries.

However, at the end, the proper data are retrieved. Best regards, Franko

eigan commented 9 years ago

Hi!

Thanks for your bug report! :) I added some code to check if textual and weather stations exists in the xml. They are now simply ignored if they are not located in the xml file.