Oracle8(TM) Server Spatial Cartridge User's Guide and Reference Release 8.0.3 A53264_01 |
|
Spatial Cartridge has undergone an architectural change for this release. A reliance on partitioned tables has changed to utilize improved spatial indexing.
The functions described in this chapter are not required for creating or maintaining a spatial database, however, they are provided for convenience in working with legacy data in partitioned point data tables. They are used with SQL SELECT, INSERT, UPDATE, and DELETE statements to perform the following functions:
When using these functions in basic SQL statements, use the form: SDO_<function>. When using the functions inside a PL/SQL block, use a period (.) instead of the underscore.
This chapter contains descriptions of the spatial functions listed in Table 8-1:
Additional functions that support partitioned point data can be found in Chapter 5, "Administrative Procedures" and Appendix A, "Sample SQL Scripts".
This function creates a dimension from a bounded value, which is a value contained in a set of values expressed as a lower boundary and an upper boundary.
SDO_BVALUETODIM (value, lower_boundary, upper_boundary, decimal_scale)
This function returns a dimension. Data type is RAW.
Example 8-1 shows the SDO_BVALUETODIM() function:
SQL> INSERT INTO sourcetable1(SAMPLENAME,DATA_PT)
2> VALUES ('SAMPLE1',SDO_ENCODE(SDO_BVALUETODIM(10,-100,100,7),
3> SDO_BVALUETODIM(20,-100,100,7));
This function evaluates the relationship between an area or point described by an HHCODE and another HHCODE, or a range of HHCODEs expressed as an upper bound and lower bound.
SDO_COMPARE (hhcode_expression, {hhcode_expression|lower_bound_HHCODE,upper_bound_HHCODE})
This function returns one of the following:
Data type is VARCHAR2.
Example 8-2 selects all points that fall within the given multidimensional range.
SQL> SELECT SDO_GID FROM layer1_SDOINDEX WHERE
2> SDO_COMPARE(SDO_MAXCODE,
3> SDO_ENCODE(5,5),
4> SDO_ENCODE(25,25))='INSIDE';
Example 8-3 selects GIDs based on interaction between their spatial index tiles:
SQL> SELECT SDO_GID FROM layer1_SDOINDEX A, layer2_SDOINDEX B
2> WHERE SDO_COMPARE(A.SDO_CODE,B.SDO_CODE) != 'OUTSIDE';
This function creates a dimension from an Oracle DATE data type. The component number determines the level of resolution of the date in the dimension.
SDO_DATETODIM (date[, component])
This function returns a dimension. Data type is RAW.
You must use a valid Oracle8 date format string.
Example 8-4 shows the SDO_DATETODIM()
function:
SQL> INSERT INTO sourcetable1(SAMPLENAME,DATA_PT)
2> VAUES('SAMPLE1',SDO_ENCODE(SDO_DATETODIM(TO_DATE('19-Jul-96'),
3> SDO_BVALUETODIM(100,-1000,1000,7)));
This function extracts a single dimension from an HHCODE.
SDO_DECODE (hhcode_expression, dimension_number)
hhcode_expression |
Specifies an expression that evaluates to an HHCODE. |
dimension_number |
Specifies the dimension number to extract. |
This function returns a dimension. Data type is RAW.
The SDO_DECODE()
function is called once for each dimension to be decoded.
Example 8-5 shows the SDO_DECODE()
function:
SQL> SELECT
2> SDO_TO_BVALUE(SDO_DECODE(DATA_PT,1),1,6),
3> SDO_TO_BVALUE(SDO_DECODE(DATA_PT,2),-100,100),
4> SDO_TO_DATE(SDO_DECODE(DATA_PT,3))
5> FROM sourcetable1 WHERE SAMPLENAME='SAMPLE1';
This function combines dimensions to create the HHCODE that describes an area or point.
SDO_ENCODE (dimension1[,dimension2 ...])
dimension |
Specifies an expression created by the SDO_BVALUETODIM or SDO_DATETODIM functions. |
This function returns an HHCODE. Data type is RAW.
Consider the following when using this function:
Example 8-6 shows the SDO_ENCODE()
function:
SQL> INSERT INTO sourcetable1(SAMPLENAME,DATA_PT)
2> VALUES ('SAMPLE1',SDO_ENCODE(SDO_BVALUETODIM(500,6),
3> SDO_BVALUETODIM(30,-100,100,10),
4> SDO_DATETODIM(TO_DATE('05-Jul-96'),3)));
This function returns the original bounded data value of a dimension.
SDO_TO_BVALUE (dimension, lower_boundary, upper_boundary)
This function returns a bounded data value. Data type is NUMBER.
This function returns a number that is the value for a dimension within the specified range. This is not necessarily the range for which the dimension was originally created.
Example 8-7 shows the SDO_TO_BVALUE()
function:
SQL> SELECT (SDO_TO_BVALUE(SDO_DECODE(DATA_PT,2),-100,100)
2> FROM sourcetable1 WHERE SAMPLENAME='SAMPLE1';
This function returns the original date value of a dimension.
dimension |
Specifies the dimension. |
This function returns an Oracle DATE data type.
None
Example 8-8 shows the SDO_TO_DATE()
function:
SQL> SELECT SDO_TO_DATE(SDO_DECODE(DATA_PT,3))
2> FROM sourcetable1 WHERE SAMPLENAME='SAMPLE1';