本文整理汇总了C++中bsonelementset::iterator::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::toString方法的具体用法?C++ iterator::toString怎么用?C++ iterator::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bsonelementset::iterator
的用法示例。
在下文中一共展示了iterator::toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uassert
// Get the index keys for elements that are GeoJSON.
void S2AccessMethod::getGeoKeys(const BSONElementSet& elements, BSONObjSet* out) const {
for (BSONElementSet::iterator i = elements.begin(); i != elements.end(); ++i) {
uassert(16754, "Can't parse geometry from element: " + i->toString(),
i->isABSONObj());
const BSONObj &obj = i->Obj();
vector<string> cells;
bool succeeded = S2SearchUtil::getKeysForObject(obj, _params, &cells);
uassert(16755, "Can't extract geo keys from object, malformed geometry?:"
+ obj.toString(), succeeded);
uassert(16756, "Unable to generate keys for (likely malformed) geometry: "
+ obj.toString(),
cells.size() > 0);
for (vector<string>::const_iterator it = cells.begin(); it != cells.end(); ++it) {
BSONObjBuilder b;
b.append("", *it);
out->insert(b.obj());
}
}
if (0 == out->size()) {
BSONObjBuilder b;
b.appendNull("");
out->insert(b.obj());
}
}
示例2: parent
// Get the index keys for elements that are GeoJSON.
void S2AccessMethod::getGeoKeys(const BSONElementSet& elements, BSONObjSet* out) const {
S2RegionCoverer coverer;
_params.configureCoverer(&coverer);
// See here for GeoJSON format: geojson.org/geojson-spec.html
for (BSONElementSet::iterator i = elements.begin(); i != elements.end(); ++i) {
uassert(16754, "Can't parse geometry from element: " + i->toString(),
i->isABSONObj());
const BSONObj &obj = i->Obj();
vector<string> cells;
S2Polyline line;
S2Cell point;
// We only support GeoJSON polygons. Why?:
// 1. we don't automagically do WGS84/flat -> WGS84, and
// 2. the old polygon format must die.
if (GeoParser::isGeoJSONPolygon(obj)) {
S2Polygon polygon;
GeoParser::parseGeoJSONPolygon(obj, &polygon);
keysFromRegion(&coverer, polygon, &cells);
} else if (GeoParser::parseLineString(obj, &line)) {
keysFromRegion(&coverer, line, &cells);
} else if (GeoParser::parsePoint(obj, &point)) {
S2CellId parent(point.id().parent(_params.finestIndexedLevel));
cells.push_back(parent.toString());
} else {
uasserted(16755, "Can't extract geo keys from object, malformed geometry?:"
+ obj.toString());
}
uassert(16756, "Unable to generate keys for (likely malformed) geometry: "
+ obj.toString(),
cells.size() > 0);
for (vector<string>::const_iterator it = cells.begin(); it != cells.end(); ++it) {
BSONObjBuilder b;
b.append("", *it);
out->insert(b.obj());
}
}
if (0 == out->size()) {
BSONObjBuilder b;
b.appendNull("");
out->insert(b.obj());
}
}