Faster connection geometry in JTS?

I wrote some code to combine (join) geometry. I wrapped it in Java8 Collector threads . Internally, it just uses the Geometry # union to combine the geometry:

geometries[0] = geometries[0].union(geometry);

      

Unfortunately, it is rather slow.

Can this be done faster with some use of prepared geometry or some other hacks?

UPDATE

The geometry is as follows: enter image description here

and they have very different scales.

+3


source to share


2 answers


Consider using a unified join. See http://bjornharrtell.github.io/jsts/1.2.1/apidocs/org/locationtech/jts/operation/union/UnaryUnionOp.html



+1


source


Your stated approach will be slow as it concatenates each geometry sequentially into a result that will probably get bigger and bigger with each merge.

The Unary union uses a spatial index to group geometries and combine them hierarchically for better performance. Unfortunately, this may not work with the sequential nature of Java streams.



PreparedGeometry does not offer any acceleration for overlay operations such as union.

+1


source







All Articles