Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to merge (lanelet::ConstLanelets& road_lanelets)into a boost::geometry polygon? It's extremely urgent. Please help me. #374

Open
0116lhc opened this issue Dec 3, 2024 · 2 comments

Comments

@0116lhc
Copy link

0116lhc commented Dec 3, 2024

I need to use a vector map to filter the point cloud. Since the map is divided into many segments, the efficiency is a bit low. I want to merge all the small segments into a boost::geometry polygon. However, I've searched through the code but couldn't find any relevant examples, which is really frustrating. My code is as follows. I'm asking for your help. Mainly, please tell me how to obtain the coordinates x and y from road_lanelets[0].polygon2d().basicPolygon() so that I can convert them into the boost::geometry polygon format. Thank you in advance.

Polygon Lanelet2MapFilterComponent::getPolygons(lanelet::ConstLanelets & road_lanelets) { Polygon resultPolygon; lanelet::BasicPolygon2d temp_polygon = road_lanelets[0].polygon2d().basicPolygon(); // TODO: change to boost::geometry::polygon // int size = road_lanelets.size(); // for (int i = 1; i < size; ++i) { // boost::geometry::union_(temp_polygon, road_lanelets[i].polygon2d().basicPolygon(), resultPolygon); // } return resultPolygon; }

@immel-f
Copy link
Contributor

immel-f commented Dec 4, 2024

A lanelet basic polygon is in essence a std::vector of Eigen vectors that is also already registered with boost geometry as a ring. That may already work with boost::geometry::_union, but I am not too sure as that is more related to boost and less to Lanelet2.

@0116lhc
Copy link
Author

0116lhc commented Dec 5, 2024

I'm really grateful for your reply. Mainly, I want to know how to obtain the x and y coordinates of each point of the lanelet::BasicPolygon2d type. In this way, I can get the coordinates of each point and convert them into boost::geometry::polygon. Could you please help me test how to obtain the coordinates of the points in an object of the lanelet::BasicPolygon2d type? I've actually tried it myself, but I don't know how to operate it, so I'm coming here to ask for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants