WKT linestring to SDO_GEOMETRY:为什么有这么多空值?

WKT linestring to SDO_GEOMETRY: Why are there so many nulls?

我有一个众所周知的文本 (WKT) 线串,我想将其转换为 SDO_GEOMETRY:

select sdo_geometry(
    'LINESTRING(675939.0 4861635.0, 675881.8 4861589.9)' ,300001)  as sdo
from dual


SDO                                                                             
--------------------------------------------------------------------------------
SDO_GEOMETRY(2002,300001,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),MDSYS.SDO_OR
DINATE_ARRAY(675939,4861635,675881.8,4861589.9,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NUL
L,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL))                                

1 row selected.

为什么生成的 SDO_GEOMETRY 有这么多空值,可以避免吗?

我在

上试过了
select banner from v$version;

BANNER
----------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
PL/SQL Release 12.1.0.1.0 - Production
CORE    12.1.0.1.0  Production
TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
NLSRTL Version 12.1.0.1.0 - Production

如下:

with data as (
select sdo_geometry('LINESTRING(675939.0 4861635.0, 675881.8 4861589.9)' ,300001) as sdo
from dual
)
select sdo, sdo_util.GetNumVertices(sdo) numPoints, sdo_util.getNumElem(sdo) numElements
  from data;

SDO                NUMPOINTS NUMELEMENTS
------------------ ---------- -----------
SDO_GEOMETRY(2002,300001,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(675939,4861635,675881.8,4861589.9))  2           1

我正在使用 SQL 开发人员。

我试过你原来的 WKT 并得到了正确答案。

我拿了原始的 WKT 并这样做了:

with data as (
select SDO_GEOMETRY(2002,300001,NULL,
           SDO_ELEM_INFO_ARRAY(1,2,1),
           SDO_ORDINATE_ARRAY(
           675939.072782156,4861635.03887627, 675881.887546735,4861589.91445772,
           675879.176511937,4861586.04156585, 675877.955649557,4861580.51231971,
           675879.89623824, 4861575.48551016, 675976.967341076,4861477.69703032,
           675982.195781809,4861474.59875878, 675988.005161569,4861472.46858959,
           675994.20185149, 4861471.30679544, 676000.979396532,4861470.91948528,
           676006.788765802,4861471.30679544, 676011.629843934,4861472.27503414,
           676150.620431142,4861517.83428384)
       ) as geom
  from dual
)
select a.geom.Get_WKT(),a.geom.sdo_srid as srid
  from data a;

GET_WKT() 的转换失败:

Error report:
SQL Error: ORA-24323: value not allowed
ORA-06512: at "MDSYS.MDPRVT_SRID", line 143
ORA-06512: at "MDSYS.SDO_UTIL", line 2828
ORA-06512: at "MDSYS.SDO_GEOMETRY", line 36
24323. 00000 -  "value not allowed"
*Cause:    A null value or a bogus value was passed in for a mandatory
           parameter.
*Action:   Verify that all mandatory parameters are properly initialized.

如果删除 300001 的 SRID,它会起作用:

with data as (
select SDO_GEOMETRY(2002,NULL,NULL,
           SDO_ELEM_INFO_ARRAY(1,2,1),
           SDO_ORDINATE_ARRAY(
           675939.072782156,4861635.03887627, 675881.887546735,4861589.91445772,
           675879.176511937,4861586.04156585, 675877.955649557,4861580.51231971,
           675879.89623824, 4861575.48551016, 675976.967341076,4861477.69703032,
           675982.195781809,4861474.59875878, 675988.005161569,4861472.46858959,
           675994.20185149, 4861471.30679544, 676000.979396532,4861470.91948528,
           676006.788765802,4861471.30679544, 676011.629843934,4861472.27503414,
           676150.620431142,4861517.83428384)
       ) as geom
  from dual
)
select sdo_geometry(a.geom.Get_WKT(),a.geom.sdo_srid) as geom
  from data a;

GEOM
--------------------------------------------------------------------------------------------------
SDO_GEOMETRY(2002,NULL,NULL,
             SDO_ELEM_INFO_ARRAY(1,2,1),
             SDO_ORDINATE_ARRAY(675939.072782156,4861635.03887627,675881.887546735,4861589.91445772,675879.176511937,4861586.04156585,675877.955649557,4861580.51231971,675879.89623824,4861575.48551016,675976.967341076,4861477.69703032,675982.195781809,4861474.59875878,675988.005161569,4861472.46858959,675994.20185149,4861471.30679544,676000.979396532,4861470.91948528,676006.788765802,4861471.30679544,676011.629843934,4861472.27503414,676150.620431142,4861517.83428384))

SRID 是否已在 Oracle 中注册?

select * from cs_srs where srid = 300001;

no rows selected

按照文档为 300001 创建 SRID 条目或将其从所有 sdo_geometry 个对象中删除。

我认为 @pauldzy's comment in a related post 是正确答案。

I believe your process to convert the data from SDE is SDO is just fine but Toad is tricking you into thinking its not. Cast your results into a wkt or json CLOB and all will look as expected.