Converting a LineString to a CompoundCurve

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting a LineString to a CompoundCurve

Andreas Neumann-4
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?

----------------

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.

Thank you, if you have an idea!

Andreas

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting a LineString to a CompoundCurve

Sandro Santilli-4
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;

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting a LineString to a CompoundCurve

Andreas Neumann-4

Hi Strk,

Yes - ST_ForceCurve() - that's the function I was looking for. Thank you very much!

Thanks also for explaining, that ST_LineToCurve() falls back to LineString if it can't generate a curve.

Andreas

On 2016-10-07 11:28, Sandro Santilli wrote:

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;

 

 

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting a LineString to a CompoundCurve

Simon Greener
In reply to this post by Andreas Neumann-4
Andreas,

> 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?
>
> ----------------
>
> 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.
>
> Thank you, if you have an idea!

I've done some work on this in the past for customers. The function looks for triplets that form a circular arc and turn them into a circular linestring.

I can see if I can dig it up if someone else has not already helped you out.

Oh, like most things spatial, can you give us an example before/after (WKT)?

regards
Simon
--
Holder of "2011 Oracle Spatial Excellence Award for Education and Research."
SpatialDB Advice and Design, Solutions Architecture and Programming,
Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified Professional
Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio Specialist.
39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
Website: www.spatialdbadvisor.com
   Email: [hidden email]
   Voice: +61 362 396397
Mobile: +61 418 396391
Skype: sggreener
Longitude: 147.20515 (147° 12' 18" E)
Latitude: -43.01530 (43° 00' 55" S)
GeoHash: r22em9r98wg
NAC:W80CK 7SWP3
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting a LineString to a CompoundCurve

Andreas Neumann-4

Hi Simon,

Thank you. Strk already helped me. I was actually looking for ST_ForceCurve(), which is forcing my geometries into a CompoundCurve geometry, because my target table has a constraint on this geometry type. I don't care too much if the actual geometry is  a LineString or a CircularArc (for this particular case).

Thank you,

Andreas

On 2016-10-07 12:58, Simon Greener wrote:

Andreas,

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?

----------------

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.

Thank you, if you have an idea!

I've done some work on this in the past for customers. The function looks for triplets that form a circular arc and turn them into a circular linestring.

I can see if I can dig it up if someone else has not already helped you out.

Oh, like most things spatial, can you give us an example before/after (WKT)?

regards
Simon
-- 
Holder of "2011 Oracle Spatial Excellence Award for Education and Research."
SpatialDB Advice and Design, Solutions Architecture and Programming,
Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified Professional
Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio Specialist.
39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
Website: www.spatialdbadvisor.com
  Email: [hidden email]
  Voice: +61 362 396397
Mobile: +61 418 396391
Skype: sggreener
Longitude: 147.20515 (147° 12' 18" E)
Latitude: -43.01530 (43° 00' 55" S)
GeoHash: r22em9r98wg
NAC:W80CK 7SWP3
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users

 

 

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-users