Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Calculating the distance between coordinates using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Platform(s): S60 3rd Edition
S60 5th Edition
Platform Security
Signing Required: Self-Signed
Capabilities: Location
Keywords: TCoordinate
Created: tepaa (09 Jun 2009)
Last edited: lpvalente (23 Sep 2014)



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


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


TReal32 CLocation::CalculateDistanceL(const TCoordinate& aFrom, const TCoordinate& aTo) 
TReal32 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 "));


The distance between you and your friend is calculated.

This page was last modified on 23 September 2014, at 19:59.
67 page views in the last 30 days.