Correct way to programmatically add cartographic polygons


I’m trying to create cartographic polygons programmatically at runtime and I’m struggling with getting the spline point coordinates right.

I’m mimicking what the quick add panel does in the editor and I’m doing the following:

  1. Spawn a ACesiumCartographicPolygon actor with the same transform as the georeference
  2. Parent the new actor to the georeference
  3. Set the spline points on the polygon

I have my target spline points in latlongs and I’d like to set these on the polygon so they end up in the correct location, but regardless of what transforms I try I just can’t seem to get the right result. I was hoping using the georeference to convert from latlongs to unreal position and setting the points in World space would work, but it seems it doesn’t matter if I set the spline points in Local or World space, so I feel like I’m missing some transformation behind the scenes.

Any chance someone can point me in the right direction?

Hi, I recently had a similar problem. See the screenshots below for my blueprints. (the initial inspiration came from this post (Can Exclusion Zones Be Updated at Runtime? - #3 by janine)

The cube is a static mesh actor I place in the world and with the local bounds I’m calculating the four corners of a square. I’m using local Unreal locations. Neither world location nor lat/long.
The actor I call Get Actor Transform on is the parent of the Cube mesh.

The order of elements in the Spline Points array caused me some confusion so maybe look into that as well.

Afterwards I’m getting the CesiumPolygonRasterOverlay component from the Cesium3DTileset that’s placed in the level and I add the previously spawned CartographicPolygon to the Polygons array.

Oh and if you plan on removing the polygon during runtime as well and you run into issues there, maybe check out my thread where I dealt with this problem :smiley:

Hey if this helps you.
We’d set it up like this:

After this we loop we loop trough all tilesets witht the RefreshTileset function to update the cut-areas.

Thank you both, but this isn’t my problem. I can add the polygons just fine. What I struggle with is specifically using latlongs for the spline points and have them placed at the correct location in the unreal world.

Well jeez, I had a silly bug. I assumed latitude, longitude, height but it’s actually longitude, latitude, height in the FVector3. Everything seems to work as expected now.

Ah, yes I’ve run into that one as well some time ago :smiley: