×
Namespaces

Variants
Actions

Calculating the distance between coordinates using Symbian C++

From Nokia Developer 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
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)

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 23 September 2014, at 19:59.
108 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.

×