这篇教程C++ CPLGetXMLNode函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLGetXMLNode函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetXMLNode函数的具体用法?C++ CPLGetXMLNode怎么用?C++ CPLGetXMLNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLGetXMLNode函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: importXMLAuthoritystatic void importXMLAuthority(CPLXMLNode *psSrcXML, OGRSpatialReference *poSRS, const char *pszSourceKey, const char *pszTargetKey){ CPLXMLNode *psIDNode = CPLGetXMLNode(psSrcXML, pszSourceKey); CPLXMLNode *psNameNode = CPLGetXMLNode(psIDNode, "name"); CPLXMLNode *psCodeSpace = CPLGetXMLNode(psNameNode, "codeSpace"); const char *pszAuthority, *pszCode; char *pszURN; int nCode = 0; if (psIDNode == NULL || psNameNode == NULL || psCodeSpace == NULL) return; pszURN = CPLStrdup(CPLGetXMLValue(psCodeSpace, "", "")); if (!parseURN(pszURN, NULL, &pszAuthority, &pszCode)) { CPLFree(pszURN); return; } if (strlen(pszCode) == 0) pszCode = (char*) CPLGetXMLValue(psNameNode, "", ""); if (pszCode != NULL) nCode = atoi(pszCode); if (nCode != 0) poSRS->SetAuthority(pszTargetKey, pszAuthority, nCode); CPLFree(pszURN);}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:34,
示例2: WCTSIsTransformablevoid WCTSIsTransformable( CPLXMLNode *psOperation ){ OGRSpatialReference *poSrcCRS, *poDstCRS; CPLXMLNode *psSrcXMLCRS, *psDstXMLCRS;/* -------------------------------------------------------------------- *//* Translate the source CRS. *//* -------------------------------------------------------------------- */ psSrcXMLCRS = CPLGetXMLNode( psOperation, "SourceCRS" ); if( psSrcXMLCRS == NULL ) WCTSEmitServiceException( "Unable to identify SourceCRS.CoordinateReferenceSystem" ); poSrcCRS = WCTSImportCoordinateReferenceSystem( psSrcXMLCRS );/* -------------------------------------------------------------------- *//* Translate the destination CRS. *//* -------------------------------------------------------------------- */ psDstXMLCRS = CPLGetXMLNode( psOperation, "TargetCRS" ); if( psDstXMLCRS == NULL ) WCTSEmitServiceException( "Unable to identify DestinationCRS.CoordinateReferenceSystem" ); poDstCRS = WCTSImportCoordinateReferenceSystem( psDstXMLCRS );/* -------------------------------------------------------------------- *//* Create a transformation object between the coordinate *//* systems as an added step of verification that they are *//* supported. *//* -------------------------------------------------------------------- */ OGRCoordinateTransformation *poCT; const char *pszResult; poCT = OGRCreateCoordinateTransformation( poSrcCRS, poDstCRS ); if( poCT == NULL ) pszResult = "false"; else { delete poCT; pszResult = "true"; } delete poSrcCRS; delete poDstCRS;/* -------------------------------------------------------------------- *//* Return the answer. *//* -------------------------------------------------------------------- */ printf( "Content-type: text/xml%c%c", 10, 10 ); printf( "<?xml version=/"1.0/" encoding=/"UTF-8/"?>/n" ); printf( "<TransformableResponse xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xsi:noNamespaceSchemaLocation=/"http://www.deegree.org/xml/schemas/wcts/transformableResponse.xsd/" transformable=/"%s/"/>/n", pszResult ); exit( 0 );}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:57,
示例3: getProjectionParmstatic double getProjectionParm(CPLXMLNode *psRootNode, int nParameterCode, const char* /*pszMeasureType */, double dfDefault){ CPLXMLNode *psUsesParameter; for (psUsesParameter = psRootNode->psChild; psUsesParameter != NULL; psUsesParameter = psUsesParameter->psNext) { if (psUsesParameter->eType != CXT_Element) continue; if (!EQUAL(psUsesParameter->pszValue, "usesParameterValue") && !EQUAL(psUsesParameter->pszValue, "usesValue")) continue; if (getEPSGObjectCodeValue(CPLGetXMLNode(psUsesParameter, "valueOfParameter"), "parameter", 0) == nParameterCode) { const char *pszValue = CPLGetXMLValue(psUsesParameter, "value", NULL); if (pszValue != NULL) return atof(pszValue); else return dfDefault; } } return dfDefault;}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:35,
示例4: getNormalizedValuestatic double getNormalizedValue(CPLXMLNode *psNode, const char *pszPath, const char* /*pszMeasure*/, double dfDefault){ CPLXMLNode *psTargetNode; CPLXMLNode *psValueNode; if (pszPath == NULL || strlen(pszPath) == 0) psTargetNode = psNode; else psTargetNode = CPLGetXMLNode(psNode, pszPath); if (psTargetNode == NULL) return dfDefault; for (psValueNode = psTargetNode->psChild; psValueNode != NULL && psValueNode->eType != CXT_Text; psValueNode = psValueNode->psNext) {} if (psValueNode == NULL) return dfDefault; // Add normalization later. return atof(psValueNode->pszValue);}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:28,
示例5: CPLParseXMLFileCPLErr GDALWMSRasterBand::ReportWMSException(const char *file_name) { CPLErr ret = CE_None; int reported_errors_count = 0; CPLXMLNode *orig_root = CPLParseXMLFile(file_name); CPLXMLNode *root = orig_root; if (root != NULL) { root = CPLGetXMLNode(root, "=ServiceExceptionReport"); } if (root != NULL) { CPLXMLNode *n = CPLGetXMLNode(root, "ServiceException"); while (n != NULL) { const char *exception = CPLGetXMLValue(n, "=ServiceException", ""); const char *exception_code = CPLGetXMLValue(n, "=ServiceException.code", ""); if (exception[0] != '/0') { if (exception_code[0] != '/0') { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: The server returned exception code '%s': %s", exception_code, exception); ++reported_errors_count; } else { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: The server returned exception: %s", exception); ++reported_errors_count; } } else if (exception_code[0] != '/0') { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: The server returned exception code '%s'.", exception_code); ++reported_errors_count; } n = n->psNext; if (n != NULL) { n = CPLGetXMLNode(n, "=ServiceException"); } } } else { ret = CE_Failure; } if (orig_root != NULL) { CPLDestroyXMLNode(orig_root); } if (reported_errors_count == 0) { ret = CE_Failure; } return ret;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:45,
示例6: CPLGetXMLNodevoid *GDALDeserializeGCPTransformer( CPLXMLNode *psTree ){ GDAL_GCP *pasGCPList = 0; int nGCPCount = 0; void *pResult = NULL; int nReqOrder = 0; int bReversed = 0; int bRefine = 0; int nMinimumGcps = 0; double dfTolerance = 0.0; /* -------------------------------------------------------------------- */ /* Check for GCPs. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" ); if( psGCPList != NULL ) { GDALDeserializeGCPListFromXML( psGCPList, &pasGCPList, &nGCPCount, NULL ); }/* -------------------------------------------------------------------- *//* Get other flags. *//* -------------------------------------------------------------------- */ nReqOrder = atoi(CPLGetXMLValue(psTree,"Order","3")); bReversed = atoi(CPLGetXMLValue(psTree,"Reversed","0")); bRefine = atoi(CPLGetXMLValue(psTree,"Refine","0")); nMinimumGcps = atoi(CPLGetXMLValue(psTree,"MinimumGcps","6")); dfTolerance = CPLAtof(CPLGetXMLValue(psTree,"Tolerance","1.0"));/* -------------------------------------------------------------------- *//* Generate transformation. *//* -------------------------------------------------------------------- */ if(bRefine) { pResult = GDALCreateGCPRefineTransformer( nGCPCount, pasGCPList, nReqOrder, bReversed, dfTolerance, nMinimumGcps ); } else { pResult = GDALCreateGCPTransformer( nGCPCount, pasGCPList, nReqOrder, bReversed ); }/* -------------------------------------------------------------------- *//* Cleanup GCP copy. *//* -------------------------------------------------------------------- */ GDALDeinitGCPs( nGCPCount, pasGCPList ); CPLFree( pasGCPList ); return pResult;}
开发者ID:koordinates,项目名称:gdal,代码行数:56,
示例7: 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,
示例8: CPLGetXMLNodeCPLXMLNode *OGRFMECacheIndex::FindMatch( const char *pszDriver, const char *pszDataset, IFMEStringArray &oUserDirectives ){ CPLXMLNode *psCDS; if( psTree == NULL ) return NULL; for( psCDS = psTree->psChild; psCDS != NULL; psCDS = psCDS->psNext ) { if( !EQUAL(pszDriver,CPLGetXMLValue(psCDS,"Driver","")) ) continue; if( !EQUAL(pszDataset,CPLGetXMLValue(psCDS,"DSName","")) ) continue; CPLXMLNode *psDirective; int bMatch = TRUE; int iDir; psDirective = CPLGetXMLNode( psCDS, "UserDirectives.Directive" ); for( iDir = 0; iDir < (int)oUserDirectives.entries() && bMatch; iDir++ ) { if( psDirective == NULL || psDirective->psChild == NULL ) bMatch = FALSE; else if( !EQUAL(psDirective->psChild->pszValue, oUserDirectives(iDir)) ) bMatch = FALSE; else psDirective = psDirective->psNext; } if( iDir < (int) oUserDirectives.entries() || !bMatch || (psDirective != NULL && psDirective->psNext != NULL) ) continue; return psCDS; } return NULL;}
开发者ID:0004c,项目名称:node-gdal,代码行数:45,
示例9: CPLGetXMLNodevoid *GDALDeserializeTPSTransformer( CPLXMLNode *psTree ){ GDAL_GCP *pasGCPList = 0; int nGCPCount = 0; void *pResult; int bReversed; /* -------------------------------------------------------------------- */ /* Check for GCPs. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" ); if( psGCPList != NULL ) { GDALDeserializeGCPListFromXML( psGCPList, &pasGCPList, &nGCPCount, NULL ); } /* -------------------------------------------------------------------- */ /* Get other flags. */ /* -------------------------------------------------------------------- */ bReversed = atoi(CPLGetXMLValue(psTree,"Reversed","0")); /* -------------------------------------------------------------------- */ /* Generate transformation. */ /* -------------------------------------------------------------------- */ pResult = GDALCreateTPSTransformer( nGCPCount, pasGCPList, bReversed ); /* -------------------------------------------------------------------- */ /* Cleanup GCP copy. */ /* -------------------------------------------------------------------- */ GDALDeinitGCPs( nGCPCount, pasGCPList ); CPLFree( pasGCPList ); return pResult;}
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:39,
示例10: CPLFindFilebool GMLRegistry::Parse(){ if( osRegistryPath.empty() ) { const char *pszFilename = CPLFindFile("gdal", "gml_registry.xml"); if( pszFilename ) osRegistryPath = pszFilename; } if( osRegistryPath.empty() ) return false; CPLXMLNode *psRootNode = CPLParseXMLFile(osRegistryPath); if( psRootNode == NULL ) return false; CPLXMLNode *psRegistryNode = CPLGetXMLNode(psRootNode, "=gml_registry"); if( psRegistryNode == NULL ) { CPLDestroyXMLNode(psRootNode); return false; } CPLXMLNode *psIter = psRegistryNode->psChild; while( psIter != NULL ) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "namespace") == 0 ) { GMLRegistryNamespace oNameSpace; if( oNameSpace.Parse(osRegistryPath, psIter) ) { aoNamespaces.push_back(oNameSpace); } } psIter = psIter->psNext; } CPLDestroyXMLNode(psRootNode); return true;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:36,
示例11: CPLStrdupCPLErr VRTDataset::XMLInit( CPLXMLNode *psTree, const char *pszVRTPath ){ if( pszVRTPath != NULL ) this->pszVRTPath = CPLStrdup(pszVRTPath);/* -------------------------------------------------------------------- *//* Check for an SRS node. *//* -------------------------------------------------------------------- */ if( strlen(CPLGetXMLValue(psTree, "SRS", "")) > 0 ) { OGRSpatialReference oSRS; CPLFree( pszProjection ); pszProjection = NULL; if( oSRS.SetFromUserInput( CPLGetXMLValue(psTree, "SRS", "") ) == OGRERR_NONE ) oSRS.exportToWkt( &pszProjection ); }/* -------------------------------------------------------------------- *//* Check for a GeoTransform node. *//* -------------------------------------------------------------------- */ if( strlen(CPLGetXMLValue(psTree, "GeoTransform", "")) > 0 ) { const char *pszGT = CPLGetXMLValue(psTree, "GeoTransform", ""); char **papszTokens; papszTokens = CSLTokenizeStringComplex( pszGT, ",", FALSE, FALSE ); if( CSLCount(papszTokens) != 6 ) { CPLError( CE_Warning, CPLE_AppDefined, "GeoTransform node does not have expected six values."); } else { for( int iTA = 0; iTA < 6; iTA++ ) adfGeoTransform[iTA] = atof(papszTokens[iTA]); bGeoTransformSet = TRUE; } CSLDestroy( papszTokens ); }/* -------------------------------------------------------------------- *//* Check for GCPs. *//* -------------------------------------------------------------------- */ CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" ); if( psGCPList != NULL ) { CPLXMLNode *psXMLGCP; OGRSpatialReference oSRS; const char *pszRawProj = CPLGetXMLValue(psGCPList, "Projection", ""); CPLFree( pszGCPProjection ); if( strlen(pszRawProj) > 0 && oSRS.SetFromUserInput( pszRawProj ) == OGRERR_NONE ) oSRS.exportToWkt( &pszGCPProjection ); else pszGCPProjection = CPLStrdup(""); // Count GCPs. int nGCPMax = 0; for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; psXMLGCP = psXMLGCP->psNext ) nGCPMax++; pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),nGCPMax); for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; psXMLGCP = psXMLGCP->psNext ) { GDAL_GCP *psGCP = pasGCPList + nGCPCount; if( !EQUAL(psXMLGCP->pszValue,"GCP") || psXMLGCP->eType != CXT_Element ) continue; GDALInitGCPs( 1, psGCP ); CPLFree( psGCP->pszId ); psGCP->pszId = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Id","")); CPLFree( psGCP->pszInfo ); psGCP->pszInfo = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Info","")); psGCP->dfGCPPixel = atof(CPLGetXMLValue(psXMLGCP,"Pixel","0.0")); psGCP->dfGCPLine = atof(CPLGetXMLValue(psXMLGCP,"Line","0.0")); psGCP->dfGCPX = atof(CPLGetXMLValue(psXMLGCP,"X","0.0")); psGCP->dfGCPY = atof(CPLGetXMLValue(psXMLGCP,"Y","0.0")); psGCP->dfGCPZ = atof(CPLGetXMLValue(psXMLGCP,"Z","0.0")); nGCPCount++; } }//.........这里部分代码省略.........
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,
示例12: GMLParseFeatureTypestaticGMLFeatureClass* GMLParseFeatureType(CPLXMLNode *psSchemaNode, const char* pszName, CPLXMLNode *psComplexType){/* -------------------------------------------------------------------- *//* Grab the sequence of extensions greatgrandchild. *//* -------------------------------------------------------------------- */ CPLXMLNode *psAttrSeq = CPLGetXMLNode( psComplexType, "complexContent.extension.sequence" ); if( psAttrSeq == NULL ) { return NULL; }/* -------------------------------------------------------------------- *//* We are pretty sure this going to be a valid Feature class *//* now, so create it. *//* -------------------------------------------------------------------- */ GMLFeatureClass *poClass = new GMLFeatureClass( pszName );/* -------------------------------------------------------------------- *//* Loop over each of the attribute elements being defined for *//* this feature class. *//* -------------------------------------------------------------------- */ CPLXMLNode *psAttrDef; int nAttributeIndex = 0; int bGotUnrecognizedType = FALSE; for( psAttrDef = psAttrSeq->psChild; psAttrDef != NULL; psAttrDef = psAttrDef->psNext ) { if( strcmp(psAttrDef->pszValue,"group") == 0 ) { /* Too complex schema for us. Aborts parsing */ delete poClass; return NULL; } if( !EQUAL(psAttrDef->pszValue,"element") ) continue; /* MapServer WFS writes element type as an attribute of element */ /* not as a simpleType definition */ const char* pszType = CPLGetXMLValue( psAttrDef, "type", NULL ); const char* pszElementName = CPLGetXMLValue( psAttrDef, "name", NULL ); if (pszType != NULL) { const char* pszStrippedNSType = StripNS(pszType); int nWidth = 0, nPrecision = 0; GMLPropertyType gmlType = GMLPT_Untyped; if (EQUAL(pszStrippedNSType, "string") || EQUAL(pszStrippedNSType, "Character")) gmlType = GMLPT_String; /* TODO: Would be nice to have a proper date type */ else if (EQUAL(pszStrippedNSType, "date") || EQUAL(pszStrippedNSType, "dateTime")) gmlType = GMLPT_String; else if (EQUAL(pszStrippedNSType, "real") || EQUAL(pszStrippedNSType, "double") || EQUAL(pszStrippedNSType, "float") || EQUAL(pszStrippedNSType, "decimal")) gmlType = GMLPT_Real; else if (EQUAL(pszStrippedNSType, "short") || EQUAL(pszStrippedNSType, "int") || EQUAL(pszStrippedNSType, "integer") || EQUAL(pszStrippedNSType, "long")) gmlType = GMLPT_Integer; else if (strncmp(pszType, "gml:", 4) == 0) { const AssocNameType* psIter = apsPropertyTypes; while(psIter->pszName) { if (strncmp(pszType + 4, psIter->pszName, strlen(psIter->pszName)) == 0) { if (poClass->GetGeometryAttributeIndex() != -1) { CPLDebug("GML", "Geometry field already found ! Ignoring the following ones"); } else { poClass->SetGeometryElement(pszElementName); poClass->SetGeometryType(psIter->eType); poClass->SetGeometryAttributeIndex( nAttributeIndex ); nAttributeIndex ++; } break; } psIter ++; }//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,
示例13: GMLParseXSDint GMLParseXSD( const char *pszFile, std::vector<GMLFeatureClass*> & aosClasses){ if( pszFile == NULL ) return FALSE;/* -------------------------------------------------------------------- *//* Load the raw XML file. *//* -------------------------------------------------------------------- */ CPLXMLNode *psXSDTree = CPLParseXMLFile( pszFile ); if( psXSDTree == NULL ) return FALSE;/* -------------------------------------------------------------------- *//* Strip off any namespace qualifiers. *//* -------------------------------------------------------------------- */ CPLStripXMLNamespace( psXSDTree, NULL, TRUE );/* -------------------------------------------------------------------- *//* Find <schema> root element. *//* -------------------------------------------------------------------- */ CPLXMLNode *psSchemaNode = CPLGetXMLNode( psXSDTree, "=schema" ); if( psSchemaNode == NULL ) { CPLDestroyXMLNode( psXSDTree ); return FALSE; }/* ==================================================================== *//* Process each feature class definition. *//* ==================================================================== */ CPLXMLNode *psThis; for( psThis = psSchemaNode->psChild; psThis != NULL; psThis = psThis->psNext ) {/* -------------------------------------------------------------------- *//* Check for <xs:element> node. *//* -------------------------------------------------------------------- */ if( psThis->eType != CXT_Element || !EQUAL(psThis->pszValue,"element") ) continue;/* -------------------------------------------------------------------- *//* Check the substitution group. *//* -------------------------------------------------------------------- */ const char *pszSubGroup = StripNS(CPLGetXMLValue(psThis,"substitutionGroup","")); // Old OGR produced elements for the feature collection. if( EQUAL(pszSubGroup, "_FeatureCollection") ) continue; if( !EQUAL(pszSubGroup, "_Feature") && !EQUAL(pszSubGroup, "AbstractFeature") /* AbstractFeature used by GML 3.2 */ ) { continue; } /* -------------------------------------------------------------------- *//* Get name *//* -------------------------------------------------------------------- */ const char *pszName; pszName = CPLGetXMLValue( psThis, "name", NULL ); if( pszName == NULL ) { continue; }/* -------------------------------------------------------------------- *//* Get type and verify relationship with name. *//* -------------------------------------------------------------------- */ const char *pszType; pszType = CPLGetXMLValue( psThis, "type", NULL ); if (pszType == NULL) { CPLXMLNode *psComplexType = CPLGetXMLNode( psThis, "complexType" ); if (psComplexType) { GMLFeatureClass* poClass = GMLParseFeatureType(psSchemaNode, pszName, psComplexType); if (poClass) aosClasses.push_back(poClass); } continue; } if( strstr( pszType, ":" ) != NULL ) pszType = strstr( pszType, ":" ) + 1; if( EQUAL(pszType, pszName) ) { /* A few WFS servers return a type name which is the element name */ /* without any _Type or Type suffix */ /* e.g. : http://apollo.erdas.com/erdas-apollo/vector/Cherokee?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=iwfs:Air */ } else if( !EQUALN(pszType,pszName,strlen(pszName)) || !(EQUAL(pszType+strlen(pszName),"_Type") ||//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,
示例14: CPLErrorGDALDataset *TSXDataset::Open( GDALOpenInfo *poOpenInfo ) {/* -------------------------------------------------------------------- *//* Is this a TerraSAR-X product file? *//* -------------------------------------------------------------------- */ if (!TSXDataset::Identify( poOpenInfo )) { return NULL; /* nope */ }/* -------------------------------------------------------------------- *//* Confirm the requested access is supported. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { CPLError( CE_Failure, CPLE_NotSupported, "The TSX driver does not support update access to existing" " datasets./n" ); return NULL; } CPLString osFilename; if( poOpenInfo->bIsDirectory ) { osFilename = CPLFormCIFilename( poOpenInfo->pszFilename, CPLGetFilename( poOpenInfo->pszFilename ), "xml" ); } else osFilename = poOpenInfo->pszFilename; /* Ingest the XML */ CPLXMLNode *psData = CPLParseXMLFile( osFilename ); if (psData == NULL) return NULL; /* find the product components */ CPLXMLNode *psComponents = CPLGetXMLNode( psData, "=level1Product.productComponents" ); if (psComponents == NULL) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to find <productComponents> tag in file./n" ); CPLDestroyXMLNode(psData); return NULL; } /* find the product info tag */ CPLXMLNode *psProductInfo = CPLGetXMLNode( psData, "=level1Product.productInfo" ); if (psProductInfo == NULL) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to find <productInfo> tag in file./n" ); CPLDestroyXMLNode(psData); return NULL; }/* -------------------------------------------------------------------- *//* Create the dataset. *//* -------------------------------------------------------------------- */ TSXDataset *poDS = new TSXDataset();/* -------------------------------------------------------------------- *//* Read in product info. *//* -------------------------------------------------------------------- */ poDS->SetMetadataItem( "SCENE_CENTRE_TIME", CPLGetXMLValue( psProductInfo, "sceneInfo.sceneCenterCoord.azimuthTimeUTC", "unknown" ) ); poDS->SetMetadataItem( "OPERATIONAL_MODE", CPLGetXMLValue( psProductInfo, "generationInfo.groundOperationsType", "unknown" ) ); poDS->SetMetadataItem( "ORBIT_CYCLE", CPLGetXMLValue( psProductInfo, "missionInfo.orbitCycle", "unknown" ) ); poDS->SetMetadataItem( "ABSOLUTE_ORBIT", CPLGetXMLValue( psProductInfo, "missionInfo.absOrbit", "unknown" ) ); poDS->SetMetadataItem( "ORBIT_DIRECTION", CPLGetXMLValue( psProductInfo, "missionInfo.orbitDirection", "unknown" ) ); poDS->SetMetadataItem( "IMAGING_MODE", CPLGetXMLValue( psProductInfo, "acquisitionInfo.imagingMode", "unknown" ) ); poDS->SetMetadataItem( "PRODUCT_VARIANT", CPLGetXMLValue( psProductInfo, "productVariantInfo.productVariant", "unknown" ) ); char *pszDataType = CPLStrdup( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageDataType", "unknown" ) ); poDS->SetMetadataItem( "IMAGE_TYPE", pszDataType ); /* Get raster information */ int nRows = atoi( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.numberOfRows", "" ) ); int nCols = atoi( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.numberOfColumns", "" ) ); poDS->nRasterXSize = nCols; poDS->nRasterYSize = nRows; poDS->SetMetadataItem( "ROW_SPACING", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.rowSpacing", "unknown" ) ); poDS->SetMetadataItem( "COL_SPACING", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.columnSpacing", "unknown" ) ); poDS->SetMetadataItem( "COL_SPACING_UNITS", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.columnSpacing.units", "unknown" ) );//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例15: CPLGetXMLNodevoid *GDALDeserializeGCPTransformer( CPLXMLNode *psTree ){ GDAL_GCP *pasGCPList = 0; int nGCPCount = 0; void *pResult; int nReqOrder; int bReversed; int bRefine; int nMinimumGcps; double dfTolerance; /* -------------------------------------------------------------------- */ /* Check for GCPs. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" ); if( psGCPList != NULL ) { int nGCPMax = 0; CPLXMLNode *psXMLGCP; // Count GCPs. for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; psXMLGCP = psXMLGCP->psNext ) nGCPMax++; pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),nGCPMax); for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; psXMLGCP = psXMLGCP->psNext ) { GDAL_GCP *psGCP = pasGCPList + nGCPCount; if( !EQUAL(psXMLGCP->pszValue,"GCP") || psXMLGCP->eType != CXT_Element ) continue; GDALInitGCPs( 1, psGCP ); CPLFree( psGCP->pszId ); psGCP->pszId = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Id","")); CPLFree( psGCP->pszInfo ); psGCP->pszInfo = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Info","")); psGCP->dfGCPPixel = atof(CPLGetXMLValue(psXMLGCP,"Pixel","0.0")); psGCP->dfGCPLine = atof(CPLGetXMLValue(psXMLGCP,"Line","0.0")); psGCP->dfGCPX = atof(CPLGetXMLValue(psXMLGCP,"X","0.0")); psGCP->dfGCPY = atof(CPLGetXMLValue(psXMLGCP,"Y","0.0")); psGCP->dfGCPZ = atof(CPLGetXMLValue(psXMLGCP,"Z","0.0")); nGCPCount++; } }/* -------------------------------------------------------------------- *//* Get other flags. *//* -------------------------------------------------------------------- */ nReqOrder = atoi(CPLGetXMLValue(psTree,"Order","3")); bReversed = atoi(CPLGetXMLValue(psTree,"Reversed","0")); bRefine = atoi(CPLGetXMLValue(psTree,"Refine","0")); nMinimumGcps = atoi(CPLGetXMLValue(psTree,"MinimumGcps","6")); dfTolerance = atof(CPLGetXMLValue(psTree,"Tolerance","1.0"));/* -------------------------------------------------------------------- *//* Generate transformation. *//* -------------------------------------------------------------------- */ if(bRefine) { pResult = GDALCreateGCPRefineTransformer( nGCPCount, pasGCPList, nReqOrder, bReversed, dfTolerance, nMinimumGcps ); } else { pResult = GDALCreateGCPTransformer( nGCPCount, pasGCPList, nReqOrder, bReversed ); } /* -------------------------------------------------------------------- *//* Cleanup GCP copy. *//* -------------------------------------------------------------------- */ GDALDeinitGCPs( nGCPCount, pasGCPList ); CPLFree( pasGCPList ); return pResult;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:87,
示例16: CPLErrorGDALDataset *TSXDataset::Open( GDALOpenInfo *poOpenInfo ) {/* -------------------------------------------------------------------- *//* Is this a TerraSAR-X product file? *//* -------------------------------------------------------------------- */ if (!TSXDataset::Identify( poOpenInfo )) { return NULL; /* nope */ } /* -------------------------------------------------------------------- *//* Confirm the requested access is supported. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { CPLError( CE_Failure, CPLE_NotSupported, "The TSX driver does not support update access to existing" " datasets./n" ); return NULL; } /* Ingest the XML */ CPLXMLNode *psData, *psComponents, *psProductInfo; psData = CPLParseXMLFile( poOpenInfo->pszFilename ); /* find the product components */ psComponents = CPLGetXMLNode( psData, "=level1Product.productComponents" ); if (psComponents == NULL) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to find <productComponents> tag in file./n" ); return NULL; } /* find the product info tag */ psProductInfo = CPLGetXMLNode( psData, "=level1Product.productInfo" ); if (psComponents == NULL) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to find <productInfo> tag in file./n" ); return NULL; }/* -------------------------------------------------------------------- *//* Create the dataset. *//* -------------------------------------------------------------------- */ TSXDataset *poDS = new TSXDataset(); poDS->fp = poOpenInfo->fp; poOpenInfo->fp = NULL;/* -------------------------------------------------------------------- *//* Read in product info. *//* -------------------------------------------------------------------- */ poDS->SetMetadataItem( "SCENE_CENTRE_TIME", CPLGetXMLValue( psProductInfo, "sceneInfo.sceneCenterCoord.azimuthTimeUTC", "unknown" ) ); poDS->SetMetadataItem( "OPERATIONAL_MODE", CPLGetXMLValue( psProductInfo, "generationInfo.groundOperationsType", "unknown" ) ); poDS->SetMetadataItem( "ORBIT_CYCLE", CPLGetXMLValue( psProductInfo, "missionInfo.orbitCycle", "unknown" ) ); poDS->SetMetadataItem( "ABSOLUTE_ORBIT", CPLGetXMLValue( psProductInfo, "missionInfo.absOrbit", "unknown" ) ); poDS->SetMetadataItem( "ORBIT_DIRECTION", CPLGetXMLValue( psProductInfo, "missionInfo.orbitDirection", "unknown" ) ); poDS->SetMetadataItem( "IMAGING_MODE", CPLGetXMLValue( psProductInfo, "acquisitionInfo.imagingMode", "unknown" ) ); poDS->SetMetadataItem( "PRODUCT_VARIANT", CPLGetXMLValue( psProductInfo, "productVariantInfo.productVariant", "unknown" ) ); char *pszDataType = strdup( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageDataType", "unknown" ) ); poDS->SetMetadataItem( "IMAGE_TYPE", pszDataType ); /* Get raster information */ int nRows = atoi( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.numberOfRows", "" ) ); int nCols = atoi( CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.numberOfColumns", "" ) ); poDS->nRasterXSize = nCols; poDS->nRasterYSize = nRows; poDS->SetMetadataItem( "ROW_SPACING", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.rowSpacing", "unknown" ) ); poDS->SetMetadataItem( "COL_SPACING", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.columnSpacing", "unknown" ) ); poDS->SetMetadataItem( "COL_SPACING_UNITS", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.columnSpacing.units", "unknown" ) ); /* Get equivalent number of looks */ poDS->SetMetadataItem( "AZIMUTH_LOOKS", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.azimuthLooks", "unknown" ) ); poDS->SetMetadataItem( "RANGE_LOOKS", CPLGetXMLValue( psProductInfo, "imageDataInfo.imageRaster.rangeLooks", "unknown" ) ); const char *pszProductVariant; pszProductVariant = CPLGetXMLValue( psProductInfo, "productVariantInfo.productVariant", "unknown" ); poDS->SetMetadataItem( "PRODUCT_VARIANT", pszProductVariant ); /* Determine what product variant this is */ if (EQUALN(pszProductVariant,"SSC",3)) poDS->nProduct = eSSC;//.........这里部分代码省略.........
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:101,
示例17: CPLParseXMLFilebool TSXDataset::getGCPsFromGEOREF_XML(char *pszGeorefFilename){ //open GEOREF.xml CPLXMLNode *psGeorefData = CPLParseXMLFile( pszGeorefFilename ); if (psGeorefData==NULL) return false; //get the ellipsoid and semi-major, semi-minor axes OGRSpatialReference osr; CPLXMLNode *psSphere = CPLGetXMLNode( psGeorefData, "=geoReference.referenceFrames.sphere" ); if (psSphere!=NULL) { const char *pszEllipsoidName = CPLGetXMLValue( psSphere, "ellipsoidID", "" ); const double minor_axis = CPLAtof(CPLGetXMLValue( psSphere, "semiMinorAxis", "0.0" )); const double major_axis = CPLAtof(CPLGetXMLValue( psSphere, "semiMajorAxis", "0.0" )); //save datum parameters to the spatial reference if ( EQUAL(pszEllipsoidName, "") || minor_axis==0.0 || major_axis==0.0 ) { CPLError(CE_Warning,CPLE_AppDefined,"Warning- incomplete" " ellipsoid information. Using wgs-84 parameters./n"); osr.SetWellKnownGeogCS( "WGS84" ); } else if ( EQUAL( pszEllipsoidName, "WGS84" ) ) { osr.SetWellKnownGeogCS( "WGS84" ); } else { const double inv_flattening = major_axis/(major_axis - minor_axis); osr.SetGeogCS( "","",pszEllipsoidName, major_axis, inv_flattening); } } //get gcps CPLXMLNode *psGeolocationGrid = CPLGetXMLNode( psGeorefData, "=geoReference.geolocationGrid" ); if (psGeolocationGrid==NULL) { CPLDestroyXMLNode( psGeorefData ); return false; } nGCPCount = atoi(CPLGetXMLValue( psGeolocationGrid, "numberOfGridPoints.total", "0" )); //count the gcps if the given count value is invalid CPLXMLNode *psNode; if (nGCPCount<=0) { for( psNode = psGeolocationGrid->psChild; psNode != NULL; psNode = psNode->psNext ) if( EQUAL(psNode->pszValue,"gridPoint") ) nGCPCount++ ; } //if there are no gcps, fail if(nGCPCount<=0) { CPLDestroyXMLNode( psGeorefData ); return false; } //put some reasonable limits of the number of gcps if (nGCPCount>MAX_GCPS ) nGCPCount=MAX_GCPS; //allocate memory for the gcps pasGCPList = reinterpret_cast<GDAL_GCP *>( CPLCalloc(sizeof(GDAL_GCP), nGCPCount) ); //loop through all gcps and set info //save the number allocated to ensure it does not run off the end of the array const int gcps_allocated = nGCPCount; nGCPCount=0; //reset to zero and count //do a check on the grid point to make sure it has lat,long row, and column //it seems that only SSC products contain row, col - how to map lat long otherwise?? //for now fail if row and col are not present - just check the first and assume the rest are the same for( psNode = psGeolocationGrid->psChild; psNode != NULL; psNode = psNode->psNext ) { if( !EQUAL(psNode->pszValue,"gridPoint") ) continue; if ( !strcmp(CPLGetXMLValue(psNode,"col","error"), "error") || !strcmp(CPLGetXMLValue(psNode,"row","error"), "error") || !strcmp(CPLGetXMLValue(psNode,"lon","error"), "error") || !strcmp(CPLGetXMLValue(psNode,"lat","error"), "error")) { CPLDestroyXMLNode( psGeorefData ); return false; } } for( psNode = psGeolocationGrid->psChild; psNode != NULL; psNode = psNode->psNext ) { //break out if the end of the array has been reached if (nGCPCount >= gcps_allocated) { CPLError(CE_Warning, CPLE_AppDefined, "GDAL TSX driver: Truncating the number of GCPs."); break; } GDAL_GCP *psGCP = pasGCPList + nGCPCount; if( !EQUAL(psNode->pszValue,"gridPoint") ) continue;//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例18: ParseKMLGeometrystatic OGRGeometry* ParseKMLGeometry(/* const */ CPLXMLNode* psXML){ OGRGeometry* poGeom = nullptr; const char* pszGeomType = psXML->pszValue; if (strcmp(pszGeomType, "Point") == 0) { const char* pszCoordinates = CPLGetXMLValue(psXML, "coordinates", nullptr); if (pszCoordinates) { char** papszTokens = CSLTokenizeString2(pszCoordinates, ",", 0); if (CSLCount(papszTokens) == 2) poGeom = new OGRPoint(CPLAtof(papszTokens[0]), CPLAtof(papszTokens[1])); else if (CSLCount(papszTokens) == 3) poGeom = new OGRPoint(CPLAtof(papszTokens[0]), CPLAtof(papszTokens[1]), CPLAtof(papszTokens[2])); CSLDestroy(papszTokens); } } else if (strcmp(pszGeomType, "LineString") == 0) { const char* pszCoordinates = CPLGetXMLValue(psXML, "coordinates", nullptr); if (pszCoordinates) { OGRLineString* poLS = new OGRLineString(); ParseLineString(poLS, pszCoordinates); poGeom = poLS; } } else if (strcmp(pszGeomType, "Polygon") == 0) { OGRPolygon* poPoly = nullptr; CPLXMLNode* psOuterBoundary = CPLGetXMLNode(psXML, "outerBoundaryIs"); if (psOuterBoundary) { CPLXMLNode* psLinearRing = CPLGetXMLNode(psOuterBoundary, "LinearRing"); const char* pszCoordinates = CPLGetXMLValue( psLinearRing ? psLinearRing : psOuterBoundary, "coordinates", nullptr); if (pszCoordinates) { OGRLinearRing* poLS = new OGRLinearRing(); ParseLineString(poLS, pszCoordinates); poPoly = new OGRPolygon(); poPoly->addRingDirectly(poLS); poGeom = poPoly; } if (poPoly) { CPLXMLNode* psIter = psXML->psChild; while(psIter) { if (psIter->eType == CXT_Element && strcmp(psIter->pszValue, "innerBoundaryIs") == 0) { psLinearRing = CPLGetXMLNode(psIter, "LinearRing"); pszCoordinates = CPLGetXMLValue( psLinearRing ? psLinearRing : psIter, "coordinates", nullptr); if (pszCoordinates) { OGRLinearRing* poLS = new OGRLinearRing(); ParseLineString(poLS, pszCoordinates); poPoly->addRingDirectly(poLS); } } psIter = psIter->psNext; } } } } else if (strcmp(pszGeomType, "MultiGeometry") == 0) { CPLXMLNode* psIter = nullptr; OGRwkbGeometryType eType = wkbUnknown; for(psIter = psXML->psChild; psIter; psIter = psIter->psNext) { if (psIter->eType == CXT_Element) { OGRwkbGeometryType eNewType = wkbUnknown; if (strcmp(psIter->pszValue, "Point") == 0) { eNewType = wkbPoint; } else if (strcmp(psIter->pszValue, "LineString") == 0) { eNewType = wkbLineString; } else if (strcmp(psIter->pszValue, "Polygon") == 0) { eNewType = wkbPolygon; } else break; if (eType == wkbUnknown) eType = eNewType; else if (eType != eNewType) break; } } OGRGeometryCollection* poColl = nullptr; if (psIter != nullptr)//.........这里部分代码省略.........
开发者ID:koordinates,项目名称:gdal,代码行数:101,
示例19: GetMetadatavoid GDALJP2AbstractDataset::LoadVectorLayers(int bOpenRemoteResources){ char** papszGMLJP2 = GetMetadata("xml:gml.root-instance"); if( papszGMLJP2 == NULL ) return; GDALDriver* poMemDriver = (GDALDriver*)GDALGetDriverByName("Memory"); if( poMemDriver == NULL ) return; CPLXMLNode* psRoot = CPLParseXMLString(papszGMLJP2[0]); if( psRoot == NULL ) return; CPLXMLNode* psCC = CPLGetXMLNode(psRoot, "=gmljp2:GMLJP2CoverageCollection"); if( psCC == NULL ) { CPLDestroyXMLNode(psRoot); return; } // Find feature collections CPLXMLNode* psCCChildIter = psCC->psChild; int nLayersAtCC = 0; int nLayersAtGC = 0; for( ; psCCChildIter != NULL; psCCChildIter = psCCChildIter->psNext ) { if( psCCChildIter->eType != CXT_Element || strcmp(psCCChildIter->pszValue, "gmljp2:featureMember") != 0 || psCCChildIter->psChild == NULL || psCCChildIter->psChild->eType != CXT_Element ) continue; CPLXMLNode* psGCorGMLJP2Features = psCCChildIter->psChild; int bIsGC = ( strstr(psGCorGMLJP2Features->pszValue, "GridCoverage") != NULL ); CPLXMLNode* psGCorGMLJP2FeaturesChildIter = psGCorGMLJP2Features->psChild; for( ; psGCorGMLJP2FeaturesChildIter != NULL; psGCorGMLJP2FeaturesChildIter = psGCorGMLJP2FeaturesChildIter->psNext ) { if( psGCorGMLJP2FeaturesChildIter->eType != CXT_Element || strcmp(psGCorGMLJP2FeaturesChildIter->pszValue, "gmljp2:feature") != 0 || psGCorGMLJP2FeaturesChildIter->psChild == NULL ) continue; CPLXMLNode* psFC = NULL; int bFreeFC = FALSE; CPLString osGMLTmpFile; CPLXMLNode* psChild = psGCorGMLJP2FeaturesChildIter->psChild; if( psChild->eType == CXT_Attribute && strcmp(psChild->pszValue, "xlink:href") == 0 && strncmp(psChild->psChild->pszValue, "gmljp2://xml/", strlen("gmljp2://xml/")) == 0 ) { const char* pszBoxName = psChild->psChild->pszValue + strlen("gmljp2://xml/"); char** papszBoxData = GetMetadata(CPLSPrintf("xml:%s", pszBoxName)); if( papszBoxData != NULL ) { psFC = CPLParseXMLString(papszBoxData[0]); bFreeFC = TRUE; } else { CPLDebug("GMLJP2", "gmljp2:feature references %s, but no corresponding box found", psChild->psChild->pszValue); } } if( psChild->eType == CXT_Attribute && strcmp(psChild->pszValue, "xlink:href") == 0 && (strncmp(psChild->psChild->pszValue, "http://", strlen("http://")) == 0 || strncmp(psChild->psChild->pszValue, "https://", strlen("https://")) == 0) ) { if( !bOpenRemoteResources ) CPLDebug("GMLJP2", "Remote feature collection %s mentionned in GMLJP2 box", psChild->psChild->pszValue); else osGMLTmpFile = "/vsicurl/" + CPLString(psChild->psChild->pszValue); } else if( psChild->eType == CXT_Element && strstr(psChild->pszValue, "FeatureCollection") != NULL ) { psFC = psChild; } if( psFC == NULL && osGMLTmpFile.size() == 0 ) continue; if( psFC != NULL ) { osGMLTmpFile = CPLSPrintf("/vsimem/gmljp2/%p/my.gml", this); // Create temporary .gml file CPLSerializeXMLTreeToFile(psFC, osGMLTmpFile); } CPLDebug("GMLJP2", "Found a FeatureCollection at %s level", (bIsGC) ? "GridCoverage" : "CoverageCollection"); CPLString osXSDTmpFile; if( psFC ) { // Try to localize its .xsd schema in a GMLJP2 auxiliary box//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,
示例20: CPLParseXMLStringGDALDataset *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,
示例21: CPLGetXMLNodeGDALDataset* ECRGTOCDataset::Build(const char* pszTOCFilename, CPLXMLNode* psXML, CPLString osProduct, CPLString osDiscId, const char* pszOpenInfoFilename){ CPLXMLNode* psTOC = CPLGetXMLNode(psXML, "=Table_of_Contents"); if (psTOC == NULL) { CPLError(CE_Warning, CPLE_AppDefined, "Cannot find Table_of_Contents element"); return NULL; } double dfGlobalMinX = 0, dfGlobalMinY = 0, dfGlobalMaxX = 0, dfGlobalMaxY= 0; double dfGlobalPixelXSize = 0, dfGlobalPixelYSize = 0; int bGlobalExtentValid = FALSE; ECRGTOCDataset* poDS = new ECRGTOCDataset(); int nSubDatasets = 0; int bLookForSubDataset = osProduct.size() != 0 && osDiscId.size() != 0; int nCountSubDataset = 0; poDS->SetDescription( pszOpenInfoFilename ); poDS->papszFileList = poDS->GDALDataset::GetFileList(); for(CPLXMLNode* psIter1 = psTOC->psChild; psIter1 != NULL; psIter1 = psIter1->psNext) { if (!(psIter1->eType == CXT_Element && psIter1->pszValue != NULL && strcmp(psIter1->pszValue, "product") == 0)) continue; const char* pszProductTitle = CPLGetXMLValue(psIter1, "product_title", NULL); if (pszProductTitle == NULL) { CPLError(CE_Warning, CPLE_AppDefined, "Cannot find product_title attribute"); continue; } if (bLookForSubDataset && strcmp(pszProductTitle, osProduct.c_str()) != 0) continue; for(CPLXMLNode* psIter2 = psIter1->psChild; psIter2 != NULL; psIter2 = psIter2->psNext) { if (!(psIter2->eType == CXT_Element && psIter2->pszValue != NULL && strcmp(psIter2->pszValue, "disc") == 0)) continue; const char* pszDiscId = CPLGetXMLValue(psIter2, "id", NULL); if (pszDiscId == NULL) { CPLError(CE_Warning, CPLE_AppDefined, "Cannot find id attribute"); continue; } if (bLookForSubDataset && strcmp(pszDiscId, osDiscId.c_str()) != 0) continue; nCountSubDataset ++; CPLXMLNode* psFrameList = CPLGetXMLNode(psIter2, "frame_list"); if (psFrameList == NULL) { CPLError(CE_Warning, CPLE_AppDefined, "Cannot find frame_list element"); continue; } int nValidFrames = 0; std::vector<FrameDesc> aosFrameDesc; int nSubDatasetScale = -1; for(CPLXMLNode* psIter3 = psFrameList->psChild; psIter3 != NULL; psIter3 = psIter3->psNext) { if (!(psIter3->eType == CXT_Element && psIter3->pszValue != NULL && strcmp(psIter3->pszValue, "scale") == 0)) continue; const char* pszSize = CPLGetXMLValue(psIter3, "size", NULL); if (pszSize == NULL) { CPLError(CE_Warning, CPLE_AppDefined, "Cannot find size attribute"); continue; }//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例22: atoiCPLErr VRTWarpedDataset::XMLInit( CPLXMLNode *psTree, const char *pszVRTPath ){ CPLErr eErr;/* -------------------------------------------------------------------- *//* Initialize blocksize before calling sub-init so that the *//* band initializers can get it from the dataset object when *//* they are created. *//* -------------------------------------------------------------------- */ nBlockXSize = atoi(CPLGetXMLValue(psTree,"BlockXSize","512")); nBlockYSize = atoi(CPLGetXMLValue(psTree,"BlockYSize","128"));/* -------------------------------------------------------------------- *//* Initialize all the general VRT stuff. This will even *//* create the VRTWarpedRasterBands and initialize them. *//* -------------------------------------------------------------------- */ eErr = VRTDataset::XMLInit( psTree, pszVRTPath ); if( eErr != CE_None ) return eErr;/* -------------------------------------------------------------------- *//* Find the GDALWarpOptions XML tree. *//* -------------------------------------------------------------------- */ CPLXMLNode *psOptionsTree; psOptionsTree = CPLGetXMLNode( psTree, "GDALWarpOptions" ); if( psOptionsTree == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Count not find required GDALWarpOptions in XML." ); return CE_Failure; }/* -------------------------------------------------------------------- *//* Adjust the SourceDataset in the warp options to take into *//* account that it is relative to the VRT if appropriate. *//* -------------------------------------------------------------------- */ int bRelativeToVRT = atoi(CPLGetXMLValue(psOptionsTree, "SourceDataset.relativeToVRT", "0" )); const char *pszRelativePath = CPLGetXMLValue(psOptionsTree, "SourceDataset", "" ); char *pszAbsolutePath; if( bRelativeToVRT ) pszAbsolutePath = CPLStrdup(CPLProjectRelativeFilename( pszVRTPath, pszRelativePath ) ); else pszAbsolutePath = CPLStrdup(pszRelativePath); CPLSetXMLValue( psOptionsTree, "SourceDataset", pszAbsolutePath ); CPLFree( pszAbsolutePath );/* -------------------------------------------------------------------- *//* And instantiate the warp options, and corresponding warp *//* operation. *//* -------------------------------------------------------------------- */ GDALWarpOptions *psWO; psWO = GDALDeserializeWarpOptions( psOptionsTree ); if( psWO == NULL ) return CE_Failure; this->eAccess = GA_Update; psWO->hDstDS = this;/* -------------------------------------------------------------------- *//* Instantiate the warp operation. *//* -------------------------------------------------------------------- */ poWarper = new GDALWarpOperation(); eErr = poWarper->Initialize( psWO ); if( eErr != CE_None) {/* -------------------------------------------------------------------- *//* We are responsible for cleaning up the transformer outselves. *//* -------------------------------------------------------------------- */ if( psWO->pTransformerArg != NULL ) GDALDestroyTransformer( psWO->pTransformerArg ); } GDALDestroyWarpOptions( psWO ); if( eErr != CE_None ) { delete poWarper; poWarper = NULL; }/* -------------------------------------------------------------------- *//* Generate overviews, if appropriate. *//* -------------------------------------------------------------------- */ char **papszTokens = CSLTokenizeString( CPLGetXMLValue( psTree, "OverviewList", "" )); int iOverview; for( iOverview = 0; papszTokens != NULL && papszTokens[iOverview] != NULL;//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,
示例23: CPLCreateXMLNode//.........这里部分代码省略......... papszCategoryNames[iEntry] ); if( psLastChild == NULL ) psCT_XML->psChild = psNode; else psLastChild->psNext = psNode; psLastChild = psNode; } }/* -------------------------------------------------------------------- *//* Histograms. *//* -------------------------------------------------------------------- */ if( psSavedHistograms != NULL ) CPLAddXMLChild( psTree, CPLCloneXMLTree( psSavedHistograms ) );/* -------------------------------------------------------------------- *//* Color Table. *//* -------------------------------------------------------------------- */ if( poColorTable != NULL ) { CPLXMLNode *psCT_XML = CPLCreateXMLNode( psTree, CXT_Element, "ColorTable" ); CPLXMLNode* psLastChild = NULL; for( int iEntry=0; iEntry < poColorTable->GetColorEntryCount(); iEntry++ ) { GDALColorEntry sEntry; CPLXMLNode *psEntry_XML = CPLCreateXMLNode( NULL, CXT_Element, "Entry" ); if( psLastChild == NULL ) psCT_XML->psChild = psEntry_XML; else psLastChild->psNext = psEntry_XML; psLastChild = psEntry_XML; poColorTable->GetColorEntryAsRGB( iEntry, &sEntry ); CPLSetXMLValue( psEntry_XML, "#c1", CPLSPrintf("%d",sEntry.c1) ); CPLSetXMLValue( psEntry_XML, "#c2", CPLSPrintf("%d",sEntry.c2) ); CPLSetXMLValue( psEntry_XML, "#c3", CPLSPrintf("%d",sEntry.c3) ); CPLSetXMLValue( psEntry_XML, "#c4", CPLSPrintf("%d",sEntry.c4) ); } }/* ==================================================================== *//* Overviews *//* ==================================================================== */ for( int iOvr = 0; iOvr < (int)apoOverviews.size(); iOvr ++ ) { CPLXMLNode *psOVR_XML = CPLCreateXMLNode( psTree, CXT_Element, "Overview" ); int bRelativeToVRT; const char *pszRelativePath; VSIStatBufL sStat; if( VSIStatExL( apoOverviews[iOvr].osFilename, &sStat, VSI_STAT_EXISTS_FLAG ) != 0 ) { pszRelativePath = apoOverviews[iOvr].osFilename; bRelativeToVRT = FALSE; } else { pszRelativePath = CPLExtractRelativePath( pszVRTPath, apoOverviews[iOvr].osFilename, &bRelativeToVRT ); } CPLSetXMLValue( psOVR_XML, "SourceFilename", pszRelativePath ); CPLCreateXMLNode( CPLCreateXMLNode( CPLGetXMLNode( psOVR_XML, "SourceFilename" ), CXT_Attribute, "relativeToVRT" ), CXT_Text, bRelativeToVRT ? "1" : "0" ); CPLSetXMLValue( psOVR_XML, "SourceBand", CPLSPrintf("%d",apoOverviews[iOvr].nBand) ); } /* ==================================================================== *//* Mask band (specific to that raster band) *//* ==================================================================== */ if( poMaskBand != NULL ) { CPLXMLNode *psBandTree = poMaskBand->SerializeToXML(pszVRTPath); if( psBandTree != NULL ) { CPLXMLNode *psMaskBandElement = CPLCreateXMLNode( psTree, CXT_Element, "MaskBand" ); CPLAddXMLChild( psMaskBandElement, psBandTree ); } } return psTree;}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,
示例24: CPLErrorCPLErr VRTRasterBand::XMLInit( CPLXMLNode * psTree, const char *pszVRTPath ){/* -------------------------------------------------------------------- *//* Validate a bit. *//* -------------------------------------------------------------------- */ if( psTree == NULL || psTree->eType != CXT_Element || !EQUAL(psTree->pszValue,"VRTRasterBand") ) { CPLError( CE_Failure, CPLE_AppDefined, "Invalid node passed to VRTRasterBand::XMLInit()." ); return CE_Failure; }/* -------------------------------------------------------------------- *//* Set the band if provided as an attribute. *//* -------------------------------------------------------------------- */ const char* pszBand = CPLGetXMLValue( psTree, "band", NULL); if( pszBand != NULL ) { nBand = atoi(pszBand); }/* -------------------------------------------------------------------- *//* Set the band if provided as an attribute. *//* -------------------------------------------------------------------- */ const char *pszDataType = CPLGetXMLValue( psTree, "dataType", NULL); if( pszDataType != NULL ) { eDataType = GDALGetDataTypeByName(pszDataType); }/* -------------------------------------------------------------------- *//* Apply any band level metadata. *//* -------------------------------------------------------------------- */ oMDMD.XMLInit( psTree, TRUE );/* -------------------------------------------------------------------- *//* Collect various other items of metadata. *//* -------------------------------------------------------------------- */ SetDescription( CPLGetXMLValue( psTree, "Description", "" ) ); if( CPLGetXMLValue( psTree, "NoDataValue", NULL ) != NULL ) SetNoDataValue( CPLAtofM(CPLGetXMLValue( psTree, "NoDataValue", "0" )) ); if( CPLGetXMLValue( psTree, "HideNoDataValue", NULL ) != NULL ) bHideNoDataValue = CSLTestBoolean( CPLGetXMLValue( psTree, "HideNoDataValue", "0" ) ); SetUnitType( CPLGetXMLValue( psTree, "UnitType", NULL ) ); SetOffset( atof(CPLGetXMLValue( psTree, "Offset", "0.0" )) ); SetScale( atof(CPLGetXMLValue( psTree, "Scale", "1.0" )) ); if( CPLGetXMLValue( psTree, "ColorInterp", NULL ) != NULL ) { const char *pszInterp = CPLGetXMLValue( psTree, "ColorInterp", NULL ); SetColorInterpretation(GDALGetColorInterpretationByName(pszInterp)); }/* -------------------------------------------------------------------- *//* Category names. *//* -------------------------------------------------------------------- */ if( CPLGetXMLNode( psTree, "CategoryNames" ) != NULL ) { CPLXMLNode *psEntry; CSLDestroy( papszCategoryNames ); papszCategoryNames = NULL; CPLStringList oCategoryNames; for( psEntry = CPLGetXMLNode( psTree, "CategoryNames" )->psChild; psEntry != NULL; psEntry = psEntry->psNext ) { if( psEntry->eType != CXT_Element || !EQUAL(psEntry->pszValue,"Category") || (psEntry->psChild != NULL && psEntry->psChild->eType != CXT_Text) ) continue; oCategoryNames.AddString( (psEntry->psChild) ? psEntry->psChild->pszValue : ""); } papszCategoryNames = oCategoryNames.StealList(); }/* -------------------------------------------------------------------- *//* Collect a color table. *//* -------------------------------------------------------------------- */ if( CPLGetXMLNode( psTree, "ColorTable" ) != NULL ) { CPLXMLNode *psEntry; GDALColorTable oTable; int iEntry = 0; for( psEntry = CPLGetXMLNode( psTree, "ColorTable" )->psChild; psEntry != NULL; psEntry = psEntry->psNext ) { GDALColorEntry sCEntry;//.........这里部分代码省略.........
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,
示例25: CPLCreateXMLNodeCPLXMLNode *VRTWarpedDataset::SerializeToXML( const char *pszVRTPath ){ CPLXMLNode *psTree; psTree = VRTDataset::SerializeToXML( pszVRTPath ); if( psTree == NULL ) return psTree;/* -------------------------------------------------------------------- *//* Set subclass. *//* -------------------------------------------------------------------- */ CPLCreateXMLNode( CPLCreateXMLNode( psTree, CXT_Attribute, "subClass" ), CXT_Text, "VRTWarpedDataset" );/* -------------------------------------------------------------------- *//* Serialize the block size. *//* -------------------------------------------------------------------- */ CPLCreateXMLElementAndValue( psTree, "BlockXSize", CPLSPrintf( "%d", nBlockXSize ) ); CPLCreateXMLElementAndValue( psTree, "BlockYSize", CPLSPrintf( "%d", nBlockYSize ) );/* -------------------------------------------------------------------- *//* Serialize the overview list. *//* -------------------------------------------------------------------- */ if( nOverviewCount > 0 ) { char *pszOverviewList; int iOverview; pszOverviewList = (char *) CPLMalloc(nOverviewCount*8 + 10); pszOverviewList[0] = '/0'; for( iOverview = 0; iOverview < nOverviewCount; iOverview++ ) { int nOvFactor; nOvFactor = (int) (0.5+GetRasterXSize() / (double) papoOverviews[iOverview]->GetRasterXSize()); sprintf( pszOverviewList + strlen(pszOverviewList), "%d ", nOvFactor ); } CPLCreateXMLElementAndValue( psTree, "OverviewList", pszOverviewList ); CPLFree( pszOverviewList ); }/* ==================================================================== *//* Serialize the warp options. *//* ==================================================================== */ CPLXMLNode *psWOTree; if( poWarper != NULL ) {/* -------------------------------------------------------------------- *//* We reset the destination dataset name so it doesn't get *//* written out in the serialize warp options. *//* -------------------------------------------------------------------- */ char *pszSavedName = CPLStrdup(GetDescription()); SetDescription(""); psWOTree = GDALSerializeWarpOptions( poWarper->GetOptions() ); CPLAddXMLChild( psTree, psWOTree ); SetDescription( pszSavedName ); CPLFree( pszSavedName );/* -------------------------------------------------------------------- *//* We need to consider making the source dataset relative to *//* the VRT file if possible. Adjust accordingly. *//* -------------------------------------------------------------------- */ CPLXMLNode *psSDS = CPLGetXMLNode( psWOTree, "SourceDataset" ); int bRelativeToVRT; char *pszRelativePath; pszRelativePath = CPLStrdup( CPLExtractRelativePath( pszVRTPath, psSDS->psChild->pszValue, &bRelativeToVRT ) ); CPLFree( psSDS->psChild->pszValue ); psSDS->psChild->pszValue = pszRelativePath; CPLCreateXMLNode( CPLCreateXMLNode( psSDS, CXT_Attribute, "relativeToVRT" ), CXT_Text, bRelativeToVRT ? "1" : "0" ); } return psTree;}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:95,
示例26: CPLAssertint OGRVRTDataSource::Initialize( CPLXMLNode *psTree, const char *pszNewName, int bUpdate ){ CPLAssert( nLayers == 0 ); this->psTree = psTree;/* -------------------------------------------------------------------- *//* Set name, and capture the directory path so we can use it *//* for relative datasources. *//* -------------------------------------------------------------------- */ CPLString osVRTDirectory = CPLGetPath( pszNewName ); pszName = CPLStrdup( pszNewName );/* -------------------------------------------------------------------- *//* Look for the OGRVRTDataSource node, it might be after an *//* <xml> node. *//* -------------------------------------------------------------------- */ CPLXMLNode *psVRTDSXML = CPLGetXMLNode( psTree, "=OGRVRTDataSource" ); if( psVRTDSXML == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Did not find the <OGRVRTDataSource> node in the root of the document,/n" "this is not really an OGR VRT." ); return FALSE; }/* -------------------------------------------------------------------- *//* Determine if we must proxy layers. *//* -------------------------------------------------------------------- */ int nOGRVRTLayerCount = CountOGRVRTLayers(psVRTDSXML); int nMaxSimultaneouslyOpened = atoi(CPLGetConfigOption("OGR_VRT_MAX_OPENED", "100")); if( nMaxSimultaneouslyOpened < 1 ) nMaxSimultaneouslyOpened = 1; if( nOGRVRTLayerCount > nMaxSimultaneouslyOpened ) poLayerPool = new OGRLayerPool(nMaxSimultaneouslyOpened);/* -------------------------------------------------------------------- *//* Look for layers. *//* -------------------------------------------------------------------- */ CPLXMLNode *psLTree; for( psLTree=psVRTDSXML->psChild; psLTree != NULL; psLTree=psLTree->psNext ) { if( psLTree->eType != CXT_Element ) continue;/* -------------------------------------------------------------------- *//* Create the layer object. *//* -------------------------------------------------------------------- */ OGRLayer *poLayer = InstanciateLayer(psLTree, osVRTDirectory, bUpdate); if( poLayer == NULL ) continue;/* -------------------------------------------------------------------- *//* Add layer to data source layer list. *//* -------------------------------------------------------------------- */ papoLayers = (OGRLayer **) CPLRealloc( papoLayers, sizeof(OGRLayer *) * (nLayers+1) ); papoLayers[nLayers++] = poLayer; } return TRUE;}
开发者ID:0004c,项目名称:node-gdal,代码行数:67,
注:本文中的CPLGetXMLNode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLGetXMLValue函数代码示例 C++ CPLGetPath函数代码示例 |