Get Geometry of Polygon Clip with Terrain for Flood Water Simulation

I am trying to intersect polygon A with the terrain to create a new polygon (polygon B). Polygon A is a geojson cesium ion asset which covers my entire area of interest as shown below:

floood

I am altering the height of polygon A to simulate flood water level as shown below. The parts of polygon A that appear above the terrain (TerrainProvider is a DEM geotif cesium ion asset) are shown in semi-transparent blue:

Using JS code Is there a way to get the latitude and longitude point geometry (or anything else) of the intersection between the parts of polygon A above the terrain and the terrain itself so I can create a new polygon (polygon B).

Thank you for any help!

I’ve created a webpack application and am also using the turf.js library.

I think I have a work flow idea:

  1. For example, my flood height is 10 m
  2. Make a duplicate of polygon A, convert from Cartographic to Degrees to get latitude and longitude, and then append my desired 10 m height as a third parameter.
  3. Convert back to Cartographic, and at 10m height on terrain, get corresponding xy coords using Cesium.sampleTerrainMostDetailed.
  4. Convert these xy coords back to Degrees and then create a turf.polygon.
  5. Add to viewer and adjust height visualisation to check the geometry.

Any thoughts? Does these seem plausible?