org.opengts.geocoder
Class ReverseGeocodeProviderAdapter

java.lang.Object
  extended by org.opengts.geocoder.ReverseGeocodeProviderAdapter
All Implemented Interfaces:
ReverseGeocodeProvider
Direct Known Subclasses:
GeoNames, GisGraphy, GoogleGeocodeV2, GoogleGeocodeV3, Nominatim, TinyGeocoder

public abstract class ReverseGeocodeProviderAdapter
extends java.lang.Object
implements ReverseGeocodeProvider


Field Summary
static java.lang.String _PROP_isEnabled
           
static long DEFAULT_MAX_FAILOVER_SECONDS
           
static long MIN_FAILOVER_SECONDS
           
static java.lang.String[] PROP_alwaysFast
           
static java.lang.String[] PROP_maxFailoverSeconds
           
static java.lang.String PROP_ReverseGeocodeProvider_
           
 
Constructor Summary
ReverseGeocodeProviderAdapter(java.lang.String name, java.lang.String key, RTProperties rtProps)
          Constructor
 
Method Summary
protected  java.lang.String[] _getUserPass()
          Parse and return the user name and password
static void _main()
           
 java.lang.String getAuthorization()
          Gets the authorization key of this ReverseGeocodeProvider
 ReverseGeocodeProvider getFailoverReverseGeocodeProvider()
          Gets the failover ReverseGeocodeProvider
 java.lang.String getFailoverReverseGeocodeProviderName()
          Gets the failover ReverseGeocodeProvider name
 long getMaximumFailoverElapsedSec()
           
 java.lang.String getName()
          Gets the name of this ReverseGeocodeProvider
protected  java.lang.String getPassword()
          Return authorization password.
 RTProperties getProperties()
          Gets the properties for this ReverseGeocodeProvider
abstract  ReverseGeocode getReverseGeocode(GeoPoint gp, java.lang.String localeStr, boolean cache)
          Returns the best address for the specified GeoPoint
protected  java.lang.String getUsername()
          Return authorization username.
 boolean hasFailoverReverseGeocodeProvider()
          Has a failover ReverseGeocodeProvider
 boolean isEnabled()
          Returns true if this ReverseGeocodeProvider is enabled
 boolean isFastOperation()
          Returns true if this operation will take less than about 20ms to complete the returned value is used to determine whether the 'getReverseGeocode' operation should be performed immediately, or lazily (ie.
protected  boolean isReverseGeocodeFailoverMode()
          Returns true if failover mode is active
static void main(java.lang.String[] args)
           
 void setAuthorization(java.lang.String key)
          Sets the authorization key of this ReverseGeocodeProvider
 void setFailoverReverseGeocodeProvider(ReverseGeocodeProvider rgp)
          Sets the failover ReverseGeocodeProvider
 void setName(java.lang.String name)
          Sets the name of this ReverseGeocodeProvider
 void setProperties(RTProperties rtProps)
          Sets the properties for this ReverseGeocodeProvider
protected  void startReverseGeocodeFailoverMode()
          Start failover mode (with default timeout)
protected  void startReverseGeocodeFailoverMode(long failoverTimeoutSec)
          Start failover mode (with specified timeout)
 java.lang.String toString()
          Returns a String representation of this instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_ReverseGeocodeProvider_

public static final java.lang.String PROP_ReverseGeocodeProvider_
See Also:
Constant Field Values

_PROP_isEnabled

public static final java.lang.String _PROP_isEnabled
See Also:
Constant Field Values

PROP_alwaysFast

public static final java.lang.String[] PROP_alwaysFast

PROP_maxFailoverSeconds

public static final java.lang.String[] PROP_maxFailoverSeconds

DEFAULT_MAX_FAILOVER_SECONDS

public static long DEFAULT_MAX_FAILOVER_SECONDS

MIN_FAILOVER_SECONDS

public static long MIN_FAILOVER_SECONDS
Constructor Detail

ReverseGeocodeProviderAdapter

public ReverseGeocodeProviderAdapter(java.lang.String name,
                                     java.lang.String key,
                                     RTProperties rtProps)
Constructor

Parameters:
name - The name of this reverse-geocode provider
key - The access key (may be null)
rtProps - The properties (may be null)
Method Detail

setName

public void setName(java.lang.String name)
Sets the name of this ReverseGeocodeProvider

Parameters:
name - The name of this reverse-geocode provider

getName

public java.lang.String getName()
Gets the name of this ReverseGeocodeProvider

Specified by:
getName in interface ReverseGeocodeProvider
Returns:
The name of this reverse-geocode provider

setAuthorization

public void setAuthorization(java.lang.String key)
Sets the authorization key of this ReverseGeocodeProvider

Parameters:
key - The key of this reverse-geocode provider

getAuthorization

public java.lang.String getAuthorization()
Gets the authorization key of this ReverseGeocodeProvider

Returns:
The access key of this reverse-geocode provider

setFailoverReverseGeocodeProvider

public void setFailoverReverseGeocodeProvider(ReverseGeocodeProvider rgp)
Sets the failover ReverseGeocodeProvider

Specified by:
setFailoverReverseGeocodeProvider in interface ReverseGeocodeProvider
Parameters:
rgp - The failover ReverseGeocodeProvider

getFailoverReverseGeocodeProvider

public ReverseGeocodeProvider getFailoverReverseGeocodeProvider()
Gets the failover ReverseGeocodeProvider

Specified by:
getFailoverReverseGeocodeProvider in interface ReverseGeocodeProvider
Returns:
The failover ReverseGeocodeProvider

getFailoverReverseGeocodeProviderName

public java.lang.String getFailoverReverseGeocodeProviderName()
Gets the failover ReverseGeocodeProvider name

Returns:
The failover ReverseGeocodeProvider name, or an empty string if no failover is defined.

hasFailoverReverseGeocodeProvider

public boolean hasFailoverReverseGeocodeProvider()
Has a failover ReverseGeocodeProvider

Returns:
True if this instance has a failover ReverseGeocodeProvider

startReverseGeocodeFailoverMode

protected void startReverseGeocodeFailoverMode()
Start failover mode (with default timeout)


startReverseGeocodeFailoverMode

protected void startReverseGeocodeFailoverMode(long failoverTimeoutSec)
Start failover mode (with specified timeout)

Parameters:
failoverTimeoutSec - The explicit failover timeout, or <= 0 for the default timeout.

isReverseGeocodeFailoverMode

protected boolean isReverseGeocodeFailoverMode()
Returns true if failover mode is active


_getUserPass

protected java.lang.String[] _getUserPass()
Parse and return the user name and password

Returns:
The username and password (always a 2 element array)

getUsername

protected java.lang.String getUsername()
Return authorization username. This assumes that the username and password are separated by a ':' character

Returns:
The username

getPassword

protected java.lang.String getPassword()
Return authorization password. This assumes that the username and password are separated by a ':' character

Returns:
The password

setProperties

public void setProperties(RTProperties rtProps)
Sets the properties for this ReverseGeocodeProvider

Parameters:
rtProps - The properties for this reverse-geocode provider

getProperties

public RTProperties getProperties()
Gets the properties for this ReverseGeocodeProvider

Returns:
The properties for this reverse-geocode provider

toString

public java.lang.String toString()
Returns a String representation of this instance

Overrides:
toString in class java.lang.Object
Returns:
A String representation of this instance

isEnabled

public boolean isEnabled()
Returns true if this ReverseGeocodeProvider is enabled

Specified by:
isEnabled in interface ReverseGeocodeProvider
Returns:
True if enabled

isFastOperation

public boolean isFastOperation()
Description copied from interface: ReverseGeocodeProvider
Returns true if this operation will take less than about 20ms to complete the returned value is used to determine whether the 'getReverseGeocode' operation should be performed immediately, or lazily (ie. in a separate thread).

Specified by:
isFastOperation in interface ReverseGeocodeProvider
Returns:
True if this is a fast (ie. local) operation

getMaximumFailoverElapsedSec

public long getMaximumFailoverElapsedSec()

getReverseGeocode

public abstract ReverseGeocode getReverseGeocode(GeoPoint gp,
                                                 java.lang.String localeStr,
                                                 boolean cache)
Description copied from interface: ReverseGeocodeProvider
Returns the best address for the specified GeoPoint

Specified by:
getReverseGeocode in interface ReverseGeocodeProvider
Returns:
The reverse-geocoded adress

_main

public static void _main()

main

public static void main(java.lang.String[] args)