MongoDB C++ Driver
legacy-1.1.2
|
#include <point.h>
Public Member Functions | |
Point (const BSONObj &bson) | |
Point constructor. More... | |
Point (const TCoordinates &coords) | |
Point constructor. More... | |
virtual BSONObj | toBSON () const |
Obtain a BSON representation of this point. More... | |
virtual BoundingBox< TCoordinates > | getBoundingBox () const |
Get the bounding box of this point. More... | |
virtual GeoObjType | getType () const |
Get the geometry type of this object. More... | |
TCoordinates | getCoordinates () const |
Get the coordinates of this point. More... | |
double | operator[] (size_t dimension) const |
Get the position of this point in the given dimension. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from mongo::geo::Geometry< TCoordinates > | |
static BoundingBox< TCoordinates > * | computeBoundingBox (const std::vector< Point< TCoordinates > > &points) |
Compute the bounding box around the given points. More... | |
static BoundingBox< TCoordinates > * | computeBoundingBox (const std::vector< BoundingBox< TCoordinates > > &bboxes) |
Compute the smallest bounding box that contains the given bounding boxes. More... | |
static BoundingBox< TCoordinates > * | parseBoundingBox (const BSONObj &bson) |
Parses the bounding box defined by the given geometry shape, represented in BSON. More... | |
Represents a Point.
Example Usage:
Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords); Query nearPointQuery = MONGO_QUERY("loc" << NEAR(point)); conn.query("foo.bar", nearPointQuery);
|
explicit |
Point constructor.
bson | A BSON representation of the point. |
Example Usage:
Point<Coordinates2D> point(BSON( "type" << "Point" << "coordinates" << BSON_ARRAY(1 << 2)));
|
explicit |
Point constructor.
coords | The coordinates of the point. |
Example Usage:
Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords);
|
virtual |
Get the bounding box of this point.
The bounding box of any single Point is just the point itself.
Example Usage:
Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords); BoundingBox<Coordinates2D> bbox = point.getBoundingBox();
Implements mongo::geo::GeoObj< TCoordinates >.
|
inline |
Get the coordinates of this point.
Example Usage:
Point<Coordinates2D> point(BSON( "type" << "Point" << "coordinates" << BSON_ARRAY(1 << 2))); Coordinates2D coords = point.getCoordinates(); std::cout << coords.toBSON().jsonString() << std::endl; { "coordinates": [ 1, 2 ] }
|
inlinevirtual |
Get the geometry type of this object.
Useful if you have a generic GeoObj<TCoordinates>* and you want to determine what specific type it is.
Example Usage:
BSONObj unknownGeoObject = cursor->next(); GeoObj<Coordinates2D>* obj = Parser<Coordinates2D>::parse(unknownGeoObject); if (obj->getType() == GeoObjType_Point) { Point<Coordinates2D>* pointPtr = static_cast< Point<Coordinates2D>* >obj; // do things with pointPtr... } else if ...
Implements mongo::geo::GeoObj< TCoordinates >.
|
inline |
Get the position of this point in the given dimension.
dimension | The coordinate dimension sought. |
Example Usage:
Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords); for (size_t i = 0; i < coords::dimensionality(); ++i) std::cout << point[i] << " "; "1 2 "
|
inlinevirtual |
Obtain a BSON representation of this point.
Example Usage:
Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords); BSONObj bson = point.toBSON();
std::cout << bson.jsonString() << std::endl; { "type" : "Point", "coordinates" : [ 1, 2 ] }
Implements mongo::geo::GeoObj< TCoordinates >.