Class Index | File Index

Classes


Class ilib.GeoLocator

Create an instance that can geographically locate a phone number.

The location of the number is calculated according to the following rules:

  1. If the areaCode property is undefined or empty, or if the number specifies a country code for which we do not have information, then the area property may be missing from the returned object. In this case, only the country object will be returned.
  2. If there is no area code, but there is a mobile prefix, service code, or emergency code, then a fixed string indicating the type of number will be returned.
  3. The country object is filled out according to the countryCode property of the phone number.
  4. If the phone number does not have an explicit country code, the MCC will be used if it is available. The country code can be gleaned directly from the MCC. If the MCC of the carrier to which the phone is currently connected is available, it should be passed in so that local phone numbers will look correct.
  5. If the country's dialling plan mandates a fixed length for phone numbers, and a particular number exceeds that length, then the area code will not be given on the assumption that the number has problems in the first place and we cannot guess correctly.
The returned area property varies in specificity according to the locale. In North America, the area is no finer than large parts of states or provinces. In Germany and the UK, the area can be as fine as small towns.

If the number passed in is invalid, no geolocation will be performed. If the location information about the country where the phone number is located is not available, then the area information will be missing and only the country will be available.

The options parameter can contain any one of the following properties:


Defined in: ilib-dyn-full.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
ilib.GeoLocator(options)
Method Summary
Method Attributes Method Name and Description
 
country(number)
Returns a string that describes the ISO-3166-2 country code of the given phone number.
 
locate(number, options)
Returns a the location of the given phone number, if known.
Class Detail
ilib.GeoLocator(options)
Parameters:
{Object} options
parameters controlling the geolocation of the phone number.
Method Detail
{string} country(number)
Returns a string that describes the ISO-3166-2 country code of the given phone number.

If the phone number is a local phone number and does not contain any country information, this routine will return the region for the current formatter instance.

Parameters:
{ilib.PhoneNumber} number
An ilib.PhoneNumber instance
Returns:
{string}

{Object} locate(number, options)
Returns a the location of the given phone number, if known. The returned object has 2 properties, each of which has an sn (short name) and an ln (long name) string. Additionally, the country code, if given, includes the 2 letter ISO code for the recognized country. { "country": { "sn": "North America", "ln": "North America and the Caribbean Islands", "code": "us" }, "area": { "sn": "California", "ln": "Central California: San Jose, Los Gatos, Milpitas, Sunnyvale, Cupertino, Gilroy" } } The location name is subject to the following rules: If the areaCode property is undefined or empty, or if the number specifies a country code for which we do not have information, then the area property may be missing from the returned object. In this case, only the country object will be returned. If there is no area code, but there is a mobile prefix, service code, or emergency code, then a fixed string indicating the type of number will be returned. The country object is filled out according to the countryCode property of the phone number. If the phone number does not have an explicit country code, the MCC will be used if it is available. The country code can be gleaned directly from the MCC. If the MCC of the carrier to which the phone is currently connected is available, it should be passed in so that local phone numbers will look correct. If the country's dialling plan mandates a fixed length for phone numbers, and a particular number exceeds that length, then the area code will not be given on the assumption that the number has problems in the first place and we cannot guess correctly. The returned area property varies in specificity according to the locale. In North America, the area is no finer than large parts of states or provinces. In Germany and the UK, the area can be as fine as small towns. The strings returned from this function are already localized to the given locale, and thus are ready for display to the user. If the number passed in is invalid, an empty object is returned. If the location information about the country where the phone number is located is not available, then the area information will be missing and only the country will be returned. The options parameter can contain any one of the following properties:
Parameters:
{ilib.PhoneNumber} number
phone number to locate
{Object} options
options governing the way this ares is loaded
Returns:
{Object} an object that describes the country and the area in that country corresponding to this phone number. Each of the country and area contain a short name (sn) and long name (ln) that describes the location.

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Feb 02 2016 16:00:49 GMT-0800 (PST)