diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-02-03 20:14:56 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-02-03 20:14:56 +0000 |
commit | 3b5787f26087d46c2964b28e2f5f5a165d820f57 (patch) | |
tree | 244661fcb3d904abae2363560d100daae14d51cf /vsm | |
parent | ee681536a92362033703a379b200ba333ed5b42b (diff) |
add code that will be useful later
Diffstat (limited to 'vsm')
-rw-r--r-- | vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp index 231be9b6f73..4a03c93127a 100644 --- a/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp +++ b/vsm/src/vespa/vsm/vsm/slimefieldwriter.cpp @@ -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()); |