0

I have a query that produces an LRS SDO_GEOMETRY as WKT (Oracle 18c):

select  
    SDO_UTIL.TO_WKTGEOMETRY(SDO_LRS.CONVERT_TO_LRS_GEOM(sdo_geometry('LINESTRING(1 2,3 4)'))) 
from
    dual

Output:
LINESTRING (1.0 2.0 0.0, 3.0 4.0 2.82842712474619)
          ^

That output isn't quite the format that I need. I need the WKT to indicate that the third dimension is M-values, not imply that the third dimension is Y-values:

LINESTRING M (1.0 2.0 0.0, 3.0 4.0 2.82842712474619)
           ^

How can I output a LRS SDO_GEOMETRY using the LINESTRING M format?

(Or the MULTILINESTRING M format, if the geometry is multi-part.)

1 Answer 1

0

I suppose I could use the REPLACE() function to replace LINESTRING ( with LINESTRING M (:

select
    replace(sdo_geom,   'LINESTRING (',   'LINESTRING M ('   ) as wkt_m
from
    (
    select  
        SDO_UTIL.TO_WKTGEOMETRY(SDO_LRS.CONVERT_TO_LRS_GEOM(sdo_geometry('LINESTRING(1 2,3 4)'))) as sdo_geom
    from
        dual
    )

Output:
LINESTRING M (1.0 2.0 0.0, 3.0 4.0 2.82842712474619)
           ^

It seems to work for multi-part LRS geometries too:

select
    replace(sdo_geom,   'LINESTRING (',   'LINESTRING M ('   ) as wkt_m
from
    (
    select  
        SDO_UTIL.TO_WKTGEOMETRY(SDO_LRS.CONVERT_TO_LRS_GEOM(sdo_geometry('MULTILINESTRING ((1 2,3 4),(5 6,7 8))'))) as sdo_geom
    from
        dual
    )

MULTILINESTRING M ((1.0 2.0 0.0, 3.0 4.0 2.82842712474619), (5.0 6.0 2.82842712474619, 7.0 8.0 5.65685424949238))
^^^^^           ^   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.