greiner-hormann icon indicating copy to clipboard operation
greiner-hormann copied to clipboard

optimize decomposing clip calls

Open tcql opened this issue 10 years ago • 2 comments
trafficstars

Because clipping with GH means decomposing to pairwise clip calls, there's a lot of looping and array modification in some of the operations. This can result in very slow operations when you have complex inputs, such as very large multipolygons.

I think we could optimize this a lot by doing some checks before looping over and clipping shapes multiple times. For instance, I think we could detect whether two shapes are touching in advance, and maybe even keep an internal index of shape relationships internally so consecutive internal GH calls won't have to do lots of useless legwork.

tcql avatar May 06 '15 20:05 tcql

Looking at the code, I think the biggest optimization you can make is getting rid of pretty much ALL array cloning, slicing and splicing. Given that you convert arrays to linked lists in the GH call itself, you can refactor the code in such a way so that you convert rings once outside and then operate them without the need to do needless copy of data.

mourner avatar May 11 '15 08:05 mourner

:+1: I was just talking to @morganherlocker about this the other day. I'm also pretty sure that in the current state, cloning is not necessary for most of the operations anyway, so this should definitely clean stuff up & give some perf boost

tcql avatar May 11 '15 11:05 tcql