|
16#
create table t_triangle_valid as
with t as
(select level n,
ceil(level / 3) x,
decode(mod(level, 3), 0, 3, mod(level, 3)) y
from dual
connect by level <= 9),
triangle_valid as
(select a,a_x,a_y,b,b_x,b_y,c,c_x,c_y,
sdo_geometry(2003,
null,
null,
sdo_elem_info_array(1,1003,1),
sdo_ordinate_array(a_x,a_y,b_x,b_y,c_x,c_y,a_x,a_y)
) as geometry
from (select t1.n a,
t1.x a_x,
t1.y a_y,
t2.n b,
t2.x b_x,
t2.y b_y,
t3.n c,
t3.x c_x,
t3.y c_y
from t t1, t t2, t t3
where t1.n < t2.n
and t2.n < t3.n)
where not (a_x = b_x and b_x = c_x)
and not (a_y = b_y and b_y = c_y)
and (a, b, c) not in ((1, 5, 9), (3, 5, 7)))
select * from triangle_valid;
INSERT INTO USER_SDO_GEOM_METADATA
VALUES (
'T_TRIANGLE_VALID',
'GEOMETRY',
MDSYS.SDO_DIM_ARRAY( -- 20X20 grid
MDSYS.SDO_DIM_ELEMENT('X', 0, 10, 0.01),
MDSYS.SDO_DIM_ELEMENT('Y', 0, 10, 0.01)
),
NULL -- SRID
);
CREATE INDEX T_TRIANGLE_VALID_idx
ON T_TRIANGLE_VALID(GEOMETRY)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;
SQL> select count(*)
2 from t_triangle_valid p,t_triangle_valid q
3 where instr(p.a||p.b||p.c,q.a) = 0
4 and instr(p.a||p.b||p.c,q.b) = 0
5 and instr(p.a||p.b||p.c,q.c) = 0
6 and sdo_anyinteract(p.geometry,q.geometry) != 'TRUE';
COUNT(*)
----------
356
|
|