30#include <boost/scoped_ptr.hpp>
32#include "mongo/client/export_macros.h"
51template <
typename TCoordinates>
77 explicit Point(
const TCoordinates& coords);
134 return GeoObjType_Point;
171 return _coords[dimension];
175 static BSONObj createBSON(
const TCoordinates& coords);
178 TCoordinates _coords;
179 mutable boost::scoped_ptr<BoundingBox<TCoordinates> > _boundingBox;
184template <
typename TCoordinates>
186 : _bson(
GeoObj<TCoordinates>::validateType(bson, kPointTypeStr)),
187 _coords(
Geometry<TCoordinates>::parseCoords(bson)),
188 _boundingBox(
Geometry<TCoordinates>::parseBoundingBox(bson)) {}
190template <
typename TCoordinates>
192 : _bson(createBSON(coords)), _coords(coords) {}
194template <
typename TCoordinates>
196 : _bson(other._bson), _coords(other._coords) {
202 if (other._boundingBox)
206template <
typename TCoordinates>
207Point<TCoordinates>& Point<TCoordinates>::operator=(Point<TCoordinates> other) {
209 swap(_bson, other._bson);
210 swap(_coords, other._coords);
211 swap(_boundingBox, other._boundingBox);
215template <
typename TCoordinates>
218 _boundingBox.reset(computeBoundingBox());
219 return *_boundingBox.get();
222template <
typename TCoordinates>
228template <
typename TCoordinates>
229BoundingBox<TCoordinates>* Point<TCoordinates>::computeBoundingBox()
const {
230 return new BoundingBox<TCoordinates>(_coords, _coords);
Utility for creating a BSONObj.
Definition bsonobjbuilder.h:53
BSONObjBuilder & append(const BSONElement &e)
append element to the object we are building
Definition bsonobjbuilder.h:124
BSONObjBuilder & appendElements(BSONObj x)
add all the fields from the object specified to this object
BSONObj obj()
destructive The returned BSONObj will free the buffer when it is finished.
Definition bsonobjbuilder.h:618
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representa...
Definition bsonobj.h:78
Represents a bounding box.
Definition boundingbox.h:67
Represents a Point.
Definition point.h:52
Point(const BSONObj &bson)
Point constructor.
Definition point.h:185
double operator[](size_t dimension) const
Get the position of this point in the given dimension.
Definition point.h:170
TCoordinates getCoordinates() const
Get the coordinates of this point.
Definition point.h:151
virtual BSONObj toBSON() const
Obtain a BSON representation of this point.
Definition point.h:96
virtual GeoObjType getType() const
Get the geometry type of this object.
Definition point.h:133
virtual BoundingBox< TCoordinates > getBoundingBox() const
Get the bounding box of this point.
Definition point.h:216
GeoObjType
An enum to represent the type of geometry of a Geo object.
Definition constants.h:45
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20