GeoCoordinate Class Reference

Geographic coordinate. More...

#include <geocoordinate.h>

List of all members.

Public Member Functions

 GeoCoordinate ()
 Constructs a null coordinate.
 GeoCoordinate (double latitude, double longitude)
 Constructs a coordinate with given latitude and longitude values.
 GeoCoordinate (const SceneCoordinate &coordinate)
 Constructs a coordinate with values converted from the given SceneCoordinate.
qreal distanceTo (const GeoCoordinate &other) const
 Distance to other coordinate.
bool isNull () const
 Check if coordinate is (0.0, 0.0).
bool isValid ()
 Check if coordinate is valid.
double latitude () const
 Returns the latitude value.
double longitude () const
 Returns the longitude value.
void setLatitude (double latitude)
 Sets the latitude.
void setLongitude (double longitude)
 Sets the longitude.

Private Types

enum  ValidityFlag { NoCoordinatesSet = 0x0, LatitudeSet = 0x1, LongitudeSet = 0x2 }
 

Flag values for coordinate validity.


Private Member Functions

void convertFrom (const SceneCoordinate &coordinate)
 Convert values from SceneCoordinate.
void registerMetaType ()
 Register meta type and stream operators for using the class with QVariant and QSetting.

Private Attributes

double m_latitude
 Latitude value.
double m_longitude
 Longitude value.
int m_validityFlags
 Coordinate validity flags.

Static Private Attributes

static bool m_metaTypeIsRegistered = false
 Is the meta type already registered?

Friends

const GeoCoordinate operator- (const GeoCoordinate &coordinate1, const GeoCoordinate &coordinate2)
 Subtract operator.
QDataStream & operator<< (QDataStream &out, const GeoCoordinate &coordinate)
 Output operator.
QDataStream & operator>> (QDataStream &in, GeoCoordinate &coordinate)
 Input operator.

Detailed Description

Geographic coordinate.

Author:
Jussi Laitinen - jussi.laitinen@ixonos.com
Sami Rämö - sami.ramo@ixonos.com

Constructor & Destructor Documentation

GeoCoordinate::GeoCoordinate ( double  latitude,
double  longitude 
)

Constructs a coordinate with given latitude and longitude values.

Parameters:
latitude Latitude value
longitude Longitude value
GeoCoordinate::GeoCoordinate ( const SceneCoordinate coordinate  ) 

Constructs a coordinate with values converted from the given SceneCoordinate.

Parameters:
coordinate Scene coordinate

Member Function Documentation

void GeoCoordinate::convertFrom ( const SceneCoordinate coordinate  )  [private]

Convert values from SceneCoordinate.

Parameters:
coordinate Scene coordinate
qreal GeoCoordinate::distanceTo ( const GeoCoordinate other  )  const

Distance to other coordinate.

This calculation returns the great-circle distance between the two coordinates, with an assumption that the Earth is spherical. Calculation is done using haversine formula. Altitude is not used in the calculation.

Parameters:
other Coordinate where the distance is calculated from this coordinate
Returns:
Distance to other coordinate (in meters)
bool GeoCoordinate::isNull (  )  const

Check if coordinate is (0.0, 0.0).

Returns:
True if both latitude and longitude are 0.0, otherwise false
bool GeoCoordinate::isValid (  ) 

Check if coordinate is valid.

Latitude and longitude values must be set, latitude must be -90..90 and longitude must be -180..180 for valid coordinate.

Returns:
true if coordinate is valid, false otherwise
double GeoCoordinate::latitude (  )  const

Returns the latitude value.

Returns:
latitude
double GeoCoordinate::longitude (  )  const

Returns the longitude value.

Returns:
longitude
void GeoCoordinate::registerMetaType (  )  [private]

Register meta type and stream operators for using the class with QVariant and QSetting.

Registering is done only once at the first time the GeoCoordinate object is constructed.

void GeoCoordinate::setLatitude ( double  latitude  ) 

Sets the latitude.

Parameters:
latitude Latitude value
void GeoCoordinate::setLongitude ( double  longitude  ) 

Sets the longitude.

Parameters:
longitude Longitude value

Friends And Related Function Documentation

const GeoCoordinate operator- ( const GeoCoordinate coordinate1,
const GeoCoordinate coordinate2 
) [friend]

Subtract operator.

Returns:
Returns a GeoCoordinate object that is formed by subtracting coordinate2 from coordinate1. Each component is subtracted separately.
QDataStream& operator<< ( QDataStream &  out,
const GeoCoordinate coordinate 
) [friend]

Output operator.

Parameters:
out Output stream
coordinate Coordinate object which is written to the stream
QDataStream& operator>> ( QDataStream &  in,
GeoCoordinate coordinate 
) [friend]

Input operator.

Parameters:
in Input stream
coordinate Object where the values from the stream are saved

The documentation for this class was generated from the following files:

Generated on Fri Sep 3 12:05:41 2010 for Situare client for Maemo by  doxygen 1.6.1