##### Actions

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 over the next few weeks. Thanks for all your past and future contributions.

# Calculating the distance between coordinates using Symbian C++

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

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: lpvalente (23 Sep 2014)

## 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`

`#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 coordinatesTCoordinate friend; // Calculate distance    TReal32 ret = CalculateDistanceL(you,friend); // Distance in metersTBuf<50> distance;distance.Format(_L("%.1f"), ret);distance.Append(_L(" m "));`

## Postconditions

The distance between you and your friend is calculated.