Guide d'utilisation et de référence

ST_AsBinary

ST_AsBinary utilise un objet de type géométrie en entrée et renvoie sa représentation binaire connue (WKB - well-known binary). ST_AsBinary n'accepte pas les géométries vides en entrée (SQLSTATE 38827).

Syntaxe

db2gse.ST_AsBinary(g db2gse.ST_Geometry)

Type de retour

BLOB(1m)

Exemples

Le fragment de code suivant illustre comment la fonction ST_AsBinary convertit les multipolygones des bâtis contenus dans la table BUILDINGFOOTPRINTS en multipolygones de type WKB. Ceux-ci sont transmis à la fonction draw_polygon à des fins d'affichage.

/* Create the SQL expression. */
strcpy(sqlstmt, "select db2gse.ST_AsBinary (footprint) from BUILDINGFOOTPRINTS
where db2gse.EnvelopesIntersect(footprint, db2gse.ST_PolyFromWKB(cast(? as
blob(1m)),
db2gse.coordref()..srid(0)))");
 
/* Prepare the SQL statement. */
SQLPrepare(hstmt, (UCHAR *)sqlstmt, SQL_NTS);
 
/* Set the pcbvalue1 length of the shape. */
pcbvalue1 = blob_len;
 
/* Bind the shape parameter */
SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_BLOB, blob_len,
0, shape, 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);
  


[ Début de page | Page précédente | Page suivante | Table des matières | Index ]