Chapter 6. Location Aware Services application development 217
19.Finally the MappingService is used to request the map specifying the bounds,
the mapping options, and the overlay. The Map object represents a map that
includes image data, width, height, and format, and the geographical area
covered by the map.
Example 6-9 Requesting the map
Map map = mappingService.getMap(bounds, options, overlays);
20.The Map.getData() returns the map as a byte array. This can be used to
render the map on a canvas, save it as a GIF file and render it as an HTML
and so on.
6.4 Developing a Location Aware Services adapter
Location Aware Services uses adapters that can be dynamically plugged in for
enabling services from service providers. Service providers should write custom
adapters that communicate with their infrastructure to provide the necessary
service. Location Aware Services provides adapters for several service
providers. See Chapter 5, “Location Aware Services” on page 155 for a list of
supported service providers.
In order to enable Location Aware Services to use your custom adapter to
provide the service, you should develop the adapter in accordance with the
interfaces defined and register the adapter for the specific service.
All service adapters for Location Aware Services must extend the
com.ibm.atlas.adapters.LocationServiceAdapter class.
The LocationServiceAdapter class is an abstract class that contains the following
methods:
򐂰 public void init(LocationServiceConfig config)
򐂰 public LocationServiceConfig getConfig()
򐂰 public void setClientOptions(ServiceRequestOptions options)
򐂰 public abstract ServiceCapabilities getCapabilities()
The Location Service Factory calls the init method when the adapter is first
created. The adapter can override this method to perform any required
initialization procedures, including authentication if it is session-based, or testing
communication with the remote provider's site. If the adapter overrides this
method, it should call super.init first. The setClientOptions method sets the
clientName, clientPassword and userLanguagePreference properties in the
ServiceRequestOptions object to values given in the adapter's init properties or,
218 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
if not given there, to defaults specified in the atlas.properties file. All adapters
must call this method when their main service methods are invoked.
The getCapabilities method returns a service-specific subclass of
ServiceCapabilities. A DirectoryServiceAdapter must return a
DirectoryCapabilities object, a GeocodingServiceAdapter must return a
GeocodingCapabilities object, and so on. Since the ServiceCapabilities
subclasses provide constructors that take a Properties object as a parameter,
each adapter's responsibility is to retrieve the service's properties from the
Service Registry and pass them to the constructor. Thus, a MappingService
adapter's getCapabilities method would typically be implemented as illustrated in
Example 6-10.
Example 6-10 Sample MappingService adapter’s getCapabilities method
ServiceCapabilities getCapabilities() {
ServiceRegistry svcReg = config.getFactory().getServiceRegistry();
Properties svcProps = svcReg.getServiceProperties(config.getName());
return new MappingCapabilities(svcProps);
}
For location service providers that offer two or more of the Location Aware
Services, it may be desirable to create a superclass that is extended by all the
provider's service adapters. This superclass would extend
LocationServiceAdapter and would typically handle the low-level communication
with the service provider that is common to all the adapters.
Depending on the type of service, service adapters should implement one of the
service interfaces. These service interfaces are defined in the com.ibm.adapters
package. The following interfaces are included in this package:
򐂰 DevicePositionServiceAdapter
򐂰 DirectoryServiceAdapter
򐂰 GeocodingServiceAdapter
򐂰 MappingServiceAdapter
򐂰 ReverseGeocodingServiceAdapter
򐂰 RoutingServiceAdapter

Get IBM WebSphere Everyplace Access V5 Handbook for Developers and Administrators Volume IV: Advanced Topics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.