From 7ee3f30ea1a425cc8e4379616d7ffd415b9dbb62 Mon Sep 17 00:00:00 2001 From: johannes-fischer <42044738+johannes-fischer@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:09:29 +0200 Subject: [PATCH] Add/fix python repr interface for 2d lines/points (#348) * Add/fix python repr interface for 2d lines/points * Remove whitespace --------- Co-authored-by: poggenhans --- lanelet2_python/python_api/core.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lanelet2_python/python_api/core.cpp b/lanelet2_python/python_api/core.cpp index 1e8a0ce1..54faea85 100644 --- a/lanelet2_python/python_api/core.cpp +++ b/lanelet2_python/python_api/core.cpp @@ -665,7 +665,7 @@ BOOST_PYTHON_MODULE(PYTHON_API_MODULE_NAME) { // NOLINT to_python_converter(); to_python_converter(); to_python_converter(); - + implicitly_convertible(); implicitly_convertible(); implicitly_convertible(); @@ -700,6 +700,8 @@ BOOST_PYTHON_MODULE(PYTHON_API_MODULE_NAME) { // NOLINT .def(IsConstPrimitive()) .add_property("x", getXWrapper, "x coordinate") .add_property("y", getYWrapper, "y coordinate") + .def( + "__repr__", +[](const ConstPoint2d& p) { return makeRepr("ConstPoint2d", p.id(), p.x(), p.y(), repr(p.attributes())); }) .def("basicPoint", &ConstPoint2d::basicPoint, return_internal_reference<>(), "Returns a plain 2D point primitive (no ID, no attributes) for efficient geometry operations"); class_>( @@ -796,8 +798,8 @@ BOOST_PYTHON_MODULE(PYTHON_API_MODULE_NAME) { // NOLINT "returned in reversed order") .def( "__repr__", - +[](const ConstLineString3d& ls) { - return makeRepr("LineString3d", ls.id(), repr(list(ls)), repr(ls.attributes())); + +[](const LineString2d& ls) { + return makeRepr("LineString2d", ls.id(), repr(list(ls)), repr(ls.attributes())); }) .def(IsLineString());