本文整理汇总了C++中VRTDataset::XMLInit方法的典型用法代码示例。如果您正苦于以下问题:C++ VRTDataset::XMLInit方法的具体用法?C++ VRTDataset::XMLInit怎么用?C++ VRTDataset::XMLInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRTDataset
的用法示例。
在下文中一共展示了VRTDataset::XMLInit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPLParseXMLString
GDALDataset *VRTDataset::OpenXML( const char *pszXML, const char *pszVRTPath,
GDALAccess eAccess)
{
/* -------------------------------------------------------------------- */
/* Parse the XML. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psTree;
psTree = CPLParseXMLString( pszXML );
if( psTree == NULL )
return NULL;
CPLXMLNode *psRoot = CPLGetXMLNode( psTree, "=VRTDataset" );
if (psRoot == NULL)
{
CPLError( CE_Failure, CPLE_AppDefined,
"Missing VRTDataset element." );
CPLDestroyXMLNode( psTree );
return NULL;
}
if( CPLGetXMLNode( psRoot, "rasterXSize" ) == NULL
|| CPLGetXMLNode( psRoot, "rasterYSize" ) == NULL
|| CPLGetXMLNode( psRoot, "VRTRasterBand" ) == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Missing one of rasterXSize, rasterYSize or bands on"
" VRTDataset." );
CPLDestroyXMLNode( psTree );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create the new virtual dataset object. */
/* -------------------------------------------------------------------- */
VRTDataset *poDS;
int nXSize = atoi(CPLGetXMLValue(psRoot,"rasterXSize","0"));
int nYSize = atoi(CPLGetXMLValue(psRoot,"rasterYSize","0"));
if ( !GDALCheckDatasetDimensions(nXSize, nYSize) )
{
CPLDestroyXMLNode( psTree );
return NULL;
}
if( strstr(pszXML,"VRTWarpedDataset") != NULL )
poDS = new VRTWarpedDataset( nXSize, nYSize );
else
{
poDS = new VRTDataset( nXSize, nYSize );
poDS->eAccess = eAccess;
}
if( poDS->XMLInit( psRoot, pszVRTPath ) != CE_None )
{
delete poDS;
poDS = NULL;
}
/* -------------------------------------------------------------------- */
/* Try to return a regular handle on the file. */
/* -------------------------------------------------------------------- */
CPLDestroyXMLNode( psTree );
return poDS;
}