这篇教程C++ CPLGetConfigOption函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLGetConfigOption函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetConfigOption函数的具体用法?C++ CPLGetConfigOption怎么用?C++ CPLGetConfigOption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLGetConfigOption函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CPLMutexHolderOptionalLockDOGRErr FGdbDriver::RollbackTransaction(OGRDataSource*& poDSInOut, int& bOutHasReopenedDS){ CPLMutexHolderOptionalLockD(hMutex); bOutHasReopenedDS = FALSE; OGRMutexedDataSource* poMutexedDS = (OGRMutexedDataSource*)poDSInOut; FGdbDataSource* poDS = (FGdbDataSource* )poMutexedDS->GetBaseDataSource(); FGdbDatabaseConnection* pConnection = poDS->GetConnection(); if( !pConnection->IsLocked() ) { CPLError(CE_Failure, CPLE_NotSupported, "No transaction in progress"); return OGRERR_FAILURE; } bOutHasReopenedDS = TRUE; CPLString osName(poMutexedDS->GetName()); CPLString osNameOri(osName); if( osName[osName.size()-1] == '/' || osName[osName.size()-1] == '//' ) osName.resize(osName.size()-1); //int bPerLayerCopyingForTransaction = poDS->HasPerLayerCopyingForTransaction(); pConnection->m_nRefCount ++; delete poDSInOut; poDSInOut = NULL; poMutexedDS = NULL; poDS = NULL; pConnection->CloseGeodatabase(); CPLString osEditedName(osName); osEditedName += ".ogredited"; OGRErr eErr = OGRERR_NONE; if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE1") || CPLUnlinkTree(osEditedName) != 0 ) { CPLError(CE_Warning, CPLE_AppDefined, "Cannot remove %s. Manual cleanup required", osEditedName.c_str()); eErr = OGRERR_FAILURE; } pConnection->m_pGeodatabase = new Geodatabase; long hr = ::OpenGeodatabase(StringToWString(osName), *(pConnection->m_pGeodatabase)); if (EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE2") || FAILED(hr)) { delete pConnection->m_pGeodatabase; pConnection->m_pGeodatabase = NULL; pConnection->SetLocked(FALSE); Release(osName); GDBErr(hr, "Failed to re-open Geodatabase. Dataset should be closed"); return OGRERR_FAILURE; } FGdbDataSource* pDS = new FGdbDataSource(this, pConnection); pDS->Open(osNameOri, TRUE, NULL); //pDS->SetPerLayerCopyingForTransaction(bPerLayerCopyingForTransaction); poDSInOut = new OGRMutexedDataSource(pDS, TRUE, hMutex, TRUE); pConnection->SetLocked(FALSE); return eErr;}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:67,
示例2: CleanOverviewsCPLErrGDALDefaultOverviews::BuildOverviews( const char * pszBasename, const char * pszResampling, int nOverviews, int * panOverviewList, int nBands, int * panBandList, GDALProgressFunc pfnProgress, void * pProgressData){ if( pfnProgress == nullptr ) pfnProgress = GDALDummyProgress; if( nOverviews == 0 ) return CleanOverviews();/* -------------------------------------------------------------------- *//* If we don't already have an overview file, we need to decide *//* what format to use. *//* -------------------------------------------------------------------- */ if( poODS == nullptr ) { bOvrIsAux = CPLTestBool(CPLGetConfigOption( "USE_RRD", "NO" )); if( bOvrIsAux ) { osOvrFilename = CPLResetExtension(poDS->GetDescription(),"aux"); VSIStatBufL sStatBuf; if( VSIStatExL( osOvrFilename, &sStatBuf, VSI_STAT_EXISTS_FLAG ) == 0 ) osOvrFilename.Printf( "%s.aux", poDS->GetDescription() ); } }/* -------------------------------------------------------------------- *//* If we already have the overviews open, but they are *//* read-only, then try and reopen them read-write. *//* -------------------------------------------------------------------- */ else if( poODS->GetAccess() == GA_ReadOnly ) { GDALClose( poODS ); poODS = GDALDataset::Open( osOvrFilename, GDAL_OF_RASTER | GDAL_OF_UPDATE); if( poODS == nullptr ) return CE_Failure; }/* -------------------------------------------------------------------- *//* Our TIFF overview support currently only works safely if all *//* bands are handled at the same time. *//* -------------------------------------------------------------------- */ if( !bOvrIsAux && nBands != poDS->GetRasterCount() ) { CPLError( CE_Failure, CPLE_NotSupported, "Generation of overviews in external TIFF currently only " "supported when operating on all bands. " "Operation failed." ); return CE_Failure; }/* -------------------------------------------------------------------- *//* If a basename is provided, use it to override the internal *//* overview filename. *//* -------------------------------------------------------------------- */ if( pszBasename == nullptr && osOvrFilename.length() == 0 ) pszBasename = poDS->GetDescription(); if( pszBasename != nullptr ) { if( bOvrIsAux ) osOvrFilename.Printf( "%s.aux", pszBasename ); else osOvrFilename.Printf( "%s.ovr", pszBasename ); }/* -------------------------------------------------------------------- *//* Establish which of the overview levels we already have, and *//* which are new. We assume that band 1 of the file is *//* representative. *//* -------------------------------------------------------------------- */ GDALRasterBand *poBand = poDS->GetRasterBand( 1 ); int nNewOverviews = 0; int *panNewOverviewList = static_cast<int *>( CPLCalloc(sizeof(int), nOverviews) ); double dfAreaNewOverviews = 0; double dfAreaRefreshedOverviews = 0; std::vector<bool> abValidLevel(nOverviews, true); std::vector<bool> abRequireRefresh(nOverviews, false); bool bFoundSinglePixelOverview = false; for( int i = 0; i < nOverviews && poBand != nullptr; i++ ) { // If we already have a 1x1 overview and this new one would result // in it too, then don't create it. if( bFoundSinglePixelOverview && (poBand->GetXSize() + panOverviewList[i] - 1) / panOverviewList[i] == 1 && (poBand->GetXSize() + panOverviewList[i] - 1) / panOverviewList[i] == 1 ) { abValidLevel[i] = false; continue;//.........这里部分代码省略.........
开发者ID:OSGeo,项目名称:gdal,代码行数:101,
示例3: CPLGetConfigOptionint S57ClassRegistrar::LoadInfo( const char * pszDirectory, const char * pszProfile, int bReportErr ){ FILE *fp; char szTargetFile[1024]; if( pszDirectory == NULL ) pszDirectory = CPLGetConfigOption("S57_CSV",NULL);/* ==================================================================== *//* Read the s57objectclasses file. *//* ==================================================================== */ if( pszProfile == NULL ) pszProfile = CPLGetConfigOption( "S57_PROFILE", "" ); if( EQUAL(pszProfile, "Additional_Military_Layers") ) { sprintf( szTargetFile, "s57objectclasses_%s.csv", "aml" ); } else if ( EQUAL(pszProfile, "Inland_Waterways") ) { sprintf( szTargetFile, "s57objectclasses_%s.csv", "iw" ); } else if( strlen(pszProfile) > 0 ) { sprintf( szTargetFile, "s57objectclasses_%s.csv", pszProfile ); } else { strcpy( szTargetFile, "s57objectclasses.csv" ); } if( !FindFile( szTargetFile, pszDirectory, bReportErr, &fp ) ) return FALSE;/* -------------------------------------------------------------------- *//* Skip the line defining the column titles. *//* -------------------------------------------------------------------- */ const char * pszLine = ReadLine( fp ); if( !EQUAL(pszLine, "/"Code/",/"ObjectClass/",/"Acronym/",/"Attribute_A/"," "/"Attribute_B/",/"Attribute_C/",/"Class/",/"Primitives/"" ) ) { CPLError( CE_Failure, CPLE_AppDefined, "s57objectclasses columns don't match expected format!/n" ); return FALSE; }/* -------------------------------------------------------------------- *//* Read and form string list. *//* -------------------------------------------------------------------- */ CSLDestroy( papszClassesInfo ); papszClassesInfo = (char **) CPLCalloc(sizeof(char *),MAX_CLASSES); nClasses = 0; while( nClasses < MAX_CLASSES && (pszLine = ReadLine(fp)) != NULL ) { papszClassesInfo[nClasses] = CPLStrdup(pszLine); if( papszClassesInfo[nClasses] == NULL ) break; nClasses++; } if( nClasses == MAX_CLASSES ) CPLError( CE_Warning, CPLE_AppDefined, "MAX_CLASSES exceeded in S57ClassRegistrar::LoadInfo()./n" );/* -------------------------------------------------------------------- *//* Cleanup, and establish state. *//* -------------------------------------------------------------------- */ if( fp != NULL ) VSIFClose( fp ); iCurrentClass = -1; if( nClasses == 0 ) return FALSE;/* ==================================================================== *//* Read the attributes list. *//* ==================================================================== */ if( EQUAL(pszProfile, "Additional_Military_Layers") ) { sprintf( szTargetFile, "s57attributes_%s.csv", "aml" ); } else if ( EQUAL(pszProfile, "Inland_Waterways") ) { sprintf( szTargetFile, "s57attributes_%s.csv", "iw" ); } else if( strlen(pszProfile) > 0 ) { sprintf( szTargetFile, "s57attributes_%s.csv", pszProfile ); }//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,
示例4: 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);/* -------------------------------------------------------------------- *//* Apply any dataset level metadata. *//* -------------------------------------------------------------------- */ oMDMD.XMLInit( psVRTDSXML, TRUE );/* -------------------------------------------------------------------- *//* 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. *//* -------------------------------------------------------------------- */ nLayers ++; papoLayers = (OGRLayer **) CPLRealloc( papoLayers, sizeof(OGRLayer *) * nLayers ); papoLayers[nLayers-1] = poLayer; paeLayerType = (OGRLayerType*) CPLRealloc( paeLayerType, sizeof(int) * nLayers ); if( poLayerPool != NULL && EQUAL(psLTree->pszValue,"OGRVRTLayer")) { paeLayerType[nLayers - 1] = OGR_VRT_PROXIED_LAYER; } else if( EQUAL(psLTree->pszValue,"OGRVRTLayer") ) { paeLayerType[nLayers - 1] = OGR_VRT_LAYER; } else { paeLayerType[nLayers - 1] = OGR_VRT_OTHER_LAYER; } } return TRUE;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:88,
示例5: CPLErrorGDALDataset* ZMapDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, int bStrict, CPL_UNUSED char ** papszOptions, GDALProgressFunc pfnProgress, void * pProgressData ){/* -------------------------------------------------------------------- *//* Some some rudimentary checks *//* -------------------------------------------------------------------- */ int nBands = poSrcDS->GetRasterCount(); if (nBands == 0) { CPLError( CE_Failure, CPLE_NotSupported, "ZMap driver does not support source dataset with zero band./n"); return NULL; } if (nBands != 1) { CPLError( (bStrict) ? CE_Failure : CE_Warning, CPLE_NotSupported, "ZMap driver only uses the first band of the dataset./n"); if (bStrict) return NULL; } if( pfnProgress && !pfnProgress( 0.0, NULL, pProgressData ) ) return NULL;/* -------------------------------------------------------------------- *//* Get source dataset info *//* -------------------------------------------------------------------- */ const int nXSize = poSrcDS->GetRasterXSize(); const int nYSize = poSrcDS->GetRasterYSize(); if (nXSize == 1 || nYSize == 1) { return NULL; } double adfGeoTransform[6]; poSrcDS->GetGeoTransform(adfGeoTransform); if (adfGeoTransform[2] != 0 || adfGeoTransform[4] != 0) { CPLError( CE_Failure, CPLE_NotSupported, "ZMap driver does not support CreateCopy() from skewed or " "rotated dataset./n"); return NULL; }/* -------------------------------------------------------------------- *//* Create target file *//* -------------------------------------------------------------------- */ VSILFILE* fp = VSIFOpenL(pszFilename, "wb"); if (fp == NULL) { CPLError( CE_Failure, CPLE_AppDefined, "Cannot create %s", pszFilename ); return NULL; } const int nFieldSize = 20; const int nValuesPerLine = 4; const int nDecimalCount = 7; int bHasNoDataValue = FALSE; double dfNoDataValue = poSrcDS->GetRasterBand(1)->GetNoDataValue(&bHasNoDataValue); if (!bHasNoDataValue) dfNoDataValue = 1.e30; VSIFPrintfL(fp, "!/n"); VSIFPrintfL(fp, "! Created by GDAL./n"); VSIFPrintfL(fp, "!/n"); VSIFPrintfL(fp, "@GRID FILE, GRID, %d/n", nValuesPerLine); WriteRightJustified(fp, nFieldSize, 10); VSIFPrintfL(fp, ","); WriteRightJustified(fp, dfNoDataValue, 10); VSIFPrintfL(fp, ","); WriteRightJustified(fp, "", 10); VSIFPrintfL(fp, ","); WriteRightJustified(fp, nDecimalCount, 10); VSIFPrintfL(fp, ","); WriteRightJustified(fp, 1, 10); VSIFPrintfL(fp, "/n"); WriteRightJustified(fp, nYSize, 10); VSIFPrintfL(fp, ","); WriteRightJustified(fp, nXSize, 10); VSIFPrintfL(fp, ","); if (CPLTestBool(CPLGetConfigOption("ZMAP_PIXEL_IS_POINT", "FALSE"))) { WriteRightJustified(fp, adfGeoTransform[0] + adfGeoTransform[1] / 2, 14, 7); VSIFPrintfL(fp, ","); WriteRightJustified(fp, adfGeoTransform[0] + adfGeoTransform[1] * nXSize - adfGeoTransform[1] / 2, 14, 7); VSIFPrintfL(fp, ",");//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例6: VFKReader/*! /brief VFKReaderSQLite constructor*/VFKReaderSQLite::VFKReaderSQLite(const char *pszFilename) : VFKReader(pszFilename){ const char *pszDbNameConf; CPLString osDbName; CPLString osCommand; VSIStatBufL sStatBufDb, sStatBufVfk; /* open tmp SQLite DB (re-use DB file if already exists) */ pszDbNameConf = CPLGetConfigOption("OGR_VFK_DB_NAME", NULL); if (pszDbNameConf) { osDbName = pszDbNameConf; } else { osDbName = CPLResetExtension(m_pszFilename, "db"); } size_t nLen = osDbName.length(); if( nLen > 2048 ) { nLen = 2048; osDbName.resize(nLen); } m_pszDBname = new char [nLen+1]; std::strncpy(m_pszDBname, osDbName.c_str(), nLen); m_pszDBname[nLen] = 0; CPLDebug("OGR-VFK", "Using internal DB: %s", m_pszDBname); if (CPLTestBool(CPLGetConfigOption("OGR_VFK_DB_SPATIAL", "YES"))) m_bSpatial = TRUE; /* build geometry from DB */ else m_bSpatial = FALSE; /* store also geometry in DB */ m_bNewDb = TRUE; if (VSIStatL(osDbName, &sStatBufDb) == 0) { if (CPLTestBool(CPLGetConfigOption("OGR_VFK_DB_OVERWRITE", "NO"))) { m_bNewDb = TRUE; /* overwrite existing DB */ CPLDebug("OGR-VFK", "Internal DB (%s) already exists and will be overwritten", m_pszDBname); VSIUnlink(osDbName); } else { if (VSIStatL(pszFilename, &sStatBufVfk) == 0 && sStatBufVfk.st_mtime > sStatBufDb.st_mtime) { CPLDebug("OGR-VFK", "Found %s but ignoring because it appears/n" "be older than the associated VFK file.", osDbName.c_str()); m_bNewDb = TRUE; VSIUnlink(osDbName); } else { m_bNewDb = FALSE; /* re-use existing DB */ } } } /* if (m_bNewDb) { CPLError(CE_Warning, CPLE_AppDefined, "INFO: No internal SQLite DB found. Reading VFK data may take some time..."); } */ CPLDebug("OGR-VFK", "New DB: %s Spatial: %s", m_bNewDb ? "yes" : "no", m_bSpatial ? "yes" : "no"); char* pszErrMsg; if (SQLITE_OK != sqlite3_open(osDbName, &m_poDB)) { CPLError(CE_Failure, CPLE_AppDefined, "Creating SQLite DB failed: %s", sqlite3_errmsg(m_poDB)); } if (!m_bNewDb) { char** papszResult; int nRowCount, nColCount; /* check if DB is up-to-date datasource */ pszErrMsg = NULL; papszResult = NULL; nRowCount = nColCount = 0; osCommand.Printf("SELECT * FROM %s LIMIT 1", VFK_DB_TABLE); sqlite3_get_table(m_poDB, osCommand.c_str(), &papszResult, &nRowCount, &nColCount, &pszErrMsg); sqlite3_free_table(papszResult); sqlite3_free(pszErrMsg); pszErrMsg = NULL; if (nColCount != 6) { /* it seems that DB is outdated, let's create new DB from * scratch */ if (SQLITE_OK != sqlite3_close(m_poDB)) { CPLError(CE_Failure, CPLE_AppDefined, "Closing SQLite DB failed: %s", sqlite3_errmsg(m_poDB));//.........这里部分代码省略.........
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:101,
示例7: CPLGetConfigOptionOGRDGNLayer::OGRDGNLayer( const char * pszName, DGNHandle hDGN, int bUpdate ) { this->hDGN = hDGN; this->bUpdate = bUpdate;/* -------------------------------------------------------------------- *//* Work out what link format we are using. *//* -------------------------------------------------------------------- */ OGRFieldType eLinkFieldType; pszLinkFormat = (char *) CPLGetConfigOption( "DGN_LINK_FORMAT", "FIRST" ); if( EQUAL(pszLinkFormat,"FIRST") ) eLinkFieldType = OFTInteger; else if( EQUAL(pszLinkFormat,"LIST") ) eLinkFieldType = OFTIntegerList; else if( EQUAL(pszLinkFormat,"STRING") ) eLinkFieldType = OFTString; else { CPLError( CE_Warning, CPLE_AppDefined, "DGN_LINK_FORMAT=%s, but only FIRST, LIST or STRING supported.", pszLinkFormat ); pszLinkFormat = (char *) "FIRST"; eLinkFieldType = OFTInteger; } pszLinkFormat = CPLStrdup(pszLinkFormat);/* -------------------------------------------------------------------- *//* Create the feature definition. *//* -------------------------------------------------------------------- */ poFeatureDefn = new OGRFeatureDefn( pszName ); poFeatureDefn->Reference(); OGRFieldDefn oField( "", OFTInteger );/* -------------------------------------------------------------------- *//* Element type *//* -------------------------------------------------------------------- */ oField.SetName( "Type" ); oField.SetType( OFTInteger ); oField.SetWidth( 2 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* Level number. *//* -------------------------------------------------------------------- */ oField.SetName( "Level" ); oField.SetType( OFTInteger ); oField.SetWidth( 2 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* graphic group *//* -------------------------------------------------------------------- */ oField.SetName( "GraphicGroup" ); oField.SetType( OFTInteger ); oField.SetWidth( 4 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* ColorIndex *//* -------------------------------------------------------------------- */ oField.SetName( "ColorIndex" ); oField.SetType( OFTInteger ); oField.SetWidth( 3 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* Weight *//* -------------------------------------------------------------------- */ oField.SetName( "Weight" ); oField.SetType( OFTInteger ); oField.SetWidth( 2 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* Style *//* -------------------------------------------------------------------- */ oField.SetName( "Style" ); oField.SetType( OFTInteger ); oField.SetWidth( 1 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* EntityNum *//* -------------------------------------------------------------------- */ oField.SetName( "EntityNum" ); oField.SetType( eLinkFieldType ); oField.SetWidth( 0 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,
示例8: RasterliteCreateTablesOGRDataSourceH RasterliteCreateTables(OGRDataSourceH hDS, const char* pszTableName, int nSRSId, int bWipeExistingData){ CPLString osSQL; CPLString osOldVal = CPLGetConfigOption("SQLITE_LIST_ALL_TABLES", "FALSE"); CPLString osDBName = OGR_DS_GetName(hDS); CPLString osRasterLayer; osRasterLayer.Printf("%s_rasters", pszTableName); CPLString osMetatadataLayer; osMetatadataLayer.Printf("%s_metadata", pszTableName); OGRLayerH hLyr; if (OGR_DS_GetLayerByName(hDS, osRasterLayer.c_str()) == NULL) {/* -------------------------------------------------------------------- *//* The table don't exist. Create them *//* -------------------------------------------------------------------- */ /* Create _rasters table */ osSQL.Printf ("CREATE TABLE /"%s/" (" "id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," "raster BLOB NOT NULL)", osRasterLayer.c_str()); OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL); /* Create _metadata table */ osSQL.Printf ("CREATE TABLE /"%s/" (" "id INTEGER NOT NULL PRIMARY KEY," "source_name TEXT NOT NULL," "tile_id INTEGER NOT NULL," "width INTEGER NOT NULL," "height INTEGER NOT NULL," "pixel_x_size DOUBLE NOT NULL," "pixel_y_size DOUBLE NOT NULL)", osMetatadataLayer.c_str()); OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL); /* Add geometry column to _metadata table */ osSQL.Printf("SELECT AddGeometryColumn('%s', 'geometry', %d, 'POLYGON', 2)", osMetatadataLayer.c_str(), nSRSId); if ((hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL)) == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Check that the OGR SQLite driver has Spatialite support"); OGRReleaseDataSource(hDS); return NULL; } OGR_DS_ReleaseResultSet(hDS, hLyr); /* Create spatial index on _metadata table */ osSQL.Printf("SELECT CreateSpatialIndex('%s', 'geometry')", osMetatadataLayer.c_str()); if ((hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL)) == NULL) { OGRReleaseDataSource(hDS); return NULL; } OGR_DS_ReleaseResultSet(hDS, hLyr); /* Re-open the DB to take into account the new tables*/ OGRReleaseDataSource(hDS); CPLSetThreadLocalConfigOption("SQLITE_LIST_ALL_TABLES", "TRUE"); hDS = OGROpen(osDBName.c_str(), TRUE, NULL); CPLSetThreadLocalConfigOption("SQLITE_LIST_ALL_TABLES", osOldVal.c_str()); } else { /* Check that the existing SRS is consistent with the one of the new */ /* data to be inserted */ osSQL.Printf("SELECT srid FROM geometry_columns WHERE f_table_name = '%s'", osMetatadataLayer.c_str()); hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL); if (hLyr) { int nExistingSRID = -1; OGRFeatureH hFeat = OGR_L_GetNextFeature(hLyr); if (hFeat) { nExistingSRID = OGR_F_GetFieldAsInteger(hFeat, 0); OGR_F_Destroy(hFeat); } OGR_DS_ReleaseResultSet(hDS, hLyr); if (nExistingSRID != nSRSId) { if (bWipeExistingData) { osSQL.Printf("UPDATE geometry_columns SET srid = %d " "WHERE f_table_name = /"%s/"", nSRSId, osMetatadataLayer.c_str()); OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL); /* Re-open the DB to take into account the change of SRS */ OGRReleaseDataSource(hDS); CPLSetThreadLocalConfigOption("SQLITE_LIST_ALL_TABLES", "TRUE");//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例9: RasterliteCreateCopy//.........这里部分代码省略......... { if (bExists) { CPLError(CE_Failure, CPLE_AppDefined, "Database already exists. Explicit table name must be specified"); return NULL; } osTableName = CPLGetBasename(osDBName.c_str()); } CPLString osRasterLayer; osRasterLayer.Printf("%s_rasters", osTableName.c_str()); CPLString osMetatadataLayer; osMetatadataLayer.Printf("%s_metadata", osTableName.c_str());/* -------------------------------------------------------------------- *//* Create or open the SQLite DB *//* -------------------------------------------------------------------- */ if (OGRGetDriverCount() == 0) OGRRegisterAll(); OGRSFDriverH hSQLiteDriver = OGRGetDriverByName("SQLite"); if (hSQLiteDriver == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot load OGR SQLite driver"); return NULL; } OGRDataSourceH hDS; CPLString osOldVal = CPLGetConfigOption("SQLITE_LIST_ALL_TABLES", "FALSE"); CPLSetThreadLocalConfigOption("SQLITE_LIST_ALL_TABLES", "TRUE"); if (!bExists) { char** papszOGROptions = CSLAddString(NULL, "SPATIALITE=YES"); hDS = OGR_Dr_CreateDataSource(hSQLiteDriver, osDBName.c_str(), papszOGROptions); CSLDestroy(papszOGROptions); } else { hDS = OGROpen(osDBName.c_str(), TRUE, NULL); } CPLSetThreadLocalConfigOption("SQLITE_LIST_ALL_TABLES", osOldVal.c_str()); if (hDS == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot load or create SQLite database"); return NULL; } CPLString osSQL; /* -------------------------------------------------------------------- *//* Get the SRID for the SRS *//* -------------------------------------------------------------------- */ int nSRSId = RasterliteInsertSRID(hDS, poSrcDS->GetProjectionRef());/* -------------------------------------------------------------------- *//* Create or wipe existing tables *//* -------------------------------------------------------------------- */ int bWipeExistingData =
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:67,
示例10: CPLAssertbool OGRVRTDataSource::Initialize( CPLXMLNode *psTreeIn, const char *pszNewName, int bUpdate ){ CPLAssert(nLayers == 0); AddForbiddenNames(pszNewName); psTree = psTreeIn; // 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 == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "Did not find the <OGRVRTDataSource> node in the root of the " "document, this is not really an OGR VRT."); return false; } // Determine if we must proxy layers. const int nOGRVRTLayerCount = CountOGRVRTLayers(psVRTDSXML); const int nMaxSimultaneouslyOpened = std::max(atoi(CPLGetConfigOption("OGR_VRT_MAX_OPENED", "100")), 1); if( nOGRVRTLayerCount > nMaxSimultaneouslyOpened ) poLayerPool = new OGRLayerPool(nMaxSimultaneouslyOpened); // Apply any dataset level metadata. oMDMD.XMLInit(psVRTDSXML, TRUE); // Look for layers. for( CPLXMLNode *psLTree = psVRTDSXML->psChild; psLTree != nullptr; psLTree = psLTree->psNext ) { if( psLTree->eType != CXT_Element ) continue; // Create the layer object. OGRLayer *poLayer = InstantiateLayer(psLTree, osVRTDirectory, bUpdate); if( poLayer == nullptr ) continue; // Add layer to data source layer list. nLayers++; papoLayers = static_cast<OGRLayer **>( CPLRealloc(papoLayers, sizeof(OGRLayer *) * nLayers)); papoLayers[nLayers - 1] = poLayer; paeLayerType = static_cast<OGRLayerType *>( CPLRealloc(paeLayerType, sizeof(int) * nLayers)); if( poLayerPool != nullptr && EQUAL(psLTree->pszValue, "OGRVRTLayer") ) { paeLayerType[nLayers - 1] = OGR_VRT_PROXIED_LAYER; } else if( EQUAL(psLTree->pszValue, "OGRVRTLayer") ) { paeLayerType[nLayers - 1] = OGR_VRT_LAYER; } else { paeLayerType[nLayers - 1] = OGR_VRT_OTHER_LAYER; } } return true;}
开发者ID:OSGeo,项目名称:gdal,代码行数:73,
示例11: whileOGRDataSource *OGRVRTDriver::Open( const char * pszFilename, int bUpdate ){ OGRVRTDataSource *poDS; char *pszXML = NULL;/* -------------------------------------------------------------------- *//* Are we being passed the XML definition directly? *//* Skip any leading spaces/blanks. *//* -------------------------------------------------------------------- */ const char *pszTestXML = pszFilename; while( *pszTestXML != '/0' && isspace( (unsigned char)*pszTestXML ) ) pszTestXML++; if( EQUALN(pszTestXML,"<OGRVRTDataSource>",18) ) { pszXML = CPLStrdup(pszTestXML); }/* -------------------------------------------------------------------- *//* Open file and check if it contains appropriate XML. *//* -------------------------------------------------------------------- */ else { VSILFILE *fp; char achHeader[512]; fp = VSIFOpenL( pszFilename, "rb" ); if( fp == NULL ) return NULL; memset( achHeader, 0, sizeof(achHeader) ); VSIFReadL( achHeader, 1, sizeof(achHeader)-1, fp ); if( strstr(achHeader,"<OGRVRTDataSource") == NULL ) { VSIFCloseL( fp ); return NULL; } VSIStatBufL sStatBuf; if ( VSIStatL( pszFilename, &sStatBuf ) != 0 || sStatBuf.st_size > 1024 * 1024 ) { CPLDebug( "VRT", "Unreasonable long file, not likely really VRT" ); VSIFCloseL( fp ); return NULL; }/* -------------------------------------------------------------------- *//* It is the right file, now load the full XML definition. *//* -------------------------------------------------------------------- */ int nLen = (int) sStatBuf.st_size; VSIFSeekL( fp, 0, SEEK_SET ); pszXML = (char *) VSIMalloc(nLen+1); if (pszXML == NULL) { VSIFCloseL( fp ); return NULL; } pszXML[nLen] = '/0'; if( ((int) VSIFReadL( pszXML, 1, nLen, fp )) != nLen ) { CPLFree( pszXML ); VSIFCloseL( fp ); return NULL; } VSIFCloseL( fp ); }/* -------------------------------------------------------------------- *//* Parse the XML. *//* -------------------------------------------------------------------- */ CPLXMLNode *psTree = CPLParseXMLString( pszXML ); if( psTree == NULL ) { CPLFree( pszXML ); return NULL; }/* -------------------------------------------------------------------- *//* XML Validation. *//* -------------------------------------------------------------------- */ if( CSLTestBoolean(CPLGetConfigOption("GDAL_XML_VALIDATION", "YES")) ) { const char* pszXSD = CPLFindFile( "gdal", "ogrvrt.xsd" ); if( pszXSD != NULL ) { std::vector<CPLString> aosErrors; CPLPushErrorHandlerEx(OGRVRTErrorHandler, &aosErrors); int bRet = CPLValidateXML(pszXML, pszXSD, NULL); CPLPopErrorHandler(); if( !bRet ) { if( aosErrors.size() > 0 &&//.........这里部分代码省略.........
开发者ID:0004c,项目名称:node-gdal,代码行数:101,
示例12: CPLGetConfigOptionint OGRMDBJavaEnv::Init(){ if (jvm_static == NULL) { JavaVM* vmBuf[1]; jsize nVMs; /* Are we already called from Java ? */ if (JNI_GetCreatedJavaVMs(vmBuf, 1, &nVMs) == JNI_OK && nVMs == 1) { jvm = vmBuf[0]; if (jvm->GetEnv((void **)&env, JNI_VERSION_1_2) == JNI_OK) { bCalledFromJava = TRUE; } else { jvm = NULL; env = NULL; } } else { JavaVMInitArgs args; JavaVMOption options[1]; args.version = JNI_VERSION_1_2; const char* pszClassPath = CPLGetConfigOption("CLASSPATH", NULL); CPLString osClassPathOption; if (pszClassPath) { args.nOptions = 1; osClassPathOption.Printf("-Djava.class.path=%s", pszClassPath); options[0].optionString = (char*) osClassPathOption.c_str(); args.options = options; } else args.nOptions = 0; args.ignoreUnrecognized = JNI_FALSE; int ret = JNI_CreateJavaVM(&jvm, (void **)&env, &args); if (ret != 0 || jvm == NULL || env == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "JNI_CreateJavaVM failed (%d)", ret); return FALSE; } jvm_static = jvm; env_static = env; } } else { jvm = jvm_static; env = env_static; } CHECK(byteArray_class, env->FindClass("[B")); CHECK(file_class, env->FindClass("java/io/File")); CHECK(file_constructor, env->GetMethodID(file_class, "<init>", "(Ljava/lang/String;)V")); CHECK(database_class, env->FindClass("com/healthmarketscience/jackcess/Database")); CHECK(database_open, env->GetStaticMethodID(database_class, "open", "(Ljava/io/File;Z)Lcom/healthmarketscience/jackcess/Database;")); CHECK(database_close, env->GetMethodID(database_class, "close", "()V")); CHECK(database_getTableNames, env->GetMethodID(database_class, "getTableNames", "()Ljava/util/Set;")); CHECK(database_getTable, env->GetMethodID(database_class, "getTable", "(Ljava/lang/String;)Lcom/healthmarketscience/jackcess/Table;")); CHECK(table_class, env->FindClass("com/healthmarketscience/jackcess/Table")); CHECK(table_getColumns, env->GetMethodID(table_class, "getColumns", "()Ljava/util/List;")); CHECK(table_iterator, env->GetMethodID(table_class, "iterator", "()Ljava/util/Iterator;")); CHECK(table_getRowCount, env->GetMethodID(table_class, "getRowCount", "()I")); CHECK(column_class, env->FindClass("com/healthmarketscience/jackcess/Column")); CHECK(column_getName, env->GetMethodID(column_class, "getName", "()Ljava/lang/String;")); CHECK(column_getType, env->GetMethodID(column_class, "getType", "()Lcom/healthmarketscience/jackcess/DataType;")); CHECK(column_getLength, env->GetMethodID(column_class, "getLength", "()S")); CHECK(column_isVariableLength, env->GetMethodID(column_class, "isVariableLength", "()Z")); CHECK(datatype_class, env->FindClass("com/healthmarketscience/jackcess/DataType")); CHECK(datatype_getValue, env->GetMethodID(datatype_class, "getValue", "()B")); CHECK(list_class, env->FindClass("java/util/List")); CHECK(list_iterator, env->GetMethodID(list_class, "iterator", "()Ljava/util/Iterator;")); CHECK(set_class, env->FindClass("java/util/Set")); CHECK(set_iterator, env->GetMethodID(set_class, "iterator", "()Ljava/util/Iterator;")); CHECK(map_class, env->FindClass("java/util/Map")); CHECK(map_get, env->GetMethodID(map_class, "get", "(Ljava/lang/Object;)Ljava/lang/Object;")); CHECK(iterator_class, env->FindClass("java/util/Iterator")); CHECK(iterator_hasNext, env->GetMethodID(iterator_class, "hasNext", "()Z")); CHECK(iterator_next, env->GetMethodID(iterator_class, "next", "()Ljava/lang/Object;")); CHECK(object_class, env->FindClass("java/lang/Object")); CHECK(object_toString, env->GetMethodID(object_class, "toString", "()Ljava/lang/String;")); CHECK(object_getClass, env->GetMethodID(object_class, "getClass", "()Ljava/lang/Class;")); CHECK(boolean_class, env->FindClass("java/lang/Boolean")); CHECK(boolean_booleanValue, env->GetMethodID(boolean_class, "booleanValue", "()Z"));//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例13: CPLAssertint OGRGeomediaDataSource::Open( const char * pszNewName, int bUpdate, CPL_UNUSED int bTestOpen ){ CPLAssert( nLayers == 0 );/* -------------------------------------------------------------------- *//* If this is the name of an MDB file, then construct the *//* appropriate connection string. Otherwise clip of GEOMEDIA: to *//* get the DSN. *//* *//* -------------------------------------------------------------------- */ char *pszDSN = NULL; if( STARTS_WITH_CI(pszNewName, "GEOMEDIA:") ) pszDSN = CPLStrdup( pszNewName + 9 ); else { const char *pszDSNStringTemplate = NULL; pszDSNStringTemplate = CPLGetConfigOption( "GEOMEDIA_DRIVER_TEMPLATE", "DRIVER=Microsoft Access Driver (*.mdb);DBQ=%s"); if (!CheckDSNStringTemplate(pszDSNStringTemplate)) { CPLError( CE_Failure, CPLE_AppDefined, "Illegal value for GEOMEDIA_DRIVER_TEMPLATE option"); return FALSE; } pszDSN = (char *) CPLMalloc(strlen(pszNewName)+strlen(pszDSNStringTemplate)+100); /* coverity[tainted_string] */ snprintf( pszDSN, strlen(pszNewName)+strlen(pszDSNStringTemplate)+100, pszDSNStringTemplate, pszNewName ); }/* -------------------------------------------------------------------- *//* Initialize based on the DSN. *//* -------------------------------------------------------------------- */ CPLDebug( "Geomedia", "EstablishSession(%s)", pszDSN ); if( !oSession.EstablishSession( pszDSN, NULL, NULL ) ) { CPLError( CE_Failure, CPLE_AppDefined, "Unable to initialize ODBC connection to DSN for %s,/n" "%s", pszDSN, oSession.GetLastError() ); CPLFree( pszDSN ); return FALSE; } CPLFree( pszDSN ); pszName = CPLStrdup( pszNewName ); bDSUpdate = bUpdate;/* -------------------------------------------------------------------- *//* Collect list of tables and their supporting info from *//* GAliasTable. *//* -------------------------------------------------------------------- */ CPLString osGFeaturesTable = GetTableNameFromType("INGRFeatures"); if (osGFeaturesTable.size() == 0) return FALSE; CPLString osGeometryProperties = GetTableNameFromType("INGRGeometryProperties"); CPLString osGCoordSystemTable = GetTableNameFromType("GCoordSystemTable"); std::vector<char **> apapszGeomColumns; { CPLODBCStatement oStmt( &oSession ); oStmt.Appendf( "SELECT FeatureName, PrimaryGeometryFieldName FROM %s", osGFeaturesTable.c_str() ); if( !oStmt.ExecuteSQL() ) { CPLDebug( "GEOMEDIA", "SELECT on %s fails, perhaps not a geomedia geodatabase?/n%s", osGFeaturesTable.c_str(), oSession.GetLastError() ); return FALSE; } while( oStmt.Fetch() ) { int i, iNew = static_cast<int>(apapszGeomColumns.size()); char **papszRecord = NULL; for( i = 0; i < 2; i++ ) papszRecord = CSLAddString( papszRecord, oStmt.GetColData(i) ); apapszGeomColumns.resize(iNew+1); apapszGeomColumns[iNew] = papszRecord; } } std::vector<OGRSpatialReference*> apoSRS; if (osGeometryProperties.size() != 0 && osGCoordSystemTable.size() != 0) { std::vector<CPLString> aosGUID; { CPLODBCStatement oStmt( &oSession ); oStmt.Appendf( "SELECT GCoordSystemGUID FROM %s", osGeometryProperties.c_str() ); if( !oStmt.ExecuteSQL() ) { CPLDebug( "GEOMEDIA", "SELECT on %s fails, perhaps not a geomedia geodatabase?/n%s",//.........这里部分代码省略.........
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,
示例14: OGRSQLiteExecuteSQLOGRLayer * OGRSQLiteExecuteSQL( GDALDataset* poDS, const char *pszStatement, OGRGeometry *poSpatialFilter, CPL_UNUSED const char *pszDialect ){ char* pszTmpDBName = (char*) CPLMalloc(256); sprintf(pszTmpDBName, "/vsimem/ogr2sqlite/temp_%p.db", pszTmpDBName); OGRSQLiteDataSource* poSQLiteDS = NULL; int nRet; int bSpatialiteDB = FALSE; CPLString osOldVal; const char* pszOldVal = CPLGetConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", NULL); if( pszOldVal != NULL ) { osOldVal = pszOldVal; pszOldVal = osOldVal.c_str(); }/* -------------------------------------------------------------------- *//* Create in-memory sqlite/spatialite DB *//* -------------------------------------------------------------------- */#ifdef HAVE_SPATIALITE/* -------------------------------------------------------------------- *//* Creating an empty spatialite DB (with spatial_ref_sys populated *//* has a non-neglectable cost. So at the first attempt, let's make *//* one and cache it for later use. *//* -------------------------------------------------------------------- */#if 1 static vsi_l_offset nEmptyDBSize = 0; static GByte* pabyEmptyDB = NULL; { static CPLMutex* hMutex = NULL; CPLMutexHolder oMutexHolder(&hMutex); static int bTried = FALSE; if( !bTried && CSLTestBoolean(CPLGetConfigOption("OGR_SQLITE_DIALECT_USE_SPATIALITE", "YES")) ) { bTried = TRUE; char* pszCachedFilename = (char*) CPLMalloc(256); sprintf(pszCachedFilename, "/vsimem/ogr2sqlite/reference_%p.db",pszCachedFilename); char** papszOptions = CSLAddString(NULL, "SPATIALITE=YES"); OGRSQLiteDataSource* poCachedDS = new OGRSQLiteDataSource(); nRet = poCachedDS->Create( pszCachedFilename, papszOptions ); CSLDestroy(papszOptions); papszOptions = NULL; delete poCachedDS; if( nRet ) /* Note: the reference file keeps the ownership of the data, so that */ /* it gets released with VSICleanupFileManager() */ pabyEmptyDB = VSIGetMemFileBuffer( pszCachedFilename, &nEmptyDBSize, FALSE ); CPLFree( pszCachedFilename ); } } /* The following configuration option is useful mostly for debugging/testing */ if( pabyEmptyDB != NULL && CSLTestBoolean(CPLGetConfigOption("OGR_SQLITE_DIALECT_USE_SPATIALITE", "YES")) ) { GByte* pabyEmptyDBClone = (GByte*)VSIMalloc(nEmptyDBSize); if( pabyEmptyDBClone == NULL ) { CPLFree(pszTmpDBName); return NULL; } memcpy(pabyEmptyDBClone, pabyEmptyDB, nEmptyDBSize); VSIFCloseL(VSIFileFromMemBuffer( pszTmpDBName, pabyEmptyDBClone, nEmptyDBSize, TRUE )); poSQLiteDS = new OGRSQLiteDataSource(); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", "NO"); nRet = poSQLiteDS->Open( pszTmpDBName, TRUE, NULL ); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", pszOldVal); if( !nRet ) { /* should not happen really ! */ delete poSQLiteDS; VSIUnlink(pszTmpDBName); CPLFree(pszTmpDBName); return NULL; } bSpatialiteDB = TRUE; }#else /* No caching version */ poSQLiteDS = new OGRSQLiteDataSource(); char** papszOptions = CSLAddString(NULL, "SPATIALITE=YES"); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", "NO"); nRet = poSQLiteDS->Create( pszTmpDBName, papszOptions ); CPLSetThreadLocalConfigOption("OGR_SQLITE_STATIC_VIRTUAL_OGR", pszOldVal); CSLDestroy(papszOptions); papszOptions = NULL; if( nRet ) { bSpatialiteDB = TRUE; }#endif else//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
示例15: CPLXMLSchemaResolveIncludestaticvoid CPLXMLSchemaResolveInclude( const char* pszMainSchemaLocation, CPLXMLNode *psSchemaNode ){ std::set<CPLString> osAlreadyIncluded; bool bTryAgain; do { CPLXMLNode *psLast = NULL; bTryAgain = false; CPLXMLNode *psThis = psSchemaNode->psChild; for( ; psThis != NULL; psThis = psThis->psNext ) { if( psThis->eType == CXT_Element && EQUAL(psThis->pszValue,"include") ) { const char* pszSchemaLocation = CPLGetXMLValue(psThis, "schemaLocation", NULL); if( pszSchemaLocation != NULL && osAlreadyIncluded.count( pszSchemaLocation) == 0 ) { osAlreadyIncluded.insert( pszSchemaLocation ); if( !STARTS_WITH(pszSchemaLocation, "http://") && !STARTS_WITH(pszSchemaLocation, "https://") && CPLIsFilenameRelative(pszSchemaLocation ) ) { pszSchemaLocation = CPLFormFilename( CPLGetPath(pszMainSchemaLocation), pszSchemaLocation, NULL ); } CPLXMLNode *psIncludedXSDTree = GMLParseXMLFile( pszSchemaLocation ); if( psIncludedXSDTree != NULL ) { CPLStripXMLNamespace( psIncludedXSDTree, NULL, TRUE ); CPLXMLNode *psIncludedSchemaNode = CPLGetXMLNode( psIncludedXSDTree, "=schema" ); if( psIncludedSchemaNode != NULL ) { /* Substitute de <include> node by its content */ CPLXMLNode* psFirstChildElement = CPLGetFirstChildNode(psIncludedSchemaNode); if( psFirstChildElement != NULL ) { CPLXMLNode* psCopy = CPLCloneXMLTree(psFirstChildElement); if( psLast != NULL ) psLast->psNext = psCopy; else psSchemaNode->psChild = psCopy; CPLXMLNode* psNext = psThis->psNext; psThis->psNext = NULL; CPLDestroyXMLNode(psThis); psThis = CPLGetLastNode(psCopy); psThis->psNext = psNext; /* In case the included schema also contains */ /* includes */ bTryAgain = true; } } CPLDestroyXMLNode( psIncludedXSDTree ); } } } psLast = psThis; } } while( bTryAgain ); const char* pszSchemaOutputName = CPLGetConfigOption("GML_SCHEMA_OUTPUT_NAME", NULL); if( pszSchemaOutputName != NULL ) { CPLSerializeXMLTreeToFile( psSchemaNode, pszSchemaOutputName ); }}
开发者ID:ryandavid,项目名称:rotobox,代码行数:80,
示例16: CSLTestBoolean/** * /brief Fetch a document from an url and return in a string. * * @param pszURL valid URL recognized by underlying download library (libcurl) * @param papszOptions option list as a NULL-terminated array of strings. May be NULL. * The following options are handled : * <ul> * <li>TIMEOUT=val, where val is in seconds</li> * <li>HEADERS=val, where val is an extra header to use when getting a web page. * For example "Accept: application/x-ogcwkt" * <li>HTTPAUTH=[BASIC/NTLM/GSSNEGOTIATE/ANY] to specify an authentication scheme to use. * <li>USERPWD=userid:password to specify a user and password for authentication * <li>POSTFIELDS=val, where val is a nul-terminated string to be passed to the server * with a POST request. * <li>PROXY=val, to make requests go through a proxy server, where val is of the * form proxy.server.com:port_number * <li>PROXYUSERPWD=val, where val is of the form username:password * <li>PROXYAUTH=[BASIC/NTLM/DIGEST/ANY] to specify an proxy authentication scheme to use. * <li>NETRC=[YES/NO] to enable or disable use of $HOME/.netrc, default YES. * <li>CUSTOMREQUEST=val, where val is GET, PUT, POST, DELETE, etc.. (GDAL >= 1.9.0) * <li>COOKIE=val, where val is formatted as COOKIE1=VALUE1; COOKIE2=VALUE2; ... * <li>MAX_RETRY=val, where val is the maximum number of retry attempts if a 503 or * 504 HTTP error occurs. Default is 0. (GDAL >= 2.0) * <li>RETRY_DELAY=val, where val is the number of seconds between retry attempts. * Default is 30. (GDAL >= 2.0) * </ul> * * Alternatively, if not defined in the papszOptions arguments, the PROXY, * PROXYUSERPWD, PROXYAUTH, NETRC, MAX_RETRY and RETRY_DELAY values are searched in the configuration * options named GDAL_HTTP_PROXY, GDAL_HTTP_PROXYUSERPWD, GDAL_PROXY_AUTH, * GDAL_HTTP_NETRC, GDAL_HTTP_MAX_RETRY and GDAL_HTTP_RETRY_DELAY. * * @return a CPLHTTPResult* structure that must be freed by * CPLHTTPDestroyResult(), or NULL if libcurl support is disabled */CPLHTTPResult *CPLHTTPFetch( const char *pszURL, char **papszOptions ){ if( strncmp(pszURL, "/vsimem/", strlen("/vsimem/")) == 0 && /* Disabled by default for potential security issues */ CSLTestBoolean(CPLGetConfigOption("CPL_CURL_ENABLE_VSIMEM", "FALSE")) ) { CPLString osURL(pszURL); const char* pszPost = CSLFetchNameValue( papszOptions, "POSTFIELDS" ); if( pszPost != NULL ) /* Hack: we append post content to filename */ { osURL += "&POSTFIELDS="; osURL += pszPost; } vsi_l_offset nLength = 0; CPLHTTPResult* psResult = (CPLHTTPResult* )CPLCalloc(1, sizeof(CPLHTTPResult)); GByte* pabyData = VSIGetMemFileBuffer( osURL, &nLength, FALSE ); if( pabyData == NULL ) { CPLDebug("HTTP", "Cannot find %s", osURL.c_str()); psResult->nStatus = 1; psResult->pszErrBuf = CPLStrdup(CPLSPrintf("HTTP error code : %d", 404)); CPLError( CE_Failure, CPLE_AppDefined, "%s", psResult->pszErrBuf ); } else if( nLength != 0 ) { psResult->nDataLen = (size_t)nLength; psResult->pabyData = (GByte*) CPLMalloc((size_t)nLength + 1); memcpy(psResult->pabyData, pabyData, (size_t)nLength); psResult->pabyData[(size_t)nLength] = 0; } if( psResult->pabyData != NULL && strncmp((const char*)psResult->pabyData, "Content-Type: ", strlen("Content-Type: ")) == 0 ) { const char* pszContentType = (const char*)psResult->pabyData + strlen("Content-type: "); const char* pszEOL = strchr(pszContentType, '/r'); if( pszEOL ) pszEOL = strchr(pszContentType, '/n'); if( pszEOL ) { int nLength = pszEOL - pszContentType; psResult->pszContentType = (char*)CPLMalloc(nLength + 1); memcpy(psResult->pszContentType, pszContentType, nLength); psResult->pszContentType[nLength] = 0; } } return psResult; }#ifndef HAVE_CURL (void) papszOptions; (void) pszURL; CPLError( CE_Failure, CPLE_NotSupported, "GDAL/OGR not compiled with libcurl support, remote requests not supported." ); return NULL;#else/* -------------------------------------------------------------------- *//* Are we using a persistent named session? If so, search for *//* or create it. *//* *///.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例17: VFKDataBlock/*! /brief Create DB table from VFKDataBlock (SQLITE only) /param poDataBlock pointer to VFKDataBlock instance*/void VFKReaderSQLite::AddDataBlock(IVFKDataBlock *poDataBlock, const char *pszDefn){ const char *pszBlockName; const char *pszKey; CPLString osCommand, osColumn; bool bUnique; VFKPropertyDefn *poPropertyDefn; sqlite3_stmt *hStmt; bUnique = !CPLTestBool(CPLGetConfigOption("OGR_VFK_DB_IGNORE_DUPLICATES", "NO")); pszBlockName = poDataBlock->GetName(); /* register table in VFK_DB_TABLE */ osCommand.Printf("SELECT COUNT(*) FROM %s WHERE " "table_name = '%s'", VFK_DB_TABLE, pszBlockName); hStmt = PrepareStatement(osCommand.c_str()); if (ExecuteSQL(hStmt) == OGRERR_NONE && sqlite3_column_int(hStmt, 0) == 0) { osCommand.Printf("CREATE TABLE '%s' (", pszBlockName); for (int i = 0; i < poDataBlock->GetPropertyCount(); i++) { poPropertyDefn = poDataBlock->GetProperty(i); if (i > 0) osCommand += ","; osColumn.Printf("%s %s", poPropertyDefn->GetName(), poPropertyDefn->GetTypeSQL().c_str()); osCommand += osColumn; } osColumn.Printf(",%s integer", FID_COLUMN); osCommand += osColumn; if (poDataBlock->GetGeometryType() != wkbNone) { osColumn.Printf(",%s blob", GEOM_COLUMN); osCommand += osColumn; } osCommand += ")"; ExecuteSQL(osCommand.c_str()); /* CREATE TABLE */ /* create indices */ osCommand.Printf("%s_%s", pszBlockName, FID_COLUMN); CreateIndex(osCommand.c_str(), pszBlockName, FID_COLUMN, !EQUAL(pszBlockName, "SBP")); pszKey = ((VFKDataBlockSQLite *) poDataBlock)->GetKey(); if (pszKey) { osCommand.Printf("%s_%s", pszBlockName, pszKey); CreateIndex(osCommand.c_str(), pszBlockName, pszKey, bUnique); } if (EQUAL(pszBlockName, "SBP")) { /* create extra indices for SBP */ CreateIndex("SBP_OB", pszBlockName, "OB_ID", FALSE); CreateIndex("SBP_HP", pszBlockName, "HP_ID", FALSE); CreateIndex("SBP_DPM", pszBlockName, "DPM_ID", FALSE); CreateIndex("SBP_OB_HP_DPM", pszBlockName, "OB_ID,HP_ID,DPM_ID", bUnique); CreateIndex("SBP_OB_POR", pszBlockName, "OB_ID,PORADOVE_CISLO_BODU", FALSE); CreateIndex("SBP_HP_POR", pszBlockName, "HP_ID,PORADOVE_CISLO_BODU", FALSE); CreateIndex("SBP_DPM_POR", pszBlockName, "DPM_ID,PORADOVE_CISLO_BODU", FALSE); } else if (EQUAL(pszBlockName, "HP")) { /* create extra indices for HP */ CreateIndex("HP_PAR1", pszBlockName, "PAR_ID_1", FALSE); CreateIndex("HP_PAR2", pszBlockName, "PAR_ID_2", FALSE); } else if (EQUAL(pszBlockName, "OB")) { /* create extra indices for OP */ CreateIndex("OB_BUD", pszBlockName, "BUD_ID", FALSE); } /* update VFK_DB_TABLE meta-table */ osCommand.Printf("INSERT INTO %s (file_name, table_name, " "num_records, num_features, num_geometries, table_defn) VALUES " "('%s', '%s', -1, 0, 0, '%s')", VFK_DB_TABLE, m_pszFilename, pszBlockName, pszDefn); ExecuteSQL(osCommand.c_str()); sqlite3_finalize(hStmt); } return VFKReader::AddDataBlock(poDataBlock, NULL);}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:91,
示例18: CPLErrorVvoid CPLErrorV(CPLErr eErrClass, int err_no, const char *fmt, va_list args ){ CPLErrorContext *psCtx = CPLGetErrorContext();/* -------------------------------------------------------------------- *//* Expand the error message *//* -------------------------------------------------------------------- */#if defined(HAVE_VSNPRINTF) { int nPR; va_list wrk_args;#ifdef va_copy va_copy( wrk_args, args );#else wrk_args = args;#endif/* -------------------------------------------------------------------- *//* If CPL_ACCUM_ERROR_MSG=ON accumulate the error messages, *//* rather than just replacing the last error message. *//* -------------------------------------------------------------------- */ int nPreviousSize = 0; if ( psCtx->psHandlerStack != NULL && EQUAL(CPLGetConfigOption( "CPL_ACCUM_ERROR_MSG", "" ), "ON")) { nPreviousSize = strlen(psCtx->szLastErrMsg); if (nPreviousSize) { if (nPreviousSize + 1 + 1 >= psCtx->nLastErrMsgMax) { psCtx->nLastErrMsgMax *= 3; psCtx = (CPLErrorContext *) CPLRealloc(psCtx, sizeof(CPLErrorContext) - DEFAULT_LAST_ERR_MSG_SIZE + psCtx->nLastErrMsgMax + 1); CPLSetTLS( CTLS_ERRORCONTEXT, psCtx, TRUE ); } psCtx->szLastErrMsg[nPreviousSize] = '/n'; psCtx->szLastErrMsg[nPreviousSize+1] = '0'; nPreviousSize ++; } } while( ((nPR = vsnprintf( psCtx->szLastErrMsg+nPreviousSize, psCtx->nLastErrMsgMax-nPreviousSize, fmt, wrk_args )) == -1 || nPR >= psCtx->nLastErrMsgMax-nPreviousSize-1) && psCtx->nLastErrMsgMax < 1000000 ) {#ifdef va_copy va_end( wrk_args ); va_copy( wrk_args, args );#else wrk_args = args;#endif psCtx->nLastErrMsgMax *= 3; psCtx = (CPLErrorContext *) CPLRealloc(psCtx, sizeof(CPLErrorContext) - DEFAULT_LAST_ERR_MSG_SIZE + psCtx->nLastErrMsgMax + 1); CPLSetTLS( CTLS_ERRORCONTEXT, psCtx, TRUE ); } va_end( wrk_args ); }#else vsprintf( psCtx->szLastErrMsg, fmt, args);#endif/* -------------------------------------------------------------------- *//* If the user provided his own error handling function, then *//* call it, otherwise print the error to stderr and return. *//* -------------------------------------------------------------------- */ psCtx->nLastErrNo = err_no; psCtx->eLastErrType = eErrClass; if( CPLGetConfigOption("CPL_LOG_ERRORS",NULL) != NULL ) CPLDebug( "CPLError", "%s", psCtx->szLastErrMsg );/* -------------------------------------------------------------------- *//* Invoke the current error handler. *//* -------------------------------------------------------------------- */ if( psCtx->psHandlerStack != NULL ) { psCtx->psHandlerStack->pfnHandler(eErrClass, err_no, psCtx->szLastErrMsg); } else { CPLMutexHolderD( &hErrorMutex ); if( pfnErrorHandler != NULL ) pfnErrorHandler(eErrClass, err_no, psCtx->szLastErrMsg); } if( eErrClass == CE_Fatal ) abort();}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:93,
示例19: CPLStrdupint OGRGFTDataSource::Open( const char * pszFilename, int bUpdateIn){ if (!EQUALN(pszFilename, "GFT:", 4)) return FALSE; bReadWrite = bUpdateIn; pszName = CPLStrdup( pszFilename ); osAuth = OGRGFTGetOptionValue(pszFilename, "auth"); if (osAuth.size() == 0) osAuth = CPLGetConfigOption("GFT_AUTH", ""); osRefreshToken = OGRGFTGetOptionValue(pszFilename, "refresh"); if (osRefreshToken.size() == 0) osRefreshToken = CPLGetConfigOption("GFT_REFRESH_TOKEN", ""); osAPIKey = CPLGetConfigOption("GFT_APIKEY", GDAL_API_KEY); CPLString osTables = OGRGFTGetOptionValue(pszFilename, "tables"); bUseHTTPS = TRUE; osAccessToken = OGRGFTGetOptionValue(pszFilename, "access"); if (osAccessToken.size() == 0) osAccessToken = CPLGetConfigOption("GFT_ACCESS_TOKEN",""); if (osAccessToken.size() == 0 && osRefreshToken.size() > 0) { osAccessToken.Seize(GOA2GetAccessToken(osRefreshToken, FUSION_TABLE_SCOPE)); if (osAccessToken.size() == 0) return FALSE; } if (osAccessToken.size() == 0 && osAuth.size() > 0) { osRefreshToken.Seize(GOA2GetRefreshToken(osAuth, FUSION_TABLE_SCOPE)); if (osRefreshToken.size() == 0) return FALSE; } if (osAccessToken.size() == 0) { if (osTables.size() == 0) { CPLError(CE_Failure, CPLE_AppDefined, "Unauthenticated access requires explicit tables= parameter"); return FALSE; } } if (osTables.size() != 0) { char** papszTables = CSLTokenizeString2(osTables, ",", 0); for(int i=0;papszTables && papszTables[i];i++) { papoLayers = (OGRLayer**) CPLRealloc(papoLayers, (nLayers + 1) * sizeof(OGRLayer*)); papoLayers[nLayers ++] = new OGRGFTTableLayer(this, papszTables[i], papszTables[i]); } CSLDestroy(papszTables); return TRUE; } /* Get list of tables */ CPLHTTPResult * psResult = RunSQL("SHOW TABLES"); if (psResult == NULL) return FALSE; char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || psResult->pszErrBuf != NULL || strncmp(pszLine, "table id,name", strlen("table id,name")) != 0) { CPLHTTPDestroyResult(psResult); return FALSE; } pszLine = OGRGFTGotoNextLine(pszLine); while(pszLine != NULL && *pszLine != 0) { char* pszNextLine = OGRGFTGotoNextLine(pszLine); if (pszNextLine) pszNextLine[-1] = 0; char** papszTokens = CSLTokenizeString2(pszLine, ",", 0); if (CSLCount(papszTokens) == 2) { CPLString osTableId(papszTokens[0]); CPLString osLayerName(papszTokens[1]); for(int i=0;i<nLayers;i++) { if (strcmp(papoLayers[i]->GetName(), osLayerName) == 0) { osLayerName += " ("; osLayerName += osTableId; osLayerName += ")"; break; }//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,
示例20: CPLDebugvoid CPLDebug( const char * pszCategory, const char * pszFormat, ... ){ CPLErrorContext *psCtx = CPLGetErrorContext(); char *pszMessage; va_list args; const char *pszDebug = CPLGetConfigOption("CPL_DEBUG",NULL);#define ERROR_MAX 25000/* -------------------------------------------------------------------- *//* Does this message pass our current criteria? *//* -------------------------------------------------------------------- */ if( pszDebug == NULL ) return; if( !EQUAL(pszDebug,"ON") && !EQUAL(pszDebug,"") ) { size_t i, nLen = strlen(pszCategory); for( i = 0; pszDebug[i] != '/0'; i++ ) { if( EQUALN(pszCategory,pszDebug+i,nLen) ) break; } if( pszDebug[i] == '/0' ) return; }/* -------------------------------------------------------------------- *//* Allocate a block for the error. *//* -------------------------------------------------------------------- */ pszMessage = (char *) VSIMalloc( ERROR_MAX ); if( pszMessage == NULL ) return; /* -------------------------------------------------------------------- *//* Dal -- always log a timestamp as the first part of the line *//* to ensure one is looking at what one should be looking at! *//* -------------------------------------------------------------------- */ pszMessage[0] = '/0';#ifdef TIMESTAMP_DEBUG if( CPLGetConfigOption( "CPL_TIMESTAMP", NULL ) != NULL ) { strcpy( pszMessage, VSICTime( VSITime(NULL) ) ); // On windows anyway, ctime puts a /n at the end, but I'm not // convinced this is standard behaviour, so we'll get rid of it // carefully if (pszMessage[strlen(pszMessage) -1 ] == '/n') { pszMessage[strlen(pszMessage) - 1] = 0; // blow it out } strcat( pszMessage, ": " ); }#endif/* -------------------------------------------------------------------- *//* Add the category. *//* -------------------------------------------------------------------- */ strcat( pszMessage, pszCategory ); strcat( pszMessage, ": " ); /* -------------------------------------------------------------------- *//* Format the application provided portion of the debug message. *//* -------------------------------------------------------------------- */ va_start(args, pszFormat);#if defined(HAVE_VSNPRINTF) vsnprintf(pszMessage+strlen(pszMessage), ERROR_MAX - strlen(pszMessage), pszFormat, args);#else vsprintf(pszMessage+strlen(pszMessage), pszFormat, args);#endif va_end(args);/* -------------------------------------------------------------------- *//* Invoke the current error handler. *//* -------------------------------------------------------------------- */ if( psCtx->psHandlerStack != NULL ) { psCtx->psHandlerStack->pfnHandler( CE_Debug, CPLE_None, pszMessage ); } else { CPLMutexHolderD( &hErrorMutex ); if( pfnErrorHandler != NULL ) pfnErrorHandler( CE_Debug, CPLE_None, pszMessage ); } VSIFree( pszMessage );}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:94,
示例21: CPLAssert//.........这里部分代码省略......... oHost = papszItems[i] + 5; else if( STARTS_WITH_CI(papszItems[i], "port=") ) nPort = atoi(papszItems[i] + 5); else if( STARTS_WITH_CI(papszItems[i], "tables=") ) { CSLDestroy(papszTableNames); papszTableNames = CSLTokenizeStringComplex( papszItems[i] + 7, ";", FALSE, FALSE ); } else CPLError( CE_Warning, CPLE_AppDefined, "'%s' in MYSQL datasource definition not recognised and ignored.", papszItems[i] ); } CSLDestroy( papszItems ); /* -------------------------------------------------------------------- */ /* Try to establish connection. */ /* -------------------------------------------------------------------- */ hConn = mysql_init( NULL ); if( hConn == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "mysql_init() failed." ); } /* -------------------------------------------------------------------- */ /* Set desired options on the connection: charset and timeout. */ /* -------------------------------------------------------------------- */ if( hConn ) { const char *pszTimeoutLength = CPLGetConfigOption( "MYSQL_TIMEOUT", "0" ); unsigned int timeout = atoi(pszTimeoutLength); mysql_options(hConn, MYSQL_OPT_CONNECT_TIMEOUT, (char*)&timeout); mysql_options(hConn, MYSQL_SET_CHARSET_NAME, "utf8" ); } /* -------------------------------------------------------------------- */ /* Perform connection. */ /* -------------------------------------------------------------------- */ if( hConn && mysql_real_connect( hConn, oHost.length() ? oHost.c_str() : NULL, oUser.length() ? oUser.c_str() : NULL, oPassword.length() ? oPassword.c_str() : NULL, oDB.length() ? oDB.c_str() : NULL, nPort, NULL, CLIENT_INTERACTIVE ) == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "MySQL connect failed for: %s/n%s", pszNewName + 6, mysql_error( hConn ) ); mysql_close( hConn ); hConn = NULL; } if( hConn == NULL ) { CSLDestroy( papszTableNames ); return FALSE; } else {
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:67,
示例22: CPLLoggingErrorHandlervoid CPL_STDCALL CPLLoggingErrorHandler( CPLErr eErrClass, int nError, const char * pszErrorMsg ){ static int bLogInit = FALSE; static FILE * fpLog = stderr; if( !bLogInit ) { const char *cpl_log = NULL; CPLSetConfigOption( "CPL_TIMESTAMP", "ON" ); bLogInit = TRUE; cpl_log = CPLGetConfigOption("CPL_LOG", NULL ); fpLog = stderr; if( cpl_log != NULL && EQUAL(cpl_log,"OFF") ) { fpLog = NULL; } else if( cpl_log != NULL ) { char* pszPath; int i = 0; pszPath = (char*)CPLMalloc(strlen(cpl_log) + 20); strcpy(pszPath, cpl_log); while( (fpLog = fopen( pszPath, "rt" )) != NULL ) { fclose( fpLog ); /* generate sequenced log file names, inserting # before ext.*/ if (strrchr(cpl_log, '.') == NULL) { sprintf( pszPath, "%s_%d%s", cpl_log, i++, ".log" ); } else { size_t pos = 0; char *cpl_log_base = strdup(cpl_log); pos = strcspn(cpl_log_base, "."); if (pos > 0) { cpl_log_base[pos] = '/0'; } sprintf( pszPath, "%s_%d%s", cpl_log_base, i++, ".log" ); free(cpl_log_base); } } fpLog = fopen( pszPath, "wt" ); CPLFree(pszPath); } } if( fpLog == NULL ) return; if( eErrClass == CE_Debug ) fprintf( fpLog, "%s/n", pszErrorMsg ); else if( eErrClass == CE_Warning ) fprintf( fpLog, "Warning %d: %s/n", nError, pszErrorMsg ); else fprintf( fpLog, "ERROR %d: %s/n", nError, pszErrorMsg ); fflush( fpLog );}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:72,
示例23: VSIFOpenL//.........这里部分代码省略......... /* Parse third header line */ pszLine = CPLReadLine2L(fp, 100, NULL); if (pszLine == NULL) { VSIFCloseL(fp); return NULL; } papszTokens = CSLTokenizeString2( pszLine, ",", 0 ); if (CSLCount(papszTokens) != 6) { CSLDestroy(papszTokens); VSIFCloseL(fp); return NULL; } const int nRows = atoi(papszTokens[0]); const int nCols = atoi(papszTokens[1]); const double dfMinX = CPLAtofM(papszTokens[2]); const double dfMaxX = CPLAtofM(papszTokens[3]); const double dfMinY = CPLAtofM(papszTokens[4]); const double dfMaxY = CPLAtofM(papszTokens[5]); CSLDestroy(papszTokens); papszTokens = NULL; if (!GDALCheckDatasetDimensions(nCols, nRows) || nCols == 1 || nRows == 1) { VSIFCloseL(fp); return NULL; } /* Ignore fourth header line */ pszLine = CPLReadLine2L(fp, 100, NULL); if (pszLine == NULL) { VSIFCloseL(fp); return NULL; } /* Check fifth header line */ pszLine = CPLReadLine2L(fp, 100, NULL); if (pszLine == NULL || pszLine[0] != '@') { VSIFCloseL(fp); return NULL; }/* -------------------------------------------------------------------- *//* Create a corresponding GDALDataset. *//* -------------------------------------------------------------------- */ ZMapDataset *poDS = new ZMapDataset(); poDS->fp = fp; poDS->nDataStartOff = VSIFTellL(fp); poDS->nValuesPerLine = nValuesPerLine; poDS->nFieldSize = nFieldSize; poDS->nDecimalCount = nDecimalCount; poDS->nRasterXSize = nCols; poDS->nRasterYSize = nRows; poDS->dfNoDataValue = dfNoDataValue; if (CPLTestBool(CPLGetConfigOption("ZMAP_PIXEL_IS_POINT", "FALSE"))) { const double dfStepX = (dfMaxX - dfMinX) / (nCols - 1); const double dfStepY = (dfMaxY - dfMinY) / (nRows - 1); poDS->adfGeoTransform[0] = dfMinX - dfStepX / 2; poDS->adfGeoTransform[1] = dfStepX; poDS->adfGeoTransform[3] = dfMaxY + dfStepY / 2; poDS->adfGeoTransform[5] = -dfStepY; } else { const double dfStepX = (dfMaxX - dfMinX) / nCols ; const double dfStepY = (dfMaxY - dfMinY) / nRows; poDS->adfGeoTransform[0] = dfMinX; poDS->adfGeoTransform[1] = dfStepX; poDS->adfGeoTransform[3] = dfMaxY; poDS->adfGeoTransform[5] = -dfStepY; }/* -------------------------------------------------------------------- *//* Create band information objects. *//* -------------------------------------------------------------------- */ poDS->nBands = 1; poDS->SetBand( 1, new ZMapRasterBand( poDS ) );/* -------------------------------------------------------------------- *//* Initialize any PAM information. *//* -------------------------------------------------------------------- */ poDS->SetDescription( poOpenInfo->pszFilename ); poDS->TryLoadXML();/* -------------------------------------------------------------------- *//* Support overviews. *//* -------------------------------------------------------------------- */ poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); return( poDS );}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例24: CPLSerializeXMLTreeCPLErr GDALWMSDataset::Initialize(CPLXMLNode *config, char **l_papszOpenOptions) { CPLErr ret = CE_None; char* pszXML = CPLSerializeXMLTree( config ); if (pszXML) { m_osXML = pszXML; CPLFree(pszXML); } // Generic options that apply to all minidrivers // UserPwd const char *pszUserPwd = CPLGetXMLValue(config, "UserPwd", ""); if (pszUserPwd[0] != '/0') m_osUserPwd = pszUserPwd; const char *pszUserAgent = CPLGetXMLValue(config, "UserAgent", ""); if (pszUserAgent[0] != '/0') m_osUserAgent = pszUserAgent; else m_osUserAgent = CPLGetConfigOption("GDAL_HTTP_USERAGENT", ""); const char *pszReferer = CPLGetXMLValue(config, "Referer", ""); if (pszReferer[0] != '/0') m_osReferer = pszReferer; if (ret == CE_None) { const char *pszHttpZeroBlockCodes = CPLGetXMLValue(config, "ZeroBlockHttpCodes", ""); if (pszHttpZeroBlockCodes[0] == '/0') { m_http_zeroblock_codes.insert(204); } else { char **kv = CSLTokenizeString2(pszHttpZeroBlockCodes, ",", CSLT_HONOURSTRINGS); for (int i = 0; i < CSLCount(kv); i++) { int code = atoi(kv[i]); if (code <= 0) { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: Invalid value of ZeroBlockHttpCodes " "/"%s/", comma separated HTTP response codes expected.", kv[i]); ret = CE_Failure; break; } m_http_zeroblock_codes.insert(code); } CSLDestroy(kv); } } if (ret == CE_None) { const char *pszZeroExceptions = CPLGetXMLValue(config, "ZeroBlockOnServerException", ""); if (pszZeroExceptions[0] != '/0') { m_zeroblock_on_serverexceptions = StrToBool(pszZeroExceptions); if (m_zeroblock_on_serverexceptions == -1) { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: Invalid value of ZeroBlockOnServerException " "/"%s/", true/false expected.", pszZeroExceptions); ret = CE_Failure; } } } if (ret == CE_None) { const char *max_conn = CPLGetXMLValue(config, "MaxConnections", ""); if (max_conn[0] != '/0') { m_http_max_conn = atoi(max_conn); } else { m_http_max_conn = 2; } } if (ret == CE_None) { const char *timeout = CPLGetXMLValue(config, "Timeout", ""); if (timeout[0] != '/0') { m_http_timeout = atoi(timeout); } else { m_http_timeout = 300; } } if (ret == CE_None) { const char *offline_mode = CPLGetXMLValue(config, "OfflineMode", ""); if (offline_mode[0] != '/0') { const int offline_mode_bool = StrToBool(offline_mode); if (offline_mode_bool == -1) { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: Invalid value of OfflineMode, true / false expected."); ret = CE_Failure; } else { m_offline_mode = offline_mode_bool; } } else { m_offline_mode = 0; } } if (ret == CE_None) { const char *advise_read = CPLGetXMLValue(config, "AdviseRead", "");//.........这里部分代码省略.........
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,
示例25: CPLDebug//.........这里部分代码省略........./* file. *//* *//* We only use the .aux file for overviews if they already have *//* overviews existing, or if USE_RRD is set true. *//* -------------------------------------------------------------------- */ if( !poODS && !EQUAL(pszInitName,":::VIRTUAL:::") && GDALCanFileAcceptSidecarFile(pszInitName) ) { bool bTryFindAssociatedAuxFile = true; if( papszInitSiblingFiles ) { CPLString osAuxFilename = CPLResetExtension( pszInitName, "aux"); int iSibling = CSLFindString( papszInitSiblingFiles, CPLGetFilename(osAuxFilename) ); if( iSibling < 0 ) { osAuxFilename = pszInitName; osAuxFilename += ".aux"; iSibling = CSLFindString( papszInitSiblingFiles, CPLGetFilename(osAuxFilename) ); if( iSibling < 0 ) bTryFindAssociatedAuxFile = false; } } if( bTryFindAssociatedAuxFile ) { poODS = GDALFindAssociatedAuxFile( pszInitName, poDS->GetAccess(), poDS ); } if( poODS ) { const bool bUseRRD = CPLTestBool(CPLGetConfigOption("USE_RRD","NO")); bOvrIsAux = true; if( GetOverviewCount(1) == 0 && !bUseRRD ) { bOvrIsAux = false; GDALClose( poODS ); poODS = nullptr; } else { osOvrFilename = poODS->GetDescription(); } } }/* -------------------------------------------------------------------- *//* If we still don't have an overview, check to see if we have *//* overview metadata referencing a remote (i.e. proxy) or local *//* subdataset overview dataset. *//* -------------------------------------------------------------------- */ if( poODS == nullptr ) { const char *pszProxyOvrFilename = poDS->GetMetadataItem( "OVERVIEW_FILE", "OVERVIEWS" ); if( pszProxyOvrFilename != nullptr ) { if( STARTS_WITH_CI(pszProxyOvrFilename, ":::BASE:::") ) { const CPLString osPath = CPLGetPath(poDS->GetDescription()); osOvrFilename =
开发者ID:OSGeo,项目名称:gdal,代码行数:67,
示例26: mainint main( int argc, char ** argv ){ int i; int bGotSRS = FALSE; int bPretty = FALSE; int bOutputAll = FALSE; int bValidate = FALSE; const char *pszInput = NULL; const char *pszOutputType = "all"; char *pszOutput = NULL; OGRSpatialReference oSRS; VSILFILE *fp = NULL; GDALDataset *poGDALDS = NULL; OGRDataSource *poOGRDS = NULL; OGRLayer *poLayer = NULL; char *pszProjection = NULL; int bDebug = FALSE; CPLErrorHandler oErrorHandler = NULL; int bIsFile = FALSE; /* Check strict compilation and runtime library version as we use C++ API */ if (! GDAL_CHECK_VERSION(argv[0])) exit(1); /* Must process GDAL_SKIP before GDALAllRegister(), but we can't call */ /* GDALGeneralCmdLineProcessor before it needs the drivers to be registered */ /* for the --format or --formats options */ for( i = 1; i < argc; i++ ) { if( EQUAL(argv[i],"--config") && i + 2 < argc && EQUAL(argv[i + 1], "GDAL_SKIP") ) { CPLSetConfigOption( argv[i+1], argv[i+2] ); i += 2; } } argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 ); if( argc < 1 ) exit( -argc ); /* -------------------------------------------------------------------- */ /* Parse arguments. */ /* -------------------------------------------------------------------- */ for( i = 1; i < argc; i++ ) { CPLDebug( "gdalsrsinfo", "got arg #%d : [%s]", i, argv[i] ); if( EQUAL(argv[i], "--utility_version") ) { printf("%s was compiled against GDAL %s and is running against GDAL %s/n", argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME")); return 0; } else if( EQUAL(argv[i], "-h") ) Usage(); else if( EQUAL(argv[i], "-o") && i < argc - 1) pszOutputType = argv[++i]; else if( EQUAL(argv[i], "-p") ) bPretty = TRUE; else if( EQUAL(argv[i], "-V") ) bValidate = TRUE; else if( argv[i][0] == '-' ) { CSLDestroy( argv ); Usage(); } else pszInput = argv[i]; } if ( pszInput == NULL ) { CSLDestroy( argv ); Usage(); } /* Register drivers */ GDALAllRegister(); OGRRegisterAll(); /* Search for SRS */ /* temporarily supress error messages we may get from xOpen() */ bDebug = CSLTestBoolean(CPLGetConfigOption("CPL_DEBUG", "OFF")); if ( ! bDebug ) oErrorHandler = CPLSetErrorHandler ( CPLQuietErrorHandler ); /* If argument is a file, try to open it with GDALOpen() and get the projection */ fp = VSIFOpenL( pszInput, "r" ); if ( fp ) { bIsFile = TRUE; VSIFCloseL( fp ); /* try to open with GDAL */ CPLDebug( "gdalsrsinfo", "trying to open with GDAL" );//.........这里部分代码省略.........
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,
示例27: STARTS_WITHbool GMLASConfiguration::Load(const char* pszFilename){ // Allow configuration to be inlined CPLXMLNode* psRoot = STARTS_WITH(pszFilename, "<Configuration>") ? CPLParseXMLString(pszFilename) : CPLParseXMLFile(pszFilename); if( psRoot == NULL ) { Finalize(); return false; } CPLXMLTreeCloser oCloser(psRoot); // Validate the configuration file if( CPLTestBool(CPLGetConfigOption("GDAL_XML_VALIDATION", "YES")) ) { const char* pszXSD = CPLFindFile( "gdal", "gmlasconf.xsd" ); if( pszXSD != NULL ) { std::vector<CPLString> aosErrors; const CPLErr eErrClass = CPLGetLastErrorType(); const CPLErrorNum nErrNum = CPLGetLastErrorNo(); const CPLString osErrMsg = CPLGetLastErrorMsg(); CPLPushErrorHandlerEx(GMLASConfigurationErrorHandler, &aosErrors); int bRet = CPLValidateXML(pszFilename, pszXSD, NULL); CPLPopErrorHandler(); if( !bRet && aosErrors.size() > 0 && strstr(aosErrors[0].c_str(), "missing libxml2 support") == NULL ) { for(size_t i = 0; i < aosErrors.size(); i++) { CPLError(CE_Warning, CPLE_AppDefined, "%s", aosErrors[i].c_str()); } } else { CPLErrorSetState(eErrClass, nErrNum, osErrMsg); } } } m_bAllowRemoteSchemaDownload = CPLGetXMLBoolValue(psRoot, "=Configuration.AllowRemoteSchemaDownload", ALLOW_REMOTE_SCHEMA_DOWNLOAD_DEFAULT ); m_bAllowXSDCache = CPLGetXMLBoolValue( psRoot, "=Configuration.SchemaCache.enabled", ALLOW_XSD_CACHE_DEFAULT ); if( m_bAllowXSDCache ) { m_osXSDCacheDirectory = CPLGetXMLValue(psRoot, "=Configuration.SchemaCache.Directory", ""); } m_bValidate = CPLGetXMLBoolValue( psRoot, "=Configuration.Validation.enabled", VALIDATE_DEFAULT ); if( m_bValidate ) { m_bFailIfValidationError = CPLGetXMLBoolValue(psRoot, "=Configuration.Validation.FailIfError", FAIL_IF_VALIDATION_ERROR_DEFAULT ); } m_bExposeMetadataLayers = CPLGetXMLBoolValue( psRoot, "=Configuration.ExposeMetadataLayers", EXPOSE_METADATA_LAYERS_DEFAULT ); m_bAlwaysGenerateOGRId = CPLGetXMLBoolValue( psRoot, "=Configuration.LayerBuildingRules.AlwaysGenerateOGRId", ALWAYS_GENERATE_OGR_ID_DEFAULT ); m_bRemoveUnusedLayers = CPLGetXMLBoolValue( psRoot, "=Configuration.LayerBuildingRules.RemoveUnusedLayers", REMOVE_UNUSED_LAYERS_DEFAULT ); m_bRemoveUnusedFields = CPLGetXMLBoolValue( psRoot, "=Configuration.LayerBuildingRules.RemoveUnusedFields", REMOVE_UNUSED_FIELDS_DEFAULT ); m_bUseArrays = CPLGetXMLBoolValue( psRoot, "=Configuration.LayerBuildingRules.UseArrays", USE_ARRAYS_DEFAULT ); m_bIncludeGeometryXML = CPLGetXMLBoolValue( psRoot, "=Configuration.LayerBuildingRules.GML.IncludeGeometryXML", INCLUDE_GEOMETRY_XML_DEFAULT ); m_bInstantiateGMLFeaturesOnly = CPLGetXMLBoolValue( psRoot, "=Configuration.LayerBuildingRules.GML.InstantiateGMLFeaturesOnly", INSTANTIATE_GML_FEATURES_ONLY_DEFAULT ); m_nIdentifierMaxLength = atoi( CPLGetXMLValue( psRoot, "=Configuration.LayerBuildingRules.IdentifierMaxLength", "0" ) ); m_bCaseInsensitiveIdentifier = CPLGetXMLBoolValue( psRoot, "=Configuration.LayerBuildingRules.CaseInsensitiveIdentifier", CASE_INSENSITIVE_IDENTIFIER_DEFAULT ); CPLXMLNode* psIgnoredXPaths = CPLGetXMLNode(psRoot,//.........这里部分代码省略.........
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,
示例28: CPLGetConfigOptionvoid IDADataset::ReadColorTable(){/* -------------------------------------------------------------------- *//* Decide what .clr file to look for and try to open. *//* -------------------------------------------------------------------- */ CPLString osCLRFilename; osCLRFilename = CPLGetConfigOption( "IDA_COLOR_FILE", "" ); if( strlen(osCLRFilename) == 0 ) osCLRFilename = CPLResetExtension(GetDescription(), "clr" ); FILE *fp = VSIFOpen( osCLRFilename, "r" ); if( fp == NULL ) { osCLRFilename = CPLResetExtension(osCLRFilename, "CLR" ); fp = VSIFOpen( osCLRFilename, "r" ); } if( fp == NULL ) return;/* -------------------------------------------------------------------- *//* Skip first line, with the column titles. *//* -------------------------------------------------------------------- */ CPLReadLine( fp );/* -------------------------------------------------------------------- *//* Create a RAT to populate. *//* -------------------------------------------------------------------- */ GDALRasterAttributeTable *poRAT = new GDALRasterAttributeTable(); poRAT->CreateColumn( "FROM", GFT_Integer, GFU_Min ); poRAT->CreateColumn( "TO", GFT_Integer, GFU_Max ); poRAT->CreateColumn( "RED", GFT_Integer, GFU_Red ); poRAT->CreateColumn( "GREEN", GFT_Integer, GFU_Green ); poRAT->CreateColumn( "BLUE", GFT_Integer, GFU_Blue ); poRAT->CreateColumn( "LEGEND", GFT_String, GFU_Name );/* -------------------------------------------------------------------- *//* Apply lines. *//* -------------------------------------------------------------------- */ const char *pszLine = CPLReadLine( fp ); int iRow = 0; while( pszLine != NULL ) { char **papszTokens = CSLTokenizeStringComplex( pszLine, " /t", FALSE, FALSE ); if( CSLCount( papszTokens ) >= 5 ) { poRAT->SetValue( iRow, 0, atoi(papszTokens[0]) ); poRAT->SetValue( iRow, 1, atoi(papszTokens[1]) ); poRAT->SetValue( iRow, 2, atoi(papszTokens[2]) ); poRAT->SetValue( iRow, 3, atoi(papszTokens[3]) ); poRAT->SetValue( iRow, 4, atoi(papszTokens[4]) ); // find name, first nonspace after 5th token. const char *pszName = pszLine; // skip from while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip to while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip red while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip green while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip blue while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip pre-name white space while( *pszName == ' ' || *pszName == '/t' ) pszName++; poRAT->SetValue( iRow, 5, pszName ); iRow++; }//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,
示例29: psDTEDDTEDDataset::DTEDDataset() : psDTED(NULL){ pszFilename = CPLStrdup("unknown"); pszProjection = CPLStrdup(""); bVerifyChecksum = CPLTestBool(CPLGetConfigOption("DTED_VERIFY_CHECKSUM", "NO"));}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:6,
注:本文中的CPLGetConfigOption函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLGetExtension函数代码示例 C++ CPLGetBasename函数代码示例 |