10.12.2012 Views

Oracle Spatial User's Guide and Reference - InfoLab

Oracle Spatial User's Guide and Reference - InfoLab

Oracle Spatial User's Guide and Reference - InfoLab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Querying <strong>Spatial</strong> Data<br />

■ geometry2 is an object of type SDO_GEOMETRY. This object may or may not<br />

come from a table. If it comes from a table, it may or may not be spatially<br />

indexed.<br />

■ param is a quoted string with the mask keyword <strong>and</strong> a valid mask value, as<br />

explained in the documentation for the SDO_RELATE operator in Chapter 12.<br />

The following examples perform both primary <strong>and</strong> secondary filter operations.<br />

They return all the geometries in Figure 4–2 that lie within or overlap the query<br />

window. The result of these examples is objects geom_1 <strong>and</strong> geom_2.<br />

Example 4–4 performs both primary <strong>and</strong> secondary filter operations without<br />

inserting the query window into a table. The window will be indexed in memory<br />

<strong>and</strong> performance will be very good.<br />

Example 4–4 Secondary Filter Using a Temporary Query Window<br />

SELECT A.Feature_ID FROM TARGET A<br />

WHERE sdo_relate(A.shape, SDO_geometry(2003,NULL,NULL,<br />

SDO_elem_info_array(1,1003,3),<br />

SDO_ordinate_array(x1,y1, x2,y2)),<br />

'mask=anyinteract') = 'TRUE';<br />

In Example 4–4, (x1,y1) <strong>and</strong> (x2,y2) are the lower-left <strong>and</strong> upper-right corners<br />

of the query window.<br />

Example 4–5 assumes the query window was inserted into a table called<br />

WINDOWS, with an ID value of WINS_1.<br />

Example 4–5 Secondary Filter Using a Stored Query Window<br />

SELECT A.Feature_ID FROM TARGET A, WINDOWS B<br />

WHERE B.ID = 'WINS_1' AND<br />

sdo_relate(A.shape, B.shape,<br />

'mask=anyinteract') = 'TRUE';<br />

If the B.SHAPE column is not spatially indexed, the SDO_RELATE operator indexes<br />

the query window in memory <strong>and</strong> performance is very good.<br />

If the B.SHAPE column is spatially indexed with the same SDO_LEVEL value as the<br />

A.SHAPE column, the SDO_RELATE operator reuses the existing index, <strong>and</strong><br />

performance is very good or better.<br />

If the B.SHAPE column is spatially indexed with a different SDO_LEVEL value than<br />

the A.SHAPE column, the SDO_RELATE operator reindexes B.SHAPE in the same<br />

Indexing <strong>and</strong> Querying <strong>Spatial</strong> Data 4-13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!