I have one 3D polygon and one 2D polygon. I know that 2D polygon is inside 3D polygon (when projected on the plane) and I want to find Z-coordinate for 2D polygon points. The idea is to apply triangulation and get Z coordinate value from 3D polygon.
Here is my code:
def getZAtInteraction(threeDPolygon: Geometry, twoDPolygon: Geometry): List[Long] = {
val builder = new ConformingDelaunayTriangulationBuilder()
//builder.setTolerance(0.0000001D) ???
builder.setSites(threeDPolygon)
twoDPolygon.getCoordinates.toList.map { coordinate =>
builder.getSubdivision.locate(coordinate).dest().getZ.toLong
}
Sometimes I get exception
com.vividsolutions.jts.triangulate.quadedge.LocateFailureException: Locate failed to converge (at edge: LINESTRING( XXX1.97904355 YYY1.35001210000007, XXX2.9790435 YYY2.3499198)). Possible causes include invalid Subdivision topology or very close sites
Google suggests to set tolerance ConformingDelaunayTriangulationBuilder
Is it good suggestion?
What is the right way to estimate tolerance?