0

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?

1 Answer 1

0

So... actually data it self is the root cause of the problem. Doesn't seem to be surprising. One of polygons have area 10 square centimeters. The other one is 100 meters. The small one is placed right on the edge of the big one. I've cleaned up my data and now it works like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.