Making ellipse geometry from some known parameters using PostGIS?

How to create an ellipse geometry with postgis from known axis coordinates and peak radius ?

From picture below :

Point A and Point B is known lat/lon

R is a known result of fresnelZone calculation (in Meters).

Yes I read this and this (using shapely instead of Postgis), but I don't know how to implement/adopt it to my need.

I would go with CIRCULARSTRING. You already know the coordinates of start point and end point, and the coordinates for the peak radius can be easily calculated.

Thus, the half of your desired ellipse could be represented as

``````CIRCULARSTRING(StartPointX StartPointY, PeakRadiusX PeakRadiusY, EndPointX EndPointY)
``````

The other half being the same with negative values of peak radius

``````    CIRCULARSTRING(StartPointX StartPointY, -PeakRadiusX -PeakRadiusY, EndPointX EndPointY)
``````

Union those two halfs and you should have your ellipse complete.

• the united geometry will be a linestring not a (multi-)polygon? Commented Jul 20, 2017 at 7:47
• dear @michal-zimmermann, and how to calculate that PeakRadius (positive and negative) ? I can calculate that X point using SELECT ST_AsText(ST_Centroid('LINESTRING(StartY StartX, EndY EndX)')) Commented Jul 20, 2017 at 7:58
• @LaughU I thing the compound will be polygon, using CURVEPOLYGON(CIRCULARSTRING(StartY, StartX, PeakY, PeakX, EndY EndX),(StartY, StartX, -PeakY, -PeakX, EndY EndX)) Commented Jul 20, 2017 at 8:07
• @BinoOetomo if you know the `R`, just add it to the StartY value. Commented Jul 20, 2017 at 10:52
• @michal-zimmerann thankyou for your response. I think I got the picture. Your answer inspire me, but not directly solve my question. Should I mark it as solved ? I think pseudo code will be : 1. Get centroid poin of AB--> cp 2. Get Bearing of AB --> b0 3. count b0 + 90 --> b1 4. count b0 - 90 --> b2 5. make point using cp, distance (fz), b1 --> peak1 ( use ST_Project) 6. make point using cp, distance (fz), b2 --> peak2 ( use ST_Project) 7. curve polygon ( circular string (A peak1 B),(A peak2 B) Commented Jul 20, 2017 at 13:47