I have a problem drawing an ellipse in PostGIS and 4326 system.
My parameters are:
"geography" : {"type":"Ellipse",
"smallSide":100,
"bigSide" : 110,
"rotation" : 0,
"coordinates":[8.54736328125,46.37156925087649]}
Searching on web (stack overflow) I came up to a solution that is close to my request but I have some problem with Scale and Translate.
ST_AsEWKT(ST_Translate( ST_Rotate( ST_Scale( ST_Buffer(ST_Point(8.54736328125,46.37156925087649)::geography, 3000)::geometry, 0.3,0.5)::geometry, 0), 8.54736328125,46.37156925087649))
The center is set in Switzerland.
This function has 2 big problem: 1. The Ellipse is not centered in the original coords; 2. I don't know how to convert xFactor/yFactor of Scale to match meters parameters;
I've tried to split the function to check where the problem starts:
If you stop to the circle, it works perfecly:
ST_Buffer(ST_Point(8.54736328125,46.37156925087649)::geography, 3000)::geometry
Than there is the ST_SCALE. This function will shrink the circle to create an ellipse.
It accepts a geometry and a couple of "factor" (xFactor and yFactor).
If you launch it with 1,1, you get the same circle.
select ST_AsEWKT( ST_Scale( ST_Buffer(ST_Point(8.54736328125,46.37156925087649)::geography, 3000)::geometry, 1,1)::geometry);
If you change the "factors" (for example 0,3 and 0.5), you get an ellipse but its completely translated (in Niger, Africa).
The original function has a translate after the scale to move back the shape to the original point. I don't know why but using original center coords, I get an Ellipse in Sweden:
select ST_AsEWKT(ST_Translate( ST_Rotate( ST_Scale( ST_Buffer(ST_Point(8.54736328125,46.37156925087649)::geography, 3000)::geometry, 0.5,0.3)::geometry, 0), 8.54736328125,46.37156925087649));
I think is a problem about projection and Referring System (the ellipse in sweden is cleary smaller) but im too noobs to understand where to fix.



