Java – Using 3D Intersection with JTS Topology Suite

javajts-topology-suite

Not sure this is the correct place to ask. I have no code to show, just wondering if this can be handled with JTS.

Is it possible to handle 3D intersections with JTS?
Given that we have two polygons, in this case with XYZ coordinates(coplanar and aligned).

Looking on different ways to split P1 into two polygons, one that is not covered by P2 and the other one that is covered by P2.

enter image description here

Best Answer

According to the JTS FAQ, this library does not allow the manipulation of 3D geometry :

4. Does JTS support 3D operations?

JTS does not provide support for true 3D Geometry and operations. However, JTS does allow Coordinates to carry an elevation or Z value. This does not provide true 3D support, but does allow "2.5D" uses which are required in some geospatial applications.

see https://locationtech.github.io/jts/jts-faq.html#B4

Personally, the only times I tried to do this kind of processing I ended up using the CGAL library. It is a library that is quite complicated to access, but it allows you to do all kinds of 3D operations. In your case you should refer to this part of the documentation : 3D Boolean Operations on Nef Polyhedra.

Note that there is an alternative kernel for PostGIS that allows you to do some 3D operations with CGAL (see SFCGAL functions). But only the simplest operations are possible, complex or specific treatments require a direct use of CGAL.

However, if all the geometries you want to process are coplanar and aligned, you can cheat. Reproject all geometries in a two-dimensional reference frame (e.g. X are plane length and Y the plan height) and do your processing in this reference frame.