com.nutiteq.services
Class GeocodingService

java.lang.Object
  extended by com.nutiteq.services.GeocodingService
All Implemented Interfaces:
ResourceDataWaiter, ResourceRequestor, com.nutiteq.kml.KmlElementsWaiter, KmlService, Service

public class GeocodingService
extends java.lang.Object
implements Service, com.nutiteq.kml.KmlElementsWaiter, KmlService, ResourceRequestor, ResourceDataWaiter

Default implementation for geocoding services. Uses default Nutiteq backend for searching.

Additional search parameters can be added to search URL by appending these to baseurl used in service creation.


Field Summary
static java.lang.String DEFAULT_URL
          URL for default backend.
static int NETWORK_ERROR
           
static int NOT_FOUND
           
static java.lang.String SEARCH_TYPE_GEOCODING
          Search type for geocoding (place search)
static java.lang.String SEARCH_TYPE_POI
          Search type for POI search
static int SERVER_ERROR
           
 
Constructor Summary
GeocodingService(GeocodingResultWaiter resultWaiter, java.lang.String baseurl, java.lang.String lang, WgsPoint searchNear, java.lang.String query, java.lang.String searchType, int[] categories, int numberOfElements, boolean gzipResponse)
           
 
Method Summary
 void addKmlPlaces(KmlService service, KmlPlace[] read)
           
 void cancel()
          Cancel service execution
 void dataRetrieved(byte[] data)
          Data for resource retrieved
 void execute()
          Performe service action
 int getCachingLevel()
          Define at which level should given resource be cached.
 java.lang.String getServiceUrl(WgsBoundingBox boundingBox, int zoom)
          Called after if needsUpdate has returned true.
 int maxResults()
          Maximum number of results returned from this service.
 boolean needsUpdate(WgsBoundingBox boundingBox, int zoom)
          Does the service need an update.
 void notifyError()
          Notify implementing object about retrieval error
 java.lang.String resourcePath()
          Get path to resource.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NETWORK_ERROR

public static final int NETWORK_ERROR
See Also:
Constant Field Values

NOT_FOUND

public static final int NOT_FOUND
See Also:
Constant Field Values

SERVER_ERROR

public static final int SERVER_ERROR
See Also:
Constant Field Values

SEARCH_TYPE_GEOCODING

public static final java.lang.String SEARCH_TYPE_GEOCODING
Search type for geocoding (place search)

See Also:
Constant Field Values

SEARCH_TYPE_POI

public static final java.lang.String SEARCH_TYPE_POI
Search type for POI search

See Also:
Constant Field Values

DEFAULT_URL

public static final java.lang.String DEFAULT_URL
URL for default backend.

See Also:
Constant Field Values
Constructor Detail

GeocodingService

public GeocodingService(GeocodingResultWaiter resultWaiter,
                        java.lang.String baseurl,
                        java.lang.String lang,
                        WgsPoint searchNear,
                        java.lang.String query,
                        java.lang.String searchType,
                        int[] categories,
                        int numberOfElements,
                        boolean gzipResponse)
Parameters:
resultWaiter - object waiting for search results
baseurl - baseurl for service
lang - search language
searchNear - location for searching (in WGS84)
query - query
searchType - search type (place search or POI search)
categories - possible categories for search
numberOfElements - number of elements to ask from server
gzipResponse - should response be compressed in server. Adds gzip=(yes|no) to end of url
Method Detail

execute

public void execute()
Description copied from interface: Service
Performe service action

Specified by:
execute in interface Service

resourcePath

public java.lang.String resourcePath()
Description copied from interface: ResourceRequestor
Get path to resource. Currently library supports retrieval from network and application jar

Specified by:
resourcePath in interface ResourceRequestor
Returns:
path to resource

notifyError

public void notifyError()
Description copied from interface: ResourceRequestor
Notify implementing object about retrieval error

Specified by:
notifyError in interface ResourceRequestor

dataRetrieved

public void dataRetrieved(byte[] data)
Description copied from interface: ResourceDataWaiter
Data for resource retrieved

Specified by:
dataRetrieved in interface ResourceDataWaiter
Parameters:
data - retrieved data

addKmlPlaces

public void addKmlPlaces(KmlService service,
                         KmlPlace[] read)
Specified by:
addKmlPlaces in interface com.nutiteq.kml.KmlElementsWaiter

getServiceUrl

public java.lang.String getServiceUrl(WgsBoundingBox boundingBox,
                                      int zoom)
Description copied from interface: KmlService
Called after if needsUpdate has returned true.

Specified by:
getServiceUrl in interface KmlService
Parameters:
boundingBox - bounding box for screen view of the map (coordinates in WGS84)
zoom - zoom level used
Returns:
url for retrieving displayed kml.

maxResults

public int maxResults()
Description copied from interface: KmlService
Maximum number of results returned from this service. If, for some reason, server returns more results, extra results will be ignored.

Specified by:
maxResults in interface KmlService
Returns:
number of placemarks returned by this service on one request.

needsUpdate

public boolean needsUpdate(WgsBoundingBox boundingBox,
                           int zoom)
Description copied from interface: KmlService
Does the service need an update. Called after move method.

Specified by:
needsUpdate in interface KmlService
Parameters:
boundingBox - bounding box for new map location (coordinates in WGS84)
zoom - current zoom level
Returns:
does the service need an update

cancel

public void cancel()
Description copied from interface: Service
Cancel service execution

Specified by:
cancel in interface Service

getCachingLevel

public int getCachingLevel()
Description copied from interface: ResourceRequestor
Define at which level should given resource be cached. Check Cache

Specified by:
getCachingLevel in interface ResourceRequestor
Returns:
cache level for resource