SpatialDB Advisor
Often I have need to know if the linestrings describing an sdo_geometry line or polygon object contain 3-point arc segments or elements.
If a linestring is described by, or contains, 3-point arc elements, its sdo_interpretation field in the sdo_elem_info array will contain the value “2” which means (from the Oracle Spatial documentation):
I have encapsulated my needs into a robust function isCompound that pivots the data in the sdo_elem_info array for ease of query and understanding, as follows.
create or replace Function isCompound(p_elem_info in mdsys.sdo_elem_info_array)
return integer deterministic
Is
v_compound_element_count number := 0;
Begin
SELECT count(*) as c_element_count
INTO v_compound_element_count
FROM (SELECT e.id,
e.etype,
e.offset,
e.interpretation
FROM (SELECT trunc((rownum - 1) / 3,0) as id,
sum(case when mod(rownum,3) = 1 then sei.column_value else null end) as offset,
sum(case when mod(rownum,3) = 2 then sei.column_value else null end) as etype,
sum(case when mod(rownum,3) = 0 then sei.column_value else null end) as interpretation
FROM TABLE(p_elem_info) sei
GROUP BY trunc((rownum - 1) / 3,0)
) e
) i
WHERE ( i.etype = 2 AND i.interpretation = 2 )
OR ( i.etype in (1003,2003) AND i.interpretation IN (2,4) );
Return case when v_compound_element_count > 0 then 1 else 0 end;
End isCompound;
To test, we will use the Arc/Circle/Compound sdo_geometry objects in 2.5 Geometry Examples of the Oracle Spatial documentation (that I have written to a table called OracleTestGeometries and which ships with my free PL/SQL packages):
select d as description,
isCompound(a.g.sdo_elem_info) as isCompound,
g as geom
from OracleTestGeometries a
where d like '%Arc%'
or d like '%Compou%'
or d like '%Circle%';


















<<GEOMETRY_COLUMNS for Oracle Spatial >>Extract Polygons from Compound Polygon
Thanks this helped me quite a lot today. Although I implemented the function differently I used your logic so I decided to share it but I don’t know the textile for source code, but in short I loop over the (sdo_elem_info varray)
create or replace function has_compound_curves ( geom_in in sdo_geometry)
return integer as
etype number;
interpret number;
begin
for i in geom_in.sdo_elem_info.first .. geom_in.sdo_elem_info.last loop
case
when mod(i,3) = 1 then continue;
when mod(i,3) = 2 then etype := geom_in.sdo_elem_info(i);
when mod(i,3) = 0
then
interpret := geom_in.sdo_elem_info(i);
if((etype = 2 and interpret = 2) or (etype in (1003,2003) and interpret in (2,4))) then
return 1;
end if;
end case;
end loop;
return 0;
end has_compound_curves;
This runs about 20-30 times faster and answers the same question.
I have no idea if your query up there is what you use in practice or if you simply stated it here for clarity, either way it helped me and since you share I’ll do it as well :)
— Sveinn R. Joelsson Dec 16, 11:55 pm #