Display weather from the National Weather Service
- Edit the Bot name and rename
config.example.php
toconfig.php
- If you want to use reverse GeoCoding create
.secrets.php
and add<?php const GEOCODING_APIKEY = "YourKey";
- Deploy somewhere that runs PHP.
- Ensure the
cache/
directory is writeable
For litespeed, I use the following .htaccess
caching configuration:
<IfModule LiteSpeed>
RewriteEngine On
RewriteRule (.*\.php)?$ - [E=cache-control:max-age=60]
</IfModule>
This project started as an experiment to learn about the National Weather Service APIs and present them conviently.
Then, since I am a sailor and I like to be my own weatherman, I started adding additional elements to make that workflow more convient too.
The primary goal is smartphone usability, especially loading time, presentation and convienience.
- Implement
/icons
- Implement
/glossary
- Implement location configuration
- Display the synopsis as an
<summary>
- Look for AFD warnings of "disagreement" or confidence or storm
- Diff the AFD between issuances
- Add SailFlow https://api.weatherflow.com/wxengine/rest/graph/getGraph?spot_id=1788&time_start=2019-09-07%2000:00:00&time_end=2019-09-07%2024:00:00&units_wind=kts&fields=wind&wf_token=27c8cfd62708b58ac7fa8d1442326751&color_plot_bg=0xFAFAFA&wind_speed_floor=31&graph_height=330&graph_width=635&type=line4&format=raw&v=1.1&cb=1567869210596
- Add
manifest.json
for PWA (mostly to control add to homescreen) - Use a cookie after releases to clear the cache
- Refactor templating to
p()
- Refactor helpers out of classes (should it be a static?)
- Refactor constants to
config.php
- Refactor to use a baseurl (see Swagger)
- Refector separate data from view
- Refactor DEBUG --> switch to logging approach? add email alerts? Avoid frequent emails by tracking "last sent time"
- Refactor AFD parser to make it less brittle
Implement/gridpoint/
Refactor Javascript into PHPAdd TidesCreate generalized loop-er (Support navigation, Allow "skip nights" toggle, Support "Jump to day")!Parameterize TTL on curlCatchRetrieveClean up HTML comments
The core API Documentation & https://www.weather.gov/documentation/services-web-api
The current code is bad and in the very least needs to be refactored with better error handling.
At the risk of over-engineering (for the sake of learning!) I'm contemplating:
- It seems like there is an opportunity to define a grammar like YACC and then generate the parser from it https://github.com/ircmaxell/PHP-Yacc
- It also seems like this should be its own library that works with PSR-4: Autoloader
https://origin.wpc.ncep.noaa.gov/basicwx/day0-7loop.html
https://origin.wpc.ncep.noaa.gov/basicwx/
https://origin.wpc.ncep.noaa.gov/sfc/loopimagesfcwbg.gif
https://origin.wpc.ncep.noaa.gov/medr/9jhwbgloop.gif
/sfc/loopimagesfcwbg.gif
/basicwx/93fndfd_loop.gif
/basicwx/94fndfd_loop.gif
/basicwx/95fndfd_loop.gif
/basicwx/96fndfd_loop.gif
/basicwx/98fndfd_loop.gif
/basicwx/99fndfd_loop.gif
/medr/9jhwbgloop.gif
/medr/9khwbgloop.gif
/medr/9lhwbgloop.gif
/medr/9mhwbgloop.gif
/medr/9nhwbgloop.gif
https://www.star.nesdis.noaa.gov/GOES/sector_band.php?sat=G16§or=ne&band=GEOCOLOR&length=12
src='https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/ne/GEOCOLOR/
WindFinder The Superforecast is based on the newest versions of high resolution weather prediction models. The Superforecast is available for Europe, North America, South Africa, Egypt and the Canary Islands. The horizontal resolution is 5 kilometers. Forecasts are computed 4 times per day. Predictions are available in time steps of 1 hour for up to 3 days into the future. Forecast and Superforecast are based on different physical models and therefore may cause divergent predictions. Due to its higher horizontal resolution the Superforecast should be more accurate, especially for locations with a complex topography and local thermal effects. The arrows point in the direction that the wind is blowing. https://www.windfinder.com/forecast/marblehead_coolidge_road https://www.windfinder.com/forecast/salem_harbor_pitman_road https://www.windfinder.com/forecast/marblehead_neck https://ocean.weather.gov/Atl_tab.shtml Currents: OSCAR
/**
* Return a formatted string like vsprintf() with named placeholders.
*
* When a placeholder doesn't have a matching key in `$args`,
* the placeholder is returned as is to see missing args.
* @param string $format
* @param array $args
* @param string $pattern
* @return string
*/
function p($format, array $args, $pattern="/\{(\w+)\}/") {
return preg_replace_callback($pattern, function ($matches) use ($args) {
return @$args[$matches[1]] ?: $matches[0];
}, $format);
}