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

Class: Services_GeoNames

Source Location: /Services_GeoNames-0.2.2/Services/GeoNames.php

Class Overview


Main interface to the GeoNames API: http://www.geonames.org/export/web-services.html


Author(s):

Version:

  • Release: 0.2.2

Copyright:

  • 2008 David JEAN LOUIS

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 78]
Main interface to the GeoNames API: http://www.geonames.org/export/web-services.html
  • Method: array children(): children(array $params)
  • Method: array cities(): cities(array $params)
  • Method: stdclass countryCode(): countryCode(array $params)
  • Method: array countryInfo(): countryInfo(array $params)
  • Method: stdclass countrySubdivision(): countrySubdivision(array $params)
  • Method: array earthquakes(): earthquakes(array $params)
  • Method: array findNearby(): findNearby(array $params)
  • Method: array findNearbyPlaceName(): findNearbyPlaceName(array $params)
  • Method: array findNearbyPostalCodes(): findNearbyPostalCodes(array $params)
  • Method: array findNearbyStreets(): findNearbyStreets(array $params)
  • Method: stdclass findNearByWeather(): findNearByWeather(array $params)
  • Method: array findNearbyWikipedia(): findNearbyWikipedia(array $params)
  • Method: stdclass findNearestAddress(): findNearestAddress(array $params)
  • Method: stdclass findNearestIntersection(): findNearestIntersection(array $params)
  • Method: stdclass get(): get(array $params)
  • Method: stdclass gtopo30(): gtopo30(array $params)
  • Method: array hierarchy(): hierarchy(array $params)
  • Method: stdclass neighbourhood(): neighbourhood(array $params)
  • Method: array neighbours(): neighbours(array $params)
  • Method: array postalCodeCountryInfo(): postalCodeCountryInfo(array $params)
  • Method: array postalCodeLookup(): postalCodeLookup(array $params)
  • Method: array postalCodeSearch(): postalCodeSearch(array $params)
  • Method: array search(): search(array $params)
  • Method: array siblings(): siblings(array $params)
  • Method: array weather(): weather(array $params)
  • Method: stdclass weatherIcao(): weatherIcao(array $params)
  • Method: stdclass srtm3(): srtm3(array $params)
  • Method: stdclass timezone(): timezone(array $params)
  • Method: array wikipediaBoundingBox(): wikipediaBoundingBox(array $params)
  • Method: array wikipediaSearch(): wikipediaSearch(array $params)
  • Author: David JEAN LOUIS <izimobil@gmail.com>
  • Version: Release: 0.2.2
  • Copyright: 2008 David JEAN LOUIS
  • Link: http://www.geonames.org/export/ws-overview.html
  • Link: http://www.geonames.org/export/web-services.html
  • Link: http://pear.php.net/package/Services_GeoNames
  • Since: Class available since release 0.1.0
  • License: MIT License


[ Top ]


Class Variables

$endpoints = array(
        'children'                => 'geonames',
        'cities'                  => 'geonames',
        'countryCode'             => false,
        'countryInfo'             => 'geonames',
        'countrySubdivision'      => false,
        'earthquakes'             => 'earthquakes',
        'findNearby'              => 'geonames',
        'findNearbyPlaceName'     => 'geonames',
        'findNearbyPostalCodes'   => 'postalCodes',
        'findNearbyStreets'       => 'streetSegment',
        'findNearByWeather'       => 'weatherObservation',
        'findNearbyWikipedia'     => 'geonames',
        'findNearestAddress'      => 'address',
        'findNearestIntersection' => 'intersection',
        'get'                     => false,
        'gtopo30'                 => false,
        'hierarchy'               => 'geonames',
        'neighbourhood'           => 'neighbourhood',
        'neighbours'              => 'geonames',
        'postalCodeCountryInfo'   => 'geonames',
        'postalCodeLookup'        => 'postalcodes', // not a typo
        'postalCodeSearch'        => 'postalCodes',
        'search'                  => 'geonames',
        'siblings'                => 'geonames',
        'weather'                 => 'weatherObservations',
        'weatherIcao'             => 'weatherObservation',
        'srtm3'                   => false,
        'timezone'                => false,
        'wikipediaBoundingBox'    => 'geonames',
        'wikipediaSearch'         => 'geonames',
    )

[line 151]

Array of supported endpoints (listed alphabetically) and their corresponding root property (if any).

Note that we only support json endpoints, so the following endpoints are not supported:

  • extendedFindNearby (JSON not available for now)
  • rssToGeo (RSS/KML only)
For a full documentation of the available endpoints services, please see: http://www.geonames.org/export/ws-overview.html.

  • Access: protected

Type:   array


[ Top ]

$request =

[line 121]

The HTTP_Request2 instance, you can customize the request if you want to (proxy, auth etc...) with the get/setRequest() methods.
  • Access: protected

Type:   HTTP_Request2


[ Top ]

$token =

[line 135]

Auth token, for commercial webservices only.
  • Access: protected

Type:   string


[ Top ]

$url =  'http://ws.geonames.org'

[line 113]

Url of the GeoNames web service.

This should not change but anyway we make it public.

  • Access: public

Type:   string


[ Top ]

$username =

[line 128]

Auth username, for commercial webservices only.
  • Access: protected

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 197]

void __construct( [string $username = null], [string $token = null])

Constructor, if you're using a commercial account (optional), you must pass your "username" and "token".
  • Access: public

Parameters:

string   $username   —  Username for commercial webservice (optional)
string   $token   —  Token for commercial webservice (optional)

[ Top ]

formatQueryString   [line 318]

string formatQueryString( [array $params = array()])

Builds a valid query string (url and utf8 encoded) to pass to the endpoint and returns it.
  • Return: The formatted query string
  • Access: protected

Parameters:

array   $params   —  Array of arguments

[ Top ]

getRequest   [line 341]

HTTP_Request2 getRequest( )

Returns the HTTP_Request2 instance.
  • Return: The request
  • Access: public

[ Top ]

getSupportedEndpoints   [line 372]

array getSupportedEndpoints( )

Returns an array of supported services endpoints.
  • Return: The endpoints array
  • Access: public

[ Top ]

sendRequest   [line 285]

string sendRequest( string $url)

Sends the request to the server using HTTP_Request2.
  • Return: The response body
  • Throws: Services_GeoNames_HTTPException When something goes wrong when building the request or requesting the server.
  • Throws: HTTP_Request2_Exception
  • Access: protected

Parameters:

string   $url   —  The full service url (url + endpoint + query string)

[ Top ]

setRequest   [line 359]

void setRequest( HTTP_Request2 $request)

Sets the HTTP_Request2 instance.
  • Access: public

Parameters:

HTTP_Request2   $request   —  The request to set

[ Top ]

__call   [line 221]

mixed __call( string $endpoint, [array $params = array()])

Method interceptor that retrieves the corresponding endpoint and return a json decoded object or throw a Services_GeoNames_Exception.
  • Return: stdclass|array The JSON decoded response or an array
  • Throws: Services_GeoNames_Exception When an invalid method is called or when the websercices returns an error
  • Access: public

Parameters:

string   $endpoint   —  The endpoint to call
array   $params   —  Array of parameters to pass to the endpoint

[ Top ]


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