2017 © Pedro Peláez
 

library metoffice

SDK for the UK MetOffice DataPoint API

image

jberns88/metoffice

SDK for the UK MetOffice DataPoint API

  • Monday, March 12, 2018
  • by MrAvenger
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 625 % Grown

The README.md

metoffice

PHP SDK for the UK MetOffice DataPoint API, (*1)

Install

``` CLI composer require jberns88/metoffice, (*2)


### Examples #### Forecasts ``` PHP //You're API key from the MetOffice $client = new \Jberns88\MetOffice\Client(['key' => '<API KEY>']); // Grab all the locations where forecast data is available. $locations = $client->getForecastLocations(); // Find the nearest location from some geo coordinates $location = $locations->getNearest(51.509865, -0.118092); // Get the daily forecasts for this location $forecasts = $location->getDailyForecasts(); // Get the forecast day $day = $forecasts->getByDate(new \DateTime('tomorrow')); // Echo out the location name echo 'Location: ' . $location->getName() . PHP_EOL; // Echo out the forecast date echo 'Date: ' . $day->getDate()->format('Y-m-d') . PHP_EOL; // Echo our the day temperature. Also caontains $day->getNight()->temperature() echo 'Temp: ' . $day->getDay()->getTemperature() . PHP_EOL; // Gust Speed echo 'Gust: ' . $day->getDay()->getGustSpeed() . PHP_EOL; // Wind speed echo 'Wind: ' . $day->getDay()->getWindSpeed() . PHP_EOL; // Weather type based on the meta offices API (https://www.metoffice.gov.uk/datapoint/support/documentation/code-definitions) echo 'Weather type: ' . $day->getDay()->getWeatherType() . PHP_EOL; echo PHP_EOL;

Observerations

``` PHP //You're API key from the MetOffice $client = new \Jberns88\MetOffice\Client(['key' => '']); // Grab all the locations where observation data is available. $locations = $client->getObservationLocations(); // Find the nearest location from some geo coordinates $location = $locations->getNearest(51.509865, -0.118092); // Get the observations $observations = $location->getHourlyObservations(); // get the observation day $day = $observations->getByDate(new \DateTime('yesterday'));, (*3)

echo 'Location: ' . $location->getName() . PHP_EOL; // Grab the highest and lowest temperatures from the day echo 'Temp: ' . $day->getLowestTemperature() . '-' . $day->getHighestTemperature() . PHP_EOL; // Grab the highest and lowest gust speeds for the day echo 'Gust: ' . $day->getHighestGustSpeed() . '-' . $day->getLowestGustSpeed() . PHP_EOL; // Grab the highest and lowest wind speeds for the day echo 'Wind: ' . $day->getHighestWindSpeed() . '-' . $day->getLowestWindSpeed() . PHP_EOL;, (*4)

//Get the observation time peroid. It will find the nearest one if an exact hour isn't given. THe met office don't hold the data for long so I've set the time quite late for this example $period = $day->getByTime(new \DateTime('11pm')); // Weather type based on the meta offices API (https://www.metoffice.gov.uk/datapoint/support/documentation/code-definitions) echo 'Weather type: ' . $period->getWeatherType() . PHP_EOL;, (*5)

```, (*6)

The Versions

12/03 2018

dev-master

9999999-dev

SDK for the UK MetOffice DataPoint API

  Sources   Download

MIT

The Requires

 

12/03 2018

0.0.2

0.0.2.0

SDK for the UK MetOffice DataPoint API

  Sources   Download

MIT

The Requires

 

12/03 2018

0.0.1

0.0.1.0

SDK for the UK MetOffice DataPoint API

  Sources   Download

MIT

The Requires