×
Namespaces

Variants
Actions
Revision as of 14:01, 16 June 2009 by copyeditor (Talk | contribs)

Calculating the distance between coordinates using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search


Template:KBCS

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition
S60 5th Edition
Article
Keywords: TCoordinate
Created: (09 Jun 2009)
Last edited: copyeditor (16 Jun 2009)

Overview

The snippet demonstrates how to calculate the distance between two coordinates.

Note: The location capability is included in the self-signing capabilities of S60 3rd Edition, Feature Pack 2 and newer platforms.

MMP file

The following libraries and capabilities are required:

LIBRARY        lbs.lib


Header

#include <LbsPosition.h>
 
public:
TReal32 CalculateDistanceL(const TCoordinate& aFrom, const TCoordinate& aTo);


Source

TReal32 CLocation::CalculateDistanceL(const TCoordinate& aFrom, const TCoordinate& aTo) 
{
TReal32 result;
aFrom.Distance(aTo,result);
return result;
}


How to use

TCoordinate you;
 
// Friend coordinates
TCoordinate friend;
 
// Calculate distance
TReal32 ret = CalculateDistanceL(you,friend);
 
// Distance in meters
TBuf<50> distance;
distance.Format(_L("%.1f"), ret);
distance.Append(_L(" m "));


Postconditions

The distance between you and your friend is calculated.

92 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×