Trixology

WeatherCat => WeatherCat Web Templates => Topic started by: saratogaWX on July 29, 2015, 03:35:29 PM

Title: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: saratogaWX on July 29, 2015, 03:35:29 PM
Saratoga templates use get-USNO-sunmoon.php to gather sun/moon data for display on the ajax-dashboard and wxastronomy.php pages (for all weather software except Weather-Display).

The US Naval Observatory has announced they will discontinue providing the data in the way used by V1.x of the script after July 31, 2015 and instead are offering a JSON feed of the data.  The V2.00 version of the script now uses the new JSON feed from them.

Template users: use the update tool (http://saratoga-weather.org/wxtemplates/updates.php) with a query of (Base-*, Plugin-*, 29-Jul-2015) to get the updated script.

Best regards,
Ken
Title: Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: wvdkuil on July 29, 2015, 04:40:24 PM
Thanks Ken for bringing this to our attention.

As there is no other source for moon-data when using  WeatherrCat , there are different scripts using the now nearly obsolete post-script.

For users having their own scripts, the API can be found at:   http://aa.usno.navy.mil/data/docs/api.php (http://aa.usno.navy.mil/data/docs/api.php)

Wim
Title: Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: wvdkuil on July 31, 2015, 06:12:31 PM
For leuven-template weathercat users, a new version of the astronomy.php  script is on-line.
This script loads the moon-rise moon-set times for the dashboard and had to be changed by the introduction of the usno api.

Wim
Title: Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: Alan Rowley on August 05, 2015, 06:31:02 AM
Wim,

I installed the new version of astronomy.php yesterday and all was working correctly. This morning, I am getting the following error message:

Quote
Notice: Undefined index: moonrise in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 502

Notice: Undefined index: moonset in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 503

To get it working again, I had to delete the file 'sunMoondata.arr' from the cache. I did read that I had to use '&force=usno', where do I use this command?

ALAN.
Title: Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: wvdkuil on August 05, 2015, 08:00:08 AM
Wim,

I installed the new version of astronomy.php yesterday and all was working correctly. This morning, I am getting the following error message:

Quote
Notice: Undefined index: moonrise in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 502

Notice: Undefined index: moonset in /home/alanrowley3/public_html/weather27/inc/astronomy.php on line 503

To get it working again, I had to delete the file 'sunMoondata.arr' from the cache. I did read that I had to use '&force=usno', where do I use this command?

ALAN.
If this is a page request  in the broser address-line
http://www.brackenhouse.net/weather27/index.php?p=10&lang=en
you add &force=xyz
http://www.brackenhouse.net/weather27/index.php?p=10&lang=en&force=xyz

If this is a page request in the browser address-line
http://www.brackenhouse.net/weather27/ 
you have to add ?force=xyz
http://www.brackenhouse.net/weather27/?force=xyz
 
So the first extra "command' starts with a  ? and all others with a  &

===

As with all forecasts  (except EWN)  the data retrieved from external sources  is valid for multiple hours.  For example there are only two new forecast / day for the met.no and yr.no forecasts. And the moon information needs to be refreshed only once/day, same with  the UV forecast and the almanac data from WU.

So when data is loaded from an external soource, that still valid data is cached. If there was an error in the data (extremely rare) or a new script version (not so rare) you can use a force=xxx to read a new data-set and refresh the cached information.

Wim
Title: Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: Alan Rowley on August 05, 2015, 09:00:56 AM
That's done Wim and all is working fine.

Do I need to use &force=usno overtime I use the astronomy.php page, or will it be ok until the script changes again?

ALAN.
Title: Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: wvdkuil on August 05, 2015, 09:08:39 AM
That's done Wim and all is working fine.

Do I need to use &force=usno overtime I use the astronomy.php page, or will it be ok until the script changes again?

ALAN.
The force=xyz  is only used when there is a problem with the data.  The moonset/rise data will be automatically refreshed first run after midnight. Normaly you never use force=xyz for any script.

Wim
Title: Re: USNO changes API to JSON.. get-USNO-sunmoon.php V2.00 available
Post by: Alan Rowley on August 05, 2015, 09:10:05 AM
Thanks Wim. Got that.