Hi everyone,

Within my automated pipeline, I've developed a method that calculate and set the smallest bounding box which included a "project contour" polygon.

The calculation has been separated in 3 steps :

- Set the bounding box center

- Set the bounding box size

- Set the bounding box orientation

Everything works very fine until today ... when I decided to include coordinates system in my pipeline.

Indeed, in "Local Coordinates" (*'LOCAL_CS["Local Coordinates",LOCAL_DATUM["Local Datum",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]'*), everything is OK,

but when I use projected coordinates system (For exemple EPSG::3946 in France), the box orientation doesn't work anymore (Center and size are OK !)...

Here is the following code for bounding box orientation setting (Where vertex_a / vertex_b / vertex_c are the corners of my minimum rotated rectangle that include my polygon) :

` cos_teta = (vertex_c.x - vertex_a.x) / vertex_a.distance(vertex_c)`

sin_teta = (vertex_c.y - vertex_a.y) / vertex_a.distance(vertex_c)

__pseudo_region.rot = [[sin_teta, -cos_teta, 0],

[cos_teta, sin_teta, 0],

[0, 0, 1]]

chunk.region.rot = chunk.transform.matrix.rotation().inv() * __pseudo_region.rot

After some investigation, my pseudo_region hasn't changed, so the problem is coming from the chunk rotation matrix (*chunk.transform.matrix.rotation()*).

I cannot understand how chunk.crs has inlfuenced the chunk.transform matrix... and have no idea how to fix the problem...

Regards