Table function that returns the set of cell IDs that intersect an object rectangle. The function is based on the concept of a single level g_nx by g_ny grid. The return value is suitable to use as an equijoin bind term.
Argument … |
Specifies … |
in_key |
a DECIMAL(18,0) value for a key that is passed back in the result rows to allow joining back to the proper object. |
o_xmin, |
the coordinates of the object rectangle. The data type of o_xmin, o_ymin, o_xmax, and o_ymax is FLOAT. |
u_xmin, |
the coordinates of the universe of interest. The data type of u_xmin, u_ymin, u_xmax, and u_ymax is FLOAT. |
g_nx, |
the number of grid cells to divide the universe into in the X and Y dimensions. The data type of g_nx and g_ny is INTEGER. |
The columns in the table that Tessellate returns are as follows.
Column Name |
Data Type |
Description |
out_key |
DECIMAL(18,0) |
A copy of the in_key input argument. |
cellid |
INTEGER |
Cell ID that intersects the object rectangle. |
Here is an example that shows the cell numbering of a single-level grid (of unspecified size) that contains 16 cells.
Consider two tables, P500000 and R5000, each of which contains a column that is a geospatial shape (column A in table P500000 and column B in table R5000).
For simplicity, the two tables have MBRs as their shapes, but any type of shape can be used by passing the MBR of the shape to the tessellation function and then doing the overlap comparison between the two shapes via the ST_Overlaps method in the final WHERE clause.
The following statement counts the number of objects that overlap between the two tables.
SELECT COUNT(*)
FROM ( SELECT *
FROM P500000 A
,TABLE(SYSSPATIAL.Tessellate(A.rkey, A.xmin, A.ymin, A.xmax, A.ymax, 0, 0, 100, 100, 100, 100 ) )T1
WHERE A.rkey = T1.out_key ) S1
,( SELECT *
FROM R5000 B
,TABLE(SYSSPATIAL.Tessellate(B.rkey, B.xmin, B.ymin, B.xmax, B.ymax, 0, 0, 100, 100, 100, 100 ) )T2
WHERE B.rkey = T2.out_key )S2
WHERE S1.cellid = S2.cellid
AND S1.xmax >= S2.xmin and S1.xmin <= S2.xmax
AND S1.ymax >= S2.ymin and S1.ymin <= S2.ymax;
Here is how the tessellation works in the preceding example.