com.nutiteq.services
Class CloudMadeGeocodingService

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

public class CloudMadeGeocodingService
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 int NETWORK_ERROR
           
static int NOT_FOUND
           
static int SERVER_ERROR
           
 
Constructor Summary
CloudMadeGeocodingService(GeocodingResultWaiter resultWaiter, java.lang.String cloudMadeKey, java.lang.String endUserId, WgsPoint around, java.lang.String aroundAddress, java.lang.String query, java.lang.String objectType, int numberOfElements, int skip, WgsBoundingBox bBox, boolean bBoxOnly, java.lang.String distance)
          CloudMade HTTP Geocoding and Geosearch API service.
CloudMadeGeocodingService(GeocodingResultWaiter resultWaiter, java.lang.String cloudMadeToken, WgsPoint around, java.lang.String aroundAddress, java.lang.String query, java.lang.String objectType, int numberOfElements, int skip, WgsBoundingBox bBox, boolean bBoxOnly, java.lang.String distance, java.lang.String cloudMadeKey)
          CloudMade HTTP Geocoding and Geosearch API service.
 
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 getDefaultIcon()
           
 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
 void placesAdded()
           
 java.lang.String resourcePath()
          Get path to resource.
 void setPlaceReadListener(com.nutiteq.kml.KmlReadListener placeReadListener)
           
 
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
Constructor Detail

CloudMadeGeocodingService

public CloudMadeGeocodingService(GeocodingResultWaiter resultWaiter,
                                 java.lang.String cloudMadeKey,
                                 java.lang.String endUserId,
                                 WgsPoint around,
                                 java.lang.String aroundAddress,
                                 java.lang.String query,
                                 java.lang.String objectType,
                                 int numberOfElements,
                                 int skip,
                                 WgsBoundingBox bBox,
                                 boolean bBoxOnly,
                                 java.lang.String distance)
CloudMade HTTP Geocoding and Geosearch API service. See CloudMade guide

Parameters:
resultWaiter - listener waiting for search results
cloudMadeKey - CloudMade service key, get from cloudmade.com
endUserId - Unique end-user ID, e.g. end-user login. Used for CloudMade token
around - Center point of the search area. Used together with distance. around must be an EPSG:4326 coordinate ("latitude,longitude"). Cannot be used together with bbox. If used together with a non-empty search_query, only one may specify an address
aroundAddress - Center point of the search area. Used together with distance. Either around or aroundAddress can be defined. Cannot be used together with bbox. If used together with a non-empty search_query, only one may specify an address
query - placename to be searched, optional for POI search
objectType - Limits search results to a specific object type. Full list of object types can be found from CloudMade web
numberOfElements - max number of results to return
skip - Number of results to skip from beginning
bBox - Bounding box of the search area
bBoxOnly - Used only if bbox is specified. If set to false, the geocoder will return results from the whole planet, but still ranking results from within the specified bbox higher, otherwise only results from within the specified bbox will be returned.
distance - Radius of the search area, in meters. Special value closest limits search results to one, closest to the center point of the search area

CloudMadeGeocodingService

public CloudMadeGeocodingService(GeocodingResultWaiter resultWaiter,
                                 java.lang.String cloudMadeToken,
                                 WgsPoint around,
                                 java.lang.String aroundAddress,
                                 java.lang.String query,
                                 java.lang.String objectType,
                                 int numberOfElements,
                                 int skip,
                                 WgsBoundingBox bBox,
                                 boolean bBoxOnly,
                                 java.lang.String distance,
                                 java.lang.String cloudMadeKey)
CloudMade HTTP Geocoding and Geosearch API service. See CloudMade guide

Parameters:
resultWaiter - listener waiting for search results
cloudMadeToken - CloudMade service key, get from cloudmade.com API
around - Center point of the search area. Used together with distance. around must be an EPSG:4326 coordinate ("latitude,longitude"). Cannot be used together with bbox. If used together with a non-empty search_query, only one may specify an address
aroundAddress - Center point of the search area. Used together with distance. Either around or aroundAddress can be defined. Cannot be used together with bbox. If used together with a non-empty search_query, only one may specify an address
query - placename to be searched, optional for POI search
objectType - Limits search results to a specific object type. Full list of object types can be found from CloudMade web
numberOfElements - max number of results to return
skip - Number of results to skip from beginning
bBox - Bounding box of the search area
bBoxOnly - Used only if bbox is specified. If set to false, the geocoder will return results from the whole planet, but still ranking results from within the specified bbox higher, otherwise only results from within the specified bbox will be returned.
distance - Radius of the search area, in meters. Special value closest limits search results to one, closest to the center point of the search area
cloudMadeKey - CloudMade service key, get from cloudmade.com
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

getDefaultIcon

public java.lang.String getDefaultIcon()
Specified by:
getDefaultIcon in interface KmlService

placesAdded

public void placesAdded()
Specified by:
placesAdded in interface KmlService

setPlaceReadListener

public void setPlaceReadListener(com.nutiteq.kml.KmlReadListener placeReadListener)
Specified by:
setPlaceReadListener in interface KmlService