[GIS] How to convert a compound geometry (Oracle) to a geometry made of straight line segments only

geometry-conversionoracle-spatial

I have an Oracle Spatial table containing compound geometries (i.e. geometries containing both straight lines segments and arcs) that I want to project in another reference system.

Using SDO_CS.TRANSFORM returns:

13294. 00000 -  "cannot transform geometry containing circular arcs"
*Cause:    It is impossible to transform a 3-point representation of
           a circular arc without distortion.
*Action:   Make sure a geometry does not contain circular arcs.

Is there a way to convert the arcs to straight lines with a SQL request?

I've read Converting arcs to straight line segments? which mentions using FME or ArcGIS Desktop to do the conversion but I don't have access to such tools. What I am looking for is a way to do that only with Oracle Spatial (I do not care if the resulting segments are raw approximations of the original geometries).

Best Answer

The function that converts arc into straight segments is SDO_GEOM.SDO_ARC_DENSIFY. Documentation for Oracle 12c is at http://docs.oracle.com/database/121/SPATL/GUID-97E8BF76-34B8-48CA-94A4-96F16B01B60C.htm#SPATL1108

There are two formats for the function

SDO_GEOM.SDO_ARC_DENSIFY(     
  geom    IN SDO_GEOMETRY,      
  dim     IN SDO_DIM_ARRAY       
  params  IN VARCHAR2      
) RETURN SDO_GEOMETRY;

or

SDO_GEOM.SDO_ARC_DENSIFY(
  geom    IN SDO_GEOMETRY,      
  tol     IN NUMBER       
  params  IN VARCHAR2      
) RETURN SDO_GEOMETRY;

Diminfo is rather painful to write by hand and therefore the latter format suits better for ad hoc queries.

An usage example with tolerance=0.1 (vertices which are closer that 0.1 meter from each other are considered to be in the same place) and arc_tolerance of 50 m (at maximum 50 meters shift is accepted due to conversion of curve into polyline)

SDO_GEOM.SDO_ARC_DENSIFY(GEOMETRIE, 0.1, 'arc_tolerance=0.05 unit=km')