+ All Categories
Home > Documents > Creating Location-Aware Applications

Creating Location-Aware Applications

Date post: 15-Nov-2014
Category:
Upload: symbian
View: 111 times
Download: 1 times
Share this document with a friend
Description:
This booklet is about writing Location Aware applications on Symbian OS. It describes the services offered to applications written in Symbian C++, Python, WRT and Flash applications. The article was formerly hosted on Symbian Developer Network. The evolving version of the article is here: http://developer.symbian.org/wiki/index.php/Creating_Location-Aware_Applications
Popular Tags:
44
Essential S60 Creating Location - Aware Applications
Transcript
Page 1: Creating Location-Aware Applications

Essential S60

CreatingLocation -AwareApplications

Page 2: Creating Location-Aware Applications
Page 3: Creating Location-Aware Applications

Reviewed by:Alexey GusevHusham HamdanPekka KosonenHeikki RasimakiJo StichburyJure SustersicLucian Tomuta

Creating Location-AwareApplicationspart of the Essential S60 series

1st edition, 10/08

Published by:Symbian Software Limited2-6 Boundary RowSouthwarkLondon SE1 8HPUKwww.symbian.com

Trademarks, copyright, disclaimer‘Symbian’, ‘Symbian OS’ and other associated Symbian marks are all trademarks of SymbianSoftware Ltd. Symbian acknowledges the trademark rights of all third parties referred to in thismaterial. Copyright © Symbian Software Ltd 2008. All rights reserved. No part of this materialmay be reproduced without the express written permission of Symbian Software Ltd. SymbianSoftware Ltd makes no warranty or guarantee about the suitability or the accuracy of theinformation contained in this document. The information contained in this document is forgeneral information purposes only and should not be used or relied upon for any otherpurpose whatsoever.

Compiled by:Richard BloorPetro Soininen

Managing Editor:Ashlee Godwin

Page 4: Creating Location-Aware Applications

Contents

Introduction.................................................................................................................................2

Location-based services on mobile devices ...............................................................................3

A background to positioning technology....................................................................................4

Satellite-based methods .........................................................................................................4

Terrestrial-based methods .......................................................................................................5

Mixed methods........................................................................................................................6

Positioning methods supported by the S60 platform ............................................................6

Location services in the S60 platform........................................................................................6

Introducing the Mobile Location Framework...........................................................................7

Working with location information..........................................................................................8

Working with landmarks ........................................................................................................13

Working with other features ..................................................................................................19

Other S60 platform runtimes ....................................................................................................20

Java technology .....................................................................................................................20

Web Runtime..........................................................................................................................21

Flash Lite ...............................................................................................................................23

Python for S60 ......................................................................................................................23

Building a complete application ...............................................................................................24

Context options.....................................................................................................................24

Sourcing context data ...........................................................................................................27

Context data storage and access ..........................................................................................28

Development and testing tools ................................................................................................29

Creating simulated location data ..........................................................................................29

Using the positioning simulation tool for testing.................................................................30

Getting to market ......................................................................................................................31

Independent channels ...........................................................................................................31

Mobile network operators .....................................................................................................32

System integrators ................................................................................................................32

Device manufacturers ............................................................................................................32

Getting further assistance .........................................................................................................32

Conclusion.................................................................................................................................33

Developer resources..................................................................................................................34

Community web sites............................................................................................................34

1

Page 5: Creating Location-Aware Applications

IntroductionIn an increasingly mobile world the desire to understand one’s surroundings and connect withwork colleagues, friends and family is growing among mobile device users. If the content ofyour application relates to locations in the physical world, your users are going to expect theapplication to be location-aware.

At the same time, an increasing proportion of S60 devices are shipping with integrated GPS.This means that accurate information on a device’s location is often readily available. However,even if a device does not include a GPS chip, many devices implement other methods ofobtaining location information.

To enable you to harness location information, S60 3rd Edition and S60 5th Edition (based onSymbian OS v9.1 to v9.4) provide an easy to use set of APIs for Symbian C++, Java ME andPython for S60. S60 5th Edition also offers you the ability to access location information inFlash Lite from Adobe and Web Runtime (WRT). These APIs are built around a common MobileLocation Framework (MLF).

This booklet provides information on:• the location-aware application market• location estimation technologies• the Symbian C++ location APIs• location APIs in other S60 platform runtimes• the factors to consider when making your application location-aware• development tools to assist with testing.

If you’re a developer looking to implement an LBS application for S60 devices, this EssentialS60 booklet is for you. While a significant portion of this booklet is dedicated to Symbian C++coding, if you want to use another S60 runtime — such as Java ME, WRT or Flash Lite — youwill still find plenty of useful information throughout the booklet. In addition, specific codinginformation for other runtimes is provided in the ‘Other S60 platform runtimes’ section. Youwill also find more documentation on Forum Nokia’s web site (www.forum.nokia.com) aboutthe LBS services provided by your chosen runtime.

When you finish reading this booklet you will be ready to start making your applications forthe S60 platform location-aware.

2

Page 6: Creating Location-Aware Applications

Location-based services on mobile devicesThe location-aware applications market is not new: enterprise and professional applicationshave been around for many years. However, the availability of inexpensive, small, low-powerGPS chips and reliable network-based location technologies has moved the industry into a growth phase (see Figure 1).

Figure 1: The location-aware application market is in a growth phase

Location-aware software covers a very broad range of applications, including:• navigation and route finding• location-based information, such as services providing information on points of interest• professional and enterprise, such as fleet management, vehicle dispatch, vehicle tracking

and personnel tracking• community, such as friend locators and location-based sharing of pictures and

information• entertainment, such as location-aware games• safety, such as child tracking, theft tracking and emergency location.

A survey conducted by CJ Driscoll and Associates (www.cjdriscoll.com) in 2006 found that ofthe ten most desired non-voice applications for mobile devices, half were location-based. Thelaunch of the Nokia N95 multimedia computer, the first S60 device with an integrated GPS,helped sales of location-aware applications from Nokia Software Market grow by over 500%during 2007.1

So, mobile device users are clearly interested in and are willing to purchase location-awareapplications.

3

1 See www.symbianone.com/content/view/5119/31 for further information.

Page 7: Creating Location-Aware Applications

This opportunity has been recognized by many of the companies that offered mapping andnavigation services on dedicated GPS devices and as services to businesses. As a result thereis already a wealth of navigation and local discovery applications available for S60 devices. Asthe market matures, S60 applications are appearing across many of the location-aware marketcategories.

This does not, however, mean that the opportunities for new location-based S60 applicationsare limited. The first wave of location-based applications largely involved transplanting existingfunctionality into an S60 application. The second wave will combine location information withother information in unique and innovative ways to truly take advantage of the capabilities ofmobile devices and fulfil the needs of mobile device users. These opportunities exist asstrongly in the consumer market as they do in business applications.

Consider the following possibilities:• An events calendar that allows users to find events by date and proximity, then provides

navigation information to assist travel to an event.• A car park finder application that allows the user to identify suitable car parking at a

location they are driving to, reserves a parking space and then provides directions to thecar park.

• An application that allows users to find the best price for a product based on the purchasecost and the cost of travel to the shop. The user could look for several products and theapplication could find the best route to balance travel costs with purchase prices.

• A personal management application that could keep track of the user’s travel betweendiary events and automatically alert meeting attendees of a delay if traffic congestion isholding up the user.

Hopefully these examples will have fired your imagination to recognize that there are still manypossibilities for location-based applications and games, and many ways in which existingapplications could benefit from location-awareness.

A background to positioning technologyThe essential information a location-aware application needs is, rather obviously, informationon location. There are several methods available for determining location and two basictechnologies: satellite-based and terrestrial radio, as well as hybrid approaches that combinethe best features of these two basic technologies. Each has its advantages and disadvantages,which we will review now.

Satellite-based methodsThese methods rely on using information supplied by a network of medium earth orbitsatellites. At the time of writing, this effectively means NAVSTAR-GPS, created by the UnitedStates Department of Defense, but which is generally referred to as the Global PositioningSystem (GPS). Other systems are in the process of being constructed or planned, such as theRussian GLONASS and the European Galileo positioning systems.

In simplistic terms, a GPS receiver estimates its location by determining its distance from atleast four GPS satellites. These distances are found using information on when a signal wastransmitted by a satellite and its location at that time. Knowing these distances, the GPSreceiver’s software can determine its location.

4

Page 8: Creating Location-Aware Applications

The advantages of GPS-based location determination are that:• it is free (once the necessary hardware has been obtained) • it does not rely on the device being connected to a radio network• it is very accurate where signals from the satellites can be received (typically within tens

of meters for consumer GPS receivers).

The principal disadvantages of GPS are that:• it requires dedicated hardware• it may not work in all locations. GPS receivers cannot be used to determine location

indoors, in built-up areas with a high density of tall buildings, or in some naturallocations such as canyons or steep sided valleys

• GPS systems do not necessarily provide an instant response, requiring time to locatesatellite signals when first requested for a location

• integrated GPS hardware can have an appreciable effect on a device’s powerconsumption. This may need to be considered during the design of applications whereprolonged use of an internal GPS receiver is likely.

Terrestrial-based methodsThese methods rely on information a device can gather about terrestrial-radio networks. Formobile devices this means mobile network base stations, but WiFi and Bluetooth technologyhotspots could also be used. If a device can determine the source of any radio signals andtheir strength then an estimate of location can be made, but only if the location of the sourceis already recorded.

The advantages of terrestrial radio-based methods are that:• they do not rely on specific GPS location hardware and so can be used by any mobile

device • these methods can often be the most accurate for determining location in built up areas.

In these areas satellite systems may be ineffective because buildings obscure theirsignals, while terrestrial radio methods benefit from a high density of mobile networkbase stations, which can be supplemented with information from the often numerousWLAN networks.

The disadvantages of these methods are that:• their accuracy can be low. Where there are a limited number of radio sources available,

accuracy may be measured in kilometers• they are unable to provide altitude information• terrestrial radio-based methods rely on the availability of information on the location of

radio sources and, where possible, information on the signal strength footprint or the useof techniques for determining the time a signal takes to arrive. As a result, thesemethods rely on either a database stored on the device, one accessed over-the-air or acombined method that caches relevant information on the device. A fixed on-devicedatabase will become less relevant over time, while use of an external database couldresult in the device user paying network charges to access it.

5

Page 9: Creating Location-Aware Applications

Mixed methods Mixed location technologies attempt to take advantage of the best characteristics of terrestrialradio and satellite-based positioning methods to improve the accuracy, time-to-first-fix oravailability of positioning information.

Several different mixed method technologies are available, including Assisted GPS System (A-GPS) and Differential Global Positioning System (DGPS). Their operation is generally similar,using the best available information to determine location, for example, an A-GPS system mayuse Secure User Plane Location (SUPL) (an Open Mobile Alliance [OMA] standard fortransferring location information) to estimate a location based on information from the cellularnetwork. This enables improved time-to-first-fix (when a location request is first made and aGPS is searching for satellites or when the signals available to the GPS are weak orincomplete).

Positioning methods supported by the S60 platformAt the time of writing, the S60 platform supports all three methods of location determinationin the following forms:

• external Bluetooth GPS• built-in GPS• A-GPS (using a built-in GPS)• network (terrestrial radio)-based triangulation.

In addition, a method of simulating location is also supported for testing purposes; thismethod is discussed later in the ‘Development and testing tools’ section.

It is also entirely possible for you to create your own location technology. The S60 platformallows applications to determine information such as the Cell ID of a connected mobilenetwork base station and the names of WLAN networks, along with signal strengthinformation. Such information could then be used, together with details from external or on-device databases, to determine the device’s location. However, in general, employing suchmethods is unnecessary.

Should you create a location estimation technology it is possible to add this to the S60platform, or specific devices, using a plug-in architecture. However, access to the positioningsystem plug-in APIs is controlled and would require the involvement of a device manufacturer.Further discussion is beyond the scope of this booklet.

Location services in the S60 platformS60 3rd Edition and S60 5th Edition offer their runtimes APIs that are positioning-methodindependent. These APIs allow applications to acquire location information as well as managelandmarks. This means that, beyond confirming that an S60 device can acquire locationinformation, an application does not need its own logic to determine a device’s location.For example, without the framework, an application designed to use an external GPS receiverwould require you to design, implement, test and maintain modules for Bluetooth discoveryand connectivity, the receiver’s power management and NMEA strings parsing. By adopting theframework you can rely on all these tasks being performed transparently by the middleware.This allows more resources to be focused on the application’s logic, while also removing theapplication’s dependency on a particular positioning technology.

6

Page 10: Creating Location-Aware Applications

Introducing the Mobile Location FrameworkThe S60 platform offers Symbian C++ developers location services through the Mobile LocationFramework (MLF). The MLF provides features to acquire location estimates, receive positioningupdates and manipulate landmarks. A key benefit of the MLF is that it provides a single set ofAPIs for location acquisition using any of the supported positioning methods. The S60platform adds a number of APIs to the core Symbian OS MLF that provides UIs for variouscommon landmark tasks, such as searching and selecting. The structure of the MLF isillustrated in Figure 2.

Figure 2: The Mobile Location Framework offered in S60 3rd Edition and beyond

The MLF offers two main functions: location acquisition and landmark management.

Location acquisitionThe Location Acquisition APIs gain their information from the MLF Location Server. The LocationServer in turn uses the Positioning plug-in framework to determine what location technologiesare available. Once an acquisition plug-in has been selected, a positioning system (PSY) plug-in (known as the ‘positioning modules’ to the API) is used to retrieve location estimates. TheLocation Server also uses a Privacy Manager subsystem to validate whether an application hasthe right to be provided with location estimates. This module is designed to validate remotelocation requests (requests made by systems the device may be attached to). When suchrequests are received, the Privacy Manager may block the request, ask for user verification orallow the request. To enable the Privacy Manager in enforcing its rules, each locationinformation requestor must identify itself to the MLF. In addition, Symbian OS platform securitypolicies are enforced such that the requesting application must possess the Location capabilityif it wants to connect to the MLF.

Note: In S60 3rd Edition, Feature Pack 2 and later, the Location capability can be granted bythe user when an application is installed. On earlier versions of the S60 platforms suchapplications would need to be certified by Symbian Signed (www.symbiansigned.com).

7

Page 11: Creating Location-Aware Applications

The abstraction of the privacy management and location acquisition technologies through theLocation Server allows Symbian OS to provide Symbian C++ developers with a single set ofAPIs for all location acquisition tasks. These APIs allow you to access information such as alocation estimate, to perform various location-based calculations, such as determiningdistances, bearings and speeds between reference points, and to translate coordinatesbetween different systems.

LandmarksThe Landmarks APIs enable the user and all location-aware applications on an S60 device tocreate, update, categorize, delete, send and receive points of interest (POIs) in shared orprivate databases on the device. In addition, remote databases of POIs can also be connectedto and shared. From S60 3rd Edition a number of UI components are available to add featuresto your applications for listing, editing and selecting landmarks based on user or application-defined criteria. These UI components remove the need to create a custom UI for POImanagement tasks.

Landmark information is transferred to and from an S60 device in a custom Landmark XML(LMX) format file, using the MIME type‘application/vnd.nokia.landmarkcollection+xml’. In addition, selected S60 3rd Edition devices have support for importing GPX format files, with this feature becomingstandard in S60 5th Edition and providing parsing support in CPosLandmarkParser. GPXformat files are identified by the MIME type ‘application/gps+xml’.

Landmark files can be sent and received via any available mechanism. This feature has anumber of uses, for example, landmarks can be embedded in a web page, site visitors canthen download the landmark to their phones and travel to the landmark using guidance fromthe navigation software installed on the device.

Now you understand the basics of the location features offered by the S60 platform, we willlook in detail at how to use the Symbian C++ APIs to obtain location information andmanipulate landmarks.

Working with location informationThe Location Acquisition API provides the mechanism by which an application can obtainlocation estimates from one of the available PSYs. The API communicates with the LocationServer through the RPositionServer and RPositioner classes. RPositionServerprovides mechanisms to connect to the Location Server and fetch information about thepositioning technology modules available on the device, while RPositioner is used to querylocation information with specific update options and to manage privacy.

8

Page 12: Creating Location-Aware Applications

Figure 3: The basic steps involved in obtaining location information with the Location Acquisition API

Opening a session to the Location ServerYour first step in working with the Location Acquisition API is to open a session to theLocation Server using RPositionServer::Connect().

void CLbsPositionRequestor::ConstructL(){...// RPositionServer iPosServer (is defined elsewhere)// remember to Close() this sessionUser::LeaveIfError(iPosServer.Connect());...}

The RPositionServer handle can be used to query information on the various positioningmodules on the device via TPositionModuleInfo and TPositionModuleStatusclasses, and can start receiving updates on their status using theTPositioningModuleStatusEvent class.

The code below iterates through the available positioning modules and gets the name of themodule to a descriptor.

9

Page 13: Creating Location-Aware Applications

void CLbsPositionRequestor::EnumerateTechnologies(){...

TPositionModuleInfo moduleinfo; TBuf<KPositionMaxModuleName> moduleName;

TUint numOfModules = 0;iPosServer.GetNumModules( numOfModules ); for( TUint i = 0; i < numOfModules; i++ )

{ // read current module info iPosServer.GetModuleInfoByIndex ( i, moduleinfo ); // only if enabled by user if(moduleinfo.IsAvailable())

{ // read current module name moduleinfo.GetModuleName( moduleName ); ... }

... }

...}

It should be noted that simply because a positioning module is available on a device, it doesnot mean that your application can make use of it. The device user has the ability todetermine which positioning modules are enabled. For example, the user may disable anintegrated GPS to prevent accurate information on their location being made available to atracking application, or turn off a network-based positioning module to ensure locationestimation does not increase their over-the-air data usage.

Opening a location requestor handleAfter setting up a session to the Location Server with RPositionServer, theRPositioner class can be used to fetch location estimates from the Location Server.

RPositioner::Open() has a couple of overloads to provide control over the way in whichthe Location Server provides information to an application. To utilize the default positioningmodule on a device, the RPositionServer handle needs to be passed as the argument.The default module can be identified by callingRPositionServer::GetDefaultModuleId(). The RPositioner::Open() overload,using positioning module selection criteria as an argument, is not supported in the S60platform at the time of writing. The positioning module selection logic has to be implementedusing RPositionServer to query for the available modules and the features ofTPositionModuleInfo must be used to find out the most suitable module.

You can open a subsession to the Location Server using the default module by calling:

// RPositioner iPositioner (is defined elsewhere)// remember to Close() this subsessioniPositioner.Open( iPosServer );

10

Page 14: Creating Location-Aware Applications

Alternatively, you can specify the module ID if you want to receive updates from a specificpositioning module, as follows:

// following the example where the module name was read// ... we want to use that specific module// remember to Close() this subsessioniPositioner.Open( iPosServer, moduleinfo.ModuleId() );

To work with multiple positioning modules, you need to open separate RPositionerhandles for each one before you can use the location estimate output provided by them. Forexample, if you want to use the fast location estimate provided by a network-basedpositioning system together with the GPS positioning module (to improve time-to-fix whenstarting a location-based application), you will need to open both modules.

Identifying the requestorTo safeguard the privacy of a user, the Location Framework requires each requestor of locationinformation to identify themselves and handle the display of appropriate notifications to the userif necessary. In practice, notifications of location information requests from C++ applications arenot pushed to the user in S60 3rd Edition, Feature Pack 1 and earlier devices, since the SymbianOS platform security Location capability is needed by the requesting processes. This meansthat applications must be Symbian Signed with the Location capability to make use of theMLF. From S60 3rd Edition, Feature Pack 2 onwards, the Location capability is user grantableand the user will be notified of the application’s desire to read location information duringinstallation. Such applications would therefore not require the application to be Symbian Signed.

Every requestor of location information must identify themselves to the Location Framework.For example, if your application acts as a proxy for a web service requesting locationinformation, you need to specify your application and the identity of the service. This allowsthe MLF’s Privacy Manager to apply the appropriate privacy rules to a location request. Arequestor may be specified as a service or a contact stored in the device’s contacts databaseas appropriate. RPositioner provides methods to set either a single requestor or multiplerequestors, using the overloaded RPositioner::SetRequestor() call.

The requestor information can be set as follows:

_LIT(KRequestor, "MyService");iPositioner.SetRequestor( CRequestor::ERequestorService,

CRequestor::EFormatApplication, KRequestor );

Setting the update options and requests for position information updatesThe Location Acquisition API provides a cached version of location information. This is usefulwhen your application has no need for periodic location updates or only needs to know thelast cached position. You call the asynchronousRPositioner::GetLastKnownPosition() to get this information. Remember that inSymbian OS asynchronous requests are issued by active objects, which are also responsible forhandling the request’s completion.

void CLbsPositionRequestor::RequestLKP(){...// TRequestStatus and TPositionInfo member variables// Get last known position.

11

Page 15: Creating Location-Aware Applications

// i.e CLbsPositionRequestor::RunL() // The result is processed in active object’s RunL methodiPositioner.GetLastKnownPosition(*iPosInfoBase,iStatus);// Set this object activeSetActive();

}

Alternatively, you can register your application to receive position change notifications. Beforerequesting position information updates, you need to specify the type, interval and validity ofposition updates to be provided by the Location Server. You should do this as follows:

void CLbsPositionRequestor::SetOptions(){TPositionUpdateOptions updateops; // Set update interval to one second updateops.SetUpdateInterval(TTimeIntervalMicroSeconds(1000000));// If position server could not get position// In 15 seconds it will terminate the position requestupdateops.SetUpdateTimeOut(TTimeIntervalMicroSeconds(15000000));// Positions which have time stamp below 0.5 seconds can be reusedupdateops.SetMaxUpdateAge(TTimeIntervalMicroSeconds(500000));// Enables location framework to send partial position data,// for example allowing only a time stamp to be delivered// to the requestor if more complete updates are not availableupdateops.SetAcceptPartialUpdates(ETrue);

// Set update optionsiPositioner.SetUpdateOptions( updateops );}

// A position update request is then started by calling// RPositioner::NotifyPositionUpdate()void CLbsPositionRequestor:: RequestPositionUpdates()

{...// The result is processed in active object’s RunL() methodiPositioner.NotifyPositionUpdate(*iPosInfoBase, iStatus);

// Set this object activeSetActive();}

The result of the request is handled in the RunL() event handler of your active object. Youneed to check for the success of the request by examining the request status variable and, onsuccessful request completions, act upon the updated position information (TPositionInfo,TCourseInfo or HPositionGenericInfo).

12

Page 16: Creating Location-Aware Applications

...void CLbsPositionRequestor::RunL()

{ switch ( iStatus.Int() )

{// The fix is validcase KErrNone:// The fix has only partially valid information.// It is guaranteed to only have a valid timestampcase KPositionPartialUpdate:

{ProcessPositionUpdate();// Issue a new request if neededRequestPositionUpdates();break;}

// The data class used was not supportedcase KErrArgument:....}

}

After a position update notification has been received, the client application must re-issue therequest if it wishes to obtain further updates.

Cleaning up and tearing downRequests issued with RPositioner and RPositionServer can be cancelled using theirCancelRequest() methods.

Subsession and session handles to the Location Server have to be closed by callingRPositioner::Close() and RPositionServer::Close() respectively.

CLbsPositionRequestor::~CLbsPositionRequestor{...//cancelling pending requests// Cancel() calls DoCancel() if the object is active

// closing sessionsiPositioner.Close();iPosServer.Close();...}

Working with landmarksThe Landmarks API offers features to access, search and update landmarks databases residinglocally on the device or available online.

The CPosLandMarksDatabase class provides APIs for creating, opening and closingdatabases as well as receiving notification of database management events. Once a databaseis open, the CPosLandmarkSearch class and associated criteria classes are used to executea landmark search, and the CPosLandmarkParser and CPosLandmarkEncoder classescan be used to import and export landmarks.

13

Page 17: Creating Location-Aware Applications

Three UI APIs are available to enable user interaction with the landmark information: • CLmkEditorDlg, which provides a dialog for editing landmark data• CLmkCategorySelectorDlg and CLmkLandmarkSelectorDlg, which provide

selection dialogs.

The data edited with CLmkEditorDlg is automatically saved in the database when thedialog is closed, so this dialog can be employed to allow the user to inspect and edit thecontent of a new landmark before it is added to the database.

Accessing and manipulating databasesThe CPosLandMarksDatabase class is used to access a landmarks database. TheLandmarks Database Management API provides facilities for listing databases as well ascreating and deleting databases. Clients can also subscribe to notifications on changes to alandmarks database.

void CLandmarkManager::ConstructL(){...// open the default landmarks database// CPosLandmarkDatabase* iDb (is defined elsewhere);iDb = CPosLandmarkDatabase::OpenL();InitializeIfNeededL();...}

Landmarks database operations, such as searching within a large set of landmarks, arepotentially time consuming. To prevent such operations blocking the main application, it isrecommended that such tasks be broken into smaller sub tasks and run incrementally byassigning an active object to run the task. The Landmark API provides the CPosLmOperationobject for such operations, as illustrated in this code used to initialize a landmarks database:

void CLandmarkManager::InitializeIfNeededL(){// check if landmarks database needs to be initialized// run the initialization via CPosLmOperation object if necessaryif (iDb.IsInitializingNeeded())

{// Create initialize operation// CPosLmOperation* iOperation// TReal32 iProgress (is defined elsewhere) iOperation = iDb.InitializeL();iOperation->NextStep( iStatus, iProgress );SetActive();}

}void CLandmarkManager::RunL()

{if ( iStatus == KPosLmOperationNotComplete )

{

14

Page 18: Creating Location-Aware Applications

// The operation has not completed.// Use iProgress to indicate progress// Perform the next initialization stepiOperation->NextStep( iStatus, iProgress );SetActive();}else{ // The operation has completed.// check for potential errors here and handle the result }

}

Operations that normally need to be run incrementally are possible using the ExecuteL()and ExecuteAndDeleteLD() Landmarks API utility methods.

Searching landmarksThe Landmarks Search API enables searching of a landmarks database. Such searches can berefined by defining names, categories, distance to a location, text values or any combination ofthese criteria. The user can also refine a search result by applying new search criteria to thecached result. The search is executed incrementally, with a similar execution model asdisplayed in the code snippet provided in the previous section. Search operation results canbe sorted using criteria such as position or category and can be iterated through using thereturned CPosLmIterator object. If search results need to be displayed to the user duringthe search, the display data functionality of the Landmarks Search API has to be used toaccess the partial result set.

The code snippet below searches for landmarks with the word ‘flowers’ in their name. Thesearch is run in one step without displaying a progress dialog or incrementally reporting searchresults.

void CLandmarkManager::ExamplifySearch(){_LIT(KSearchString, "flowers");

...

// Create a search object and provide the CPosLandmarkDatabase // object.CPosLandmarkSearch* search = CPosLandmarkSearch::NewL(*iDb);CleanupStack::PushL(search);

// Create the search criteriaCPosLmTextCriteria* crit = CPosLmTextCriteria::NewLC();crit->SetTextL(KSearchString);

// Start the search and execute it at once.ExecuteAndDeleteLD(search->StartLandmarkSearchL(*crit));CleanupStack::PopAndDestroy(crit);

// Retrieve an iterator to access the matching landmarks.CPosLmItemIterator* iter = search->MatchIteratorL();CleanupStack::PushL(iter);

15

Page 19: Creating Location-Aware Applications

// Iterate the search matches.TPosLmItemId lmID;while ((lmID = iter->NextL()) != KPosLmNullItemId)

{CPosLandmark* lm = iDb->ReadLandmarkLC(lmID);

// Do something with the landmark information...

CleanupStack::PopAndDestroy(lm);}

// delete iterator and search objectsCleanupStack::PopAndDestroy(2, search);...}

Importing and exporting landmarksThe S60 platform provides for exchanging landmark data between users or applications ondifferent devices or computers using the LMX format. The CPosLandmarkEncoder andCPosLandmarkParser classes are used to export and import landmarks.

The CPosLandmarkEncoder class either exports all landmarks or a subset based on an IDarray of the landmarks to be exported that are passed to the instantiated export object. If anyof the landmarks in the ID array are not present in the database, the entire export operationwill fail.

The code below shows how to export landmarks to a file using theCPosLandmarkDatabase() method. In this example the incremental operations areexecuted synchronously.

void CLandmarkManager::ExportSelectedLandmarksL(RArray<TPosLmItemId>& aSelectedLandmarks)

{LIT( KExportFilePath, "c:\\eposLmExport.lmx" );

// Mime type of landmarks exchange format_LIT8( KPosMimeTypeLandmarkCollectionXml,

"application/vnd.nokia.landmarkcollection+xml" );

// Create the encoder to be used for exporting landmarksCPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL( KPosMimeTypeLandmarkCollectionXml );CleanupStack::PushL( encoder );

// Point out the file to export landmark data toencoder->SetOutputFileL( KExportFilePath );

// Execute the operation in one batch// Note: There must be landmarks for specified // IDs in the database,otherwise operation

16

Page 20: Creating Location-Aware Applications

// will fail with KErrNotFound ExecuteAndDeleteLD( iDb->ExportLandmarksL(*encoder,

aSelectedLandmarks,CPosLandmarkDatabase::EIncludeCategories ) );

// Finalize encoding to complete exportExecuteAndDeleteLD( encoder->FinalizeEncodingL() );CleanupStack::PopAndDestroy( encoder );}

The import of landmark data is performed using the CPosLandmarkParser class. Importscan be for all the landmarks in the source or for a subset defined by passing an array.

The code below imports landmarks from a file using the CPosLandmarkDatabase()method.

void CLandmarkManager::ImportLandmarksL( const TDesC& aImportFilePath ){// Mime type of landmarks exchange format_LIT8( KPosMimeTypeLandmarkCollectionXml,

"application/vnd.nokia.landmarkcollection+xml");

// Create the parser to be used for importing landmarksCPosLandmarkParser* parser =

CPosLandmarkParser::NewL( KPosMimeTypeLandmarkCollectionXml );CleanupStack::PushL( parser );

// Point out the file to import landmark data fromparser->SetInputFileL( aImportFilePath );CPosLmOperation* op = iDb->ImportLandmarksL(*parser,

CPosLandmarkDatabase::EDefaultOptions );CleanupStack::PushL( op );// Execute the operation in one batchop->ExecuteL();

// Fetch the landmark iterator of imported landmark IDsCPosLmItemIterator* iter = iDb->ImportedLandmarksIteratorL( op );CleanupStack::PushL( iter );

// Fetch imported landmark data using this iterator// Iterate the search matches.TPosLmItemId lmID;while ((lmID = iter->NextL()) != KPosLmNullItemId)

{CPosLandmark* lm = iDb->ReadLandmarkLC(lmID);

// Do something with the landmark information...

17

Page 21: Creating Location-Aware Applications

CleanupStack::PopAndDestroy(lm);}

// CleanupCleanupStack::PopAndDestroy( iter );CleanupStack::PopAndDestroy( op );CleanupStack::PopAndDestroy( parser ); }

As with other landmark operations, exports and imports can be run incrementally.

Viewing or editing landmarksLandmarks can be viewed or edited using the Landmarks UI Add/Edit API, which also providesfeatures such as the option to send a landmark or view its location on a map (if a suitablemapping application, such as Nokia Maps, is present on the device). Using the viewer or editorrequires the definition of a landmark to work with, either by creating a new one or using onedefined by a search result. The dialog is then launched in either viewer or editor mode.

Figure 4: The Landmarks Add/Edit UI enables landmarks to be managed by the user

The code below launches a landmark viewer dialog for an existing landmark.

void CMyLmUiAppView::LaunchLmkViewerWithLmkIdL(TLmkItemIdDbCombiInfoalmItem)

{//extract the database handle.CPosLandmarkDatabase* db =almItem.GetLmDb();//extract the seleted landmarks item idTPosLmItemId itemId = almItem.GetItemId();

CLmkEditorDlg::TLmkEditorParams editParams;//set to make visible all the fields in viewer.editParams.iAttributes = CLmkEditorDlg::ELmkAll;//set to launch viewereditParams.iEditorMode = CLmkEditorDlg::ELmkViewer;

18

Page 22: Creating Location-Aware Applications

CLmkEditorDlg *dlg = CLmkEditorDlg::NewL(*db,itemIdeditParams);// set Mop parentdlg->SetMopParent(this);

dlg->ExecuteLD()}

Selecting landmarksThe Landmarks UI Selector API provides a mechanism to enable users to select landmarks orcategories from a list.

Figure 5: The Landmarks UI Selector API enables the user to choose landmarks or landmark categories

Here is a simple code snippet that launches a dialog allowing a user to select multiplelandmarks.

void CMyLmUiAppView::LaunchLandmarksMultipleSelectorL(){CLmkLandmarkSelectorDlg* lmkSelectDlg =

CLmkLandmarkSelectorDlg::NewL();lmkSelectDlg->SetMopParent(this);RArray<TLmkItemIdCombiInfo> selItemArray;TInt retVal = lmkSelectDlg->ExecuteLD( selItemArray );

// Use selItemArray to get the IDs of the returned landmarks…// and a handle to the database they reside at}

Working with other featuresThere is one final feature of the location services: the BLID Application Satellite Info API. ThisAPI allows information on the GPS satellites visible to the GPS hardware to be displayed.

19

Page 23: Creating Location-Aware Applications

Figure 6: In S60 3rd Edition, Feature Pack 2 and later, the BLID Application Satellite Info API offers two views of satellite information

Other S60 platform runtimesThis booklet has concentrated on developing location-aware applications using Symbian C++;however, this is not the only option. Java technology and Python offer developers location APIsin S60 3rd Edition and later. Starting with S60 5th Edition, web widgets and Flash Liteapplications gain location APIs. These APIs are introduced in this section.

Java technologyThe S60 platform offers a comprehensive set of Java Micro Edition (Java ME) APIs. Since theintroduction of S60 3rd Edition, these have included the Location API for J2ME (JSR-179). ThisAPI provides methods for determining the current location, as well as creating and accessinglandmark information. A generalized view of the API is shown in Figure 7.

Figure 7: The architecture of the Location API for Java ME

20

LocationProvider LocationListener

Page 24: Creating Location-Aware Applications

Retrieving a device’s location involves getting an instance of the LocationProvider objectand using this to retrieve location information. The example code below shows how this isdone. Note that Criteria is set to require the location fix to be accurate within 500 metersand that a timeout on the retrieval of location data has been set at 60 seconds.

public void checkLocation() throws Exception{

String string; Location l; LocationProvider lp; Coordinates c;

Criteria cr= new Criteria(); cr.setHorizontalAccuracy(500);

lp= LocationProvider.getInstance(cr);l = lp.getLocation(60);

c = l.getQualifiedCoordinates();if(c != null ) {

// Use coordinate information double lat = c.getLatitude(); double lon = c.getLongitude(); string = "\nLatitude : " + lat + "\nLongitude : " + lon;

} else {string ="Location API failed";

}midlet.displayString(string);

}

Applications created using JSR-179 have access to features similar to those offered by the MLF.As such, Java technology offers an entirely suitable alternative to Symbian C++ for the creationof sophisticated location-aware applications.

Web RuntimeWith the introduction of S60 5th Edition, WRT has been given access to S60 location andlandmarks services through a JavaScript binding to S60 Platform Services. This enablesdevelopers to perform such operations as acquiring a location, tracing location updates andmaking location-based calculations, as well as searching and modifying landmark databases.

To obtain a device’s location, JavaScript code needs to declare a service object and then getthe required service to that object. There are several services offered by the S60 PlatformServices binding; others include access to device data such as Contacts and Calendar records.The service object for location information is Service.Location of the type ILocation.

Once the object has been created, location information is obtained using theGetLocation() function. Before the function is used, however, an object for criteria isrequired. These criteria enable the control of the information returned. For example, by settingPartialUpdates to False it is possible to force the request to return a complete set ofbasic location details. This setting prevents incomplete information being returned if, forexample, a built-in GPS had not acquired a reliable fix when the request was initiated.

This code snippet shows how a simple widget uses these features to display a device’slatitude and longitude, as shown in Figure 8. Note, however, that this code does not includeappropriate error checking.

21

Page 25: Creating Location-Aware Applications

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><html>

<head><title>My Location Aware Widget</title>

<script type="text/javascript">window.onload = function() {

var serviceObject = device.getServiceObject("Service.Location", "ILocation");

var criteria = new Object();var result = serviceObject.ILocation.GetLocation(criteria);

var latitude = result.ReturnValue.Latitude;var longitude = result.ReturnValue.Longitude;

alert('Latitude= ' + latitude + '\nLongitude= ' + longitude);

};</script>

</head><body></body>

</html>

In addition to longitude and latitude, the variable returned from GetLocation() can providealtitude, satellite, speed, course and heading data. The actual information provided dependson the positioning technology in use on the device, for example, if network positioning is usedaltitude would not be included in the result.

It is also possible to get location information asynchronously using a callback extension toGetLocation().

Figure 8: Location information displayed in an example widget running in the S60 5th Edition emulator

22

Page 26: Creating Location-Aware Applications

With the introduction of S60 Platform Services support to WRT, web developers can now createlocation-based applications for S60 devices and offer features that were previously achievablein Symbian C++ and Java applications only.

Flash LiteWith the introduction of S60 5th Edition, Flash Lite developers have access to location andlandmark services through an ActionScript binding to the S60 Platform Services. This featureenables Flash Lite developers to perform such operations as acquiring a location, tracinglocation updates and making location-based calculations as well as searching and modifyinglandmark databases.

To use these features the ActionScript code needs to create a variable to hold a specific serviceobject, such as the location service. Once this is done another variable can be set to a specificattribute of the service, such as location, as shown in the following code:

var so = new Service("Service.Location", "ILocation"); var location = so.GetLocation();

The variable returned from GetLocation() can provide longitude, latitude, altitude,satellite, speed, course and heading data.

With the introduction of S60 Platform Services support to Flash Lite, developers can nowcreate location-based applications for S60 devices and offer features that were previouslyachievable in Symbian C++ and Java applications only.

Python for S60Python for S60 offers the ease and familiarity of the Python language to S60 applicationdevelopers. It is currently available as a plug-in for the S60 SDKs and Nokia devices based onS60 3rd Edition or later. The plug-ins are obtained from the Python for S60 project hosted onSourceForge (sourceforge.net/project/showfiles.php?group_id=154155).

Extensions provided in Python for S60 offer developers access to a wide range of nativeSymbian OS and S60 features, including presentation using the native S60 UI.

Support for location-aware applications is provided through the dynamically loaded extensionmodules, location and position.

The location module provides basic information from a mobile network, such as countrycode and Cell ID. Location applications using this module would need to look up locationinformation based on Cell ID.

The position module provides developers with access to location information from anexternal GPS, and for S60 3rd Edition, Feature Pack 2 or later devices, an internal GPS whereavailable.

Python for S60 does not offer the ability to create or use landmarks stored in an S60 device.

While Python for S60 is most commonly used for application prototyping, it offers developersa practical alternative to Symbian C++ and the Java language for location-aware applications.

23

Page 27: Creating Location-Aware Applications

Building a complete applicationWhile the S60 platform provides you with services for determining location and storinglandmarks, alone these are rarely sufficient to build a user friendly location-based application.So whether you are building a fully fledged navigation solution or simply updating a user’slocation to a social networking web community, location needs to be given context.

Context optionsContext will generally come from one of the following sources: mapping information,navigation services, point of interest information, user-generated content and advertising.

Mapping informationThe conventional context for a location is found on a map. However, the options for mappinginformation are numerous. The two basic options are raster or vector-based. Raster maps allowyou to use the content you would see on conventional printed maps directly. Raster maps,however, have the significant drawback of generally requiring more data to provide similarinformation to vector maps. They also offer few options for displaying summary information inoverviews and zooming into details could result in pixilation, unless different raster images areavailable for various zoom levels.

By contrast, vector maps generally require less data storage or transmission, and can offersummary and detailed views from the same data set. In addition, vector maps can offer theoption to provide either 2D or 3D views.

Figure 9: Raster maps are used in ViewRanger (www.viewranger.com) and vector maps are used in Nokia Maps

Navigation servicesIn many instances, the user of a location-aware application will want to travel from theircurrent location to a place they have identified with the application. To facilitate the user’stravel an application can offer a navigation service. Such a service would allow the user todefine criteria for the route they want to select, for example, specifying whether they are usinga motor vehicle or walking and whether they wish to avoid certain transportation networkfeatures, such as toll roads or motorways.

24

Page 28: Creating Location-Aware Applications

Figure 10: Nokia Maps offers route planning and voice guided navigation of a route

The presentation of a route can be achieved in several ways: it may be highlighted on a mapwith the user tracking their progress by comparing the route to their current location throughto offering directions on screen, possibly supplemented with voice commands.

Point of interest informationWhile a map provides a user with context to their location and, depending on the map used,basic information on major features in the surrounding area, it rarely provides specific point ofinterest (POI) information. So while a map can tell your user they are on a particular street, itdoes not provide them with any information on the attractions or services offered on thatstreet.

Figure 11: Nokia Maps showing POIs in the vicinity of Earl’s Court, London

In addition, your user may wish to answer specific questions about their surroundings, such as‘Where is the nearest restaurant?’ To do this, access is required to a database of POIs taggedwith descriptive information.

25

Page 29: Creating Location-Aware Applications

User-generated contentWhile user-generated content alone will rarely provide, at least initially, a full context tolocations, it is an engaging way of involving users in your application. User-generated contentcan cover a range of media such as still images, video and sound recording, and textualinformation describing the features of a location.

Figure 12: GyPSii (www.gypsii.com) enables its users to create content tagged with the location that the content is from

AdvertisingWhile advertising alone may not provide the sort of information your users would findpalatable, it can be used with other context information to add value to your application andgenerate additional revenue. To work effectively, the use of advertising needs to be balancedwith free or purchased content and could benefit from targeting specific user interests andneeds.

Figure 13: GyPSii (www.gypsii.com) incorporates location-based advertising unobtrusively within user-generated content

26

Page 30: Creating Location-Aware Applications

Ultimately, your final application will probably combine several of these context types. Forexample, a social networking application may allow someone to find a restaurant which isconveniently located for a group of friends to travel to, then user-generated content couldprovide independent information on the quality of the restaurant or images of its facade,advertising content could offer a discount voucher and finally a navigation service could guidethe friends to the restaurant.

Sourcing context dataThe first step in adding context to your application is determining the needs of your users.From this you can determine the nature and level of information required to provide anappropriate context.

The provision of some context may be inherent within the application. Information on thelocation of friends and family would be inherently available in an application designed to allowthe user to track those people.

User-generated content requires two enablers: a method for users to upload location-taggedinformation and a mechanism to store and retrieve this information. Location-basedadvertising, at least for now, would require a similar application-specific infrastructure.

For the remaining context information, maps, navigation services and POIs, there are optionsfor using an external provider. In fact, the sheer quantity of data and the transient nature oflocation information, such as POIs, make the use of an external service almost the onlypractical option. Even so, there are still several options to be considered, including:

• Using an on-device, third-party map data and visualization application.In this case your application would rely on another application to provide the mapvisualization and other related services to the end user. Where available, this approachremoves the burden of tasks such as map visualization and routing from your code. Inaddition, it can leverage that application’s map information download capabilities anduse data the user has already downloaded to their device. It also means map informationwill be presented in a way that is familiar to the device user. The disadvantages of thisapproach are that you will have to limit your mapping capabilities to those offered by theapplication and such an application may not be available on all devices, or may offerdifferent features on different licensees’ devices. Nokia Maps (www.nokia.com/maps)provides this capability to the built-in applications on Nokia S60 devices.

• Using a web-based GIS service.This is a popular approach to building location-aware applications that relies on a serviceprovider that offers mapping, POIs, routing and geocoding as a web service. Thisapproach removes the burden of basic map data manipulation from your application, butyour application may have to provide the presentation UI for any visualization or service,such as navigation. The licensing arrangements may also limit the ability to cache data,or the format of data supplied by the provider may result in higher network usagecompared to other methods. Examples of companies offering this service include Google(code.google.com), deCarta (www.decarta.com) and MapTP(developer.navteq.com/site/global/zones/ms/index.jsp).

• Embedding a third-party GIS engine.This approach is similar to the using a web-based GIS service; however, an on-deviceengine is used to perform the basic data acquisition and presentation tasks, hiding muchof the complexity away from your application. The principal advantages of this approach

27

Page 31: Creating Location-Aware Applications

are its flexibility compared to using a web-based GIS Service. it also guarantees that thesame visualization and service options are available on all devices and you are in controlof the UI and data presentation. At the time of writing, there are two products availablefor the S60 platform: AtlasCt Mobile Map API for J2ME (www.atlasct.com) and CarmentaMobile engine for Symbian C++ (www.carmenta.com).

• Building your own engine.This is the most complex solution as it involves using raw data from map data providers,such as TeleAtlas (www.teleatlas.com), Navteq (www.navteq.com), and regional or localproviders, and creating an engine to manipulate that data to create imagery, POI, routingand other services. This approach is likely to be most useful for specialized applications,such as those using topographic data.

An architectural view of the various options is given in Figure 14.

Figure 14: The options for implementing geospatial context information in your application

Context data storage and accessHaving determined how geospatial information is to be sourced, you need to make one furtherdecision: how the user will access this information. Will the information be provided as a fixeddata set loaded and stored on the user’s device or will the data be delivered over-the-air whenit is needed?

Providing the user with a fixed data set on their device means that they incur no additionalcosts for accessing the information, but this information will almost certainly become out ofdate and may limit coverage to the specific areas loaded at the time of purchase. Accessingthe data live allows the user to have the most up-to-date information and extend data to newgeographical areas, but means they may incur costs for data traffic on their mobile network.

Generally, the most appropriate solution is a hybrid. This may involve accessing all informationover-the-air initially but then caching it on the device or offering some elements as fixed data,such as providing a set of maps on-device but then accessing POI information over the network.

28

Page 32: Creating Location-Aware Applications

It is also possible that the selection of a particular geospatial service provider may, eithertechnically or contractually, limit the access and storage options.

Development and testing toolsS60 applications are developed on a PC using an S60 SDK in conjunction with Carbide.c++,Microsoft Visual Studio with Carbide.vs or using command line tools. Once an application hasbeen coded it is initially compiled for an S60 emulator. Using an S60 emulator, the applicationcan be tested on a PC.

Testing is an essential part of any application development project. Running an applicationwith a representative sample of data is a straightforward, if sometimes non-trivial, task formost applications. As location-aware applications rely on the physical location of a device, howis testing possible without either severely restricting the test data set or incurring a significantinvestment in S60 devices and travel?

The answer is simple. Positioning simulation tools are provided in the S60 SDK emulators andfor Nokia S60 devices to simulate location and route information through the Simulation PSY.Using locations (a single point saved as a National Marine Electronics Association [NMEA]format file) and routes (saved as Simulated Movement Format [SPS] format files), theSimulation PSY provides data for testing an application.

Creating simulated location dataThe first step in using the positioning simulation tools is creating suitable data. Here you havetwo options: recording live data or creating entirely artificial data sets.

Test data from the real worldThe advantage of using test data captured from the real world is that it can include the typicalinaccuracies that a user would encounter in using your application. To do this, you shouldcollect data in the NMEA format and then ensure that the file is saved with the extension .nme.

There are several ways to gather NMEA-dumps. Some GPS receivers may contain thefunctionality to trace data. There are also a couple of methods, with software contributed bythe developer community, documented on the Forum Nokia Wiki: the article ‘NMEA (GPS)Location Viewer’ (wiki.forum.nokia.com/index.php/NMEA_(GPS)_Location_Viewer) provides aPython for S60 script that can be used to log NMEA data, while ‘NMEAXmit - a NMEA dumperfor S60 3rd Edition’ (wiki.forum.nokia.com/index.php/NMEAXmit_-_a_NMEA_dumper_for_S60_3rd_Edition) provides a Symbian C++ application able to dumpNMEA data to a memory card or send it over a Bluetooth connection.

Using the positioning simulation route generatorThe S60 3rd Edition or later emulators include the Route utility. This allows locations androutes to be created manually.

Using the editor in the Route utility, as shown in Figure 15, routes can be created by enteringcoordinates or by drawing a route in the plot window. A map can also be imported to providereal world context to a location or route.

29

Page 33: Creating Location-Aware Applications

Figure 15: The Route utility allows locations and routes to be created

Once a location or route has been saved, it can be utilized by the application running in theemulator or on a device.

Using the positioning simulation tool for testingOnce you have your test data, the positioning simulation tool provides the mechanism bywhich you make the data available to your application, using the Simulation PSY.

The Simulation PSY and its configurator are included in the S60 SDKs; they are not on S60devices by default. For devices, the tool consists of two SIS files(SimulationPsy_ARMV5.sis [the PSY] and SimPsyConfigurator.sis [theconfigurator]) that are provided in the SDK in the\epoc32\S60tools\SimPSYConfigurator folder.

Note: The SIS files in the early S60 3rd Edition SDKs have expired certificates, so it isrecommended to use the files from the latest S60 SDK. Alternatively, the necessary files can bedownloaded from the Forum Nokia Wiki article, ‘S60 Platform: Positioning Simulation Tool’(www.forum.nokia.com/info/sw.nokia.com/id/edf2e7be-223d-4b50-af98-87e0cbe5d186/S60_3rd_Edition_Positioning_Simulation_Tool.html). In addition, at the time ofwriting, the application installs on Nokia S60 devices only.

In the S60 emulator, the Simulation PSY can be launched from the landmarks application, asshown in Figure 16, which is found in the Tools folder. On a device, the configurator can belaunched from the GPS data application, which is found either in the Tools or GPS folder. In theappropriate application, select Options > Positioning Settings. (You can also access PositioningSettings from the Settings application, usually found in the main menu or Tools folder, bychoosing General > Positioning.) In the Positioning screen, select Positioning methods. In thePositioning methods screen the Simulation option will be shown (on the emulator this is the onlyoption). Now select Options > Settings and the SimPsyConfigurator screen will allow a NMEA orSPS file to be selected. Three files are supplied with the tool. Once a simulation file has beenselected, its position information will be made available for use in your application.

30

Page 34: Creating Location-Aware Applications

Figure 16: The steps in selecting a file for position or route simulation on an S60 emulator

To make your own data sets available to the Simulation PSY configurator for the S60 emulator,store your files in the folder \epoc32\release\winscw\udeb\z\system\data. Whenworking on a device, install them in the \system\data folder on the drive on which youinstalled the positioning simulation tool. The NMEAXmit application (mentioned in the ‘Testdata from the real world’ section) can save data in the correct location so that it’s accessible tothe simulation tool.

On a device, if your application offers the user the ability to select the positioning method,then this can be used to select the Simulation PSY. If your application simply connects to thedefault PSY, then you should disable all the positioning methods except the Simulation PSY tomake the data available to your application. You can also explicitly connect to the SimulationPSY using the code outlined in the ‘Opening a location requestor handle’ section.

Getting to marketThe goal of most development projects is distribution of the resulting applications to as manyusers as possible. Fortunately, there is a wide range of distribution channels available todevelopers of S60 applications.

Independent channelsThe channels easiest to enter are those that offer applications over the Internet. Channels suchas Handango (www.handango.com), GetJar (www.getjar.com) and Handmark(www.handmark.com) offer developers a self-service mechanism; after creating an account,developers can post applications directly to the site’s catalogue.

Some Internet-based channels, such as Nokia Software Market (www.softwaremarket.nokia.com),have restrictions on the applications that can be posted. These restrictions include requiringapplications to be Symbian Signed or Java Verified. In addition, these sites may performindependent tests to ensure an application works correctly on the supported devices beforeapplications are made available for purchase.

An interesting new option for content and application distribution is MOSH. MOSH is a user-defined channel for the distribution of mobile content, allowing all developers (regardless ofcontent type) to distribute to a global market. As MOSH is a community site, it allowsdevelopers to connect easily with both the mass market and niche user communitiesworldwide. For more information visit the MOSH site (mosh.nokia.com).

31

Page 35: Creating Location-Aware Applications

Mobile network operators Operator channels also offer good outlets for applications, especially for applications that arerelevant to a particular geographical market, but these channels tend to place applications intotheir portfolio only after a vetting process.

System integratorsFor services and applications targeted at enterprise use, large system integrators can serve asa channel to target enterprises on a significant scale. Nokia for Business(www.nokiaforbusiness.com) is a channel program designed for application developers totarget large system integrators and value-added resellers.

Device manufacturersDevice manufacturers are becoming increasingly aware of the importance of services andapplications and their role in creating value for the consumer. Nokia Download! is anintegrated channel that enables developers to deploy their applications and services via an on-device application catalogue. For more information on Nokia-specific channels visitwww.forum.nokia.com/main/go_to_market/nokia_channels.html.

More information on market channels is provided in the Go to Market section of the ForumNokia site (www.forum.nokia.com/main/go_to_market) and the Developer section of the Nokiasite (www.nokia.com/developer). In addition, the Symbian Press booklet Getting to Market,which can be found on the Symbian Press web site (developer.symbian.com/booklets),provides a handy guide to finding a route to commercial success.

Getting further assistanceThe Forum Nokia web site (www.forum.nokia.com) provides access to a vast range of technicalresources designed to help you make the most of the opportunities offered by the S60platform. For specific information on location-based services there is a dedicated section withinForum Nokia (www.forum.nokia.com/lbs). The community of S60 developers, along with Nokiaexperts, also actively contributes to providing developers with support through the ForumNokia Developer Discussion Boards (discussion.forum.nokia.com) and the Forum Nokia Wiki(wiki.forum.nokia.com).

Each of these Forum Nokia resources has its own dedicated location-based applicationssection.

For situations that call for immediate support and issues not covered by the discussion boardsor wiki, Forum Nokia offers developers fee-based technical support. Developers can purchasesupport on a case-by-case basis or buy a five-case package or an annual subscription. Forsupport throughout the development of a mobile application, the Forum Nokia TechnicalConsultancy service is available to work closely with developers at every level and stage of theproject. For more information on professional support, visit the Technical Services section ofthe Forum Nokia site (www.forum.nokia.com/support).

Forum Nokia technical support also offers developers the opportunity to take advantage of theS60 API Partnering program. This program allows developers to use undocumented APIs invarious S60 devices. To request an API, a developer purchases a Partnering API Request fromthe Forum Nokia e-store and submits a support request detailing the API or functionalityrequired.

Symbian also provides information for developers creating location-aware applications. Fordocumentation, discussion forums and a wiki about Symbian OS development, visit theSymbian Developer Network site (developer.symbian.com).

32

Page 36: Creating Location-Aware Applications

ConclusionThe S60 platform offers you the ability to access location information easily and convenientlyfrom within your application. Using this information and combining it with geospatialinformation provided by your application users, data providers or advertisers enables you tooffer your users a rich and enticing location-aware experience.

This booklet has provided you with background information on the market for location-awareapplications, the basics of location estimation technology, an introduction to the MLF and theAPIs available to use it, an overview of the support for location in other S60 runtimes,information on the testing tools available, a guide to the additional geospatial data that canprovide context to a location and pointers to selling your application and getting furtherassistance.

It is now up to you to find the right way to add location-awareness to your application and, nodoubt, add to the range of exciting and engaging location-aware applications for S60 devices.

Page 37: Creating Location-Aware Applications

Developer resourcesSymbian Developer Networkdeveloper.symbian.com

Symbian Developer Network Newsletterdeveloper.symbian.com/register

Community web sites

Forum Nokiaforum.nokia.com

MOTODEVdeveloper.motorola.com

Samsung Mobile Innovatorinnovator.samsungmobile.com

Page 38: Creating Location-Aware Applications

New from

Common Design Patterns for Symbian OS: The Foundations of Smartphone Software

Multimedia on Symbian OS: Inside the Convergence Device

Common Design Patterns for Symbian OSintroduces the common design patterns usedto implement a variety of applications andservices on Symbian OS. The book describespatterns based on the architectural elementsof Symbian OS and discusses how patternssuited for desktop software must be adaptedor even avoided on a mobile platform.

Combining the insights and experience ofsubject experts within Symbian and thethird-party developer community, this bookwill be an invaluable reference for anyoneworking with multimedia on Symbian OS.The authors provide details of the nativeC++ APIs for accessing camera, video,audio, image manipulation and radio tunerfunctionality, and discuss best practice,tips and tricks.

Symbian Press: developer.symbian.com/books

Page 39: Creating Location-Aware Applications

from

Developing Software for Symbian OS, Second Edition

Quick Recipes on Symbian OS

This second edition of Developing Softwarefor Symbian OS helps software developersnew to Symbian OS to create smartphoneapplications. The original book has beenupdated for Symbian OS v9 and nowincludes a new chapter on applicationsigning and platform security, and updatesthroughout for Symbian OS v9 and changesto the development environment.

This book aims to make it easier todevelop applications by describing anumber of common programming tasksand providing clear explanations of how tocomplete them. The recipes are divided bytechnology, including graphics, multimedia,location-based services, networking,telephony, connectivity and messaging.

Full sample code is available fordownload, so it can be used as a startingpoint in your own projects.

Page 40: Creating Location-Aware Applications

from

For all Symbian C++ developers:Symbian OS Communications Programming, 2nd Editionby Iain Campbell

S60 Programming - A Tutorial Guideby Coulton & Edwards

Symbian OS Explainedby Jo Stichbury

Symbian OS Internalsby Jane Sales

Symbian OS Platform Securityby Craig Heath

Smartphone Operating System Concepts with Symbian OS by Mike Jipping

Accredited Symbian Developer Primerby Jo Stichbury & Mark Jacobs

Page 41: Creating Location-Aware Applications

from

Published Booklets

A Guide to P.I.P.S.Carbide.c++ v1.3Coding StandardsCoding TipsCoverity Prevent on Symbian OSData Sharing TipsEssential S60 - Developers’ GuideEssential UIQ - Getting StartedGetting StartedGetting to MarketJava ME on Symbian OSLocalization.NET Development on S60Performance TipsPlatform Security for allQuick Recipes Taster

Translated Booklets

Chinese RussianJapanese PersianKorean ItalianSpanish

Page 42: Creating Location-Aware Applications

Notes:

Page 43: Creating Location-Aware Applications

Notes:

Page 44: Creating Location-Aware Applications

CreatingLocation-AwareApplications

Essential S60

Adding location-awareness to S60 applications offerssignificant possibilities for extending existing applicationsor creating new ones. This Essential S60 booklet givesbackground information about positioning technologyand location-aware applications, and also provides anintroduction to the S60 APIs for developers usingSymbian C++, Java ME, Web Runtime or Flash Lite.

Creating Location-Aware Applications is part of theEssential S60 series, designed to provide information ina handy format to S60 developers.

Symbian PressSymbian Press publishes books designed tocommunicate authoritative, timely, relevant andpractical information about Symbian OS and relatedtechnologies. Information about the Symbian Pressseries can be found atdeveloper.symbian.com/books

Why? What? Where? How?


Recommended