简体   繁体   中英

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

In the example given in Oracle Docs, there is a way to create a polygon with a hole with the following syntax:

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)
  )

In my case, I have two SDO_GEOMETRY created as follows:

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;

How can I create the polygon with a hole using the two geometries above?

I've tried using

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

But I receive the error

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

EDIT: the Oracle version is 10g

MT0's thought is right. You can use 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;

You can define it by hand using the element info:

  • with the SDO_ETYPE of 1003 and SDO_INTERPRETATION of 4 to define the exterior circle using three points on the circumference; and
  • with the SDO_ETYPE of 2003 and SDO_INTERPRETATION of 4 to define the interior circle using three points on the circumference.

For example, if you want two concentric circles centred at 0,0 with an exterior radius of 10 and an interior radius of 5 then:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM