To reverse the order of the vertices within the CIRCULARSTRING I would suggest to use ST_Reverse, but it actually doesn't work with CIRCULARSTRING: it returns no error, but returns the original geometry unaltered.
Therefore, I suggest this workaround:
- Convert the geometry to text - ST_AsText
- Replace the CIRCULARSTRING for LINESTRING in the WKT of the geometry
- Create a LINESTRING from the text - ST_GeomFromText
- Reverse the LINESTRING - ST_Reverse
- Convert the resulting geometry to text - ST_AsText
- Replace the LINESTRING for CIRCULARSTRING in the WKT of the geometry
- Create a CIRCULARSTRING from the text - ST_GeomFromText
Here's the sample code:
WITH t AS
(
SELECT ST_GeomFromText('CIRCULARSTRING(5 2,-3 1.999999, -2 1, -4 2, 5 2)') AS geom
)
SELECT
ST_AsText(
ST_GeomFromText(
REPLACE(ST_AsText(
ST_Reverse(
ST_GeomFromText(REPLACE(ST_AsText(geom), 'CIRCULARSTRING', 'LINESTRING'))
)
), 'LINESTRING', 'CIRCULARSTRING')
)
)
FROM t
Result from the query above: "CIRCULARSTRING(5 2,-4 2,-2 1,-3 1.999999,5 2)"
ST_LineInterpolatePoint
returns a point geometry at a given fraction of linelength. do you have centroids of those circles? it might be easier to reconstruct the circle with the boundary of a buffer and rotate that.ST_LineToCurve
/ST_CurveToLine
!