本文整理汇总了C++中OGRGeometry::importFromWkb方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::importFromWkb方法的具体用法?C++ OGRGeometry::importFromWkb怎么用?C++ OGRGeometry::importFromWkb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::importFromWkb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFromWkb
OGRErr OGRGeometryFactory::createFromWkb(unsigned char *pabyData,
OGRSpatialReference * poSR,
OGRGeometry **ppoReturn,
int nBytes )
{
OGRwkbGeometryType eGeometryType;
OGRwkbByteOrder eByteOrder;
OGRErr eErr;
OGRGeometry *poGeom;
*ppoReturn = NULL;
if( nBytes < 5 && nBytes != -1 )
return OGRERR_NOT_ENOUGH_DATA;
/* -------------------------------------------------------------------- */
/* Get the byte order byte. The extra tests are to work around */
/* bug sin the WKB of DB2 v7.2 as identified by Safe Software. */
/* -------------------------------------------------------------------- */
eByteOrder = DB2_V72_FIX_BYTE_ORDER((OGRwkbByteOrder) *pabyData);
if( eByteOrder != wkbXDR && eByteOrder != wkbNDR )
{
CPLDebug( "OGR",
"OGRGeometryFactory::createFromWkb() - got corrupt data.\n"
"%02X%02X%02X%02X%02X%02X%02X%02X\n",
pabyData[0],
pabyData[1],
pabyData[2],
pabyData[3],
pabyData[4],
pabyData[5],
pabyData[6],
pabyData[7],
pabyData[8] );
return OGRERR_CORRUPT_DATA;
}
/* -------------------------------------------------------------------- */
/* Get the geometry feature type. For now we assume that */
/* geometry type is between 0 and 255 so we only have to fetch */
/* one byte. */
/* -------------------------------------------------------------------- */
if( eByteOrder == wkbNDR )
eGeometryType = (OGRwkbGeometryType) pabyData[1];
else
eGeometryType = (OGRwkbGeometryType) pabyData[4];
/* -------------------------------------------------------------------- */
/* Instantiate a geometry of the appropriate type, and */
/* initialize from the input stream. */
/* -------------------------------------------------------------------- */
poGeom = createGeometry( eGeometryType );
if( poGeom == NULL )
return OGRERR_UNSUPPORTED_GEOMETRY_TYPE;
/* -------------------------------------------------------------------- */
/* Import from binary. */
/* -------------------------------------------------------------------- */
eErr = poGeom->importFromWkb( pabyData, nBytes );
/* -------------------------------------------------------------------- */
/* Assign spatial reference system. */
/* -------------------------------------------------------------------- */
if( eErr == OGRERR_NONE )
{
poGeom->assignSpatialReference( poSR );
*ppoReturn = poGeom;
}
else
{
delete poGeom;
}
return eErr;
}