I create circle geometries server side on a PostGIS database like this.
UPDATE element
SET geo = ST_Buffer(
ST_MakePoint(6.1043443253471, 42.3150676015829), 6, 'quad_segs=8')
WHERE id = 1;
I then fetch the WKT to be sent to openlayers on the client browser.
SELECT ST_AsText(geo) from element where id = 1
The problem is that the circle is displayed as an ellipsis on map like here
It is probably related to projection, but I don't understand how I could create this circle server side so that it appears as a real circle on map.
Can you help me on this? Thanks in advance.
Yes, it is the projection, as a degree of longitude does not have the same ground length, in meters, as a degree of latitude.
That being said, the picture and the sample code don't not match, as the code instructs to create a 6 degrees wide buffer, which is +- 600km, and the point is in the Mediterranean sea instead of a backyard (maybe X and Y were swapped?).
To overcome this, you can pick a local CRS that preserve distances, such as UTM.
Alternatively, you can create the buffer using geography, which has a unit in meters by default, then cast back to geometry.
select ST_Buffer(
ST_MakePoint(6.1043443253471, 42.3150676015829)::geography,
6, 'quad_segs=8'
)::geometry
WHERE id = 1;