2

I have a polygon described with coordinates which have z value.

Is there any JTS utility that would allow me to get Z value for a coordinate which is inside the polygon?

I have a function for doing it.

Does it look reasonable?

private def getMinMaxEvelation(geometryWithZ:Geometry, someTwoDimGeometry: Geometry) = {
    val builder = new ConformingDelaunayTriangulationBuilder()
    builder.setSites(geometryWithZ)

    val zValues = someTwoDimGeometry.getCoordinates.toList.map{ coord =>
      builder.getSubdivision.locate(coord).dest().getZ
    }
    Elevation(minZ = zValues.min.toInt, maxZ = zValues.max.toInt)

  }
3
  • If you want to get the min and max elevation of a 2D geometry inside a 3D geometry, your code seems correct. Sep 10, 2018 at 12:10
  • true, I want to get the min and max elevation of a 2D geometry inside a 3D geometry. Thank you!
    – Capacytron
    Sep 10, 2018 at 12:12
  • Sergey, add your own answer to the question and marked it as accepted. Thanks. ;) Sep 10, 2018 at 12:30

1 Answer 1

1

Here is the code snippet. People say it's good!

private def getMinMaxEvelation(geometryWithZ:Geometry, someTwoDimGeometry: Geometry) = {
    val builder = new ConformingDelaunayTriangulationBuilder()
    builder.setSites(geometryWithZ)

    val zValues = someTwoDimGeometry.getCoordinates.toList.map{ coord =>
      builder.getSubdivision.locate(coord).dest().getZ
    }
    Elevation(minZ = zValues.min.toInt, maxZ = zValues.max.toInt)
}

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.