3

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]}

enter image description here

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

enter image description here

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).

enter image description here

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));

enter image description here

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.

underdark
  • 84,148
  • 21
  • 231
  • 413
EviSvil
  • 147
  • 4
  • ST_Translate uses delta values, not the absolute ones. That means you're moving it by 8.54736328125, not to 8.54736328125. – Michal Zimmermann Jun 12 '18 at 10:20
  • You have used 4326 and 4623 interchangeably in your question, and don't seem to have used either in construction. You *can't* convert degrees and meters. It appears you need to construct the ellipse as a circle centered on your point with a custom projection, scale it, rotate it, then deproject. – Vince Jun 12 '18 at 10:24
  • 1
  • 1
    The post is the original post where I got the function but as you can see, it doesn't work as it is. – EviSvil Jun 12 '18 at 12:46
  • 1
    @Vince The referring system is 4326 (the other was a type error). Im trying to figure out but Scale and translate change the referring system. I have tried to create a circle in 0,0 and than translate (without scale it) to my center and it became an ellipse due to distortion. I don't know how to solve it. – EviSvil Jun 12 '18 at 13:27

0 Answers0