Oracle8 Spatial Cartridge User's Guide and Reference Release 8.0.4 A53264-02 |
|
Spatial Cartridge has undergone an architectural change, beginning with the 7.3.3 release. The empshasis on partitioned tables has been replaced by the improved spatial indexing features.
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:
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 9-1.
Additional functions that support partitioned point data can be found in Chapter 5, "Administrative Procedures" and Appendix A, "Sample SQL Scripts and Tuning Tips".
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. The data type is RAW.
Example 9-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 keywords:
The data type is VARCHAR2.
Example 9-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 9-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. The data type is RAW.
You must use a valid Oracle date format string.
Example 9-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. The data type is RAW.
The SDO_DECODE() function is called once for each dimension to be decoded.
Example 9-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. The data type is RAW.
Consider the following when using this function:
Example 9-6 shows the SDO_ENCODE() function.
SQL> INSERT INTO sourcetable1(SAMPLENAME,DATA_PT)
2> VALUES ('SAMPLE1',SDO_ENCODE(SDO_BVALUETODIM(50,-100, 100, 10),
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. The 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 9-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.
SDO_TO_DATE (dimension)
dimension |
Specifies the dimension. |
This function returns an Oracle DATE data type.
Example 9-8 shows the SDO_TO_DATE() function.
SQL> SELECT SDO_TO_DATE(SDO_DECODE(DATA_PT,3))
2> FROM sourcetable1 WHERE SAMPLENAME='SAMPLE1';