本文整理汇总了C++中CPLCreateXMLNode函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLCreateXMLNode函数的具体用法?C++ CPLCreateXMLNode怎么用?C++ CPLCreateXMLNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLCreateXMLNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tr_strdup
CPLXMLNode* GMLXercesHandler::AddAttributes(CPLXMLNode* psNode, void* attr)
{
const Attributes* attrs = (const Attributes*) attr;
CPLXMLNode* psLastChild = NULL;
for(unsigned int i=0; i < attrs->getLength(); i++)
{
char* pszName = tr_strdup(attrs->getQName(i));
char* pszValue = tr_strdup(attrs->getValue(i));
CPLXMLNode* psChild = CPLCreateXMLNode(NULL, CXT_Attribute, pszName);
CPLCreateXMLNode(psChild, CXT_Text, pszValue);
CPLFree(pszName);
CPLFree(pszValue);
if (psLastChild == NULL)
psNode->psChild = psChild;
else
psLastChild->psNext = psChild;
psLastChild = psChild;
}
return psLastChild;
}
示例2: VALIDATE_POINTER1
CPLXMLNode *GDALSerializeTPSTransformer( void *pTransformArg )
{
VALIDATE_POINTER1( pTransformArg, "GDALSerializeTPSTransformer", NULL );
CPLXMLNode *psTree;
TPSTransformInfo *psInfo = static_cast<TPSTransformInfo *>(pTransformArg);
psTree = CPLCreateXMLNode( NULL, CXT_Element, "TPSTransformer" );
/* -------------------------------------------------------------------- */
/* Serialize bReversed. */
/* -------------------------------------------------------------------- */
CPLCreateXMLElementAndValue(
psTree, "Reversed",
CPLString().Printf( "%d", psInfo->bReversed ) );
/* -------------------------------------------------------------------- */
/* Attach GCP List. */
/* -------------------------------------------------------------------- */
if( psInfo->nGCPCount > 0 )
{
int iGCP;
CPLXMLNode *psGCPList = CPLCreateXMLNode( psTree, CXT_Element,
"GCPList" );
for( iGCP = 0; iGCP < psInfo->nGCPCount; iGCP++ )
{
CPLXMLNode *psXMLGCP;
GDAL_GCP *psGCP = psInfo->pasGCPList + iGCP;
psXMLGCP = CPLCreateXMLNode( psGCPList, CXT_Element, "GCP" );
CPLSetXMLValue( psXMLGCP, "#Id", psGCP->pszId );
if( psGCP->pszInfo != NULL && strlen(psGCP->pszInfo) > 0 )
CPLSetXMLValue( psXMLGCP, "Info", psGCP->pszInfo );
CPLSetXMLValue( psXMLGCP, "#Pixel",
CPLString().Printf( "%.4f", psGCP->dfGCPPixel ) );
CPLSetXMLValue( psXMLGCP, "#Line",
CPLString().Printf( "%.4f", psGCP->dfGCPLine ) );
CPLSetXMLValue( psXMLGCP, "#X",
CPLString().Printf( "%.12E", psGCP->dfGCPX ) );
CPLSetXMLValue( psXMLGCP, "#Y",
CPLString().Printf( "%.12E", psGCP->dfGCPY ) );
if( psGCP->dfGCPZ != 0.0 )
CPLSetXMLValue( psXMLGCP, "#GCPZ",
CPLString().Printf( "%.12E", psGCP->dfGCPZ ) );
}
}
return psTree;
}
示例3: OGR_G_ExportEnvelopeToKMLTree
CPLXMLNode* OGR_G_ExportEnvelopeToKMLTree( OGRGeometryH hGeometry )
{
VALIDATE_POINTER1( hGeometry, "OGR_G_ExportEnvelopeToKMLTree", NULL );
CPLXMLNode* psBox = NULL;
CPLXMLNode* psCoord = NULL;
OGREnvelope sEnvelope;
char szCoordinate[256] = { 0 };
char* pszY = NULL;
memset( &sEnvelope, 0, sizeof(sEnvelope) );
((OGRGeometry*)(hGeometry))->getEnvelope( &sEnvelope );
if( sEnvelope.MinX == 0 && sEnvelope.MaxX == 0
&& sEnvelope.MaxX == 0 && sEnvelope.MaxY == 0 )
{
/* there is apparently a special way of representing a null box
geometry ... we should use it here eventually. */
return NULL;
}
psBox = CPLCreateXMLNode( NULL, CXT_Element, "Box" );
/* -------------------------------------------------------------------- */
/* Add minxy coordinate. */
/* -------------------------------------------------------------------- */
psCoord = CPLCreateXMLNode( psBox, CXT_Element, "coord" );
MakeKMLCoordinate( szCoordinate, sEnvelope.MinX, sEnvelope.MinY, 0.0,
FALSE );
pszY = strstr(szCoordinate,",") + 1;
pszY[-1] = '\0';
CPLCreateXMLElementAndValue( psCoord, "X", szCoordinate );
CPLCreateXMLElementAndValue( psCoord, "Y", pszY );
/* -------------------------------------------------------------------- */
/* Add maxxy coordinate. */
/* -------------------------------------------------------------------- */
psCoord = CPLCreateXMLNode( psBox, CXT_Element, "coord" );
MakeKMLCoordinate( szCoordinate, sEnvelope.MaxX, sEnvelope.MaxY, 0.0,
FALSE );
pszY = strstr(szCoordinate,",") + 1;
pszY[-1] = '\0';
CPLCreateXMLElementAndValue( psCoord, "X", szCoordinate );
CPLCreateXMLElementAndValue( psCoord, "Y", pszY );
return psBox;
}
示例4: addAuthorityIDBlock
static CPLXMLNode* addAuthorityIDBlock(CPLXMLNode *psTarget,
const char *pszElement,
const char *pszAuthority,
const char *pszObjectType,
int nCode,
const char *pszVersion = "")
{
char szURN[200];
/* -------------------------------------------------------------------- */
/* Prepare partial URN without the actual code. */
/* -------------------------------------------------------------------- */
if (pszVersion == NULL)
pszVersion = "";
CPLAssert(strlen(pszAuthority) + strlen(pszObjectType) < sizeof(szURN) - 30);
sprintf(szURN, "urn:ogc:def:%s:%s:%s:",
pszObjectType, pszAuthority, pszVersion);
/* -------------------------------------------------------------------- */
/* Prepare the base name, eg. <srsID>. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psElement =
CPLCreateXMLNode(psTarget, CXT_Element, pszElement);
/* -------------------------------------------------------------------- */
/* Prepare the name element. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psName =
CPLCreateXMLNode(psElement, CXT_Element, "gml:name");
/* -------------------------------------------------------------------- */
/* Prepare the codespace attribute. */
/* -------------------------------------------------------------------- */
CPLCreateXMLNode(
CPLCreateXMLNode(psName, CXT_Attribute, "gml:codeSpace"),
CXT_Text, szURN);
/* -------------------------------------------------------------------- */
/* Attach code value to name node. */
/* -------------------------------------------------------------------- */
char szCode[32];
sprintf(szCode, "%d", nCode);
CPLCreateXMLNode(psName, CXT_Text, szCode);
return psElement;
}
示例5: CPLCreateXMLNode
CPLXMLNode *VRTWarpedRasterBand::SerializeToXML( const char *pszVRTPath )
{
CPLXMLNode *psTree = VRTRasterBand::SerializeToXML( pszVRTPath );
/* -------------------------------------------------------------------- */
/* Set subclass. */
/* -------------------------------------------------------------------- */
CPLCreateXMLNode(
CPLCreateXMLNode( psTree, CXT_Attribute, "subClass" ),
CXT_Text, "VRTWarpedRasterBand" );
return psTree;
}
示例6: CSLFetchNameValue
CPLXMLNode *WCTSAuthId2crsId( char **papszParms, const char *pszName )
{
const char *pszAuthId = CSLFetchNameValue( papszParms, pszName );
CPLXMLNode *psCRSId;
char **papszTokens;
if( pszAuthId == NULL )
WCTSEmitServiceException(
CPLSPrintf( "%s keyword missing", pszName ) );
papszTokens = CSLTokenizeString2( pszAuthId, ":", 0 );
if( CSLCount(papszTokens) != 2 )
WCTSEmitServiceException(
CPLSPrintf( "%.500s value corrupt, use 'authority:code'.",
pszName ));
psCRSId = CPLCreateXMLNode( NULL, CXT_Element, "crsID" );
CPLCreateXMLElementAndValue( psCRSId, "gml:codeSpace", papszTokens[0]);
CPLCreateXMLElementAndValue( psCRSId, "gml:code", papszTokens[1] );
CSLDestroy( papszTokens );
return psCRSId;
}
示例7: VALIDATE_POINTER1
CPLXMLNode *GDALSerializeTPSTransformer( void *pTransformArg )
{
VALIDATE_POINTER1( pTransformArg, "GDALSerializeTPSTransformer", NULL );
CPLXMLNode *psTree;
TPSTransformInfo *psInfo = static_cast<TPSTransformInfo *>(pTransformArg);
psTree = CPLCreateXMLNode( NULL, CXT_Element, "TPSTransformer" );
/* -------------------------------------------------------------------- */
/* Serialize bReversed. */
/* -------------------------------------------------------------------- */
CPLCreateXMLElementAndValue(
psTree, "Reversed",
CPLString().Printf( "%d", psInfo->bReversed ) );
/* -------------------------------------------------------------------- */
/* Attach GCP List. */
/* -------------------------------------------------------------------- */
if( psInfo->nGCPCount > 0 )
{
GDALSerializeGCPListToXML( psTree,
psInfo->pasGCPList,
psInfo->nGCPCount,
NULL );
}
return psTree;
}
示例8: PamFindMatchingHistogram
CPLErr VRTRasterBand::GetHistogram( double dfMin, double dfMax,
int nBuckets, GUIntBig * panHistogram,
int bIncludeOutOfRange, int bApproxOK,
GDALProgressFunc pfnProgress,
void *pProgressData )
{
/* -------------------------------------------------------------------- */
/* Check if we have a matching histogram. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psHistItem = PamFindMatchingHistogram( m_psSavedHistograms,
dfMin, dfMax, nBuckets,
bIncludeOutOfRange, bApproxOK );
if( psHistItem != NULL )
{
GUIntBig *panTempHist = NULL;
if( PamParseHistogram( psHistItem, &dfMin, &dfMax, &nBuckets,
&panTempHist,
&bIncludeOutOfRange, &bApproxOK ) )
{
memcpy( panHistogram, panTempHist, sizeof(GUIntBig) * nBuckets );
CPLFree( panTempHist );
return CE_None;
}
}
/* -------------------------------------------------------------------- */
/* We don't have an existing histogram matching the request, so */
/* generate one manually. */
/* -------------------------------------------------------------------- */
CPLErr eErr = GDALRasterBand::GetHistogram( dfMin, dfMax,
nBuckets, panHistogram,
bIncludeOutOfRange, bApproxOK,
pfnProgress, pProgressData );
/* -------------------------------------------------------------------- */
/* Save an XML description of this histogram. */
/* -------------------------------------------------------------------- */
if( eErr == CE_None )
{
CPLXMLNode *psXMLHist = PamHistogramToXMLTree( dfMin, dfMax, nBuckets,
panHistogram,
bIncludeOutOfRange, bApproxOK );
if( psXMLHist != NULL )
{
reinterpret_cast<VRTDataset *>( poDS )->SetNeedsFlush();
if( m_psSavedHistograms == NULL )
m_psSavedHistograms = CPLCreateXMLNode( NULL, CXT_Element,
"Histograms" );
CPLAddXMLChild( m_psSavedHistograms, psXMLHist );
}
}
return eErr;
}
示例9: addGMLId
static void addGMLId(CPLXMLNode *psParent)
{
static void *hGMLIdMutex = NULL;
CPLMutexHolderD(&hGMLIdMutex);
CPLXMLNode *psId;
static int nNextGMLId = 1;
char szIdText[40];
sprintf(szIdText, "ogrcrs%d", nNextGMLId++);
psId =
CPLCreateXMLNode(
CPLCreateXMLNode(psParent, CXT_Attribute, "gml:id"),
CXT_Text, szIdText);
}
示例10: CPLDestroyXMLNode
int OGRFMECacheIndex::Load()
{
/* -------------------------------------------------------------------- */
/* Lock the cache index file if not already locked. */
/* -------------------------------------------------------------------- */
if( hLock == NULL && !Lock() )
return FALSE;
if( psTree != NULL )
{
CPLDestroyXMLNode( psTree );
psTree = NULL;
}
/* -------------------------------------------------------------------- */
/* Open the index file. If we don't get it, we assume it is */
/* because it doesn't exist, and we create a "stub" tree in */
/* memory. */
/* -------------------------------------------------------------------- */
FILE *fpIndex;
int nLength;
char *pszIndexBuffer;
fpIndex = VSIFOpen( GetPath(), "rb" );
if( fpIndex == NULL )
{
psTree = CPLCreateXMLNode( NULL, CXT_Element, "OGRFMECacheIndex" );
return TRUE;
}
/* -------------------------------------------------------------------- */
/* Load the data from the file. */
/* -------------------------------------------------------------------- */
VSIFSeek( fpIndex, 0, SEEK_END );
nLength = VSIFTell( fpIndex );
VSIFSeek( fpIndex, 0, SEEK_SET );
pszIndexBuffer = (char *) CPLMalloc(nLength+1);
if( (int) VSIFRead( pszIndexBuffer, 1, nLength, fpIndex ) != nLength )
{
CPLError( CE_Failure, CPLE_FileIO,
"Read of %d byte index file failed.", nLength );
return FALSE;
}
VSIFClose( fpIndex );
/* -------------------------------------------------------------------- */
/* Parse the result into an inmemory XML tree. */
/* -------------------------------------------------------------------- */
pszIndexBuffer[nLength] = '\0';
psTree = CPLParseXMLString( pszIndexBuffer );
CPLFree( pszIndexBuffer );
return psTree != NULL;
}
示例11: CPLFree
CPLXMLNode *VRTKernelFilteredSource::SerializeToXML( const char *pszVRTPath )
{
CPLXMLNode *psSrc = VRTFilteredSource::SerializeToXML( pszVRTPath );
if( psSrc == nullptr )
return nullptr;
CPLFree( psSrc->pszValue );
psSrc->pszValue = CPLStrdup("KernelFilteredSource" );
if( m_nKernelSize == 0 )
return psSrc;
CPLXMLNode *psKernel = CPLCreateXMLNode( psSrc, CXT_Element, "Kernel" );
if( m_bNormalized )
CPLCreateXMLNode(
CPLCreateXMLNode( psKernel, CXT_Attribute, "normalized" ),
CXT_Text, "1" );
else
CPLCreateXMLNode(
CPLCreateXMLNode( psKernel, CXT_Attribute, "normalized" ),
CXT_Text, "0" );
const int nCoefCount = m_nKernelSize * m_nKernelSize;
const size_t nBufLen = nCoefCount * 32;
char *pszKernelCoefs = static_cast<char *>( CPLMalloc(nBufLen) );
strcpy( pszKernelCoefs, "" );
for( int iCoef = 0; iCoef < nCoefCount; iCoef++ )
CPLsnprintf( pszKernelCoefs + strlen(pszKernelCoefs),
nBufLen - strlen(pszKernelCoefs),
"%.8g ", m_padfKernelCoefs[iCoef] );
CPLSetXMLValue( psKernel, "Size", CPLSPrintf( "%d", m_nKernelSize ) );
CPLSetXMLValue( psKernel, "Coefs", pszKernelCoefs );
CPLFree( pszKernelCoefs );
return psSrc;
}
示例12: CPLFree
CPLXMLNode *VRTKernelFilteredSource::SerializeToXML( const char *pszVRTPath )
{
CPLXMLNode *psSrc = VRTFilteredSource::SerializeToXML( pszVRTPath );
CPLXMLNode *psKernel;
char *pszKernelCoefs;
int iCoef, nCoefCount = nKernelSize * nKernelSize;
if( psSrc == NULL )
return NULL;
CPLFree( psSrc->pszValue );
psSrc->pszValue = CPLStrdup("KernelFilteredSource" );
if( nKernelSize == 0 )
return psSrc;
psKernel = CPLCreateXMLNode( psSrc, CXT_Element, "Kernel" );
if( bNormalized )
CPLCreateXMLNode(
CPLCreateXMLNode( psKernel, CXT_Attribute, "normalized" ),
CXT_Text, "1" );
else
CPLCreateXMLNode(
CPLCreateXMLNode( psKernel, CXT_Attribute, "normalized" ),
CXT_Text, "0" );
pszKernelCoefs = (char *) CPLMalloc(nCoefCount * 32);
strcpy( pszKernelCoefs, "" );
for( iCoef = 0; iCoef < nCoefCount; iCoef++ )
CPLsprintf( pszKernelCoefs + strlen(pszKernelCoefs),
"%.8g ", padfKernelCoefs[iCoef] );
CPLSetXMLValue( psKernel, "Size", CPLSPrintf( "%d", nKernelSize ) );
CPLSetXMLValue( psKernel, "Coefs", pszKernelCoefs );
CPLFree( pszKernelCoefs );
return psSrc;
}
示例13: VALIDATE_POINTER1
CPLXMLNode *GDALSerializeGCPTransformer( void *pTransformArg )
{
CPLXMLNode *psTree = NULL;
GCPTransformInfo *psInfo = (GCPTransformInfo *) pTransformArg;
VALIDATE_POINTER1( pTransformArg, "GDALSerializeGCPTransformer", NULL );
psTree = CPLCreateXMLNode( NULL, CXT_Element, "GCPTransformer" );
/* -------------------------------------------------------------------- */
/* Serialize Order and bReversed. */
/* -------------------------------------------------------------------- */
CPLCreateXMLElementAndValue(
psTree, "Order",
CPLSPrintf( "%d", psInfo->nOrder ) );
CPLCreateXMLElementAndValue(
psTree, "Reversed",
CPLSPrintf( "%d", psInfo->bReversed ) );
if( psInfo->bRefine )
{
CPLCreateXMLElementAndValue(
psTree, "Refine",
CPLSPrintf( "%d", psInfo->bRefine ) );
CPLCreateXMLElementAndValue(
psTree, "MinimumGcps",
CPLSPrintf( "%d", psInfo->nMinimumGcps ) );
CPLCreateXMLElementAndValue(
psTree, "Tolerance",
CPLSPrintf( "%f", psInfo->dfTolerance ) );
}
/* -------------------------------------------------------------------- */
/* Attach GCP List. */
/* -------------------------------------------------------------------- */
if( psInfo->nGCPCount > 0 )
{
if(psInfo->bRefine)
{
remove_outliers(psInfo);
}
GDALSerializeGCPListToXML( psTree,
psInfo->pasGCPList,
psInfo->nGCPCount,
NULL );
}
return psTree;
}
示例14: addProjArg
static void addProjArg(const OGRSpatialReference *poSRS, CPLXMLNode *psBase,
const char *pszMeasureType, double dfDefault,
int nParameterID, const char *pszWKTName)
{
CPLXMLNode *psNode, *psValue;
psNode = CPLCreateXMLNode(psBase, CXT_Element, "gml:usesParameterValue");
/* -------------------------------------------------------------------- */
/* Handle the UOM. */
/* -------------------------------------------------------------------- */
const char *pszUOMValue;
if (EQUAL(pszMeasureType, "Angular"))
pszUOMValue = "urn:ogc:def:uom:EPSG::9102";
else
pszUOMValue = "urn:ogc:def:uom:EPSG::9001";
psValue = CPLCreateXMLNode(psNode, CXT_Element, "gml:value");
CPLCreateXMLNode(
CPLCreateXMLNode(psValue, CXT_Attribute, "gml:uom"),
CXT_Text, pszUOMValue);
/* -------------------------------------------------------------------- */
/* Add the parameter value itself. */
/* -------------------------------------------------------------------- */
double dfParmValue
= poSRS->GetNormProjParm(pszWKTName, dfDefault, NULL);
CPLCreateXMLNode(psValue, CXT_Text,
CPLString().Printf("%.16g", dfParmValue));
/* -------------------------------------------------------------------- */
/* Add the valueOfParameter. */
/* -------------------------------------------------------------------- */
AddValueIDWithURN(psNode, "gml:valueOfParameter", "EPSG", "parameter",
nParameterID);
}
示例15: while
CPLXMLNode* GMLExpatHandler::AddAttributes(CPLXMLNode* psNode, void* attr)
{
const char** papszIter = (const char** )attr;
CPLXMLNode* psLastChild = NULL;
while(*papszIter)
{
CPLXMLNode* psChild = CPLCreateXMLNode(NULL, CXT_Attribute, papszIter[0]);
CPLCreateXMLNode(psChild, CXT_Text, papszIter[1]);
if (psLastChild == NULL)
psNode->psChild = psChild;
else
psLastChild->psNext = psChild;
psLastChild = psChild;
papszIter += 2;
}
return psLastChild;
}