Is there any code who fix intersection issue and overlapping of polygon?

Thank you,

Kind regards

To quote from a related answer:

I think that there is no â€śbuilt-inâ€ť functionality for that (to be confirmed by the CesiumJS core team). The reason for that may be that it raises a few question about the desired interaction and details of the behavior â€¦

Should you not be able to move the mouse into the other polygon? Should you just not be able to *click* inside this polygon? Which sorts of (self-) intersections should be allowed or not?

On top of the question about interaction, this is not entirely trivial on a *technical* level.

In 2D, polygon intersections are relatively simple, at least when you ignore performance and the inevietable difficulties that come with the limited floating point precision. For example, when you have a line from (0,0) to (3,1), then the point at (1,0.33333) should probably be considered to be *on* this line, but in mathematics and in reality, it isnâ€™tâ€¦

But here, we donâ€™t have a **2D** editor. All this is happening in 3D, and the points that you are placing are *on the surface of earth*. So when you have a â€śunit squareâ€ť with points like

```
(0.0, 0.0, 0.0)
(1.0, 0.0, 0.0)
(1.0, 1.0, 0.0)
(0.0, 1.0, 0.0)
```

Should you be able to set a point at (0.5, 0.5, 1.0)? Sure, when looking from above (as in the screenshot), then this point will appear to be â€śinsideâ€ť the square. But in fact, it will be *above* the square (because the square is at height `z=0.0`

, and the point is at height `z=1.0`

).

From what you described so far, it sounds like one could find a solution that is *roughly* as follows: The points are projected on a plane that represents the tangent plane at the given position. The mouse position is also projected on that tangent plane. Then, the intersection and overlap tests can be done in 2D, on that tangent plane, but Iâ€™m not sure whether this is a viable approachâ€¦

Maybe someone has a good idea for a simple solution here, but I think that (even more than in the previous thread), there are some caveats that depend on subtle details of the implementation, the expected behavior, and the intended interaction patterns.

EDIT: You might consider to actually switch the viewer into 2D mode with `viewer.scene.mode = Cesium.SceneMode.SCENE2D`

, and this *might* simplify things here. But I havenâ€™t used that extensively, and could not provide specific guidelines here.

1 Like