MongoDB C++ Driver  legacy-1.1.2
Public Member Functions | Static Public Member Functions | List of all members
mongo::geo::Coordinates2DGeographic Class Reference

Represents a 2D geographic position (longitude, latitude). More...

#include <coordinates2dgeographic.h>

+ Inheritance diagram for mongo::geo::Coordinates2DGeographic:

Public Member Functions

 Coordinates2DGeographic (const std::vector< double > &coords)
 Coordinates2DGeographic constructor. More...
 
 Coordinates2DGeographic (const std::pair< double, double > &coords)
 Coordinates2DGeographic constructor. More...
 
 Coordinates2DGeographic (double longitude, double latitude)
 Coordinates2DGeographic constructor. More...
 
double getLongitude () const
 Get the longitude. More...
 
double getLatitude () const
 Get the latitude. More...
 
virtual std::vector< double > getValues () const
 Get the longitude and latitude values as a vector. More...
 
virtual std::pair< double, double > getValuesAsPair () const
 Get the longitude and latitude values as a pair. More...
 
virtual BSONObj toBSON () const
 Get a BSON representation of the coordinates. More...
 
virtual double operator[] (size_t dimension) const
 Get the value of this coordinate at the given dimension. More...
 

Static Public Member Functions

static size_t MONGO_CLIENT_FUNC dimensionality ()
 Get the dimensionality of this coordinate type. More...
 

Detailed Description

Represents a 2D geographic position (longitude, latitude).

Example Usage:

Coordinates2DGeographic coords(1, 2); Point<Coordinates2DGeographic> point(coords); Query nearQuery = QUERY("<field_name>" << NEAR(point)); conn.query("<db_name>.<collection_name>", nearQuery);

Constructor & Destructor Documentation

mongo::geo::Coordinates2DGeographic::Coordinates2DGeographic ( const std::vector< double > &  coords)
explicit

Coordinates2DGeographic constructor.

Parameters
coordsThe coordinate values.
Precondition
coords.size() == Coordinates2DGeographic::dimensionality().
mongo::geo::Coordinates2DGeographic::Coordinates2DGeographic ( const std::pair< double, double > &  coords)
explicit

Coordinates2DGeographic constructor.

Parameters
coordsThe coordinate values.
mongo::geo::Coordinates2DGeographic::Coordinates2DGeographic ( double  longitude,
double  latitude 
)

Coordinates2DGeographic constructor.

Parameters
longitudeThe longitude value.
latitudeThe latitude value.

Member Function Documentation

static size_t MONGO_CLIENT_FUNC mongo::geo::Coordinates2DGeographic::dimensionality ( )
inlinestatic

Get the dimensionality of this coordinate type.

Returns
2, the number of dimensions in Coordinates2DGeographic.
double mongo::geo::Coordinates2DGeographic::getLatitude ( ) const
inline

Get the latitude.

Returns
double The latitude value.
double mongo::geo::Coordinates2DGeographic::getLongitude ( ) const
inline

Get the longitude.

Returns
double The longitude value.
virtual std::vector<double> mongo::geo::Coordinates2DGeographic::getValues ( ) const
virtual

Get the longitude and latitude values as a vector.

Returns
std::vector<double> A vector [longitude, latitude] of this object's coordinate values.

Implements mongo::geo::Coordinates.

virtual std::pair<double, double> mongo::geo::Coordinates2DGeographic::getValuesAsPair ( ) const
virtual

Get the longitude and latitude values as a pair.

Returns
std::pair<double, double> A pair (longitude, latitude) of this object's coordinate values.
virtual double mongo::geo::Coordinates2DGeographic::operator[] ( size_t  dimension) const
virtual

Get the value of this coordinate at the given dimension.

Parameters
dimension0 -> longitude, 1 -> latitude, any other input besides 0 or 1 is an error.
Returns
The coordinate value at the given dimension.
Precondition
0 <= dimension < Coordinates2DGeographic::dimensionality()

Implements mongo::geo::Coordinates.

virtual BSONObj mongo::geo::Coordinates2DGeographic::toBSON ( ) const
virtual

Get a BSON representation of the coordinates.

Returns
BSONObj A BSONObj of the coordinates, structured as: { "coordinates" : [ longitude, latitude ] }

Implements mongo::geo::Coordinates.


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