×
Namespaces

Variants
Actions

Calculating the distance between coordinates using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition
S60 5th Edition
Platform Security
Signing Required: Self-Signed
Capabilities: Location
Article
Keywords: TCoordinate
Created: tepaa (09 Jun 2009)
Last edited: hamishwillee (14 Jun 2012)

Contents

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.

This page was last modified on 14 June 2012, at 05:15.
89 page views in the last 30 days.