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

Class: Services_Weather_Common

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

Class Overview


Parent class for weather-services. Defines common functions for unit conversions, checks for cache enabling and does other miscellaneous things.


Author(s):

Version:

  • Release: 1.4.7

Copyright:

  • 2005-2011 Alexander Wirtz

Methods


Child classes:

Services_Weather_Globalweather
This class acts as an interface to the soap service of capescience.com.
Services_Weather_Ejse
This class acts as an interface to the soap service of EJSE. It retrieves current weather data and forecasts based on postal codes (ZIP).
Services_Weather_Weatherdotcom
This class acts as an interface to the xml service of weather.com. It searches for given locations and retrieves current weather data as well as forecast for up to 5 days.
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.

Inherited Variables

Inherited Methods


Class Details

[line 77]
Parent class for weather-services. Defines common functions for unit conversions, checks for cache enabling and does other miscellaneous things.


[ Top ]


Method Detail

calculateDewPoint   [line 760]

float calculateDewPoint( float $temperature, float $humidity)

Calculate dewpoint from temperature and humidity This is only an approximation, there is no exact formula, this one here is called Magnus-Formula

Temperature has to be entered in deg C!


Parameters:

float   $temperature   — 
float   $humidity   — 

[ Top ]

calculateHumidity   [line 721]

float calculateHumidity( float $temperature, float $dewPoint)

Calculate humidity from temperature and dewpoint This is only an approximation, there is no exact formula, this one here is called Magnus-Formula

Temperature and dewpoint have to be entered in deg C!


Parameters:

float   $temperature   — 
float   $dewPoint   — 

[ Top ]

calculateMoonPhase   [line 823]

PEAR_Error|array calculateMoonPhase( int $date)

Calculates the moon age and phase

The algorithms for this functions were taken from the German Wikipedia entry on Julian Daycount for getting the accurate JD to the second and the overall moon calculation were done according to Stephen R. Schmitt's website, which is cited multiple times on the web for this kind of calculation.

The date has to be entered as a timestamp!


Parameters:

int   $date   — 

[ Top ]

calculateSunRiseSet   [line 991]

PEAR_Error|mixed calculateSunRiseSet( int $date, [int $retformat = null], [float $latitude = null], [float $longitude = null], [float $zenith = null], [float $gmt_offset = null], [bool $sunrise = true])

Calculates sunrise and sunset for a location

The sun position algorithm taken from the 'US Naval Observatory's Almanac for Computers', implemented by Ken Bloom <kekabloom[at]ucdavis[dot]edu> for the zmanim project, converted to C by Moshe Doron <mosdoron[at]netvision[dot]net[dot]il> and finally taken from the PHP5 sources and converted to native PHP as a wrapper.

The date has to be entered as a timestamp!

  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_SUNFUNCS_DATE_INVALID
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_SUNFUNCS_RETFORM_INVALID
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_ERROR
  • Access: public

Parameters:

int   $date   — 
int   $retformat   — 
float   $latitude   — 
float   $longitude   — 
float   $zenith   — 
float   $gmt_offset   — 
bool   $sunrise   — 

[ Top ]

calculateWindChill   [line 701]

float calculateWindChill( float $temperature, float $speed)

Calculate windchill from temperature and windspeed (enhanced formula)

Temperature has to be entered in deg F, speed in mph!


Parameters:

float   $temperature   — 
float   $speed   — 

[ Top ]

convertDistance   [line 662]

float convertDistance( float $distance, string $from, string $to)

Convert distance between km, ft and sm
  • Access: public

Parameters:

float   $distance   — 
string   $from   — 
string   $to   — 

[ Top ]

convertPressure   [line 622]

float convertPressure( float $pressure, string $from, string $to)

Convert pressure between in, hpa, mb, mm and atm
  • Access: public

Parameters:

float   $pressure   — 
string   $from   — 
string   $to   — 

[ Top ]

convertSpeed   [line 562]

float|int|bool convertSpeed( float $speed, string $from, string $to)

Convert speed between mph, kmh, kt, mps, fps and bft

Function will return "false" when trying to convert from Beaufort, as it is a scale and not a true measurement


Parameters:

float   $speed   — 
string   $from   — 
string   $to   — 

[ Top ]

convertTemperature   [line 526]

float convertTemperature( float $temperature, string $from, string $to)

Convert temperature between f and c
  • Access: public

Parameters:

float   $temperature   — 
string   $from   — 
string   $to   — 

[ Top ]

getUnitsFormat   [line 466]

array getUnitsFormat( [string $unitsFormat = ""])

Returns the selected units format
  • Access: public

Parameters:

string   $unitsFormat   — 

[ Top ]

getWeatherIcon   [line 1181]

void getWeatherIcon( string $condition, [array $clouds = array()], [float $wind = 5], [float $temperature = 70], [float $latitude = -360], [float $longitude = -360], [int $reportTime = ""])

Gets a number corresponding to a weather icon.

These numbers just happen to correspond with the icons that you get with the weather.com SDK, but open versions of them have been created. Input must be in standard units. For the icons that include day/night, we use the present time and the provided lat/lon to determine if the sun is up. A complete set of icon descriptions can be found here: http://sranshaft.wincustomize.com/Articles.aspx?AID=60165&u=0

There are a number of icon sets here: http://www.desktopsidebar.com/forums/index.php?showtopic=2441&st=0 http://www.desktopsidebar.com/forums/index.php?showtopic=819


Parameters:

string   $condition   —  The condition.
array   $clouds   —  The clouds at various levels.
float   $wind   —  Wind speed in mph.
float   $temperature   —  Temperature in deg F.
float   $latitude   —  Point latitude.
float   $longitude   —  Point longitude.
int   $reportTime   —  The time when the weather report was generated.

[ Top ]

polar2cartesian   [line 791]

array polar2cartesian( float $latitude, float $longitude)

Convert polar coordinates to cartesian coordinates
  • Access: public

Parameters:

float   $latitude   — 
float   $longitude   — 

[ Top ]

setCache   [line 242]

PEAR_Error|bool setCache( [string $cacheType = "file"], [array $cacheOptions = array()])

Enables caching the data, usage strongly recommended

Requires Cache to be installed

  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_CACHE_INIT_FAILED
  • Access: public

Parameters:

string   $cacheType   — 
array   $cacheOptions   — 

[ Top ]

setDateTimeFormat   [line 505]

void setDateTimeFormat( [string $dateFormat = ""], [string $timeFormat = ""])

Changes the representation of time and dates (see http://www.php.net/date)
  • Access: public

Parameters:

string   $dateFormat   — 
string   $timeFormat   — 

[ Top ]

setHttpOption   [line 405]

void setHttpOption( string $varName, mixed $varValue)

Sets an option for usage in HTTP_Request objects
  • Access: public

Parameters:

string   $varName   — 
mixed   $varValue   — 

[ Top ]

setHttpProxy   [line 435]

void setHttpProxy( string $httpProxy)

Sets the proxy for HTTP requests
  • Access: public

Parameters:

string   $httpProxy   — 

[ Top ]

setHttpTimeout   [line 420]

void setHttpTimeout( int $httpTimeout)

Sets the timeout in seconds for HTTP requests
  • Access: public

Parameters:

int   $httpTimeout   — 

[ Top ]

setUnitsFormat   [line 368]

void setUnitsFormat( string $unitsFormat, [array $customUnitsFormat = array()])

Changes the representation of the units (standard/metric)
  • Access: public

Parameters:

string   $unitsFormat   — 
array   $customUnitsFormat   — 

[ Top ]


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