User's Guide and Reference

EnvelopesIntersect

EnvelopesIntersect returns 1 (TRUE) if the envelopes of two geometries intersect; otherwise it returns 0 (FALSE).

Syntax

db2gse.EnvelopesIntersect(g1 db2gse.ST_Geometry, g2 db2gse.ST_Geometry)

Return type

Integer

Examples

The get_window function retrieves the display window's coordinates from the application. The window parameter is actually a polygon shape structure containing a string of coordinates that represent the display polygon. The PolyFromShape function converts the display window shape into a DB2 Spatial Extender polygon that the EnvelopesIntersect function uses as its intersection envelope. All SENSITIVE_AREAS zone polygons that intersect the interior or boundary of the display window are returned. Each polygon is fetched from the result set and passed to the draw_polygon function.

/* Get the display window coordinates as a polygon shape.
get_window(&window)
 
/* Create the SQL expression. The db2gse.EnvelopesIntersect function
  will be used to limit the result set to only those zone polygons
  that intersect the envelope of the display window. */
strcpy(sqlstmt, "select db2gse.AsBinaryShape(zone) from SENSITIVE_AREAS where
db2gse.EnvelopesIntersect (zone, db2gse.PolyFromShape(cast(? as blob(1m)), 
db2gse.coordref()..srid(0)))");
 
/* Set blob_len to the byte length of a 5 point shape polygon. */
blob_len = 128;
 
/* Prepare the SQL statement. */
SQLPrepare(hstmt, (UCHAR *)sqlstmt, SQL_NTS);
 
/* Set the pcbvalue1 to the window shape */
pcbvalue1 = blob_len;
 
/* Bind the shape parameter */
SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_BLOB, blob_len,
0, window, blob_len, &pcbvalue1);
 
/* Execute the query */
rc = SQLExecute(hstmt);
 
/* Assign the results of the query, (the Zone polygons) to the
   fetched_binary variable. */
SQLBindCol (hstmt, 1, SQL_C_Binary, fetched_binary, 100000, &ind_blob);
 
/* Fetch each polygon within the display window and display it. */
while(SQL_SUCCESS == (rc = SQLFetch(hstmt))
  draw_polygon(fetched_binary);


[ Top of Page | Previous Page | Next Page ]