I'd like to store a GML ArcByCenterPoint in PostGIS. I can work out the start, middle and end points required by the
CIRCULARSTRING type and all seems to be OK, except that when I visualise the arc it does not fit the circle that it's supposed to be part of.
Data (in lon/lat format):
Circle centre point: 29.59444 40.26333 Radius: 18 NM (27780 M) Arc start point: 29.89250 40.36667 Arc end point: 29.27528 40.31667 Arc middle points: 29.560000 40.511667 (counter-clockwise) 29.628611 40.015000 (clockwise)
SQL statements to insert the geometries. Note that I'm using
ST_CurveToLine here, because I don't know of anything that can visualise a
-- The arcs going both ways between the same start and end points INSERT INTO test (test) VALUES (ST_SetSRID(ST_CurveToLine('CIRCULARSTRING(29.8925 40.36667,29.560000 40.511667,29.27528 40.31667)'), 4326)); INSERT INTO test (test) VALUES (ST_SetSRID(ST_CurveToLine('CIRCULARSTRING(29.8925 40.36667,29.628611 40.015000,29.27528 40.31667)'), 4326)); -- The full circle INSERT INTO test (test) VALUES (ST_Buffer(ST_GeogFromText('POINT(29.59444 40.26333)'), 15 * 1852)::geometry);
Here is what the result looks like in Google Earth:
The arcs are in red and the lines from the center point to the start and end points are in blue. The arcs do touch the circle at 3 points, so it would appear that the coordinates were calculated correctly (or at least close). But the shape of both arcs is wrong - as you can see, they don't quite follow the circle.
Can anyone suggest what's going wrong here? Is either the
CIRCULARSTRING type or the
ST_CurveToLine function not doing what I expect? I'd love to take
ST_CurveToLine out of the equation and visualise the
CIRCULARSTRING directly, but I don't know of any way to do that.
Edit: I finally gave up on this approach and approximated the arc in a different way: Storing GML surface in PostGIS