Polygon Pre-Processing [Sub Division and Triangulation] is not performant with polygons having coordinates > 200k

92 Views Asked by At

I have some polygons that are quite big like having coordinates greater than 200k for those I have subdivided them into smaller pieces like this. (it was suggestion)

But still, some of the subdivided polygons have coordinates greater than 10k so for that I have used the triangulation like this.

DelaunayTriangulationBuilder delaunayTriangulationBuilder =
            new DelaunayTriangulationBuilder();
delaunayTriangulationBuilder.setSites(dividedPieceOfGeometry);
Geometry triangles = delaunayTriangulationBuilder.getTriangles(geometryFactory);
IntStream.range(0, triangles.getNumGeometries())
        .parallel()
        .mapToObj(triangles::getGeometryN)
        .map(geometryN -> geometryN.intersection(dividedPieceOfGeometry))
        .flatMap(
            possibleGeometryCollection -> {
              List<Geometry> collectedGeometries = new ArrayList<>();
              filterFromPossibleGeometries(possibleGeometryCollection, collectedGeometries); //this just extracts the geometries out of GeometryCollection
              return collectedGeometries.stream();
            })
        .toList()

Now this whole process is quite time-consuming, and I wanted to improve the performance of this pre-processing.

I am using the JTS Topology Suite to implement this functionality.

Sample Polygon: This particular polygon has 6 million points in it.

Sample Polygon

0

There are 0 best solutions below