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

Faster polygon iterator? #213

Open
snieh opened this issue Apr 23, 2019 · 1 comment
Open

Faster polygon iterator? #213

snieh opened this issue Apr 23, 2019 · 1 comment

Comments

@snieh
Copy link

@snieh snieh commented Apr 23, 2019

Is there a way to run the polygon iterator faster?
My grid_map has a size of 200x200 with resolution of 0.25, which is quite big (640.000 cells) and a even bigger polygon which intersects the gird_map. Around about 50.000 cells inside the polygon of the grid_map (globalMap) then need to be set to an value, which requires often up to 3 seconds...

for (grid_map::PolygonIterator iterator(globalMap, polygon); !iterator.isPastEnd(); ++iterator) {
globalMap.at("test", *iterator) = 0.0;
}

//Also tried this way, which needs same computation time:
auto& data_to = globalMap["test"];
for (grid_map::PolygonIterator iterator(globalMap, polygon); !iterator.isPastEnd(); ++iterator) {
float& value_to = data_to( (*iterator)[0] , (*iterator)[1] );
value_to = 0.0;
}

Any suggestions? Thanks in advance.

@zoojing
Copy link

@zoojing zoojing commented Jun 8, 2019

The provided iterator would call function is_Inside for each cell to judge if it is out of range. however, is_inside has O(n^2) complexity, which means the polygon iterator has O(n^3) complexity.
In my opinion, diy polygon scan or use bfs would be a nice idea.
Ps: the index return from get_index is not a normal sequence when you move the grid map.
Good Luck!

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.