[postgis-users] Converting a LineString to a CompoundCurve

Sandro Santilli strk at kbt.io
Fri Oct 7 02:28:15 PDT 2016


On Fri, Oct 07, 2016 at 09:12:18AM +0200, Andreas Neumann wrote:
> Hi,
> 
> I am trying to convert a LineString to a CompoundCurve.
> 
> I was trying ST_LineToCurve(), but it seems to return again a LineString ;-(
> 
> Casting with ::geometry(CompoundCurve,21781) doesn't work either.
> 
> Is this impossible to do or did I miss something?

ST_LineToCurve was probably unable to find a curve
(you may want to file a ticket for this if you think it should have done it).

In that case, it usually puts the result as a straight line
inside a COMPOUNDCURVE (a collection) - but as a final step,
if the output collection has a single element that element
is returned instead of the collection, so you end up with a simple
line (it's opinable if this is a good or bad idea).

> The reason I want to do it, is that I have some road data which is in
> CompoundCurve type. I want to use ST_LineStubstring() on this geometry, so I
> use ST_CurveToLine(). I want to convert the result back into a
> CompoundCurve, for being able to store it in a table which has a constraint
> on CompoundCurve type.

You can get back to the COMPOUND by using ST_ForceCurve (new in 2.2.0).

--strk;



More information about the postgis-users mailing list