Represents a 2D position (x, y).
More...
#include <coordinates2d.h>
|
| Coordinates2D (const std::vector< double > &coords) |
| Coordinates2D constructor.
|
|
| Coordinates2D (const std::pair< double, double > &coords) |
| Coordinates2D constructor.
|
|
| Coordinates2D (double x, double y) |
| Coordinates2D constructor.
|
|
double | getX () const |
| Get the x coordinate.
|
|
double | getY () const |
| Get the y coordinate.
|
|
virtual std::vector< double > | getValues () const |
| Get the x and y coordinates.
|
|
std::pair< double, double > | getValuesAsPair () const |
| Get the x and y coordinates as a std::pair.
|
|
virtual BSONObj | toBSON () const |
| Get a BSON representation of the coordinates.
|
|
virtual double | operator[] (size_t dimension) const |
| Get the value of this coordinate at the given dimension.
|
|
virtual std::vector< double > | getValues () const =0 |
| Get the values of these coordinates as a vector of doubles.
|
|
virtual BSONObj | toBSON () const =0 |
| Obtain a BSON representation of these coordinates.
|
|
virtual double | operator[] (size_t dimension) const =0 |
| Obtain the value of these coordinates in a particular dimension.
|
|
|
static size_t MONGO_CLIENT_FUNC | dimensionality () |
| Get the dimensionality of this coordinate type.
|
|
Represents a 2D position (x, y).
Example Usage:
Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords); Query nearQuery = QUERY("<field_name>" << NEAR(point)); conn.query("<db_name>.<collection_name>", nearQuery);
◆ Coordinates2D() [1/3]
mongo::geo::Coordinates2D::Coordinates2D |
( |
const std::vector< double > & |
coords | ) |
|
|
explicit |
◆ Coordinates2D() [2/3]
mongo::geo::Coordinates2D::Coordinates2D |
( |
const std::pair< double, double > & |
coords | ) |
|
|
explicit |
Coordinates2D constructor.
- Parameters
-
coords | The coordinate values. |
◆ Coordinates2D() [3/3]
mongo::geo::Coordinates2D::Coordinates2D |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
|
inline |
Coordinates2D constructor.
- Parameters
-
x | The x coordinate value. |
y | The y coordinate value. |
◆ dimensionality()
static size_t MONGO_CLIENT_FUNC mongo::geo::Coordinates2D::dimensionality |
( |
| ) |
|
|
inlinestatic |
Get the dimensionality of this coordinate type.
- Returns
- 2, the number of dimensions in Coordinates2D.
◆ getValues()
virtual std::vector< double > mongo::geo::Coordinates2D::getValues |
( |
| ) |
const |
|
virtual |
Get the x and y coordinates.
- Returns
- std::vector<double> A vector [x, y] of this object's coordinate values.
Implements mongo::geo::Coordinates.
◆ getValuesAsPair()
std::pair< double, double > mongo::geo::Coordinates2D::getValuesAsPair |
( |
| ) |
const |
Get the x and y coordinates as a std::pair.
- Returns
- std::pair<double, double> A std::pair (x, y) of this object's coordinate values.
◆ getX()
double mongo::geo::Coordinates2D::getX |
( |
| ) |
const |
|
inline |
Get the x coordinate.
- Returns
- double The x coordinate value.
◆ getY()
double mongo::geo::Coordinates2D::getY |
( |
| ) |
const |
|
inline |
Get the y coordinate.
- Returns
- double The y coordinate value.
◆ operator[]()
virtual double mongo::geo::Coordinates2D::operator[] |
( |
size_t |
dimension | ) |
const |
|
virtual |
Get the value of this coordinate at the given dimension.
- Parameters
-
dimension | 0 -> x, 1 -> y, any other input besides 0 or 1 is an error. |
- Returns
- The coordinate value at the given dimension.
- Precondition
- 0 <= dimension < Coordinates2D::dimensionality()
Implements mongo::geo::Coordinates.
◆ toBSON()
virtual BSONObj mongo::geo::Coordinates2D::toBSON |
( |
| ) |
const |
|
virtual |
The documentation for this class was generated from the following file: