20 #include <boost/scoped_ptr.hpp>
23 #include "mongo/client/export_macros.h"
28 #include "mongo/geo/point.h"
33 template <
typename TCoordinates>
75 return GeoObjType_LineString;
83 std::vector<Point<TCoordinates> >
getPoints()
const {
91 std::vector<Point<TCoordinates> > _points;
92 mutable boost::scoped_ptr<BoundingBox<TCoordinates> > _boundingBox;
103 template <
typename TCoordinates>
105 : _bson(
GeoObj<TCoordinates>::validateType(bson, kLineStringTypeStr)),
106 _points(
Geometry<TCoordinates>::parseAllPoints(bson)),
107 _boundingBox(
Geometry<TCoordinates>::parseBoundingBox(bson)) {}
109 template <
typename TCoordinates>
111 : _bson(createBSON(points)), _points(points) {}
113 template <
typename TCoordinates>
115 : _bson(other._bson), _points(other._points) {
121 if (other._boundingBox)
125 template <
typename TCoordinates>
126 LineString<TCoordinates>& LineString<TCoordinates>::operator=(LineString<TCoordinates> other) {
128 swap(_bson, other._bson);
129 swap(_points, other._points);
130 swap(_boundingBox, other._boundingBox);
134 template <
typename TCoordinates>
137 _boundingBox.reset(computeBoundingBox());
138 return *_boundingBox.get();
141 template <
typename TCoordinates>
144 for (
size_t i = 0; i < points.size(); ++i)
145 bab.append(points[i].toBSON()[kCoordsFieldName]);
147 return bob.
append(kTypeFieldName, kLineStringTypeStr).
append(kCoordsFieldName, bab.
arr()).obj();
150 template <
typename TCoordinates>
151 BoundingBox<TCoordinates>* LineString<TCoordinates>::computeBoundingBox()
const {
BSONArray arr()
destructive - ownership moves to returned BSONArray
Definition: bsonobjbuilder.h:804
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
std::vector< Point< TCoordinates > > getPoints() const
Obtain the points that make up this LineString.
Definition: linestring.h:83
virtual BoundingBox< TCoordinates > getBoundingBox() const
Obtain the bounding box surrounding this line string.
Definition: linestring.h:135
BSONObjBuilder & append(const BSONElement &e)
append element to the object we are building
Definition: bsonobjbuilder.h:124
virtual GeoObjType getType() const
Get the geometry type of this object.
Definition: linestring.h:74
Definition: linestring.h:34
Utility for creating a BSONObj.
Definition: bsonobjbuilder.h:53
Represents a Point.
Definition: geometry.h:36
virtual BSONObj toBSON() const
Obtain a BSON representation of the line string.
Definition: linestring.h:58
Definition: bsonobjbuilder.h:765
Definition: geometry.h:39
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78
static BoundingBox< TCoordinates > * computeBoundingBox(const std::vector< Point< TCoordinates > > &points)
Compute the bounding box around the given points.
Definition: geometry.h:137
Represents a bounding box.
Definition: boundingbox.h:67
LineString(const BSONObj &bson)
LineString constructor.
Definition: linestring.h:104