Skip to content

Commit 73381af

Browse files
committed
Add spatil c++ example
1 parent afb9cbd commit 73381af

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

examples/advanced.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ std::string MgValueToString(const mg::ConstValue &value) {
2121
value_str = std::to_string(value.ValueBool());
2222
} else if (value.type() == mg::Value::Type::Double) {
2323
value_str = std::to_string(value.ValueDouble());
24+
} else if (value.type() == mg::Value::Type::Point2d) {
25+
auto point2d = value.ValuePoint2d();
26+
value_str += "Point2D({ srid:" + std::to_string(point2d.srid()) +
27+
", x:" + std::to_string(point2d.x()) +
28+
", y:" + std::to_string(point2d.y()) + " })";
29+
} else if (value.type() == mg::Value::Type::Point3d) {
30+
auto point3d = value.ValuePoint3d();
31+
value_str += "Point3D({ srid:" + std::to_string(point3d.srid()) +
32+
", x:" + std::to_string(point3d.x()) +
33+
", y:" + std::to_string(point3d.y()) +
34+
", z:" + std::to_string(point3d.z()) + " })";
2435
} else if (value.type() == mg::Value::Type::List) {
2536
value_str += "[";
2637
for (auto item : value.ValueList()) {
@@ -63,7 +74,9 @@ int main(int argc, char *argv[]) {
6374

6475
if (!client->Execute(
6576
"CREATE (:Person:Entrepreneur {id: 0, age: 40, name: 'John', "
66-
"isStudent: false, score: 5.0});")) {
77+
"isStudent: false, score: 5.0, "
78+
"position2D: point({x: 1, y: 2, srid: 4326}), "
79+
"position3D: point({x: 8, y: 9, z: 10, srid: 9757}) });")) {
6780
std::cerr << "Failed to add data." << std::endl;
6881
return 1;
6982
}

0 commit comments

Comments
 (0)