0

我有一个众所周知的文本 (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 有这么多空值并且可以避免?

4

3 回答 3

3

我拿了原始的 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 对象中删除。

于 2020-01-12T05:24:18.873 回答
1

我试过这个

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 并得到了正确的答案。

于 2020-01-12T04:01:42.877 回答
0

我认为@pauldzy 在相关帖子中的评论是正确答案。

我相信您从 SDE 转换数据的过程是 SDO 很好,但 Toad 欺骗您认为它不是。将您的结果转换为 wkt 或 json CLOB,一切都会按预期进行。

于 2021-10-13T22:55:06.557 回答