The SE_EnvelopesIntersect() function

The SE_EnvelopesIntersect() function returns t (TRUE) if the envelopes of two geometries intersect; otherwise, it returns f (FALSE).

Syntax

SE_EnvelopesIntersect(g1 ST_Geometry, g2 ST_Geometry)

Return type

BOOLEAN

Example

The get_window() function retrieves the display window coordinates from the application. The window parameter is actually a polygon shape structure containing a string of coordinates that represents the display polygon. The SE_PolygonFromShape() function converts the display window shape into a polygon that the SE_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(&query_shape_buf, &query_shape_len);

    /* Create the SQL expression. The envelopesintersect function limits
     * the result set to only those zone polygons that intersect the
     * envelope of the display window. */
    sprintf(sql_stmt,
            "select SE_AsShape(zone) ",
            "from sensitive_areas where ",
            "SE_EnvelopesIntersect(zone,SE_PolyFromShape(?,1))");

    /* Prepare the SQL statement. */
    SQLPrepare(hstmt, (UCHAR *)sql_stmt, SQL_NTS);

    /* Bind the query geometry parameter. */
    pcbvalue1 = query_shape_len;
    SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY,
                      SQL_INFX_UDT_LVARCHAR, query_shape_len, 0,
                      query_shape_buf, query_shape_len, &pcbvalue1);

    /* Execute the query. */
    rc = SQLExecute(hstmt);

    /* Assign the results of the query (the Zone polygons) to the
       fetched_shape_buf variable. */
    SQLBindCol (hstmt, 1, SQL_C_BINARY, fetched_shape_buf, 100000,
                &fetched_shape_len);

    /* Fetch each polygon within the display window and display it. */
    while (SQL_SUCCESS == (rc = SQLFetch(hstmt)))
        draw_polygon(fetched_shape_buf);