查找具有问题形状的行(SDE.ST_GEOMETRY 空间类型)

问题描述 投票:0回答:1

Oracle 18c; ArcGIS 企业级地理数据库 10.7.1:

我有一个名为 GCSM_HC_ANNO 的表,其中有一个 SHAPE 列(用户定义的空间类型称为 SDE.ST_GEOMETRY)。

我有一个空间查询,选择与 BOUNDARY 表中的多边形空间相交的 GCSM_HC_ANNO (ST_Intersects)。仅返回前 50 行时,查询运行不会出现错误:

select 
    anno.objectid, 
    anno.shape
from 
    city.boundary boundary
cross join
    infrastr.gcsm_hc_anno anno
where  
    sde.st_intersects (boundary.shape, anno.shape) = 1

enter image description here

但是当我在 SQL Developer 的结果集中按 CTRL+End 返回所有行时,出现错误:

ORA-20002: Error converting spatial reference (SHAPE2)
ORA-06512: at "SDE.ST_GEOMETRY_SHAPELIB_PKG", line 740
ORA-06512: at "SDE.ST_GEOMETRY_OPERATORS", line 2836
ORA-06512: at "SDE.ST_GEOMETRY_OPERATORS", line 3698
ORA-06512: at "SDE.ST_RELATION_OPERATORS", line 339

这告诉我 GCSM_HC_ANNO 中的其中一个形状有问题。

使用 SQL,如何找到导致错误的行?

sql oracle geospatial spatial oracle18c
1个回答
0
投票

我可以创建内联 PL/SQL 函数(或常规函数)。

该函数通过与 BOUDNARY 表相交来测试形状。如果相交成功,则该函数返回“无错误”。但如果出现问题,则会返回“错误”。

这让我可以标记问题行,这比原始查询更有用,原始查询只会抛出一般错误,但不会告诉我问题是哪一行。

with function check_shape(anno_shape sde.st_geometry, boundary_shape sde.st_geometry) return varchar2 
is
    v_test_result varchar2(10);
begin
    select
        sde.st_intersects (boundary_shape, anno_shape)
    into     
        v_test_result
    from
        dual;
    return 'no error';
exception
  when others then
    return 'error';
end;

select 
    anno.objectid, 
    anno.shape as anno_shape,
    check_shape(anno.shape, boundary.shape) as check_shape
from 
    city.boundary boundary
cross join     
    infrastr.gcsm_hc_anno anno
where 
    check_shape(anno.shape, boundary.shape) = 'error'

enter image description here

我愿意接受有关改进功能的想法。

© www.soinside.com 2019 - 2024. All rights reserved.