本文整理汇总了C++中CPLParseXMLString函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLParseXMLString函数的具体用法?C++ CPLParseXMLString怎么用?C++ CPLParseXMLString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLParseXMLString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: WCTSEmitServiceException
CPLXMLNode *WCTSCollectRequest()
{
if( getenv("REQUEST_METHOD") == NULL )
WCTSEmitServiceException( "REQUEST_METHOD not set." );
if( EQUAL(getenv("REQUEST_METHOD"),"GET") )
return WCTSCollectKVPRequest();
/* -------------------------------------------------------------------- */
/* Read the body of the POST message into a buffer. */
/* -------------------------------------------------------------------- */
int nContentLength = 0;
char *pszXML = NULL;
if( getenv("CONTENT_LENGTH") != NULL )
{
nContentLength = atoi(getenv("CONTENT_LENGTH"));
pszXML = (char *) CPLMalloc(nContentLength+1);
if( (int) fread(pszXML, 1, nContentLength, stdin) < nContentLength )
WCTSEmitServiceException( "POST body is short." );
pszXML[nContentLength] = '\0';
}
else
{
int nXMLMax, nXMLLen=0;
nXMLMax = 100;
pszXML = (char *) CPLMalloc(nXMLMax);
while( !feof(stdin) )
{
pszXML[nXMLLen++] = fgetc(stdin);
if( nXMLLen == nXMLMax )
{
nXMLMax = nXMLMax * 2;
pszXML = (char *) CPLRealloc(pszXML, nXMLMax);
}
}
pszXML[nXMLLen] = '\0';
}
/* -------------------------------------------------------------------- */
/* Convert into an XML document. */
/* -------------------------------------------------------------------- */
CPLErrorReset();
CPLXMLNode *psTree = CPLParseXMLString( pszXML );
CPLFree( pszXML );
if( CPLGetLastErrorType() == CE_Failure )
WCTSEmitServiceException( CPLGetLastErrorMsg() );
return psTree;
}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:60,代码来源:ogrwcts.cpp
示例2: OGR_G_CreateFromGML
OGRGeometryH OGR_G_CreateFromGML( const char *pszGML )
{
if( pszGML == NULL || strlen(pszGML) == 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"GML Geometry is empty in GML2OGRGeometry()." );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Try to parse the XML snippet using the MiniXML API. If this */
/* fails, we assume the minixml api has already posted a CPL */
/* error, and just return NULL. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psGML = CPLParseXMLString( pszGML );
if( psGML == NULL )
return NULL;
/* -------------------------------------------------------------------- */
/* Convert geometry recursively. */
/* -------------------------------------------------------------------- */
OGRGeometry *poGeometry;
poGeometry = GML2OGRGeometry_XMLNode( psGML );
CPLDestroyXMLNode( psGML );
return (OGRGeometryH) poGeometry;
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:31,代码来源:gml2ogrgeometry.cpp
示例3: 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;
}
开发者ID:0004c,项目名称:node-gdal,代码行数:57,代码来源:ogrfmecacheindex.cpp
示例4: STARTS_WITH
bool netCDFWriterConfiguration::Parse(const char *pszFilename)
{
CPLXMLNode *psRoot =
STARTS_WITH(pszFilename, "<Configuration")
? CPLParseXMLString(pszFilename)
: CPLParseXMLFile(pszFilename);
if( psRoot == NULL )
return false;
CPLXMLTreeCloser oCloser(psRoot);
for( CPLXMLNode *psIter = psRoot->psChild; psIter != NULL;
psIter = psIter->psNext )
{
if( psIter->eType != CXT_Element )
continue;
if( EQUAL(psIter->pszValue, "DatasetCreationOption") )
{
SetNameValue(psIter, m_oDatasetCreationOptions);
}
else if( EQUAL(psIter->pszValue, "LayerCreationOption") )
{
SetNameValue(psIter, m_oLayerCreationOptions);
}
else if( EQUAL(psIter->pszValue, "Attribute") )
{
netCDFWriterConfigAttribute oAtt;
if( oAtt.Parse(psIter) )
m_aoAttributes.push_back(oAtt);
}
else if( EQUAL(psIter->pszValue, "Field") )
{
netCDFWriterConfigField oField;
if( oField.Parse(psIter) )
m_oFields[!oField.m_osName.empty()
? oField.m_osName
: CPLString("__") + oField.m_osNetCDFName] =
oField;
}
else if( EQUAL(psIter->pszValue, "Layer") )
{
netCDFWriterConfigLayer oLayer;
if( oLayer.Parse(psIter) )
m_oLayers[oLayer.m_osName] = oLayer;
}
else
{
CPLDebug("GDAL_netCDF", "Ignoring %s", psIter->pszValue);
}
}
m_bIsValid = true;
return true;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:54,代码来源:netcdfwriterconfig.cpp
示例5: OGR_G_ExportToKML
CPLXMLNode *OGR_G_ExportToKMLTree( OGRGeometryH hGeometry )
{
// TODO - mloskot: If passed geometry is null the pszText is non-null,
// so the condition below is false.
char *pszText = OGR_G_ExportToKML( hGeometry, NULL );
if( pszText == NULL )
return NULL;
CPLXMLNode *psTree = CPLParseXMLString( pszText );
CPLFree( pszText );
return psTree;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:14,代码来源:ogr2kmlgeometry.cpp
示例6: GDALGMLJP2GenerateMetadata
CPLXMLNode* GDALGMLJP2GenerateMetadata(
const CPLString& osTemplateFile,
const CPLString& osSourceFile
)
{
GByte* pabyStr = nullptr;
if( !VSIIngestFile( nullptr, osTemplateFile, &pabyStr, nullptr, -1 ) )
return nullptr;
CPLString osTemplate(reinterpret_cast<char *>(pabyStr));
CPLFree(pabyStr);
if( !VSIIngestFile( nullptr, osSourceFile, &pabyStr, nullptr, -1 ) )
return nullptr;
CPLString osSource(reinterpret_cast<char *>(pabyStr));
CPLFree(pabyStr);
xmlDocPtr pDoc = xmlParseDoc(
reinterpret_cast<const xmlChar *>(osSource.c_str()));
if( pDoc == nullptr )
{
CPLError(CE_Failure, CPLE_AppDefined, "Cannot parse %s",
osSourceFile.c_str());
return nullptr;
}
xmlXPathContextPtr pXPathCtx = xmlXPathNewContext(pDoc);
if( pXPathCtx == nullptr )
{
xmlFreeDoc(pDoc);
return nullptr;
}
xmlXPathRegisterFunc(pXPathCtx, reinterpret_cast<const xmlChar *>("if"),
GDALGMLJP2XPathIf);
xmlXPathRegisterFunc(pXPathCtx, reinterpret_cast<const xmlChar *>("uuid"),
GDALGMLJP2XPathUUID);
pXPathCtx->error = GDALGMLJP2XPathErrorHandler;
GDALGMLJP2RegisterNamespaces(pXPathCtx, xmlDocGetRootElement(pDoc));
CPLString osXMLRes = GDALGMLJP2EvalExpr(osTemplate, pXPathCtx, pDoc);
xmlXPathFreeContext(pXPathCtx);
xmlFreeDoc(pDoc);
return CPLParseXMLString(osXMLRes);
}
开发者ID:rouault,项目名称:gdal,代码行数:48,代码来源:gdaljp2metadatagenerator.cpp
示例7: OGR_G_ExportToGML
CPLXMLNode *OGR_G_ExportToGMLTree( OGRGeometryH hGeometry )
{
char *pszText;
CPLXMLNode *psTree;
pszText = OGR_G_ExportToGML( hGeometry );
if( pszText == NULL )
return NULL;
psTree = CPLParseXMLString( pszText );
CPLFree( pszText );
return psTree;
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:16,代码来源:ogr2gmlgeometry.cpp
示例8: main
int main( int argc, char **argv )
{
static char szXML[20000000];
FILE *fp;
if( argc == 1 )
fp = stdin;
else if( argv[1][0] == '-' )
{
printf( "Usage: xmlreformat [filename]\n" );
exit( 0 );
}
else
{
fp = fopen( argv[1], "rt" );
if( fp == NULL )
{
printf( "Failed to open file %s.\n", argv[1] );
exit( 1 );
}
}
int nLen = fread( szXML, 1, sizeof(szXML), fp );
if( nLen >= (int) sizeof(szXML)-2 ) {
fprintf( stderr,
"xmlreformat fixed sized buffer (%d bytes) exceeded.\n",
(int) sizeof(szXML) );
exit(1);
}
if( fp != stdin )
fclose( fp );
szXML[nLen] = '\0';
CPLXMLNode *poTree = CPLParseXMLString( szXML );
if( poTree != NULL )
{
char *pszRawXML = CPLSerializeXMLTree( poTree );
printf( "%s", pszRawXML );
CPLFree( pszRawXML );
CPLDestroyXMLNode( poTree );
}
return 0;
}
开发者ID:garnertb,项目名称:gdal,代码行数:47,代码来源:xmlreformat.cpp
示例9: EQUAL
CPLErr VRTSourcedRasterBand::SetMetadata( char **papszNewMD, const char *pszDomain )
{
if( pszDomain != NULL
&& (EQUAL(pszDomain,"new_vrt_sources")
|| EQUAL(pszDomain,"vrt_sources")) )
{
VRTDriver *poDriver = (VRTDriver *) GDALGetDriverByName( "VRT" );
CPLErr eErr;
int i;
if( EQUAL(pszDomain,"vrt_sources") )
{
for( int i = 0; i < nSources; i++ )
delete papoSources[i];
CPLFree( papoSources );
papoSources = NULL;
nSources = 0;
}
for( i = 0; i < CSLCount(papszNewMD); i++ )
{
const char *pszXML = CPLParseNameValue( papszNewMD[i], NULL );
CPLXMLNode *psTree = CPLParseXMLString( pszXML );
VRTSource *poSource;
if( psTree == NULL )
return CE_Failure;
poSource = poDriver->ParseSource( psTree, NULL );
CPLDestroyXMLNode( psTree );
if( poSource != NULL )
{
eErr = AddSource( poSource );
if( eErr != CE_None )
return eErr;
}
else
return CE_Failure;
}
return CE_None;
}
else
return VRTRasterBand::SetMetadata( papszNewMD, pszDomain );
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:47,代码来源:vrtsourcedrasterband.cpp
示例10: CPLParseXMLString
// ************************************************************
// ParseServerException()
// ************************************************************
void BaseProvider::ParseServerException(CString s)
{
CPLXMLNode* node = CPLParseXMLString(s);
if (node)
{
while (node) {
CPLXMLNode* nodeException = CPLGetXMLNode(node, "ServiceException");
if (nodeException) {
CString msg = CPLGetXMLValue(nodeException, "", "");
CallbackHelper::ErrorMsg(Debug::Format("WMS Server exception (%s): %s", Name, msg));
}
node = node->psNext;
}
CPLDestroyXMLNode(node);
}
}
开发者ID:liuzhumei,项目名称:MapWinGIS,代码行数:20,代码来源:BaseProvider.cpp
示例11: ParseKMLGeometry
static OGRGeometry* ParseKMLGeometry(const char* pszKML)
{
CPLXMLNode* psXML = CPLParseXMLString(pszKML);
if (psXML == nullptr)
return nullptr;
if (psXML->eType != CXT_Element)
{
CPLDestroyXMLNode(psXML);
return nullptr;
}
OGRGeometry* poGeom = ParseKMLGeometry(psXML);
CPLDestroyXMLNode(psXML);
return poGeom;
}
开发者ID:koordinates,项目名称:gdal,代码行数:17,代码来源:ogrgftlayer.cpp
示例12: CPLParseXMLString
/**
* \brief Import coordinate system from XML format (GML only currently).
*
* This method is the same as the C function OSRImportFromXML()
* @param pszXML XML string to import
* @return OGRERR_NONE on success or OGRERR_CORRUPT_DATA on failure.
*/
OGRErr OGRSpatialReference::importFromXML(const char *pszXML)
{
CPLXMLNode *psTree;
OGRErr eErr = OGRERR_UNSUPPORTED_SRS;
this->Clear();
/* -------------------------------------------------------------------- */
/* Parse the XML. */
/* -------------------------------------------------------------------- */
psTree = CPLParseXMLString(pszXML);
if (psTree == NULL)
return OGRERR_CORRUPT_DATA;
CPLStripXMLNamespace(psTree, "gml", TRUE);
/* -------------------------------------------------------------------- */
/* Import according to the root node type. We walk through */
/* root elements as there is sometimes prefix stuff like */
/* <?xml>. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psNode = psTree;
for (psNode = psTree; psNode != NULL; psNode = psNode->psNext)
{
if (EQUAL(psNode->pszValue, "GeographicCRS"))
{
eErr = importGeogCSFromXML(this, psNode);
break;
}
else if (EQUAL(psNode->pszValue, "ProjectedCRS"))
{
eErr = importProjCSFromXML(this, psNode);
break;
}
}
CPLDestroyXMLNode(psTree);
return eErr;
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:51,代码来源:ogr_srs_xml.cpp
示例13: main
int main( int argc, char **argv )
{
CPLXMLNode *poTree;
static char szXML[10000000];
FILE *fp;
int nLen;
if( argc == 1 )
fp = stdin;
else if( argv[1][0] == '-' )
{
printf( "Usage: xmlreformat [filename]\n" );
exit( 0 );
}
else
{
fp = fopen( argv[1], "rt" );
if( fp == NULL )
{
printf( "Failed to open file %s.\n", argv[1] );
exit( 1 );
}
}
nLen = fread( szXML, 1, sizeof(szXML), fp );
if( fp != stdin )
fclose( fp );
szXML[nLen] = '\0';
poTree = CPLParseXMLString( szXML );
if( poTree != NULL )
{
char *pszRawXML = CPLSerializeXMLTree( poTree );
printf( "%s", pszRawXML );
CPLFree( pszRawXML );
CPLDestroyXMLNode( poTree );
}
return 0;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:43,代码来源:xmlreformat.cpp
示例14: GMLParseXMLFile
static
CPLXMLNode* GMLParseXMLFile(const char* pszFilename)
{
if( STARTS_WITH(pszFilename, "http://") ||
STARTS_WITH(pszFilename, "https://") )
{
CPLXMLNode* psRet = NULL;
CPLHTTPResult* psResult = CPLHTTPFetch( pszFilename, NULL );
if( psResult != NULL )
{
if( psResult->pabyData != NULL )
{
psRet = CPLParseXMLString( (const char*) psResult->pabyData );
}
CPLHTTPDestroyResult(psResult);
}
return psRet;
}
else
{
return CPLParseXMLFile(pszFilename);
}
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:23,代码来源:parsexsd.cpp
示例15: CPLFree
void GDALJP2AbstractDataset::LoadJP2Metadata(GDALOpenInfo* poOpenInfo,
const char* pszOverideFilenameIn)
{
const char* pszOverideFilename = pszOverideFilenameIn;
if( pszOverideFilename == NULL )
pszOverideFilename = poOpenInfo->pszFilename;
/* -------------------------------------------------------------------- */
/* Check for georeferencing information. */
/* -------------------------------------------------------------------- */
GDALJP2Metadata oJP2Geo;
if( (poOpenInfo->fpL != NULL && pszOverideFilenameIn == NULL &&
oJP2Geo.ReadAndParse(poOpenInfo->fpL) ) ||
(!(poOpenInfo->fpL != NULL && pszOverideFilenameIn == NULL) &&
oJP2Geo.ReadAndParse( pszOverideFilename )) )
{
CPLFree(pszProjection);
pszProjection = CPLStrdup(oJP2Geo.pszProjection);
bGeoTransformValid = oJP2Geo.bHaveGeoTransform;
memcpy( adfGeoTransform, oJP2Geo.adfGeoTransform,
sizeof(double) * 6 );
nGCPCount = oJP2Geo.nGCPCount;
pasGCPList =
GDALDuplicateGCPs( oJP2Geo.nGCPCount, oJP2Geo.pasGCPList );
if( oJP2Geo.bPixelIsPoint )
GDALDataset::SetMetadataItem(GDALMD_AREA_OR_POINT, GDALMD_AOP_POINT);
if( oJP2Geo.papszRPCMD )
GDALDataset::SetMetadata( oJP2Geo.papszRPCMD, "RPC" );
}
/* -------------------------------------------------------------------- */
/* Report XML UUID box in a dedicated metadata domain */
/* -------------------------------------------------------------------- */
if (oJP2Geo.pszXMPMetadata)
{
char *apszMDList[2];
apszMDList[0] = (char *) oJP2Geo.pszXMPMetadata;
apszMDList[1] = NULL;
GDALDataset::SetMetadata(apszMDList, "xml:XMP");
}
/* -------------------------------------------------------------------- */
/* Do we have any XML boxes we would like to treat as special */
/* domain metadata? (Note: the GDAL multidomain metadata XML box */
/* has been excluded and is dealt a few lines below. */
/* -------------------------------------------------------------------- */
int iBox;
for( iBox = 0;
oJP2Geo.papszGMLMetadata
&& oJP2Geo.papszGMLMetadata[iBox] != NULL;
iBox++ )
{
char *pszName = NULL;
const char *pszXML =
CPLParseNameValue( oJP2Geo.papszGMLMetadata[iBox],
&pszName );
CPLString osDomain;
char *apszMDList[2];
osDomain.Printf( "xml:%s", pszName );
apszMDList[0] = (char *) pszXML;
apszMDList[1] = NULL;
GDALDataset::SetMetadata( apszMDList, osDomain );
CPLFree( pszName );
}
/* -------------------------------------------------------------------- */
/* Do we have GDAL metadata? */
/* -------------------------------------------------------------------- */
if( oJP2Geo.pszGDALMultiDomainMetadata != NULL )
{
CPLXMLNode* psXMLNode = CPLParseXMLString(oJP2Geo.pszGDALMultiDomainMetadata);
if( psXMLNode )
{
GDALMultiDomainMetadata oLocalMDMD;
oLocalMDMD.XMLInit(psXMLNode, FALSE);
char** papszDomainList = oLocalMDMD.GetDomainList();
char** papszIter = papszDomainList;
GDALDataset::SetMetadata(oLocalMDMD.GetMetadata());
while( papszIter && *papszIter )
{
if( !EQUAL(*papszIter, "") && !EQUAL(*papszIter, "IMAGE_STRUCTURE") )
{
if( GDALDataset::GetMetadata(*papszIter) != NULL )
{
CPLDebug("GDALJP2",
"GDAL metadata overrides metadata in %s domain over metadata read from other boxes",
*papszIter);
}
GDALDataset::SetMetadata(oLocalMDMD.GetMetadata(*papszIter), *papszIter);
}
papszIter ++;
}
CPLDestroyXMLNode(psXMLNode);
}
//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,代码来源:gdaljp2abstractdataset.cpp
示例16: VSIFOpen
int GMLReader::LoadClasses( const char *pszFile )
{
// Add logic later to determine reasonable default schema file.
if( pszFile == NULL )
return FALSE;
/* -------------------------------------------------------------------- */
/* Load the raw XML file. */
/* -------------------------------------------------------------------- */
FILE *fp;
int nLength;
char *pszWholeText;
fp = VSIFOpen( pszFile, "rb" );
if( fp == NULL )
{
CPLError( CE_Failure, CPLE_OpenFailed,
"Failed to open file %s.", pszFile );
return FALSE;
}
VSIFSeek( fp, 0, SEEK_END );
nLength = VSIFTell( fp );
VSIFSeek( fp, 0, SEEK_SET );
pszWholeText = (char *) VSIMalloc(nLength+1);
if( pszWholeText == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to allocate %d byte buffer for %s,\n"
"is this really a GMLFeatureClassList file?",
nLength, pszFile );
VSIFClose( fp );
return FALSE;
}
if( VSIFRead( pszWholeText, nLength, 1, fp ) != 1 )
{
VSIFree( pszWholeText );
VSIFClose( fp );
CPLError( CE_Failure, CPLE_AppDefined,
"Read failed on %s.", pszFile );
return FALSE;
}
pszWholeText[nLength] = '\0';
VSIFClose( fp );
if( strstr( pszWholeText, "<GMLFeatureClassList>" ) == NULL )
{
VSIFree( pszWholeText );
CPLError( CE_Failure, CPLE_AppDefined,
"File %s does not contain a GMLFeatureClassList tree.",
pszFile );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Convert to XML parse tree. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psRoot;
psRoot = CPLParseXMLString( pszWholeText );
VSIFree( pszWholeText );
// We assume parser will report errors via CPL.
if( psRoot == NULL )
return FALSE;
if( psRoot->eType != CXT_Element
|| !EQUAL(psRoot->pszValue,"GMLFeatureClassList") )
{
CPLDestroyXMLNode(psRoot);
CPLError( CE_Failure, CPLE_AppDefined,
"File %s is not a GMLFeatureClassList document.",
pszFile );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Extract feature classes for all definitions found. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psThis;
for( psThis = psRoot->psChild; psThis != NULL; psThis = psThis->psNext )
{
if( psThis->eType == CXT_Element
&& EQUAL(psThis->pszValue,"GMLFeatureClass") )
{
GMLFeatureClass *poClass;
poClass = new GMLFeatureClass();
if( !poClass->InitializeFromXML( psThis ) )
{
delete poClass;
CPLDestroyXMLNode( psRoot );
return FALSE;
//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,代码来源:gmlreader.cpp
示例17: CPLDebug
CPLErr VRTSourcedRasterBand::SetMetadataItem( const char *pszName,
const char *pszValue,
const char *pszDomain )
{
CPLDebug( "VRT", "VRTSourcedRasterBand::SetMetadataItem(%s,%s,%s)\n",
pszName, pszValue, pszDomain );
if( pszDomain != NULL
&& EQUAL(pszDomain,"new_vrt_sources") )
{
VRTDriver *poDriver = (VRTDriver *) GDALGetDriverByName( "VRT" );
CPLXMLNode *psTree = CPLParseXMLString( pszValue );
VRTSource *poSource;
if( psTree == NULL )
return CE_Failure;
poSource = poDriver->ParseSource( psTree, NULL );
CPLDestroyXMLNode( psTree );
if( poSource != NULL )
return AddSource( poSource );
else
return CE_Failure;
}
else if( pszDomain != NULL
&& EQUAL(pszDomain,"vrt_sources") )
{
int iSource;
if (sscanf(pszName, "source_%d", &iSource) != 1 || iSource < 0 ||
iSource >= nSources)
{
CPLError(CE_Failure, CPLE_AppDefined,
"%s metadata item name is not recognized. "
"Should be between source_0 and source_%d",
pszName, nSources - 1);
return CE_Failure;
}
VRTDriver *poDriver = (VRTDriver *) GDALGetDriverByName( "VRT" );
CPLXMLNode *psTree = CPLParseXMLString( pszValue );
VRTSource *poSource;
if( psTree == NULL )
return CE_Failure;
poSource = poDriver->ParseSource( psTree, NULL );
CPLDestroyXMLNode( psTree );
if( poSource != NULL )
{
delete papoSources[iSource];
papoSources[iSource] = poSource;
((VRTDataset *)poDS)->SetNeedsFlush();
return CE_None;
}
else
return CE_Failure;
}
else
return VRTRasterBand::SetMetadataItem( pszName, pszValue, pszDomain );
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:65,代码来源:vrtsourcedrasterband.cpp
示例18: H5Dopen
void BAGDataset::LoadMetadata()
{
/* -------------------------------------------------------------------- */
/* Load the metadata from the file. */
/* -------------------------------------------------------------------- */
hid_t hMDDS = H5Dopen( hHDF5, "/BAG_root/metadata" );
hid_t datatype = H5Dget_type( hMDDS );
hid_t dataspace = H5Dget_space( hMDDS );
hid_t native = H5Tget_native_type( datatype, H5T_DIR_ASCEND );
hsize_t dims[3], maxdims[3];
H5Sget_simple_extent_dims( dataspace, dims, maxdims );
pszXMLMetadata = (char *) CPLCalloc(dims[0]+1,1);
H5Dread( hMDDS, native, H5S_ALL, dataspace, H5P_DEFAULT, pszXMLMetadata );
H5Sclose( dataspace );
H5Tclose( datatype );
H5Dclose( hMDDS );
if( strlen(pszXMLMetadata) == 0 )
return;
/* -------------------------------------------------------------------- */
/* Try to get the geotransform. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psRoot = CPLParseXMLString( pszXMLMetadata );
if( psRoot == NULL )
return;
CPLStripXMLNamespace( psRoot, NULL, TRUE );
CPLXMLNode *psGeo = CPLSearchXMLNode( psRoot, "=MD_Georectified" );
if( psGeo != NULL )
{
char **papszCornerTokens =
CSLTokenizeStringComplex(
CPLGetXMLValue( psGeo, "cornerPoints.Point.coordinates", "" ),
" ,", FALSE, FALSE );
if( CSLCount(papszCornerTokens ) == 4 )
{
double dfLLX = atof( papszCornerTokens[0] );
double dfLLY = atof( papszCornerTokens[1] );
double dfURX = atof( papszCornerTokens[2] );
double dfURY = atof( papszCornerTokens[3] );
adfGeoTransform[0] = dfLLX;
adfGeoTransform[1] = (dfURX - dfLLX) / (GetRasterXSize()-1);
adfGeoTransform[3] = dfURY;
adfGeoTransform[5] = (dfLLY - dfURY) / (GetRasterYSize()-1);
adfGeoTransform[0] -= adfGeoTransform[1] * 0.5;
adfGeoTransform[3] -= adfGeoTransform[5] * 0.5;
}
CSLDestroy( papszCornerTokens );
}
CPLDestroyXMLNode( psRoot );
/* -------------------------------------------------------------------- */
/* Try to get the coordinate system. */
/* -------------------------------------------------------------------- */
OGRSpatialReference oSRS;
if( OGR_SRS_ImportFromISO19115( &oSRS, pszXMLMetadata )
== OGRERR_NONE )
{
oSRS.exportToWkt( &pszProjection );
}
}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:75,代码来源:bagdataset.cpp
示例19: 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;
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:68,代码来源:vrtdataset.cpp
示例20: main
//.........这里部分代码省略.........
if (hBand == NULL)
continue;
if( bAsXML )
{
osLine.Printf( "<BandReport band=\"%d\">", anBandList[i] );
osXML += osLine;
}
else if( !bQuiet )
{
printf( " Band %d:\n", anBandList[i] );
}
/* -------------------------------------------------------------------- */
/* Request location info for this location. It is possible */
/* only the VRT driver actually supports this. */
/* -------------------------------------------------------------------- */
CPLString osItem;
osItem.Printf( "Pixel_%d_%d", iPixelToQuery, iLineToQuery );
const char *pszLI = GDALGetMetadataItem( hBand, osItem, "LocationInfo");
if( pszLI != NULL )
{
if( bAsXML )
osXML += pszLI;
else if( !bQuiet )
printf( " %s\n", pszLI );
else if( bLIFOnly )
{
/* Extract all files, if any. */
CPLXMLNode *psRoot = CPLParseXMLString( pszLI );
if( psRoot != NULL
&& psRoot->psChild != NULL
&& psRoot->eType == CXT_Element
&& EQUAL(psRoot->pszValue,"LocationInfo") )
{
CPLXMLNode *psNode;
for( psNode = psRoot->psChild;
psNode != NULL;
psNode = psNode->psNext )
{
if( psNode->eType == CXT_Element
&& EQUAL(psNode->pszValue,"File")
&& psNode->psChild != NULL )
{
char* pszUnescaped = CPLUnescapeString(
psNode->psChild->pszValue, NULL, CPLES_XML);
printf( "%s\n", pszUnescaped );
CPLFree(pszUnescaped);
}
}
}
CPLDestroyXMLNode( psRoot );
}
}
/* -------------------------------------------------------------------- */
/* Report the pixel value of this band. */
/* -------------------------------------------------------------------- */
double adfPixel[2];
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:66,代码来源:gdallocationinfo.cpp
注:本文中的CPLParseXMLString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论