javaoptimizationjtsset-union

Union geometries faster in JTS?


I wrote code to join (union) geometries. I wrapped it into Java8 streams Collector. Inside it it just uses Geometry#union to union geometries:

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

Unfortunately, it works rather slow.

Is it possible to make it faster with some usage of prepared geometry or some other hacks?

UPDATE

Geometries are like this:enter image description here

and they are of very different scales.


Solution

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