从两个圆形几何体创建带孔的多边形作为 Oracle SDO_GEOMETRY

create polygon with a hole as Oracle SDO_GEOMETRY from two circle geometries

在 Oracle 文档中给出的示例中,有一种方法可以使用以下语法创建带孔的多边形:

SDO_GEOMETRY(
    2003,  -- two-dimensional polygon
    NULL,
    NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,1, 19,2003,1), -- polygon with hole
    SDO_ORDINATE_ARRAY(2,4, 4,3, 10,3, 13,5, 13,9, 11,13, 5,13, 2,11, 2,4,
        7,5, 7,10, 10,10, 10,5, 7,5)
  )

在我的例子中,我创建了两个 SDO_GEOMETRY,如下所示:

SELECT sdo_util.circle_polygon (longitude_1,
                                latitude_1,
                                r_1,                                         
                                tol)
           INTO inner_circle_geom
           FROM DUAL;


SELECT sdo_util.circle_polygon (longitude_2,
                                latitude_2,
                                r_2,                                         
                                tol)
           INTO outer_circle_geom
           FROM DUAL;

如何使用上面的两个几何图形创建带孔的多边形?

我试过使用

...
SDO_ORDINATE_ARRAY(outer_circle_geom.sdo_ordinates, inner_circle_geom.sdo_ordinates)

但是我收到错误

PLS-00306: wrong number or types of arguments in call to 'SDO_ORDINATE_ARRAY'

编辑:Oracle 版本为 10g

MT0的想法是对的。您可以使用 select sdo_geom.sdo_difference(
sdo_util.circle_polygon (longitude_2, latitude_2,r_2, tol),
sdo_util.circle_polygon (longitude_1, latitude_1,r_1, tol), tol)
from dual;

您可以使用元素信息手动定义它:

  • 1003SDO_ETYPE4SDO_INTERPRETATION用圆周上的三个点定义外圆;和
  • 2003SDO_ETYPE4SDO_INTERPRETATION用圆周上的三个点定义内圆

例如,如果您想要两个以 0,0 为中心、外半径为 10、内半径为 5 的同心圆,则:

SDO_GEOMETRY(
  2003, -- In the format D0XX where D is the number of dimensions and
        -- an XX value of 03 is a polygon (with or without holes)
  NULL,
  NULL,
  SDO_ELEM_INFO_ARRAY(
     1,    -- offset for the first ordinate of this element
     1003, -- this element is an exterior polygon ring 
     4,    -- which is a circle defined by 3 points on the circumference
     
     7,    -- offset for the first ordinate of this element
     2003, -- this element is an interior polygon ring
     4     -- which is a circle defined by 3 points on the circumference
  ),
  SDO_ORDINATE_ARRAY(
    10.00,   0.00, -- first point on exterior circle
     0.00,  10.00, -- second point on exterior circle
   -10.00,   0.00, -- third point on exterior circle

     5.00,   0.00, -- first point on interior circle
     0.00,  -5.00, -- second point on interior circle
    -5.00,   0.00  -- third point on interior circle
  )
);

db<>fiddle here