INSERT INTO roads values ('obj_2', mdsys.sdo_geometry(2002, null, null,
mdsys.sdo_elem_info_array(1,4,
INSERT INTO roads values ('obj_2', mdsys.sdo_geometry(2002, null, null,
mdsys.sdo_elem_info_array(1,4,
Select any objects within 1.35 distance units from the query window:
select a.feature_id
from target a
Performs a consistency check to validate a geometry:
select c.name, sdo_geom.validate_geometry(c.shape, m.diminfo)
from cola_markets c, user_sdo_geom_metadata m
where m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
Compute the difference between two geometries:
select sdo_geom.sdo_distance(c_b.shape, m.diminfo, c_d.shape, m.diminfo)
from cola_markets c_b, cola_markets c_d, user_sdo_geom_metadata m
where m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
Return the minimum bounding rectangle of all geometries in a column:
select sdo_tune.extent_of('cola_markets','shape')
Create Index:
create index states_geom on states (geom)
indextype is mdsys.spatial_index
Estimate tiling level:
select mdsys.sdo_tune.estimate_tiling_level (
'STATES', 'GEOM', 10000, 'LAYER_EXTENT') "ESTIMATE LAYER_EXTENT"
Select all the counties within a certain area:
select sum (mdsys.sdo_geom.sdo_area (c1.geom,
(SELECT diminfo
FROM sdo_geom_metadata
WHERE table_name = 'COUNTIES'
AND column_name = 'GEOM'))) area
from counties c1,
counties c2
where c2.state = 'New Jersey'
and c2.county = 'Passaic'
and mdsys.sdo_relate (c1.geom, c2.geom, 'mask=TOUCH querytype=JOIN') = 'TRUE';
Select all the cities within a particular area:
select c.city, c.pop90
from cities c
where mdsys.sdo_relate (
c.location,
mdsys.sdo_geometry (3, null, null,
mdsys.sdo_elem_info_array (1,3,3),
mdsys.sdo_ordinate_array (-109, 37, -102, 40)),
'mask=ANYINTERACT querytype=WINDOW LAYER_GTYPE=POINT') = 'TRUE';
Select all the counties that are around a particular state:
select county, c.state_abrv
from counties c, states s
where s.state = 'FLORIDA'
and mdsys.sdo_filter (c.geom, s.geom, 'querytype=JOIN') = 'TRUE';
CREATE OR REPLACE FUNCTION geom_to_string (p_geometry IN MDSYS.SDO_GEOMETRY)
RETURN VARCHAR2
AS
str VARCHAR2 (4000) := '';
vgeo MDSYS.SDO_GEOMETRY := p_geometry;
x NUMBER := 0;
y NUMBER := 0;
isi NUMBER := 0;
i NUMBER := 0;
v_dims NUMBER (2) := 0;
BEGIN
v_dims := vgeo.get_dims ();
isi := vgeo.sdo_ordinates.COUNT / v_dims;
FOR i IN 0 .. isi - 1
LOOP
x := vgeo.sdo_ordinates (i * v_dims + 1);
y := vgeo.sdo_ordinates (i * v_dims + 2);
str := str || ',' || FLOOR (x) || ',' || FLOOR (y);
END LOOP;
str := SUBSTR (str, 2, LENGTH (str));
RETURN str;
EXCEPTION
WHEN OTHERS
THEN
RETURN '';
END;
Select geoloc into work_geom from dual;
Select sdo_util.getnumvertices (work_geom) into vert from dual;
For nv in 1..vert loop
Select work_geom.sdo_ordinates ( (nv - 1 ) * 2 + 1) as x,
work_geom.sdo_ordinates ( (nv - 1 ) * 2 + 2) as y
Into x_out ,
y_out
from dual;
dbms_output.put_line( 'x = '||x_out||' and y = '||y_out );
End loop;