本文整理汇总了C++中OGR_SRSNode::importFromWkt方法的典型用法代码示例。如果您正苦于以下问题:C++ OGR_SRSNode::importFromWkt方法的具体用法?C++ OGR_SRSNode::importFromWkt怎么用?C++ OGR_SRSNode::importFromWkt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGR_SRSNode
的用法示例。
在下文中一共展示了OGR_SRSNode::importFromWkt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importFromWkt
OGRErr OGR_SRSNode::importFromWkt( char ** ppszInput, int nRecLevel, int* pnNodes )
{
const char *pszInput = *ppszInput;
int bInQuotedString = FALSE;
/* Sanity checks */
if( nRecLevel == 10 )
{
return OGRERR_CORRUPT_DATA;
}
if( *pnNodes == 1000 )
{
return OGRERR_CORRUPT_DATA;
}
/* -------------------------------------------------------------------- */
/* Clear any existing children of this node. */
/* -------------------------------------------------------------------- */
ClearChildren();
/* -------------------------------------------------------------------- */
/* Read the ``value'' for this node. */
/* -------------------------------------------------------------------- */
char szToken[512];
int nTokenLen = 0;
while( *pszInput != '\0' && nTokenLen < (int) sizeof(szToken)-1 )
{
if( *pszInput == '"' )
{
bInQuotedString = !bInQuotedString;
}
else if( !bInQuotedString
&& (*pszInput == '[' || *pszInput == ']' || *pszInput == ','
|| *pszInput == '(' || *pszInput == ')' ) )
{
break;
}
else if( !bInQuotedString
&& (*pszInput == ' ' || *pszInput == '\t'
|| *pszInput == 10 || *pszInput == 13) )
{
/* just skip over whitespace */
}
else
{
szToken[nTokenLen++] = *pszInput;
}
pszInput++;
}
if( *pszInput == '\0' || nTokenLen == sizeof(szToken) - 1 )
return OGRERR_CORRUPT_DATA;
szToken[nTokenLen++] = '\0';
SetValue( szToken );
/* -------------------------------------------------------------------- */
/* Read children, if we have a sublist. */
/* -------------------------------------------------------------------- */
if( *pszInput == '[' || *pszInput == '(' )
{
do
{
OGR_SRSNode *poNewChild;
OGRErr eErr;
pszInput++; // Skip bracket or comma.
poNewChild = new OGR_SRSNode();
(*pnNodes) ++;
eErr = poNewChild->importFromWkt( (char **) &pszInput, nRecLevel + 1, pnNodes );
if( eErr != OGRERR_NONE )
{
delete poNewChild;
return eErr;
}
AddChild( poNewChild );
// swallow whitespace
while( isspace(*pszInput) )
pszInput++;
} while( *pszInput == ',' );
if( *pszInput != ')' && *pszInput != ']' )
return OGRERR_CORRUPT_DATA;
pszInput++;
}
*ppszInput = (char *) pszInput;
return OGRERR_NONE;
}