Considerations and associated data types for spatial functions
This section provides information that you need to know when you code spatial functions.
This information includes:
- Factors to consider: the requirement to specify the schema to which spatial functions belong, and the fact that some functions can be invoked as methods.
- How to address a situation in which a spatial function cannot process the type of geometries returned by another spatial function.
- A table showing which functions take values of each spatial data type as input
When you use spatial functions, be aware of these factors:
- Before a spatial function can be called, its name must be qualified
by the name of the schema to which spatial functions belong: DB2GSE.
One way to do this is to explicitly specify the schema in the SQL
statement that references the function; for example:
SELECT db2gse.ST_Relate (g1, g2, 'T*F**FFF2') EQUALS FROM relate_test
Alternatively, to avoid specifying the schema each time a function is to be called, you can add DB2GSE to the CURRENT FUNCTION PATH special register. To obtain the current settings for this special register, type the following SQL command:VALUES CURRENT FUNCTION PATH
To update the CURRENT FUNCTION PATH special register with DB2GSE, issue the following SQL command:set CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
- Some spatial functions can be invoked as methods. In the following
code, for example, ST_Area is invoked first as a function and then
as a method. In both cases, ST_Area is coded to operate on a polygon
that has an ID of 10 and that is stored in the SALES_ZONE column of
a table named STORES. When invoked, ST_Area will return the area of
the real-world feature-Sales Zone no. 10-that the polygon represents. ST_Area invoked as a function:
SELECT ST_Area(sales_zone) FROM stores WHERE id = 10
ST_Area invoked as a method:SELECT sales_zone..ST_Area() FROM stores WHERE id = 10
The functions ST_BuildMBRAggr and ST_BuildUnionAggr are described in "MBR Aggregate" and "Union Aggregate", respectively.