add code that will be useful later
@@ -93,6 +93,35 @@ SlimeFieldWriter::traverseRecursive(const document::FieldValue & fv, Inserter &i
} else if (clazz.inherits(document::StructuredFieldValue::classId)) {
const document::StructuredFieldValue & sfv = static_cast<const document::StructuredFieldValue &>(fv);
Cursor &o = inserter.insertObject();
+#ifdef USE_V8_GEO_POSITION_RENDERING
+ if (sfv.getDataType()->getName() == "position") {
+ bool ok = true;
+ try {
+ int x = std::numeric_limits<int>::min();
+ int y = std::numeric_limits<int>::min();
+ for (const document::Field & entry : sfv) {
+ document::FieldValue::UP fval(sfv.getValue(entry));
+ if (entry.getName() == "x") {
+ x = fval->getAsInt();
+ } else if (entry.getName() == "y") {
+ y = fval->getAsInt();
+ } else {
+ ok = false;
+ }
+ }
+ if (x == std::numeric_limits<int>::min()) ok = false;
+ if (y == std::numeric_limits<int>::min()) ok = false;
+ if (ok) {
+ o.setDouble("lat", double(y) / 1.0e6);
+ o.setDouble("lng", double(x) / 1.0e6);
+ return;
+ }
+ } catch (std::exception &e) {
+ (void)e;
+ // fallback to code below
+ }
+ }
+#endif
for (const document::Field & entry : sfv) {
if (explorePath(entry.getName())) {
_currPath.push_back(entry.getName());
