CascadedPolygonUnion performance

60 views
Skip to first unread message

Marco

unread,
Nov 27, 2011, 8:53:30 AM11/27/11
to NetTopologySuite
Hi

In my current project I have to merge (union) a few thousands
polygons. As this is not a trivial task the process needs usually
around 2 minutes for the whole union. Inquiries to speed up the
processing have led me to Paul Ramseys blog:
http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html

He is describing there a fast way to union polygons with the help of
an STR-Tree. Is the current implementation of CascadedPolygonUnion in
NTS 1.x and 2.x based on a similar algorithm or is there a chance to
improve this function?

Im currently using NTS 1.x. Please let me know if there would be
already a performance increase in CascadedPolygonUnion of NTS 2.x

Thanks a lot,
Marco

FObermaier

unread,
Nov 28, 2011, 7:51:20 AM11/28/11
to NetTopologySuite
That is the implementation. IIRC there is an option to use multiple
threads, you may want to try that.
I personally doubt that the v2 implementation is any faster than the
v1 implementation, since it works on interfaces only which prevents
inlining.

Hth FObermaier

On Nov 27, 2:53 pm, Marco <ruf...@gmail.com> wrote:
> Hi
>
> In my current project I have to merge (union) a few thousands
> polygons. As this is not a trivial task the process needs usually
> around 2 minutes for the whole union. Inquiries to speed up the

> processing have led me to Paul Ramseys blog:http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-1...

Diego Guidi

unread,
Nov 28, 2011, 9:09:46 AM11/28/11
to nettopol...@googlegroups.com
> That is the implementation. IIRC there is an option to use multiple
> threads, you may want to try that.
here the issue list:
http://code.google.com/p/nettopologysuite/issues/detail?id=44
maybe can be useful to retrieve other info

Marco Birchler

unread,
Nov 30, 2011, 8:55:51 AM11/30/11
to nettopol...@googlegroups.com
Thanks for your response.

FObermaier and Diego, you wrote that there is an OPTION to use
multiple threads. Is the code not using multiple threads by default? I
did a review of your code but could not figure it out. Can you please
tell me how to enable multithreading if it isn't already?


2011/11/28 Diego Guidi <diego...@gmail.com>

> --
> You received this message because you are subscribed to the Google Groups "NetTopologySuite" group.
> To post to this group, send email to nettopol...@googlegroups.com.
> To unsubscribe from this group, send email to nettopologysui...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nettopologysuite?hl=en.
>

Diego Guidi

unread,
Nov 30, 2011, 9:13:31 AM11/30/11
to nettopol...@googlegroups.com
> how to enable multithreading if it isn't already?
talking about the trunk (NTS 1.X), the code isn't multithreading "as
is": it's up to you to split your code in "pieces" to call
asynchronously, actually, not an easy task to do.
Beware: NTS "should be" thread-safe, but as example a bug was found
yesterday: http://code.google.com/p/nettopologysuite/issues/detail?id=102

FObermaier

unread,
Dec 1, 2011, 4:42:41 AM12/1/11
to NetTopologySuite
You are right Marco, the algorithm creates worker threads for the
actual unioning of the geometries.
If you feel the algorithm is too slow, please raise an issue and
provide your sample geometries, so we can profile,
FObermaier

On Nov 30, 2:55 pm, Marco Birchler <ruf...@gmail.com> wrote:
> Thanks for your response.
>
> FObermaier and Diego, you wrote that there is an OPTION to use
> multiple threads. Is the code not using multiple threads by default? I
> did a review of your code but could not figure it out. Can you please
> tell me how to enable multithreading if it isn't already?
>

> 2011/11/28 Diego Guidi <diegogu...@gmail.com>

Diego Guidi

unread,
Dec 1, 2011, 4:50:15 AM12/1/11
to nettopol...@googlegroups.com
> talking about the trunk (NTS 1.X), the code isn't multithreading "as
> is": it's up to you to split your code in "pieces" to call
> asynchronously, actually, not an easy task to do.

Of course, CascadedPolygonUnion does actually this thing: split the
code in "pieces" that are called in different threads. Maybe it's time
to know better the code that I suppose to already know.
Sorry fot the mistake, forget my answer.

Reply all
Reply to author
Forward
0 new messages