MongoDB C++ Driver  legacy-1.1.2
Public Member Functions | List of all members
mongo::geo::Point< TCoordinates > Class Template Reference

Represents a Point. More...

#include <point.h>

+ Inheritance diagram for mongo::geo::Point< TCoordinates >:

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...
 

Detailed Description

template<typename TCoordinates>
class mongo::geo::Point< TCoordinates >

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);

Constructor & Destructor Documentation

template<typename TCoordinates >
mongo::geo::Point< TCoordinates >::Point ( const BSONObj bson)
explicit

Point constructor.

Parameters
bsonA BSON representation of the point.

Example Usage:

Point<Coordinates2D> point(BSON( "type" << "Point" << "coordinates" << BSON_ARRAY(1 << 2)));

template<typename TCoordinates >
mongo::geo::Point< TCoordinates >::Point ( const TCoordinates &  coords)
explicit

Point constructor.

Parameters
coordsThe coordinates of the point.

Example Usage:

Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords);

Member Function Documentation

template<typename TCoordinates >
BoundingBox< TCoordinates > mongo::geo::Point< TCoordinates >::getBoundingBox ( ) const
virtual

Get the bounding box of this point.

The bounding box of any single Point is just the point itself.

Returns
A bounding box with minimum and maximum coordinates equal to the coordinates of this point.

Example Usage:

Coordinates2D coords(1, 2); Point<Coordinates2D> point(coords); BoundingBox<Coordinates2D> bbox = point.getBoundingBox();

Implements mongo::geo::GeoObj< TCoordinates >.

template<typename TCoordinates>
TCoordinates mongo::geo::Point< TCoordinates >::getCoordinates ( ) const
inline

Get the coordinates of this point.

Returns
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 ] }

template<typename TCoordinates>
virtual GeoObjType mongo::geo::Point< TCoordinates >::getType ( ) const
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.

See also
Parser
Returns
GeoObjType_Point

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 >.

template<typename TCoordinates>
double mongo::geo::Point< TCoordinates >::operator[] ( size_t  dimension) const
inline

Get the position of this point in the given dimension.

Parameters
dimensionThe coordinate dimension sought.
Returns
The value of this point's position in the given dimension.

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 "

template<typename TCoordinates>
virtual BSONObj mongo::geo::Point< TCoordinates >::toBSON ( ) const
inlinevirtual

Obtain a BSON representation of this point.

Returns
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 >.


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