fzi-forschungszentrum-informatik / Lanelet2

Map handling framework for automated driving
BSD 3-Clause "New" or "Revised" License
793 stars 325 forks source link

[Question] lanelet2.geometry.findNearest functionality #142

Closed vadeshah closed 4 years ago

vadeshah commented 4 years ago

Posted this as a comment here, but wasn't sure if it would get picked up because the original issue had been marked as Closed.

I've been using the findNearest function as well with the same intent that @cbrewitt had mentioned above. I was confused about the "count" parameter and how exactly it worked. The description in the code, which I've copied below, was difficult for me to understand. If you could provide a more detailed explanation on what the "count" parameter specifies, I would greatly appreciate it.

// Idea: nearestUntil passes us elements with increasing bounding box // distance. // If this distance is greater than the actual distance (between primitives) // of the count-th furthest current element, then we can stop, because all // succeding elements will be even further away.

When I run findNearest with count=1 for a predefined Point2d that lies in my .osm map, sometimes I get 6 or more lanelets from findNearest. These lanelets are adjacent, but it is not the case that they all share an overlapping region in which my point lies. Is there any way to only get the lanelet(s) that the point lies in? Thank you in advance for your help.

poggenhans commented 4 years ago

Thanks for reporting this. You actually found a bug in the findNearest implementation that caused it to return more values than requested under some circumstances. We'll fix that soon.

The cause is that suboptimal primitives are not removed from the result as they should be, so the first count elements returned are the correct result, but the remaining elements are garbage.

Regarding your question: findNearest is supposed to return the count nearest elements, no matter how far they are. If you are interested in the lanelets that contain your point, lanelet2.geometry.findWithin2d is the better match.

vadeshah commented 4 years ago

Thanks so much!