Oracle9iAS Wireless Developer's Guide Release 2 (9.0.2) Part Number A90485-02 |
|
This document describes the reusable Location-Based Module, included in Oracle9iAS Wireless. Each section of this document presents a different topic. These sections include:
Location-based services make mobile applications easier to use and provide them with quick access to timely and critical information.
The Location Picker module enables users to pick and manage their frequently-accessed locations. Using this module, a user can specify a location that can be used by another module, such as the driving directions module. This location can be the user's default location, the current location (if mobile positioning is enabled), a Locationmark selected by the user, a recent location used by the user, or a new location to be entered by the user
The Location Picker module is used by other modules to acquire a location from the user. When used directly by the user, Location Picker provides management of the user's locationmarks and allows the user to set his "preferred" location, which is either the user's current location (when mobile positioning is available and on) or the user's default locationmarks.
Other location modules include Driving Directions, Maps, and Business Directory. These modules use the Location Picker to acquire location(s) from the user if the user does not have a "preferred" location or if the user specifically wants to change the location used for those modules.
This module integrates with positioning servers when available and is built upon the Oracle9iAS Wireless Location Application Component API.
This service requires the Oracle9iAS Wireless geocoding provider only when the geocoding of addresses is needed and the Oracle9iAS Wireless mobile positioning provider only when the positioning feature is needed. The geocoding and mobile positioning are optional features.
Name | External Providers | Instructions | From |
---|---|---|---|
Geocoding Provider |
otn.oracle.com |
See Section 15.1.3. |
2.0 |
Mobile positioning provider |
otn.oracle.com |
See Section 15.1.3. |
2.0 |
This module does not require scripts.
The Location Picker module includes the following input parameters:
You link to the location picker module using the following virtual URL:
omp://oracle/services/location/picker - Invocation Interface
The location picker has the following input call parameters:
The output parameters for the Location Picker module include the following:
The Driving Directions module allows a mobile application to provide its users with driving directions between an originating address and a destination address. It links to the Location Picker module to enable users to select originating and destination addresses not provided by Driving Directions. The Driving Directions module also links with the Maps module for enhanced routing.
This module is built upon the Oracle9iAS Wireless Location Application Component API.
This service requires the Oracle9iAS Wireless routing provider.
Name | External Provider(s) | Instructions | From |
---|---|---|---|
Routing Provider |
otn.oracle.com |
See Section 15.1.3. |
2.0 |
This module does not require scripts.
The Driving Directions module includes the following input parameters:
You link to the Driving Directions module through the following virtual URL:
omp://oracle/services/location/directions
The Driving Directions module includes the following input call parameters:
The Driving Directions Module includes the following output parameters:
Parameter Name | Mandatory | Description | Valid Value |
---|---|---|---|
STATUS |
No |
The status of a mobile call. |
CANCEL (Cancelled) |
The Business Directory module provides user with a complete business directory. This module is built on the Oracle9iAS Wireless Location Application Component API.
This module provides a "yellow pages" type interface to look for the addresses and phone numbers of registered businesses in a given radius. It has search capabilities for business names or categories. Browsing through categories is also enabled. If no location parameters are passed to this module, the location module is invoked to obtain location data for the search.
This module requires the Oracle9iAS Wireless business directory provider.
Name | External Provider(s) | Instructions | From |
---|---|---|---|
Business Directory Provider |
otn.oracle.com |
See Section 15.1.3. |
2.0 |
This module does not require scripts.
The Business Directory includes the following input parameters:
You link to the Business Directory Module using the following virtual URL:
omp://oracle/services/location/bizdir
The Business Directory Module includes the following input call parameters:
The Driving Directions Module includes the following output parameter:
STATUS
No
The status of a mobile call.
CANCEL (Cancelled)
Table 20-8 Output Parameter of the Driving Directions Module
Parameter Name
Mandatory
Description
Valid Value
The Maps module provides broad and detailed maps for a given location, supports map tiling and image map transformation for different devices. This module integrates with the Driving Directions module and is built upon the Oracle9iAS Wireless Location Application Component API.
This service requires the Oracle9iAS Wireless mapping provider.
Name | External Providers | Instructions | From |
---|---|---|---|
Mapping Provider |
otn.oracle.com |
See Section 15.1.3. |
2.0 |
The Maps module includes the following input parameters:
You link to the Maps module using the following virtual URL:
omp://oracle/services/location/maps
The Maps module includes the following input call parameters:
Table 20-10 Input Call Parameters of the Maps Module
The Maps module includes the following output parameter
STATUS
No
The status of a mobile call.
CANCEL (Cancelled)
Table 20-11 Output Parameter of the Map Module
Parameter Name
Mandatory
Description
Valid Value
The location modules use the Oracle9iAS Wireless Location Application Component APIs. These Java APIs can be used independently to write other Location Based Services (LBS). For more information on the Location Application Component API, see Section 15.2.
This section describes the main classes of these APIs. For each class, the typical use cases and the code example for each use case are given.
This interface represents a Location Mark saved by the user. It extends the Location interface which represents a location.
The typical operations a user wants to perform include:
LocationMark[ ] locationmarks = iasUser.getLocationMarks();
where iasUser is an object of User, which represents a user of Oracle9iAS Wireless wireless.
To set the city, use
locationmark.setCity(city);
For a complete listing of these methods, refer to the Oracle9iAS Wireless javadoc.
String locationmark_name = "Office";
LocationMark lm =
MetaLocator.getInstance().getModelFactory().createLocationMark(locationmark_
name,iasUser);
Location l = SpatialManager.createLocation("Oracle", "500 Oracle
Parkway","", "Redwood City, CA 94065", "US");
lm.setLocation(l);
Locator.getInstance().getPersistentLocator().getSessionManager().commitSessi
on();
LocationMark lm = MetaLocator.getInstance().getModelServices().lookupLocationMark(locationmark _id); lm.delete(); MetaLocator.getInstance().getModelFactory().save();
where locationmark_id
is an automatically generated unique Java "long" which identifies the Location Mark. To get this id, call getId()
on the LocationMark object.
LocationMark lm = MetaLocator.getInstance().getModelServices().lookupLocationMark(locationmark _id); lm.setCity("San Francisco"); Locator.getInstance().getPersistentLocator().getSessionManager().commitSessi on();
LocationMark lm = MetaLocator.getInstance().getModelServices().lookupLocationMark(locationmark _id); iasUser.setDefaultLocationMark(lm); MetaLocator.getInstance().getModelFactory().save();
The Geocoder interface abstracts the implementation of a geocoder. The geocoder implementation is specific to the geocoding content provider. For example, to use the geocoding content from MapQuest, the implementation class is oracle.panama.spatial.core.geocoder.GeocoderImplMapQuest
, which is supplied with Oracle9iAS Wireless. At the module level, the specific implementation class is transparent.
The typical operations a user wants to perform include:
Geocoder geocoder = SpatialManager.getGeocoder();
Location[} locations = geocoder.geocodeAddress(location, matchmode);
Where location is a Location object and matchmode is a String indicating how the geocoder should try to geocode the location. The valid values for matchmode are:
Refer to the Oracle9iAS Wireless javadoc for details.
location.geocode(checkWhetherNecessary, makeCorrections);
where checkWhetherNecessary
and makeCorrections
are two booleans.
The LocationHistoryManager
class manages the locations saved automatically by other modules or applications. It has methods for:
Location[] locations = LocationHistoryManager.getLocations(iasUser);
The location history is a stack of locations saved by modules or applications. The history can be used by modules and applications to eliminate the need for users to enter those locations again. The history also can be shared among all location based services. For example, a restaurant found using the Business Directory module is saved in the history and is be automatically available when the user uses the Driving Directions module to get directions to that restaurant. The maximum size of the stack is configurable by the ORACLE_SERVICES_LOCATION_PICKER_STACKSIZE service parameter. When the stack size is below the maximum, new locations are added to the stack. When the stack size reaches the maximum, a new location replaces the earliest location on the stack (that is, the location with the earliest time stamp).
long id =LocationHistoryManager.updateHistory(l, iasUser);
Where l
is an object of LocationHelper
, a class that implements the Location interface. The above code updates the location history stack with location "l" for iasUser
. Refer to Oracle9iAS Wireless modules javadoc for details on the LocationHelper
class.
The Router interface abstracts the implementation of a router, which provides turn-by-turn driving directions. The router implementation is specific to the routing content provider. For example, to use the routing content from MapQuest, the implementation class will be oracle.panama.spatial.core.router.RouterImplMapQuest
, which is supplied with Oracle9iAS Wireless. At the module level, the specific implementation class used is transparent. The typical operations a user wants to perform include:
Router router = SpatialManager.getRouter();
RoutingResult rr = router.computeRoute(starting_location, destination_ location, via_points, settings, locale);
where starting_location
and destination_location
are two Location objects, via_points
is an array of Location objects that represent the desired via points along a route (null is okay if no via points is needed), settings is a RoutingSettings
object that indicates the routing options (see below for details), and locale is the desired locale for directions output (for example, mile is used as distance unit for United States, whereas km is used in Canada). Once the RoutingResult
object is obtained, you can iterate through the maneuvers to get turn-by-turn directions. For example:
for (int i = 0; i < rr.getManeuvers().length; i++){ Maneuver m = rr.getManeuvers()[i]; System.out.println(m.getNarrative()); }
RoutingSettings settings = new RoutingSettings(); settings.setRequestMap(true); settings.setSecondaryOption(RoutingOption.overviewMapWidth, MAP_WIDTH+""); settings.setSecondaryOption(RoutingOption.overviewMapHeight, MAP_HEIGHT+""); RoutingResult rr = router.computeRoute(starting_location, destination_ location, via_points, settings, locale); String url = rr.getOverviewMapURL();
Refer to Oracle9iAS Wireless javadoc for details of available options.
The Mapper interface abstracts the implementation of a mapper, which provides maps. The mapper implementation is specific to the mapping content provider. For example, to use the mapping content from MapQuest, the implementation class will be oracle.panama.spatial.core.mapper.MapperImplMapQuest
, which is supplied with Oracle9iAS Wireless. At the module level, the specific implementation class used is transparent. The typical operations a user wants to perform include:
String mapurl = mapper.getMapURL(location, ImageFormats.GIF, location.getLongitude() - zoomlevel * MAP_LNG_SIZE, location.getLongitude() + zoomlevel * MAP_LNG_SIZE, location.getLatitude() - zoomlevel * MAP_LAT_SIZE, location.getLatitude() + zoomlevel * MAP_LAT_SIZE, MAP_WIDTH, MAP_HEIGHT, false);
Refer to the Oracle9iAS Wireless javadoc for details of this and other mapping methods.
The YPFinder
interface abstracts the implementation of a "YP" like business directory service. The YPFinder
implementation is specific to the business directory content provider. For example, to use the content from MapQuest, the implementation class will be oracle.panama.spatial.core.yp.YPFinderImplMapquest
, which is supplied with Oracle9iAS Wireless. At the module level, the specific implementation class used is transparent. The typical operations a user wants to perform include:
YPFinde
r class supports the "browsing" of business categories. These categories are defined by user based on the content provider in oracle.panama.spatial.yp.YPCategories.xml file. The location of this file needs to be specified in Oracle9iAS Wireless webtool. At runtime, the YPFinder
class has methods that support the browsing of the category hierarchy. For example, to start at the root category,
YPCategory root = finder.getCategoryAtRoot();
Then to get the subcategories at root,
YPCategory[] cats = root.getSubCategories();
YPFinder
and YPCategory.
The search can be proximity search (that is, around a location within a certain radius), using such criteria as searching a city, or a zipcode.
YPBusiness[] bizes = root.getBusinessesInRadius(location, raidus_in_meters, locale); YPBusiness[] bizes = finder.getBusinessesInSameCity(bizname, location, locale); YPBusiness represents a business and extends the Location class. So you can get the address of the business using this class or use getTelephone() to get the business phone.
This example creates a Location Mark, "Office". Note that the call SpatialManager.createLocation()
automatically geocodes the location.
import oracle.panama.model.LocationMark; import oracle.panama.model.Location; import oracle.panama.model.MetaLocator; import oracle.panama.core.util.Locator; import oracle.panama.spatial.SpatialManager; String locationmark_name = "Office"; LocationMark lm = MetaLocator.getInstance().getModelFactory().createLocationMark(locationmark_ name,iasUser); Location l = SpatialManager.createLocation("Oracle","500 Oracle Parkway","", "Redwood City, CA 94065","US"); lm.setLocation(l); Locator.getInstance().getPersistentLocator().getSessionManager().commitSession() ;
This section provides an example of the Driving Directions API and its output.
import oracle.panama.model.LocationMark; import oracle.panama.model.Location; import oracle.panama.spatial.SpatialManager; import oracle.panama.spatial.router.Router; import oracle.panama.spatial.router.RoutingSettings; import oracle.panama.spatial.router.RoutingOption; import oracle.panama.spatial.router.RoutingResult; import oracle.panama.spatial.router.Maneuver; Location starting= SpatialManager.createLocation("Oracle","500 Oracle Parkway","", "Redwood City, CA 94065","US"); Location destination = SpatialManager.createLocation("Autobahn Motors","700 Island Pkwy","", "Belmont, CA","US"); Router r = SpatialManager.getRouter(); RoutingSettings settings = new RoutingSettings(); settings.setRequestMap(true); settings.setSecondaryOption(RoutingOption.overviewMapWidth, "400"); settings.setSecondaryOption(RoutingOption.overviewMapHeight, "400"); RoutingResult rr = r.computeRoute(starting, destination, null, settings, Locale.getDefault()) for (int i = 0; i < rr.getManeuvers().length; i++){ Maneuver m = rr.getManeuvers()[i]; System.out.println((i+1)+")"+m.getNarrative()); }
import oracle.panama.model.LocationMark; import oracle.panama.model.Location; import oracle.panama.spatial.SpatialManager; import oracle.panama.spatial.mapper.Mapper; import oracle.panama.imagex.ImageFormats; Location location= SpatialManager.createLocation("Oracle","500 Oracle Parkway","", "Redwood City, CA 94065","US"); Mapper mapper = SpatialManager.getMapper(); String mapurl = mapper.getMapURL(location, ImageFormats.GIF, location.getLongitude() - 0.008, location.getLongitude() + 0.008, location.getLatitude() - 0.008, location.getLatitude() + 0.008, 400, 400, false);
This example searches for Pizza Hut within two miles of Oracle
import oracle.panama.model.LocationMark; import oracle.panama.model.Location; import oracle.panama.spatial.SpatialManager; import oracle.panama.yp.YPFinder; import oracle.panama.yp.YPBusiness; Location location= SpatialManager.createLocation("Oracle","500 Oracle Parkway","", "Redwood City, CA 94065","US"); YPFinder yp = SpatialManager.getYPFinder(); YPBusiness[] bizes = yp.getBusinessesInRadius("pizza hut", location, 2*1609.344, null); for (int k = 0; k < bizes.length; k++) { YPBusiness biz = (YPBusiness) bizes[k]; double dist = biz.getDistance(location); bizname = biz.getCompanyName(); bizaddr = biz.getAddressLine1(); bizcity = biz.getCity(); bizstate = biz.getState(); bizcountry = biz.getCountry(); bizphone = biz.getTelephone(); // output results //... }
|
Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|