Services_Weather
[ class tree: Services_Weather ] [ index: Services_Weather ] [ all elements ]

Class: Services_Weather_Metar

Source Location: /Services_Weather-1.4.7/Weather/Metar.php

Class Overview

Services_Weather_Common
   |
   --Services_Weather_Metar

This class acts as an interface to the METAR/TAF service of weather.noaa.gov. It searches for locations given in ICAO notation and retrieves the current weather data.


Author(s):

Version:

  • Release: 1.4.7

Copyright:

  • 2005-2011 Alexander Wirtz

Methods


Inherited Variables

Inherited Methods

Class: Services_Weather_Common

Services_Weather_Common::calculateDewPoint()
Calculate dewpoint from temperature and humidity This is only an approximation, there is no exact formula, this one here is called Magnus-Formula
Services_Weather_Common::calculateHumidity()
Calculate humidity from temperature and dewpoint This is only an approximation, there is no exact formula, this one here is called Magnus-Formula
Services_Weather_Common::calculateMoonPhase()
Calculates the moon age and phase
Services_Weather_Common::calculateSunRiseSet()
Calculates sunrise and sunset for a location
Services_Weather_Common::calculateWindChill()
Calculate windchill from temperature and windspeed (enhanced formula)
Services_Weather_Common::convertDistance()
Convert distance between km, ft and sm
Services_Weather_Common::convertPressure()
Convert pressure between in, hpa, mb, mm and atm
Services_Weather_Common::convertSpeed()
Convert speed between mph, kmh, kt, mps, fps and bft
Services_Weather_Common::convertTemperature()
Convert temperature between f and c
Services_Weather_Common::getUnitsFormat()
Returns the selected units format
Services_Weather_Common::getWeatherIcon()
Gets a number corresponding to a weather icon.
Services_Weather_Common::polar2cartesian()
Convert polar coordinates to cartesian coordinates
Services_Weather_Common::setCache()
Enables caching the data, usage strongly recommended
Services_Weather_Common::setDateTimeFormat()
Changes the representation of time and dates (see http://www.php.net/date)
Services_Weather_Common::setHttpOption()
Sets an option for usage in HTTP_Request objects
Services_Weather_Common::setHttpProxy()
Sets the proxy for HTTP requests
Services_Weather_Common::setHttpTimeout()
Sets the timeout in seconds for HTTP requests
Services_Weather_Common::setUnitsFormat()
Changes the representation of the units (standard/metric)

Class Details

[line 94]
This class acts as an interface to the METAR/TAF service of weather.noaa.gov. It searches for locations given in ICAO notation and retrieves the current weather data.

Of course the parsing of the METAR-data has its limitations, as it follows the Federal Meteorological Handbook No.1 with modifications to accomodate for non-US reports, so if the report deviates from these standards, you won't get it parsed correctly. Anything that is not parsed, is saved in the "noparse" array-entry, returned by getWeather(), so you can do your own parsing afterwards. This limitation is specifically given for remarks, as the class is not processing everything mentioned there, but you will get the most common fields like precipitation and temperature-changes. Again, everything not parsed, goes into "noparse".

If you think, some important field is missing or not correctly parsed, please file a feature-request/bugreport at http://pear.php.net/ and be sure to provide the METAR (or TAF) report with a _detailed_ explanation!

For working examples, please take a look at docs/Services_Weather/examples/metar-basic.php docs/Services_Weather/examples/metar-extensive.php



[ Top ]


Method Detail

getForecast   [line 1878]

PEAR_Error|array getForecast( [string $id = ""], [int $days = null], [string $unitsFormat = ""])

METAR provides no forecast per se, we use the TAF reports to generate a forecast for the announced timeperiod
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $id   — 
int   $days   —  Ignored, not applicable
string   $unitsFormat   — 

[ Top ]

getLocation   [line 1720]

PEAR_Error|array getLocation( [string $id = ""])

Returns the data for the location belonging to the ID
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $id   — 

[ Top ]

getWeather   [line 1793]

PHP_Error|array getWeather( [string $id = ""], [string $unitsFormat = ""])

Returns the weather-data for the supplied location
  • Throws: PHP_Error
  • Access: public

Parameters:

string   $id   — 
string   $unitsFormat   — 

[ Top ]

searchAirport   [line 1645]

PEAR_Error|array|string searchAirport( float $latitude, float $longitude, [int $numResults = 1])

Searches the nearest airport(s) for given coordinates, returns array of IDs or single ID
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION
  • Access: public

Parameters:

float   $latitude   — 
float   $longitude   — 
int   $numResults   — 

[ Top ]

searchLocation   [line 1489]

PEAR_Error|array|string searchLocation( string|array $location, [bool $useFirst = false])

Searches IDs for given location, returns array of possible locations or single ID
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION
  • Access: public

Parameters:

string|array   $location   — 
bool   $useFirst   —  If set, first ID of result-array is returned

[ Top ]

searchLocationByCountry   [line 1581]

PEAR_Error|array searchLocationByCountry( [string $country = ""])

Returns IDs with location-name for a given country or all available countries, if no value was given
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA
  • Access: public

Parameters:

string   $country   — 

[ Top ]

setMetarDB   [line 215]

DB_Error|bool setMetarDB( string $dsn, [array $dbOptions = array()])

Sets the parameters needed for connecting to the DB, where the location-search is fetching its data from. You need to build a DB with the external tool buildMetarDB first, it fetches the locations and airports from a NOAA-website.
  • See: DB::parseDSN
  • Throws: DB_Error
  • Access: public

Parameters:

string   $dsn   — 
array   $dbOptions   — 

[ Top ]

setMetarSource   [line 248]

PEAR_ERROR|bool setMetarSource( string $sourceMetar, [string $sourcePathMetar = ""], [string $sourceTaf = ""], [string $sourcePathTaf = ""])

Sets the source, where the class tries to locate the METAR/TAF data

Source can be http, ftp or file. Alternate sourcepaths can be provided.

  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_METAR_SOURCE_INVALID
  • Access: public

Parameters:

string   $sourceMetar   — 
string   $sourcePathMetar   — 
string   $sourceTaf   — 
string   $sourcePathTaf   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:50:59 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.