本文整理汇总了C++中OGRGeometry::exportToWkb方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::exportToWkb方法的具体用法?C++ OGRGeometry::exportToWkb怎么用?C++ OGRGeometry::exportToWkb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::exportToWkb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OGR2SQLITE_ST_AsBinary
static
void OGR2SQLITE_ST_AsBinary(sqlite3_context* pContext,
int argc, sqlite3_value** argv)
{
OGRGeometry* poGeom = OGR2SQLITE_GetGeom(pContext, argc, argv, NULL);
if( poGeom != NULL )
{
int nBLOBLen = poGeom->WkbSize();
GByte* pabyGeomBLOB = (GByte*) VSIMalloc(nBLOBLen);
if( pabyGeomBLOB != NULL )
{
if( poGeom->exportToWkb(wkbNDR, pabyGeomBLOB) == OGRERR_NONE )
sqlite3_result_blob( pContext, pabyGeomBLOB, nBLOBLen, CPLFree);
else
{
VSIFree(pabyGeomBLOB);
sqlite3_result_null (pContext);
}
}
else
sqlite3_result_null (pContext);
delete poGeom;
}
else
sqlite3_result_null (pContext);
}
示例2: CreateFeature
//.........这里部分代码省略.........
CPLDebug( "OGR_SQLITE", "prepare(%s)", osCommand.c_str() );
#endif
rc = sqlite3_prepare( hDB, osCommand, -1, &hInsertStmt, NULL );
if( rc != SQLITE_OK )
{
CPLError( CE_Failure, CPLE_AppDefined,
"In CreateFeature(): sqlite3_prepare(%s):\n %s",
osCommand.c_str(), sqlite3_errmsg(hDB) );
return OGRERR_FAILURE;
}
/* -------------------------------------------------------------------- */
/* Bind the geometry */
/* -------------------------------------------------------------------- */
int nBindField = 1;
if( osGeomColumn.size() != 0 &&
poGeom != NULL &&
eGeomFormat != OSGF_FGF )
{
if ( eGeomFormat == OSGF_WKT )
{
char *pszWKT = NULL;
poGeom->exportToWkt( &pszWKT );
rc = sqlite3_bind_text( hInsertStmt, nBindField++, pszWKT, -1, CPLFree );
}
else if( eGeomFormat == OSGF_WKB )
{
int nWKBLen = poGeom->WkbSize();
GByte *pabyWKB = (GByte *) CPLMalloc(nWKBLen + 1);
poGeom->exportToWkb( wkbNDR, pabyWKB );
rc = sqlite3_bind_blob( hInsertStmt, nBindField++, pabyWKB, nWKBLen, CPLFree );
}
else if ( eGeomFormat == OSGF_SpatiaLite )
{
int nBLOBLen;
GByte *pabySLBLOB;
ExportSpatiaLiteGeometry( poGeom, nSRSId, wkbNDR, bHasM,
bSpatialite2D, &pabySLBLOB, &nBLOBLen );
rc = sqlite3_bind_blob( hInsertStmt, nBindField++, pabySLBLOB,
nBLOBLen, CPLFree );
}
else
{
CPLAssert(0);
}
if( rc != SQLITE_OK )
{
CPLError( CE_Failure, CPLE_AppDefined,
"sqlite3_bind_blob/text() failed:\n %s",
sqlite3_errmsg(hDB) );
sqlite3_finalize( hInsertStmt );
return OGRERR_FAILURE;
}
}
/* -------------------------------------------------------------------- */
/* Bind field values. */
/* -------------------------------------------------------------------- */