从两个圆几何创建带有孔的多边形,如 Oracle SDO_GEOMETRY



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

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'

编辑:甲骨文版本是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<>小提琴在这里

最新更新