1

我有以米为单位的中心坐标和半径。如何创建 SDO_GEOMETRY 类型的圆,因为它至少需要圆的三个点,如本例所示?

INSERT INTO cola_markets VALUES(
  4,
  'cola_d',
  SDO_GEOMETRY(
    2003,  -- two-dimensional polygon
    NULL,
    NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,4), -- one circle
    SDO_ORDINATE_ARRAY(8,7, 10,9, 8,11)
  )
);
4

2 回答 2

1

只有在投影数据的情况下,才能使用三个点来表示一个圆。如果您的数据是大地数据(即您的中心位于经度/纬度),那么表示圆的唯一方法是对其进行致密化。您可以使用该SDO_UTIL.CIRCLE_POLYGON()功能来做到这一点。

例如:

SQL> select sdo_util.circle_polygon (sdo_geometry(2001, 4326, sdo_point_type(-74.064962, 40.7113, null), null, null),500,1) from dual;

SDO_UTIL.CIRCLE_POLYGON(SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(-74.064962,40.711
-------------------------------------------------------------------------------
SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(-74.064962, 40.7067975, -74.06422, 40.706833, -74.063491, 40.7069389, -74.062784, 40.7071136, -74.062112, 40.7073544, -74.061484, 40.7076573, -74.060912, 40.7080177, -74.060403, 40.7084299, -74.059966, 40.7088873, -74.059608, 40.7093828, -74.059335, 40.7099085, -74.05915, 40.7104562, -74.059057, 40.7110171, -74.059057, 40.7115826, -74.05915, 40.7121435, -74.059334, 40.7126912, -74.059608, 40.713217, -74.059966, 40.7137125, -74.060403, 40.7141699, -74.060911, 40.7145821, -74.061484, 40.7149426, -74.062111, 40.7152456, -74.062784, 40.7154863, -74.06349, 40.7156611, -74.06422, 40.715767, -74.064962, 40.7158025, -74.065704, 40.715767, -74.066434, 40.7156611, -74.06714, 40.7154863, -74.067813, 40.7152456, -74.06844, 40.7149426, -74.069013, 40.7145821, -74.069521, 40.7141699, -74.069958, 40.7137125, -74.070316, 40.713217, -74.07059, 40.7126912, -74.070774, 40.7121435, -74.070867, 40.7115826, -74.070867, 40.7110171, -74.070774, 40.7104562, -74.070589, 40.7099085, -74.070316, 40.7093828, -74.069958, 40.7088873, -74.069521, 40.7084299, -74.069012, 40.7080177, -74.06844, 40.7076573, -74.067812, 40.7073544, -74.06714, 40.7071136, -74.066433, 40.7069389, -74.065704, 40.706833, -74.064962, 40.7067975))

1 row selected. 

如果您的数据是投影的,则使用以下函数生成一个 3 点圆:

create or replace function circle (
  center sdo_geometry,
  radius number
)
return sdo_geometry
is
  x number;
  y number;
begin
  x := center.sdo_point.x;
  y := center.sdo_point.y;
  return sdo_geometry (
     2003, center.sdo_srid, null,
     sdo_elem_info_array(1, 1003, 4),
     sdo_ordinate_array (
       x-radius, y,
       x, y+radius,
       x+radius, y
    )
  );
end;
/

例如:

SQL> select circle (sdo_geometry(2001, 3857, sdo_point_type(-8244873.9, 4969851.29, null), null, null), 500) from dual;

CIRCLE(SDO_GEOMETRY(2001,3857,SDO_POINT_TYPE(-8244873.9,4969851.29,NULL),NULL,N
-------------------------------------------------------------------------------
SDO_GEOMETRY(2003, 3857, NULL, SDO_ELEM_INFO_ARRAY(1,1003, 4), SDO_ORDINATE_ARRAY(-8245373.9, 4969851.29, -8244873.9, 4970351.29, -8244373.9, 4969851.29))

已选择 1 行。

于 2015-06-27T19:50:29.587 回答
1

如果给定中心 (x,y) 和半径 r,那么您可以简单地形成 3 个点,如下所示:(x-r,y),(x,y+r),(x+r,y)并在 SDO_ORDINATE_ARRAY 中使用它们。在 oracle 文档中,它提到它们需要 3 个非共线点,它们位于圆的圆周上。上面提到的点,给这样的点。

于 2015-11-12T08:56:53.907 回答