Package Geoclue :: Module Base :: Class DiscoverLocation

[hide private]
[frames] | no frames]

# Class DiscoverLocation

source code

Discovers the location form the best available provider

DiscoverLocation is a object that provides a nice API interface for Geoclue.

Instance Methods | [hide private]

__init__(self, providers_path=`'``/usr/share/geoclue-providers``'`) Construct a DiscoverLocation object. | source code

init(self, accuracy=1, resource=1) Initializes Geoclue. | source code

provider_status(self, provider) Checks a provider's status. | source code

provider_info(self, provider) Returns the provider's Info. | source code

set_requirements(self, accuracy, time, require_updates, resource) Set the client requirements. | source code

on_address_provider_changed(self, name, description, service, path) | source code

on_position_provider_changed(self, name, description, service, path) | source code

update_location_address(self, address) Updates the the location's address with the given `address`. | source code

on_address_changed(self, timestamp, address, accuracy) When the address changes the location info dictionary is updated. | source code

on_position_changed(self, fields, timestamp, latitude, longitude, altitude, accuracy) When the position changes the location info dictionary is updated. | source code

get_location_info(self) Returns the location info dictionary. | source code

get_available_providers(self) Returns the available providers. | source code

set_position_provider(self, provider_name) Set the position provider to a given `provider_name` (if exists). | source code

validate_address(self, address) Receives the address and validates/corrects it. | source code

set_address_provider(self, provider_name, address=None) Set the address provider | source code

get_position_provider(self) Returns the name of the current position provider. | source code

get_address_provider(self) Returns the name of the current address provider. | source code

compare_position(self, latitude, longitude, proximity_factor=None) Compare the current position to a given position. | source code

reverse_position(self, latitude, longitude, accuracy) Returns an address that corresponds to a given position. | source code

connect(self, func) Connects a given function to the signal. | source code

disconnect(self, func) Disconnects a given function from the signal. | source code

Method Details | [hide private]

### __init__(self, providers_path=`'``/usr/share/geoclue-providers``'`)
(Constructor)

source code

Construct a DiscoverLocation object.

Parameters:
  - `providers_path` - The path to the providers. The default path to the providers is /usr/share/geoclue-providers.

### init(self, accuracy=1, resource=1)

source code

Initializes Geoclue.

Parameters:
  - `accuracy` - The desired accuracy.
  - `resource` - The resource to be used.

### provider_status(self, provider)

source code

Checks a provider's status.

Parameters:
  - `provider` - A provider instance.
Returns:
  The status.

### provider_info(self, provider)

source code

Returns the provider's Info.

Returns:
  A dictionary with the provider's name and descripiton.

### set_requirements(self, accuracy, time, require_updates, resource)

source code

Set the client requirements.

Parameters:
  - `accuracy` - The required minimum accuracy.
  - `time` - The minimum time between update signals.
  - `require_updates` - `True` if updates are required or `False` if updates are not required.
  - `resource` - The resources that are allowed to be used.

### on_address_changed(self, timestamp, address, accuracy)

source code

When the address changes the location info dictionary is updated.

Parameters:
  - `timestamp` - The timestamp.
  - `address` - The new address.

### on_position_changed(self, fields, timestamp, latitude, longitude, altitude, accuracy)

source code

When the position changes the location info dictionary is updated.

Parameters:
  - `fields` - The fields.
  - `timestamp` - The timestamp.
  - `latitude` - The new latitude.
  - `longitude` - The new longitude.
  - `altitude` - The new altitude.
  - `accuracy` - The accuracy.

### get_location_info(self)

source code

Returns the location info dictionary.

Returns:
  The location info dictionary.

### get_available_providers(self)

source code

Returns the available providers.

Returns:
  A list of dictionarys, [PROVIDER, ADDRESS, POSITION, GEOCODING, REVERSE GEOCODING], with the name and True of False for supporting each of them

### set_position_provider(self, provider_name)

source code

Set the position provider to a given `provider_name` (if exists).

Parameters:
  - `provider_name` - The provider's name
Returns:
  `True` if the provider exists or `False` if a provider does not exist.

### validate_address(self, address)

source code

Receives the address and validates/corrects it.

Parameters:
  - `address` - The address dictionary.
Returns:
  The address (with possible corrections).

### set_address_provider(self, provider_name, address=None)

source code

Set the address provider

Parameters:
  - `provider_name` - the provider's name
  - `address` - the new address (for Manual and Localnet providers)
Returns:
  `True` if the provider exists or `False` if a provider does not exist.

### get_position_provider(self)

source code

Returns the name of the current position provider.

Returns:
  The name of the current position provider.

### get_address_provider(self)

source code

Returns the name of the current address provider.

Returns:
  The name of the current address provider.

### compare_position(self, latitude, longitude, proximity_factor=None)

source code

Compare the current position to a given position.

Note: ploum's contribution

Parameters:
  - `latitude` - latitude of the position
  - `longitude` - longitude of the position
  - `proximity_factor` - the near by proximity factor. ie, 0.5 is 500 meters

### reverse_position(self, latitude, longitude, accuracy)

source code

Returns an address that corresponds to a given position.

Parameters:
  - `latitude` - The position's latitude.
  - `longitude` - The position's longitude.
  - `accuracy` - The accuracy.
Returns:
  An address.

### connect(self, func)

source code

Connects a given function to the signal. The signal action if any change to the info location dictionary.

Parameters:
  - `func` - The function to connect to the signal.

### disconnect(self, func)

source code

Disconnects a given function from the signal.

Parameters:
  - `func` - The function to disconnect from the signal.