这篇教程C++ CSLFetchBoolean函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CSLFetchBoolean函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLFetchBoolean函数的具体用法?C++ CSLFetchBoolean怎么用?C++ CSLFetchBoolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CSLFetchBoolean函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CPLErrorOGRLayer *OGRCARTODBDataSource::ICreateLayer( const char *pszName, OGRSpatialReference *poSpatialRef, OGRwkbGeometryType eGType, char ** papszOptions ){ if (!bReadWrite) { CPLError(CE_Failure, CPLE_AppDefined, "Operation not available in read-only mode"); return NULL; }/* -------------------------------------------------------------------- *//* Do we already have this layer? If so, should we blow it *//* away? *//* -------------------------------------------------------------------- */ int iLayer; for( iLayer = 0; iLayer < nLayers; iLayer++ ) { if( EQUAL(pszName,papoLayers[iLayer]->GetName()) ) { if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") ) { DeleteLayer( iLayer ); } else { CPLError( CE_Failure, CPLE_AppDefined, "Layer %s already exists, CreateLayer failed./n" "Use the layer creation option OVERWRITE=YES to " "replace it.", pszName ); return NULL; } } } CPLString osName(pszName); if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) { char* pszTmp = OGRPGCommonLaunderName(pszName); osName = pszTmp; CPLFree(pszTmp); } OGRCARTODBTableLayer* poLayer = new OGRCARTODBTableLayer(this, osName); int bGeomNullable = CSLFetchBoolean(papszOptions, "GEOMETRY_NULLABLE", TRUE); int bCartoDBify = CSLFetchBoolean(papszOptions, "CARTODBFY", CSLFetchBoolean(papszOptions, "CARTODBIFY", TRUE)); poLayer->SetLaunderFlag( CSLFetchBoolean(papszOptions,"LAUNDER",TRUE) ); poLayer->SetDeferedCreation(eGType, poSpatialRef, bGeomNullable, bCartoDBify); papoLayers = (OGRCARTODBTableLayer**) CPLRealloc( papoLayers, (nLayers + 1) * sizeof(OGRCARTODBTableLayer*)); papoLayers[nLayers ++] = poLayer; return poLayer;}
开发者ID:drownedout,项目名称:datamap,代码行数:58,
示例2: QStringQString QgsRasterFileWriter::driverForExtension( const QString &extension ){ QString ext = extension.trimmed(); if ( ext.isEmpty() ) return QString(); if ( ext.startsWith( '.' ) ) ext.remove( 0, 1 ); GDALAllRegister(); int const drvCount = GDALGetDriverCount(); for ( int i = 0; i < drvCount; ++i ) { GDALDriverH drv = GDALGetDriver( i ); if ( drv ) { char **driverMetadata = GDALGetMetadata( drv, nullptr ); if ( CSLFetchBoolean( driverMetadata, GDAL_DCAP_RASTER, false ) ) { QString drvName = GDALGetDriverShortName( drv ); QStringList driverExtensions = QString( GDALGetMetadataItem( drv, GDAL_DMD_EXTENSIONS, nullptr ) ).split( ' ' ); Q_FOREACH ( const QString &driver, driverExtensions ) { if ( driver.compare( ext, Qt::CaseInsensitive ) == 0 ) return drvName; } } } }
开发者ID:anitagraser,项目名称:QGIS,代码行数:31,
示例3: write_mapvoid write_map(fs::path file_path, GDALDataType data_type, boost::shared_ptr<Map_Matrix<DataFormat> > data, std::string WKTprojection, GeoTransform transform, std::string driverName) throw(std::runtime_error){ GDALAllRegister(); //This registers all availble raster file formats for use with this utility. How neat is that. We can input any GDAL supported rater file format. const char *pszFormat = driverName.c_str(); GDALDriver * poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); if (poDriver == NULL) { throw std::runtime_error("No driver for file tyle found"); } char ** papszMetadata = poDriver->GetMetadata(); if (!(CSLFetchBoolean(papszMetadata, GDAL_DCAP_CREATE, FALSE))) { throw std::runtime_error("Driver does not support raster creation"); } char **papszOptions = NULL; papszOptions = CSLSetNameValue(papszOptions, "COMPRESS", "LZW"); GDALDataset *poDstDS = poDriver->Create(file_path.string().c_str(), (int)data->NCols(), (int)data->NRows(), 1, data_type, papszOptions); double adfGeoTransform[6] = {1, 1, 1, 1, 1, 1}; adfGeoTransform[0] = transform.x_origin; adfGeoTransform[1] = transform.pixel_width; adfGeoTransform[2] = transform.x_line_space; adfGeoTransform[3] = transform.y_origin; adfGeoTransform[4] = transform.pixel_height; adfGeoTransform[5] = transform.y_line_space; const char * psz_WKT = WKTprojection.c_str(); poDstDS->SetGeoTransform(adfGeoTransform); poDstDS->SetProjection(psz_WKT); DataFormat * pafScanline = new DataFormat[data->NCols() * data->NRows()]; int pafIterator = 0; for (int i = 0; i < data->NRows(); i++) { for (int j = 0; j < data->NCols(); j++) { pafScanline[pafIterator] = data->Get(i, j); pafIterator++; } } GDALRasterBand * poBand = poDstDS->GetRasterBand(1); poBand->SetNoDataValue(data->NoDataValue()); poBand->RasterIO(GF_Write, 0, 0, (int) data->NCols(), (int) data->NRows(), pafScanline, (int) data->NCols(), (int) data->NRows(), data_type, 0, 0); GDALClose( (GDALDatasetH) poDstDS);}
开发者ID:jeffrey-newman,项目名称:Aggregate-Map,代码行数:51,
示例4: GDALAllRegistervoid QgsRasterCalcDialog::insertAvailableOutputFormats(){ GDALAllRegister(); int nDrivers = GDALGetDriverCount(); for ( int i = 0; i < nDrivers; ++i ) { GDALDriverH driver = GDALGetDriver( i ); if ( driver != NULL ) { char** driverMetadata = GDALGetMetadata( driver, NULL ); if ( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) ) { mOutputFormatComboBox->addItem( GDALGetDriverLongName( driver ), QVariant( GDALGetDriverShortName( driver ) ) ); //store the driver shortnames and the corresponding extensions //(just in case the user does not give an extension for the output file name) int index = 0; while (( driverMetadata ) && driverMetadata[index] != 0 ) { QStringList metadataTokens = QString( driverMetadata[index] ).split( "=", QString::SkipEmptyParts ); if ( metadataTokens.size() < 1 ) { break; } if ( metadataTokens[0] == "DMD_EXTENSION" ) { if ( metadataTokens.size() < 2 ) { ++index; continue; } mDriverExtensionMap.insert( QString( GDALGetDriverShortName( driver ) ), metadataTokens[1] ); break; } ++index; } } } } //and set last used driver in combo box QSettings s; QString lastUsedDriver = s.value( "/RasterCalculator/lastOutputFormat", "GeoTIFF" ).toString(); int lastDriverIndex = mOutputFormatComboBox->findText( lastUsedDriver ); if ( lastDriverIndex != -1 ) { mOutputFormatComboBox->setCurrentIndex( lastDriverIndex ); }}
开发者ID:RealworldSystems,项目名称:Quantum-GIS,代码行数:51,
示例5: GDALAllRegistervoid QgsRasterCalcDialog::insertAvailableOutputFormats(){ GDALAllRegister(); int nDrivers = GDALGetDriverCount(); for ( int i = 0; i < nDrivers; ++i ) { GDALDriverH driver = GDALGetDriver( i ); if ( driver ) { char** driverMetadata = GDALGetMetadata( driver, nullptr ); if ( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) ) { QString driverShortName = GDALGetDriverShortName( driver ); QString driverLongName = GDALGetDriverLongName( driver ); if ( driverShortName == "MEM" ) { // in memory rasters are not (yet) supported because the GDAL dataset handle // would need to be passed directly to QgsRasterLayer (it is not possible to // close it in raster calculator and reopen the dataset again in raster layer) continue; } mOutputFormatComboBox->addItem( driverLongName, driverShortName ); //store the driver shortnames and the corresponding extensions //(just in case the user does not give an extension for the output file name) QString driverExtension = GDALGetMetadataItem( driver, GDAL_DMD_EXTENSION, nullptr ); mDriverExtensionMap.insert( driverShortName, driverExtension ); } } } //and set last used driver in combo box QSettings s; QString lastUsedDriver = s.value( "/RasterCalculator/lastOutputFormat", "GeoTIFF" ).toString(); int lastDriverIndex = mOutputFormatComboBox->findText( lastUsedDriver ); if ( lastDriverIndex != -1 ) { mOutputFormatComboBox->setCurrentIndex( lastDriverIndex ); }}
开发者ID:AM7000000,项目名称:QGIS,代码行数:42,
示例6: GDALGetDriverByNameGDALDriverH QgsRasterCalculator::openOutputDriver(){ char **driverMetadata; //open driver GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() ); if ( outputDriver == NULL ) { return outputDriver; //return NULL, driver does not exist } driverMetadata = GDALGetMetadata( outputDriver, NULL ); if ( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) ) { return NULL; //driver exist, but it does not support the create operation } return outputDriver;}
开发者ID:mmubangizi,项目名称:qgis,代码行数:20,
示例7: GDALGetDriverByNameGDALDriverH QgsRelief::openOutputDriver(){ char **driverMetadata = nullptr; //open driver GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() ); if ( !outputDriver ) { return outputDriver; //return nullptr, driver does not exist } driverMetadata = GDALGetMetadata( outputDriver, nullptr ); if ( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) ) { return nullptr; //driver exist, but it does not support the create operation } return outputDriver;}
开发者ID:GeoCat,项目名称:QGIS,代码行数:20,
示例8: mainint main(int argc, char *argv[]){ GDALDataset *poDataset; GDALAllRegister(); if(argc != 3){ std::cout << "usage:/n" << argv[0] << " src_file dest_file/n"; exit(0); } const std::string name = argv[1]; const std::string destName = argv[2]; poDataset = (GDALDataset *) GDALOpen(name.c_str(), GA_ReadOnly ); if( poDataset == NULL ){ std::cout << "Failed to open " << name << "/n"; }else{ const char *pszFormat = "GTiff"; GDALDriver *poDriver; char **papszMetadata; poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); if( poDriver == NULL ){ std::cout << "Cant open driver/n"; exit(1); } papszMetadata = GDALGetMetadata( poDriver, NULL ); if( !CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) ){ std::cout << "Create Method not suported!/n"; } if( !CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATECOPY, FALSE ) ){ std::cout << "CreateCopy() method not suported./n"; } char **papszOptions = NULL; GDALDataset *dest = poDriver->Create(destName.c_str() , poDataset->GetRasterXSize(), poDataset->GetRasterYSize(), 3, GDT_Byte, papszOptions ); std::cout << "Reading file " << name << "/n"; std::cout << "x= " << poDataset->GetRasterXSize() << ", h=" << poDataset->GetRasterYSize() << ", bands= " << poDataset->GetRasterCount() << "/n"; GDALRasterBand *data; data = poDataset->GetRasterBand(1); GDALDataType type = data->GetRasterDataType(); printDataType(type); int size = data->GetXSize()*data->GetYSize(); std::cout << "size=" << size << " , w*h = " << poDataset->GetRasterXSize()*poDataset->GetRasterYSize() << "/n"; float *buffer; buffer = (float *) CPLMalloc(sizeof(float)*size); data->RasterIO(GF_Read, 0, 0, data->GetXSize(), data->GetYSize(), buffer, data->GetXSize(), data->GetYSize(), GDT_Float32, 0, 0 ); GDALRasterBand *destBand1 = dest->GetRasterBand(1); GDALRasterBand *destBand2 = dest->GetRasterBand(2); GDALRasterBand *destBand3 = dest->GetRasterBand(3); // GDALRasterBand *destBand4 = dest->GetRasterBand(4); // Metadata, double geot[6]; poDataset->GetGeoTransform(geot); dest->SetGeoTransform(geot);// adfGeoTransform ); dest->SetProjection( poDataset->GetProjectionRef() ); GByte destWrite1[size]; // = (GUInt32 *) CPLMalloc(sizeof(GUInt32)*size); GByte destWrite2[size]; GByte destWrite3[size]; // GByte destWrite4[size]; unsigned int i; float max=0, min=0; for(i=0; i<size; i++){ if(max < buffer[i]){ max = buffer[i];//.........这里部分代码省略.........
开发者ID:fsvieira,项目名称:html5-dem-viewer,代码行数:101,
示例9: GDALWarpCutlineMaskerCPLErrGDALWarpCutlineMasker( void *pMaskFuncArg, CPL_UNUSED int nBandCount, CPL_UNUSED GDALDataType eType, int nXOff, int nYOff, int nXSize, int nYSize, GByte ** /*ppImageData */, int bMaskIsFloat, void *pValidityMask ){ GDALWarpOptions *psWO = (GDALWarpOptions *) pMaskFuncArg; float *pafMask = (float *) pValidityMask; CPLErr eErr; GDALDriverH hMemDriver; if( nXSize < 1 || nYSize < 1 ) return CE_None;/* -------------------------------------------------------------------- *//* Do some minimal checking. *//* -------------------------------------------------------------------- */ if( !bMaskIsFloat ) { CPLAssert( FALSE ); return CE_Failure; } if( psWO == NULL || psWO->hCutline == NULL ) { CPLAssert( FALSE ); return CE_Failure; } hMemDriver = GDALGetDriverByName("MEM"); if (hMemDriver == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "GDALWarpCutlineMasker needs MEM driver"); return CE_Failure; }/* -------------------------------------------------------------------- *//* Check the polygon. *//* -------------------------------------------------------------------- */ OGRGeometryH hPolygon = (OGRGeometryH) psWO->hCutline; OGREnvelope sEnvelope; if( wkbFlatten(OGR_G_GetGeometryType(hPolygon)) != wkbPolygon && wkbFlatten(OGR_G_GetGeometryType(hPolygon)) != wkbMultiPolygon ) { CPLAssert( FALSE ); return CE_Failure; } OGR_G_GetEnvelope( hPolygon, &sEnvelope ); if( sEnvelope.MaxX + psWO->dfCutlineBlendDist < nXOff || sEnvelope.MinX - psWO->dfCutlineBlendDist > nXOff + nXSize || sEnvelope.MaxY + psWO->dfCutlineBlendDist < nYOff || sEnvelope.MinY - psWO->dfCutlineBlendDist > nYOff + nYSize ) { // We are far from the blend line - everything is masked to zero. // It would be nice to realize no work is required for this whole // chunk! memset( pafMask, 0, sizeof(float) * nXSize * nYSize ); return CE_None; }/* -------------------------------------------------------------------- *//* Create a byte buffer into which we can burn the *//* mask polygon and wrap it up as a memory dataset. *//* -------------------------------------------------------------------- */ GByte *pabyPolyMask = (GByte *) CPLCalloc( nXSize, nYSize ); GDALDatasetH hMemDS; double adfGeoTransform[6] = { 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 }; char szDataPointer[100]; char *apszOptions[] = { szDataPointer, NULL }; memset( szDataPointer, 0, sizeof(szDataPointer) ); sprintf( szDataPointer, "DATAPOINTER=" ); CPLPrintPointer( szDataPointer+strlen(szDataPointer), pabyPolyMask, sizeof(szDataPointer) - strlen(szDataPointer) ); hMemDS = GDALCreate( hMemDriver, "warp_temp", nXSize, nYSize, 0, GDT_Byte, NULL ); GDALAddBand( hMemDS, GDT_Byte, apszOptions ); GDALSetGeoTransform( hMemDS, adfGeoTransform );/* -------------------------------------------------------------------- *//* Burn the polygon into the mask with 1.0 values. *//* -------------------------------------------------------------------- */ int nTargetBand = 1; double dfBurnValue = 255.0; int anXYOff[2]; char **papszRasterizeOptions = NULL; if( CSLFetchBoolean( psWO->papszWarpOptions, "CUTLINE_ALL_TOUCHED", FALSE )) papszRasterizeOptions = CSLSetNameValue( papszRasterizeOptions, "ALL_TOUCHED", "TRUE" );//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
示例10: CPLErrorGDALDataset *NTv2Dataset::Create( const char * pszFilename, int nXSize, int nYSize, int nBands, GDALDataType eType, char ** papszOptions ){ if( eType != GDT_Float32 ) { CPLError( CE_Failure, CPLE_AppDefined, "Attempt to create NTv2 file with unsupported data type '%s'.", GDALGetDataTypeName( eType ) ); return NULL; } if( nBands != 4 ) { CPLError( CE_Failure, CPLE_AppDefined, "Attempt to create NTv2 file with unsupported " "band number '%d'.", nBands); return NULL; }/* -------------------------------------------------------------------- *//* Are we extending an existing file? *//* -------------------------------------------------------------------- */ int bAppend = CSLFetchBoolean(papszOptions,"APPEND_SUBDATASET",FALSE);/* -------------------------------------------------------------------- *//* Try to open or create file. *//* -------------------------------------------------------------------- */ VSILFILE *fp = NULL; if( bAppend ) fp = VSIFOpenL( pszFilename, "rb+" ); else fp = VSIFOpenL( pszFilename, "wb" ); if( fp == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Attempt to open/create file `%s' failed./n", pszFilename ); return NULL; }/* -------------------------------------------------------------------- *//* Create a file level header if we are creating new. *//* -------------------------------------------------------------------- */ char achHeader[11*16] = { '/0' }; const char *pszValue = NULL; GUInt32 nNumFile = 1; bool bMustSwap = false; bool bIsLE = false; if( !bAppend ) { memset( achHeader, 0, sizeof(achHeader) ); bIsLE = EQUAL(CSLFetchNameValueDef(papszOptions,"ENDIANNESS", "LE"), "LE");#ifdef CPL_LSB bMustSwap = !bIsLE;#else bMustSwap = bIsLE;#endif memcpy( achHeader + 0*16, "NUM_OREC", 8 ); int nNumOrec = 11; SwapPtr32IfNecessary( bMustSwap, &nNumOrec ); memcpy( achHeader + 0*16 + 8, &nNumOrec, 4 ); memcpy( achHeader + 1*16, "NUM_SREC", 8 ); int nNumSrec = 11; SwapPtr32IfNecessary( bMustSwap, &nNumSrec ); memcpy( achHeader + 1*16 + 8, &nNumSrec, 4 ); memcpy( achHeader + 2*16, "NUM_FILE", 8 ); SwapPtr32IfNecessary( bMustSwap, &nNumFile ); memcpy( achHeader + 2*16 + 8, &nNumFile, 4 ); SwapPtr32IfNecessary( bMustSwap, &nNumFile ); memcpy( achHeader + 3*16, "GS_TYPE ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "GS_TYPE", "SECONDS"); memcpy( achHeader + 3*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 4*16, "VERSION ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "VERSION", "" ); memcpy( achHeader + 4*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 5*16, "SYSTEM_F ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "SYSTEM_F", "" ); memcpy( achHeader + 5*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 6*16, "SYSTEM_T ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "SYSTEM_T", "" ); memcpy( achHeader + 6*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 7*16, "MAJOR_F ", 8); memcpy( achHeader + 8*16, "MINOR_F ", 8 ); memcpy( achHeader + 9*16, "MAJOR_T ", 8 ); memcpy( achHeader + 10*16, "MINOR_T ", 8 );//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例11: atoiOGRLayer * OGRMSSQLSpatialDataSource::CreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ char *pszTableName = NULL; char *pszSchemaName = NULL; const char *pszGeomType = NULL; const char *pszGeomColumn = NULL; int nCoordDimension = 3; /* determine the dimension */ if( eType == wkbFlatten(eType) ) nCoordDimension = 2; if( CSLFetchNameValue( papszOptions, "DIM") != NULL ) nCoordDimension = atoi(CSLFetchNameValue( papszOptions, "DIM")); /* MSSQL Schema handling: Extract schema name from input layer name or passed with -lco SCHEMA. Set layer name to "schema.table" or to "table" if schema is not specified */ const char* pszDotPos = strstr(pszLayerName,"."); if ( pszDotPos != NULL ) { int length = pszDotPos - pszLayerName; pszSchemaName = (char*)CPLMalloc(length+1); strncpy(pszSchemaName, pszLayerName, length); pszSchemaName[length] = '/0'; if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) pszTableName = LaunderName( pszDotPos + 1 ); //skip "." else pszTableName = CPLStrdup( pszDotPos + 1 ); //skip "." } else { pszSchemaName = NULL; if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) pszTableName = LaunderName( pszLayerName ); //skip "." else pszTableName = CPLStrdup( pszLayerName ); //skip "." } if( CSLFetchNameValue( papszOptions, "SCHEMA" ) != NULL ) { CPLFree(pszSchemaName); pszSchemaName = CPLStrdup(CSLFetchNameValue( papszOptions, "SCHEMA" )); } if (pszSchemaName == NULL) pszSchemaName = CPLStrdup("dbo");/* -------------------------------------------------------------------- *//* Do we already have this layer? If so, should we blow it *//* away? *//* -------------------------------------------------------------------- */ int iLayer; for( iLayer = 0; iLayer < nLayers; iLayer++ ) { if( EQUAL(pszLayerName,papoLayers[iLayer]->GetTableName()) ) { if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") ) { if (!pszSchemaName) pszSchemaName = CPLStrdup(papoLayers[iLayer]->GetSchemaName()); DeleteLayer( iLayer ); } else { CPLError( CE_Failure, CPLE_AppDefined, "Layer %s already exists, CreateLayer failed./n" "Use the layer creation option OVERWRITE=YES to " "replace it.", pszLayerName ); CPLFree( pszSchemaName ); CPLFree( pszTableName ); return NULL; } } }/* -------------------------------------------------------------------- *//* Handle the GEOM_TYPE option. *//* -------------------------------------------------------------------- */ pszGeomType = CSLFetchNameValue( papszOptions, "GEOM_TYPE" ); if( !pszGeomType ) pszGeomType = "geometry"; if( !EQUAL(pszGeomType, "geometry") && !EQUAL(pszGeomType, "geography")) { CPLError( CE_Failure, CPLE_AppDefined, //.........这里部分代码省略.........
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:101,
示例12: InterruptLongResultOGRLayer *OGRMySQLDataSource::CreateLayer( const char * pszLayerNameIn, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ MYSQL_RES *hResult=NULL; CPLString osCommand; const char *pszGeometryType; const char *pszGeomColumnName; const char *pszExpectedFIDName; char *pszLayerName; int nDimension = 3; // MySQL only supports 2d currently/* -------------------------------------------------------------------- *//* Make sure there isn't an active transaction already. *//* -------------------------------------------------------------------- */ InterruptLongResult(); if( CSLFetchBoolean(papszOptions,"LAUNDER",TRUE) ) pszLayerName = LaunderName( pszLayerNameIn ); else pszLayerName = CPLStrdup( pszLayerNameIn ); if( wkbFlatten(eType) == eType ) nDimension = 2; CPLDebug("MYSQL","Creating layer %s.", pszLayerName);/* -------------------------------------------------------------------- *//* Do we already have this layer? If so, should we blow it *//* away? *//* -------------------------------------------------------------------- */ int iLayer; for( iLayer = 0; iLayer < nLayers; iLayer++ ) { if( EQUAL(pszLayerName,papoLayers[iLayer]->GetLayerDefn()->GetName()) ) { if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") ) { DeleteLayer( iLayer ); } else { CPLError( CE_Failure, CPLE_AppDefined, "Layer %s already exists, CreateLayer failed./n" "Use the layer creation option OVERWRITE=YES to " "replace it.", pszLayerName ); CPLFree( pszLayerName ); return NULL; } } } pszGeomColumnName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME" ); if (!pszGeomColumnName) pszGeomColumnName="SHAPE"; pszExpectedFIDName = CSLFetchNameValue( papszOptions, "MYSQL_FID" ); if (!pszExpectedFIDName) pszExpectedFIDName="OGR_FID"; CPLDebug("MYSQL","Geometry Column Name %s.", pszGeomColumnName); CPLDebug("MYSQL","FID Column Name %s.", pszExpectedFIDName); if( wkbFlatten(eType) == wkbNone ) { osCommand.Printf( "CREATE TABLE `%s` ( " " %s INT UNIQUE NOT NULL AUTO_INCREMENT )", pszLayerName, pszExpectedFIDName ); } else { osCommand.Printf( "CREATE TABLE `%s` ( " " %s INT UNIQUE NOT NULL AUTO_INCREMENT, " " %s GEOMETRY NOT NULL )", pszLayerName, pszExpectedFIDName, pszGeomColumnName ); } if( CSLFetchNameValue( papszOptions, "ENGINE" ) != NULL ) { osCommand += " ENGINE = "; osCommand += CSLFetchNameValue( papszOptions, "ENGINE" ); } if( !mysql_query(GetConn(), osCommand ) ) { if( mysql_field_count( GetConn() ) == 0 ) CPLDebug("MYSQL","Created table %s.", pszLayerName);//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例13: GetLayerCount//.........这里部分代码省略......... hSHP = SHPCreateLL( pszFilename, nShapeType, (SAHooks*) VSI_SHP_GetHook(b2GBLimit) ); if( hSHP == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open Shapefile `%s'./n", pszFilename ); CPLFree( pszFilename ); CPLFree( pszFilenameWithoutExt ); return NULL; } SHPSetFastModeReadObject( hSHP, TRUE ); CPLFree( pszFilename ); } else hSHP = NULL;/* -------------------------------------------------------------------- *//* Has a specific LDID been specified by the caller? *//* -------------------------------------------------------------------- */ const char *pszLDID = CSLFetchNameValue( papszOptions, "ENCODING" );/* -------------------------------------------------------------------- *//* Create a DBF file. *//* -------------------------------------------------------------------- */ pszFilename = CPLStrdup(CPLFormFilename( NULL, pszFilenameWithoutExt, "dbf" )); if( pszLDID != NULL ) hDBF = DBFCreateLL( pszFilename, pszLDID, (SAHooks*) VSI_SHP_GetHook(b2GBLimit) ); else hDBF = DBFCreateLL( pszFilename, "LDID/87",(SAHooks*) VSI_SHP_GetHook(b2GBLimit) ); if( hDBF == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open Shape DBF file `%s'./n", pszFilename ); CPLFree( pszFilename ); CPLFree( pszFilenameWithoutExt ); SHPClose(hSHP); return NULL; } CPLFree( pszFilename );/* -------------------------------------------------------------------- *//* Create the .prj file, if required. *//* -------------------------------------------------------------------- */ if( poSRS != NULL ) { char *pszWKT = NULL; CPLString osPrjFile = CPLFormFilename( NULL, pszFilenameWithoutExt, "prj"); VSILFILE *fp; /* the shape layer needs it's own copy */ poSRS = poSRS->Clone(); poSRS->morphToESRI(); if( poSRS->exportToWkt( &pszWKT ) == OGRERR_NONE && (fp = VSIFOpenL( osPrjFile, "wt" )) != NULL ) { VSIFWriteL( pszWKT, strlen(pszWKT), 1, fp ); VSIFCloseL( fp ); } CPLFree( pszWKT ); poSRS->morphFromESRI(); }/* -------------------------------------------------------------------- *//* Create the layer object. *//* -------------------------------------------------------------------- */ OGRShapeLayer *poLayer; /* OGRShapeLayer constructor expects a filename with an extension (that could be */ /* random actually), otherwise this is going to cause problems with layer */ /* names that have a dot (not speaking about the one before the shp) */ pszFilename = CPLStrdup(CPLFormFilename( NULL, pszFilenameWithoutExt, "shp" )); poLayer = new OGRShapeLayer( this, pszFilename, hSHP, hDBF, poSRS, TRUE, TRUE, eType ); CPLFree( pszFilenameWithoutExt ); CPLFree( pszFilename ); poLayer->SetResizeAtClose( CSLFetchBoolean( papszOptions, "RESIZE", FALSE ) ); poLayer->CreateSpatialIndexAtClose( CSLFetchBoolean( papszOptions, "SPATIAL_INDEX", FALSE ) ); poLayer->SetModificationDate( CSLFetchNameValue( papszOptions, "DBF_DATE_LAST_UPDATE" ) );/* -------------------------------------------------------------------- *//* Add layer to data source layer list. *//* -------------------------------------------------------------------- */ AddLayer(poLayer); return poLayer;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
示例14: CSLFetchBooleanGDALDataset *GIFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, int bStrict, char ** papszOptions, GDALProgressFunc pfnProgress, void * pProgressData ){ int nBands = poSrcDS->GetRasterCount(); int nXSize = poSrcDS->GetRasterXSize(); int nYSize = poSrcDS->GetRasterYSize(); int bInterlace = FALSE;/* -------------------------------------------------------------------- *//* Check for interlaced option. *//* -------------------------------------------------------------------- */ bInterlace = CSLFetchBoolean(papszOptions, "INTERLACING", FALSE);/* -------------------------------------------------------------------- *//* Some some rudimentary checks *//* -------------------------------------------------------------------- */ if( nBands != 1 ) { CPLError( CE_Failure, CPLE_NotSupported, "GIF driver only supports one band images./n" ); return NULL; } if (nXSize > 65535 || nYSize > 65535) { CPLError( CE_Failure, CPLE_NotSupported, "GIF driver only supports datasets up to 65535x65535 size./n" ); return NULL; } if( poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte && bStrict ) { CPLError( CE_Failure, CPLE_NotSupported, "GIF driver doesn't support data type %s. " "Only eight bit bands supported./n", GDALGetDataTypeName( poSrcDS->GetRasterBand(1)->GetRasterDataType()) ); return NULL; }/* -------------------------------------------------------------------- *//* Open the output file. *//* -------------------------------------------------------------------- */ GifFileType *hGifFile; VSILFILE *fp; fp = VSIFOpenL( pszFilename, "wb" ); if( fp == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to create %s:/n%s", pszFilename, VSIStrerror( errno ) ); return NULL; }#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 int nError; hGifFile = EGifOpen( fp, VSIGIFWriteFunc, &nError );#else hGifFile = EGifOpen( fp, VSIGIFWriteFunc );#endif if( hGifFile == NULL ) { VSIFCloseL( fp ); CPLError( CE_Failure, CPLE_OpenFailed, "EGifOpenFilename(%s) failed. Does file already exist?", pszFilename ); return NULL; }/* -------------------------------------------------------------------- *//* Prepare colortable. *//* -------------------------------------------------------------------- */ GDALRasterBand *poBand = poSrcDS->GetRasterBand(1); ColorMapObject *psGifCT; int iColor; if( poBand->GetColorTable() == NULL ) { psGifCT = GifMakeMapObject( 256, NULL ); for( iColor = 0; iColor < 256; iColor++ ) { psGifCT->Colors[iColor].Red = (GifByteType) iColor; psGifCT->Colors[iColor].Green = (GifByteType) iColor; psGifCT->Colors[iColor].Blue = (GifByteType) iColor; } } else { GDALColorTable *poCT = poBand->GetColorTable(); int nFullCount = 1;//.........这里部分代码省略.........
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:101,
示例15: CPLAssertOGRErr OGRCSVEditableLayerSynchronizer::EditableSyncToDisk(OGRLayer* poEditableLayer, OGRLayer** ppoDecoratedLayer){ CPLAssert( m_poCSVLayer == *ppoDecoratedLayer ); CPLString osLayerName(m_poCSVLayer->GetName()); CPLString osFilename(m_poCSVLayer->GetFilename()); const bool bCreateCSVT = m_poCSVLayer->GetCreateCSVT() != FALSE; CPLString osCSVTFilename(CPLResetExtension(osFilename, "csvt")); VSIStatBufL sStatBuf; const bool bHasCSVT = VSIStatL(osCSVTFilename, &sStatBuf) == 0; CPLString osTmpFilename(osFilename); CPLString osTmpCSVTFilename(osFilename); if( VSIStatL(osFilename, &sStatBuf) == 0 ) { osTmpFilename += "_ogr_tmp.csv"; osTmpCSVTFilename += "_ogr_tmp.csvt"; } const char chDelimiter = m_poCSVLayer->GetDelimiter(); OGRCSVLayer* poCSVTmpLayer = new OGRCSVLayer( osLayerName, NULL, osTmpFilename, TRUE, TRUE, chDelimiter ); poCSVTmpLayer->BuildFeatureDefn(NULL, NULL, m_papszOpenOptions); poCSVTmpLayer->SetCRLF( m_poCSVLayer->GetCRLF() ); poCSVTmpLayer->SetCreateCSVT( bCreateCSVT || bHasCSVT ); poCSVTmpLayer->SetWriteBOM( m_poCSVLayer->GetWriteBOM() ); if( m_poCSVLayer->GetGeometryFormat() == OGR_CSV_GEOM_AS_WKT ) poCSVTmpLayer->SetWriteGeometry( wkbNone, OGR_CSV_GEOM_AS_WKT, NULL ); OGRErr eErr = OGRERR_NONE; OGRFeatureDefn* poEditableFDefn = poEditableLayer->GetLayerDefn(); for( int i=0; eErr == OGRERR_NONE && i < poEditableFDefn->GetFieldCount(); i++ ) { OGRFieldDefn oFieldDefn(poEditableFDefn->GetFieldDefn(i)); int iGeomFieldIdx; if( (EQUAL(oFieldDefn.GetNameRef(), "WKT") && (iGeomFieldIdx = poEditableFDefn->GetGeomFieldIndex("")) >= 0) || (iGeomFieldIdx = poEditableFDefn->GetGeomFieldIndex(oFieldDefn.GetNameRef())) >= 0 ) { OGRGeomFieldDefn oGeomFieldDefn( poEditableFDefn->GetGeomFieldDefn(iGeomFieldIdx) ); eErr = poCSVTmpLayer->CreateGeomField( &oGeomFieldDefn ); } else { eErr = poCSVTmpLayer->CreateField( &oFieldDefn ); } } const bool bHasXY = ( m_poCSVLayer->GetXField().size() != 0 && m_poCSVLayer->GetYField().size() != 0 ); const bool bHasZ = ( m_poCSVLayer->GetZField().size() != 0 ); if( bHasXY && !CSLFetchBoolean(m_papszOpenOptions, "KEEP_GEOM_COLUMNS", TRUE) ) { if( poCSVTmpLayer->GetLayerDefn()->GetFieldIndex(m_poCSVLayer->GetXField()) < 0 ) { OGRFieldDefn oFieldDefn(m_poCSVLayer->GetXField(), OFTReal); if( eErr == OGRERR_NONE ) eErr = poCSVTmpLayer->CreateField( &oFieldDefn ); } if( poCSVTmpLayer->GetLayerDefn()->GetFieldIndex(m_poCSVLayer->GetYField()) < 0 ) { OGRFieldDefn oFieldDefn(m_poCSVLayer->GetYField(), OFTReal); if( eErr == OGRERR_NONE ) eErr = poCSVTmpLayer->CreateField( &oFieldDefn ); } if( bHasZ && poCSVTmpLayer->GetLayerDefn()->GetFieldIndex(m_poCSVLayer->GetZField()) < 0 ) { OGRFieldDefn oFieldDefn(m_poCSVLayer->GetZField(), OFTReal); if( eErr == OGRERR_NONE ) eErr = poCSVTmpLayer->CreateField( &oFieldDefn ); } } int nFirstGeomColIdx = 0; if( m_poCSVLayer->HasHiddenWKTColumn() ) { poCSVTmpLayer->SetWriteGeometry( poEditableFDefn->GetGeomFieldDefn(0)->GetType(), OGR_CSV_GEOM_AS_WKT, poEditableFDefn->GetGeomFieldDefn(0)->GetNameRef()); nFirstGeomColIdx = 1; } if( !(poEditableFDefn->GetGeomFieldCount() == 1 && bHasXY) ) { for( int i=nFirstGeomColIdx; eErr == OGRERR_NONE && i < poEditableFDefn->GetGeomFieldCount(); i++ ) { OGRGeomFieldDefn oGeomFieldDefn( poEditableFDefn->GetGeomFieldDefn(i) ); if( poCSVTmpLayer->GetLayerDefn()->GetGeomFieldIndex(oGeomFieldDefn.GetNameRef()) >= 0 ) continue; eErr = poCSVTmpLayer->CreateGeomField( &oGeomFieldDefn ); } } OGRFeature* poFeature; poEditableLayer->ResetReading();//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例16: strncpy//.........这里部分代码省略......... } }#ifdef HAVE_GDAL GDALDataset **gdalFiles; char gdalFileName[1024]; // open GDAL GeoTIFF files if(outputFormat == OUTPUT_FORMAT_GDAL_GTIFF || outputFormat == OUTPUT_FORMAT_ALL) { GDALAllRegister(); if((gdalFiles = (GDALDataset **)malloc(sizeof(GDALDataset *) * numTypes)) == NULL) { cerr << "File array allocation error" << endl; return -1; } for(i = 0; i < numTypes; i++) { if(outputType & type[i]) { strncpy(gdalFileName, outputName.c_str(), sizeof(gdalFileName)); strncat(gdalFileName, ext[i], strlen(ext[i])); strncat(gdalFileName, ".tif", strlen(".tif")); char **papszMetadata; const char *pszFormat = "GTIFF"; GDALDriver* tpDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); if (tpDriver) { papszMetadata = tpDriver->GetMetadata(); if (CSLFetchBoolean(papszMetadata, GDAL_DCAP_CREATE, FALSE)) { char **papszOptions = NULL; gdalFiles[i] = tpDriver->Create(gdalFileName, GRID_SIZE_X, GRID_SIZE_Y, 1, GDT_Float32, papszOptions); if (gdalFiles[i] == NULL) { cerr << "File open error: " << gdalFileName << endl; return -1; } else { if (adfGeoTransform) { gdalFiles[i]->SetGeoTransform(adfGeoTransform); } else { double defaultTransform [6] = { min_x - 0.5*GRID_DIST_X, // top left x (double)GRID_DIST_X, // w-e pixel resolution 0.0, // no rotation/shear min_y - 0.5*GRID_DIST_Y + GRID_DIST_Y*GRID_SIZE_Y, // top left y 0.0, // no rotation/shear -(double)GRID_DIST_Y }; // n-x pixel resolution (negative value) gdalFiles[i]->SetGeoTransform(defaultTransform); } if (wkt) gdalFiles[i]->SetProjection(wkt); } } } } else { gdalFiles[i] = NULL; } } } else {
开发者ID:gadomski,项目名称:points2grid,代码行数:67,
示例17: CPLStrdupOGRLayer *OGROCIDataSource::ICreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ char szCommand[1024]; char *pszSafeLayerName = CPLStrdup(pszLayerName); poSession->CleanName( pszSafeLayerName ); CPLDebug( "OCI", "In Create Layer ..." ); bNoLogging = CSLFetchBoolean( papszOptions, "NO_LOGGING", false );/* -------------------------------------------------------------------- *//* Do we already have this layer? If so, should we blow it *//* away? *//* -------------------------------------------------------------------- */ int iLayer; if( CSLFetchBoolean( papszOptions, "TRUNCATE", false ) ) { CPLDebug( "OCI", "Calling TruncateLayer for %s", pszLayerName ); TruncateLayer( pszSafeLayerName ); } else { for( iLayer = 0; iLayer < nLayers; iLayer++ ) { if( EQUAL(pszSafeLayerName, papoLayers[iLayer]->GetLayerDefn()->GetName()) ) { if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") ) { DeleteLayer( pszSafeLayerName ); } else { CPLError( CE_Failure, CPLE_AppDefined, "Layer %s already exists, CreateLayer failed./n" "Use the layer creation option OVERWRITE=YES to " "replace it.", pszSafeLayerName ); CPLFree( pszSafeLayerName ); return NULL; } } } }/* -------------------------------------------------------------------- *//* Try to get the SRS Id of this spatial reference system, *//* adding tot the srs table if needed. *//* -------------------------------------------------------------------- */ char szSRSId[100]; if( CSLFetchNameValue( papszOptions, "SRID" ) != NULL ) strcpy( szSRSId, CSLFetchNameValue( papszOptions, "SRID" ) ); else if( poSRS != NULL ) snprintf( szSRSId, sizeof(szSRSId), "%d", FetchSRSId( poSRS ) ); else strcpy( szSRSId, "NULL" );/* -------------------------------------------------------------------- *//* Determine name of geometry column to use. *//* -------------------------------------------------------------------- */ const char *pszGeometryName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME" ); if( pszGeometryName == NULL ) pszGeometryName = "ORA_GEOMETRY"; const bool bGeomNullable = CPLFetchBool(const_cast<const char**>(papszOptions), "GEOMETRY_NULLABLE", true);/* -------------------------------------------------------------------- *//* Create a basic table with the FID. Also include the *//* geometry if this is not a PostGIS enabled table. *//* -------------------------------------------------------------------- */ const char *pszExpectedFIDName = CPLGetConfigOption( "OCI_FID", "OGR_FID" ); OGROCIStatement oStatement( poSession );/* -------------------------------------------------------------------- *//* If geometry type is wkbNone, do not create a geometry column. *//* -------------------------------------------------------------------- */ if ( CSLFetchNameValue( papszOptions, "TRUNCATE" ) == NULL ) { if (eType == wkbNone) { snprintf( szCommand, sizeof(szCommand), "CREATE TABLE /"%s/" ( " "%s INTEGER PRIMARY KEY)", pszSafeLayerName, pszExpectedFIDName); } else { snprintf( szCommand, sizeof(szCommand),//.........这里部分代码省略.........
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:101,
示例18: CSLFetchNameValueOGRLayer *OGRPGDumpDataSource::ICreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ CPLString osCommand; const char *pszGeomType = NULL; char *pszTableName = NULL; char *pszSchemaName = NULL; int nDimension = 3; int bHavePostGIS = TRUE; const char* pszFIDColumnNameIn = CSLFetchNameValue(papszOptions, "FID"); CPLString osFIDColumnName, osFIDColumnNameEscaped; if (pszFIDColumnNameIn == NULL) osFIDColumnName = "ogc_fid"; else { if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) { char* pszLaunderedFid = OGRPGCommonLaunderName(pszFIDColumnNameIn, "PGDump"); osFIDColumnName = pszLaunderedFid; CPLFree(pszLaunderedFid); } else { osFIDColumnName = pszFIDColumnNameIn; } } osFIDColumnNameEscaped = OGRPGDumpEscapeColumnName(osFIDColumnName); if (strncmp(pszLayerName, "pg", 2) == 0) { CPLError(CE_Warning, CPLE_AppDefined, "The layer name should not begin by 'pg' as it is a reserved prefix"); } //bHavePostGIS = CSLFetchBoolean(papszOptions,"POSTGIS", TRUE); int bCreateTable = CSLFetchBoolean(papszOptions,"CREATE_TABLE", TRUE); int bCreateSchema = CSLFetchBoolean(papszOptions,"CREATE_SCHEMA", TRUE); const char* pszDropTable = CSLFetchNameValueDef(papszOptions,"DROP_TABLE", "IF_EXISTS"); if( wkbFlatten(eType) == eType ) nDimension = 2; if( CSLFetchNameValue( papszOptions, "DIM") != NULL ) nDimension = atoi(CSLFetchNameValue( papszOptions, "DIM")); /* Should we turn layers with None geometry type as Unknown/GEOMETRY */ /* so they are still recorded in geometry_columns table ? (#4012) */ int bNoneAsUnknown = CSLTestBoolean(CSLFetchNameValueDef( papszOptions, "NONE_AS_UNKNOWN", "NO")); if (bNoneAsUnknown && eType == wkbNone) eType = wkbUnknown; else if (eType == wkbNone) bHavePostGIS = FALSE; int bExtractSchemaFromLayerName = CSLTestBoolean(CSLFetchNameValueDef( papszOptions, "EXTRACT_SCHEMA_FROM_LAYER_NAME", "YES")); /* Postgres Schema handling: Extract schema name from input layer name or passed with -lco SCHEMA. Set layer name to "schema.table" or to "table" if schema == current_schema() Usage without schema name is backwards compatible */ const char* pszDotPos = strstr(pszLayerName,"."); if ( pszDotPos != NULL && bExtractSchemaFromLayerName ) { int length = pszDotPos - pszLayerName; pszSchemaName = (char*)CPLMalloc(length+1); strncpy(pszSchemaName, pszLayerName, length); pszSchemaName[length] = '/0'; if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) pszTableName = OGRPGCommonLaunderName( pszDotPos + 1, "PGDump" ); //skip "." else pszTableName = CPLStrdup( pszDotPos + 1 ); //skip "." } else { pszSchemaName = NULL; if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) pszTableName = OGRPGCommonLaunderName( pszLayerName, "PGDump" ); //skip "." else pszTableName = CPLStrdup( pszLayerName ); //skip "." } LogCommit();/* -------------------------------------------------------------------- *//* Set the default schema for the layers. *//* -------------------------------------------------------------------- */ if( CSLFetchNameValue( papszOptions, "SCHEMA" ) != NULL ) { CPLFree(pszSchemaName); pszSchemaName = CPLStrdup(CSLFetchNameValue( papszOptions, "SCHEMA" )); if (bCreateSchema)//.........这里部分代码省略.........
开发者ID:anandthakker,项目名称:node-gdal,代码行数:101,
示例19: CPLErrorOGRLayer *GNMGenericNetwork::GetPath(GNMGFID nStartFID, GNMGFID nEndFID, GNMGraphAlgorithmType eAlgorithm, char **papszOptions){ if(!m_bIsGraphLoaded && LoadGraph() != CE_None) { return NULL; } GDALDriver* poMEMDrv = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName("Memory"); if (poMEMDrv == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot load 'Memory' driver"); return NULL; } GDALDataset* poMEMDS = poMEMDrv->Create("dummy_name", 0, 0, 0, GDT_Unknown, NULL); OGRSpatialReference oDstSpaRef(GetProjectionRef()); OGRLayer* poMEMLayer = poMEMDS->CreateLayer(GetAlgorithmName(eAlgorithm, true), &oDstSpaRef, wkbGeometryCollection, NULL); OGRGNMWrappedResultLayer* poResLayer = new OGRGNMWrappedResultLayer(poMEMDS, poMEMLayer); bool bReturnEdges = CSLFetchBoolean(papszOptions, GNM_MD_FETCHEDGES, TRUE); bool bReturnVertices = CSLFetchBoolean(papszOptions, GNM_MD_FETCHVERTEX, TRUE); switch (eAlgorithm) { case GATDijkstraShortestPath: { GNMPATH path = m_oGraph.DijkstraShortestPath(nStartFID, nEndFID); // fill features in result layer FillResultLayer(poResLayer, path, 1, bReturnVertices, bReturnEdges); } break; case GATKShortestPath: { int nK = atoi(CSLFetchNameValueDef(papszOptions, GNM_MD_NUM_PATHS, "1")); CPLDebug("GNM", "Search %d path(s)", nK); std::vector<GNMPATH> paths = m_oGraph.KShortestPaths(nStartFID, nEndFID, nK); // fill features in result layer for(size_t i = 0; i < paths.size(); ++i) { FillResultLayer(poResLayer, paths[i], i + 1, bReturnVertices, bReturnEdges); } } break; case GATConnectedComponents: { GNMVECTOR anEmitters; if(NULL != papszOptions) { char** papszEmitter = CSLFetchNameValueMultiple(papszOptions, GNM_MD_EMITTER); for(int i = 0; papszEmitter[i] != NULL; ++i) { GNMGFID nEmitter = atol(papszEmitter[i]); anEmitters.push_back(nEmitter); } } if(nStartFID != -1) { anEmitters.push_back(nStartFID); } if(nStartFID != -1) { anEmitters.push_back(nEndFID); } GNMPATH path = m_oGraph.ConnectedComponents(anEmitters); // fill features in result layer FillResultLayer(poResLayer, path, 1, bReturnVertices, bReturnEdges); } break; } return poResLayer;}
开发者ID:garnertb,项目名称:gdal,代码行数:90,
示例20: ibool GDALUtilities::createRasterFile(QString& theFilename, QString& theFormat, GDALDataType theType, int theBands, int theRows, int theCols, void ** theData, double * theGeoTransform, const QgsCoordinateReferenceSystem * theCrs, double theNodataValue){ if ( theBands <= 0 ) return false; if ( theRows <= 0 ) return false; if ( theCols <= 0 ) return false; if ( !theData ) return false;/* bool formatSupported = false; QMapIterator<QString, QString> i(mSupportedFormats); while (i.hasNext()) { i.next(); if( theFormat == i.key()) { formatSupported = true; break; } } if ( !formatSupported ) return false;*/ //GDALAllRegister(); GDALDriver * driver; //set format char * format = new char[theFormat.size() + 1]; strcpy( format, theFormat.toLocal8Bit().data() ); driver = GetGDALDriverManager()->GetDriverByName(format); if( driver == NULL ) return false; char ** metadata = driver->GetMetadata(); if( !CSLFetchBoolean( metadata, GDAL_DCAP_CREATE, FALSE ) ) return false; GDALDataset * dstDS; //set options char ** options = NULL; options = CSLSetNameValue( options, "COMPRESS", "LZW" ); //if it is a GeoTIFF format set correct compression options if ( !strcmp( format, "GTiff" ) ) { if( theType == GDT_Byte ) { options = CSLSetNameValue( options, "PREDICTOR", "1" ); } else { if ( theType == GDT_UInt16 || theType == GDT_Int16 || theType == GDT_UInt32 || theType == GDT_Int32 ) { options = CSLSetNameValue( options, "PREDICTOR", "2" ); } else { options = CSLSetNameValue( options, "PREDICTOR", "3" ); } } } //set filename char * dstFilename = new char[theFilename.size() + 1]; strcpy( dstFilename, theFilename.toLocal8Bit().data() ); dstDS = driver->Create( dstFilename, theCols, theRows, theBands, theType, options ); delete dstFilename; delete [] options; //set geotransform dstDS->SetGeoTransform( theGeoTransform ); //set CRS char * crsWkt = new char[theCrs->toWkt().size() + 1]; strcpy( crsWkt, theCrs->toWkt().toLocal8Bit().data()); dstDS->SetProjection( crsWkt );//.........这里部分代码省略.........
开发者ID:GeoTeqMap,项目名称:QgisLidarPlugin,代码行数:101,
示例21: CSLFetchNameValueCPLErr VRTDataset::AddBand( GDALDataType eType, char **papszOptions ){ int i; const char *pszSubClass = CSLFetchNameValue(papszOptions, "subclass"); bNeedsFlush = 1;/* ==================================================================== *//* Handle a new raw band. *//* ==================================================================== */ if( pszSubClass != NULL && EQUAL(pszSubClass,"VRTRawRasterBand") ) { int nWordDataSize = GDALGetDataTypeSize( eType ) / 8; vsi_l_offset nImageOffset = 0; int nPixelOffset = nWordDataSize; int nLineOffset = nWordDataSize * GetRasterXSize(); const char *pszFilename; const char *pszByteOrder = NULL; int bRelativeToVRT = FALSE;/* -------------------------------------------------------------------- *//* Collect required information. *//* -------------------------------------------------------------------- */ if( CSLFetchNameValue(papszOptions, "ImageOffset") != NULL ) nImageOffset = atoi(CSLFetchNameValue(papszOptions, "ImageOffset")); if( CSLFetchNameValue(papszOptions, "PixelOffset") != NULL ) nPixelOffset = atoi(CSLFetchNameValue(papszOptions,"PixelOffset")); if( CSLFetchNameValue(papszOptions, "LineOffset") != NULL ) nLineOffset = atoi(CSLFetchNameValue(papszOptions, "LineOffset")); if( CSLFetchNameValue(papszOptions, "ByteOrder") != NULL ) pszByteOrder = CSLFetchNameValue(papszOptions, "ByteOrder"); if( CSLFetchNameValue(papszOptions, "SourceFilename") != NULL ) pszFilename = CSLFetchNameValue(papszOptions, "SourceFilename"); else { CPLError( CE_Failure, CPLE_AppDefined, "AddBand() requires a SourceFilename option for VRTRawRasterBands." ); return CE_Failure; } bRelativeToVRT = CSLFetchBoolean( papszOptions, "RelativeToVRT", FALSE );/* -------------------------------------------------------------------- *//* Create and initialize the band. *//* -------------------------------------------------------------------- */ CPLErr eErr; VRTRawRasterBand *poBand = new VRTRawRasterBand( this, GetRasterCount() + 1, eType ); eErr = poBand->SetRawLink( pszFilename, NULL, FALSE, nImageOffset, nPixelOffset, nLineOffset, pszByteOrder ); if( eErr != CE_None ) { delete poBand; return eErr; } SetBand( GetRasterCount() + 1, poBand ); return CE_None; }/* ==================================================================== *//* Handle a new "sourced" band. *//* ==================================================================== */ else { VRTSourcedRasterBand *poBand; /* ---- Check for our sourced band 'derived' subclass ---- */ if(pszSubClass != NULL && EQUAL(pszSubClass,"VRTDerivedRasterBand")) { /* We'll need a pointer to the subclass in case we need */ /* to set the new band's pixel function below. */ VRTDerivedRasterBand* poDerivedBand; poDerivedBand = new VRTDerivedRasterBand (this, GetRasterCount() + 1, eType, GetRasterXSize(), GetRasterYSize()); /* Set the pixel function options it provided. */ const char* pszFuncName = CSLFetchNameValue(papszOptions, "PixelFunctionType"); if (pszFuncName != NULL) poDerivedBand->SetPixelFunctionName(pszFuncName); const char* pszTransferTypeName = CSLFetchNameValue(papszOptions, "SourceTransferType"); if (pszTransferTypeName != NULL) { GDALDataType eTransferType =//.........这里部分代码省略.........
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,
示例22: CPLAssertint OGRBNADataSource::Create( const char *pszFilename, char **papszOptions ){ if( fpOutput != NULL) { CPLAssert( FALSE ); return FALSE; }/* -------------------------------------------------------------------- *//* Do not override exiting file. *//* -------------------------------------------------------------------- */ VSIStatBufL sStatBuf; if( VSIStatL( pszFilename, &sStatBuf ) == 0 ) return FALSE; /* -------------------------------------------------------------------- *//* Create the output file. *//* -------------------------------------------------------------------- */ pszName = CPLStrdup( pszFilename ); if( EQUAL(pszFilename,"stdout") ) fpOutput = VSIFOpenL( "/vsistdout/", "wb" ); else fpOutput = VSIFOpenL( pszFilename, "wb" ); if( fpOutput == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to create BNA file %s.", pszFilename ); return FALSE; } /* EOL token */ const char *pszCRLFFormat = CSLFetchNameValue( papszOptions, "LINEFORMAT"); if( pszCRLFFormat == NULL ) {#ifdef WIN32 bUseCRLF = TRUE;#else bUseCRLF = FALSE;#endif } else if( EQUAL(pszCRLFFormat,"CRLF") ) bUseCRLF = TRUE; else if( EQUAL(pszCRLFFormat,"LF") ) bUseCRLF = FALSE; else { CPLError( CE_Warning, CPLE_AppDefined, "LINEFORMAT=%s not understood, use one of CRLF or LF.", pszCRLFFormat );#ifdef WIN32 bUseCRLF = TRUE;#else bUseCRLF = FALSE;#endif } /* Multi line or single line format ? */ bMultiLine = CSLFetchBoolean( papszOptions, "MULTILINE", TRUE); /* Number of identifiers per record */ const char* pszNbOutID = CSLFetchNameValue ( papszOptions, "NB_IDS"); if (pszNbOutID == NULL) { nbOutID = NB_MIN_BNA_IDS; } else if (EQUAL(pszNbOutID, "NB_SOURCE_FIELDS")) { nbOutID = -1; } else { nbOutID = atoi(pszNbOutID); if (nbOutID <= 0) { CPLError( CE_Warning, CPLE_AppDefined, "NB_ID=%s not understood. Must be >=%d and <=%d or equal to NB_SOURCE_FIELDS", pszNbOutID, NB_MIN_BNA_IDS, NB_MAX_BNA_IDS ); nbOutID = NB_MIN_BNA_IDS; } if (nbOutID > NB_MAX_BNA_IDS) { CPLError( CE_Warning, CPLE_AppDefined, "NB_ID=%s not understood. Must be >=%d and <=%d or equal to NB_SOURCE_FIELDS", pszNbOutID, NB_MIN_BNA_IDS, NB_MAX_BNA_IDS ); nbOutID = NB_MAX_BNA_IDS; } } /* Ellipses export as ellipses or polygons ? */ bEllipsesAsEllipses = CSLFetchBoolean( papszOptions, "ELLIPSES_AS_ELLIPSES", TRUE); /* Number of coordinate pairs per line */ const char* pszNbPairPerLine = CSLFetchNameValue( papszOptions, "NB_PAIRS_PER_LINE"); if (pszNbPairPerLine) {//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例23: CPLErrorOGRLayer *OGRDGNDataSource::CreateLayer( const char *pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eGeomType, char **papszExtraOptions ){ const char *pszSeed, *pszMasterUnit = "m", *pszSubUnit = "cm"; const char *pszValue; int nUORPerSU=1, nSUPerMU=100; int nCreationFlags = 0, b3DRequested; double dfOriginX = -21474836.0, /* default origin centered on zero */ dfOriginY = -21474836.0, /* with two decimals of precision */ dfOriginZ = -21474836.0;/* -------------------------------------------------------------------- *//* Ensure only one layer gets created. *//* -------------------------------------------------------------------- */ if( nLayers > 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "DGN driver only supports one layer will all the elements in it." ); return NULL; }/* -------------------------------------------------------------------- *//* If the coordinate system is geographic, we should use a *//* localized default origin and resolution. *//* -------------------------------------------------------------------- */ if( poSRS != NULL && poSRS->IsGeographic() ) { dfOriginX = -200.0; dfOriginY = -200.0; pszMasterUnit = "d"; pszSubUnit = "s"; nSUPerMU = 3600; nUORPerSU = 1000; }/* -------------------------------------------------------------------- *//* Parse out various creation options. *//* -------------------------------------------------------------------- */ CSLInsertStrings( papszOptions, 0, papszExtraOptions ); b3DRequested = CSLFetchBoolean( papszOptions, "3D", (((int) eGeomType) & wkb25DBit) ); pszSeed = CSLFetchNameValue( papszOptions, "SEED" ); if( pszSeed ) nCreationFlags |= DGNCF_USE_SEED_ORIGIN | DGNCF_USE_SEED_UNITS; else if( b3DRequested ) pszSeed = CPLFindFile( "gdal", "seed_3d.dgn" ); else pszSeed = CPLFindFile( "gdal", "seed_2d.dgn" ); if( pszSeed == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "No seed file provided, and unable to find seed_2d.dgn." ); return NULL; } if( CSLFetchBoolean( papszOptions, "COPY_WHOLE_SEED_FILE", TRUE ) ) nCreationFlags |= DGNCF_COPY_WHOLE_SEED_FILE; if( CSLFetchBoolean( papszOptions, "COPY_SEED_FILE_COLOR_TABLE", TRUE ) ) nCreationFlags |= DGNCF_COPY_SEED_FILE_COLOR_TABLE; pszValue = CSLFetchNameValue( papszOptions, "MASTER_UNIT_NAME" ); if( pszValue != NULL ) { nCreationFlags &= ~DGNCF_USE_SEED_UNITS; pszMasterUnit = pszValue; } pszValue = CSLFetchNameValue( papszOptions, "SUB_UNIT_NAME" ); if( pszValue != NULL ) { nCreationFlags &= ~DGNCF_USE_SEED_UNITS; pszSubUnit = pszValue; } pszValue = CSLFetchNameValue( papszOptions, "SUB_UNITS_PER_MASTER_UNIT" ); if( pszValue != NULL ) { nCreationFlags &= ~DGNCF_USE_SEED_UNITS; nSUPerMU = atoi(pszValue); } pszValue = CSLFetchNameValue( papszOptions, "UOR_PER_SUB_UNIT" ); if( pszValue != NULL ) { nCreationFlags &= ~DGNCF_USE_SEED_UNITS; nUORPerSU = atoi(pszValue); } pszValue = CSLFetchNameValue( papszOptions, "ORIGIN" ); if( pszValue != NULL ) { char **papszTuple = CSLTokenizeStringComplex( pszValue, " ,", //.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例24: CPLStrdup//.........这里部分代码省略......... } } }/* -------------------------------------------------------------------- *//* Try to get the SRS Id of this spatial reference system, *//* adding tot the srs table if needed. *//* -------------------------------------------------------------------- */ char szSRSId[100]; if( CSLFetchNameValue( papszOptions, "SRID" ) != NULL ) strcpy( szSRSId, CSLFetchNameValue( papszOptions, "SRID" ) ); else if( poSRS != NULL ) sprintf( szSRSId, "%d", FetchSRSId( poSRS ) ); else strcpy( szSRSId, "NULL" );/* -------------------------------------------------------------------- *//* Determine name of geometry column to use. *//* -------------------------------------------------------------------- */ const char *pszGeometryName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME" ); if( pszGeometryName == NULL ) pszGeometryName = "ORA_GEOMETRY";/* -------------------------------------------------------------------- *//* Create a basic table with the FID. Also include the *//* geometry if this is not a PostGIS enabled table. *//* -------------------------------------------------------------------- */ const char *pszExpectedFIDName = CPLGetConfigOption( "OCI_FID", "OGR_FID" ); OGROCIStatement oStatement( poSession );/* -------------------------------------------------------------------- *//* If geometry type is wkbNone, do not create a geoemtry column *//* -------------------------------------------------------------------- */ if (eType == wkbNone) { sprintf( szCommand, "CREATE TABLE /"%s/" ( " "%s INTEGER)", pszSafeLayerName, pszExpectedFIDName); } else { sprintf( szCommand, "CREATE TABLE /"%s/" ( " "%s INTEGER, " "%s %s )", pszSafeLayerName, pszExpectedFIDName, pszGeometryName, SDO_GEOMETRY ); } if( oStatement.Execute( szCommand ) != CE_None ) { CPLFree( pszSafeLayerName ); return NULL; }/* -------------------------------------------------------------------- *//* Create the layer object. *//* -------------------------------------------------------------------- */ const char *pszLoaderFile = CSLFetchNameValue(papszOptions,"LOADER_FILE"); OGROCIWritableLayer *poLayer; if( pszLoaderFile == NULL ) poLayer = new OGROCITableLayer( this, pszSafeLayerName, EQUAL(szSRSId,"NULL") ? -1 : atoi(szSRSId), TRUE, TRUE ); else poLayer = new OGROCILoaderLayer( this, pszSafeLayerName, pszGeometryName, EQUAL(szSRSId,"NULL") ? -1 : atoi(szSRSId), pszLoaderFile );/* -------------------------------------------------------------------- *//* Set various options on the layer. *//* -------------------------------------------------------------------- */ poLayer->SetLaunderFlag( CSLFetchBoolean(papszOptions,"LAUNDER",FALSE) ); poLayer->SetPrecisionFlag( CSLFetchBoolean(papszOptions,"PRECISION",TRUE)); if( CSLFetchNameValue(papszOptions,"DIM") != NULL ) poLayer->SetDimension( atoi(CSLFetchNameValue(papszOptions,"DIM")) ); poLayer->SetOptions( papszOptions );/* -------------------------------------------------------------------- *//* Add layer to data source layer list. *//* -------------------------------------------------------------------- */ papoLayers = (OGROCILayer **) CPLRealloc( papoLayers, sizeof(OGROCILayer *) * (nLayers+1) ); papoLayers[nLayers++] = poLayer; CPLFree( pszSafeLayerName ); return poLayer;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例25: GDALRasterizeGeometriesCPLErr GDALRasterizeGeometries( GDALDatasetH hDS, int nBandCount, int *panBandList, int nGeomCount, OGRGeometryH *pahGeometries, GDALTransformerFunc pfnTransformer, void *pTransformArg, double *padfGeomBurnValue, char **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg ){ GDALDataType eType; int nYChunkSize, nScanlineBytes; unsigned char *pabyChunkBuf; int iY; GDALDataset *poDS = (GDALDataset *) hDS; if( pfnProgress == NULL ) pfnProgress = GDALDummyProgress;/* -------------------------------------------------------------------- *//* Do some rudimentary arg checking. *//* -------------------------------------------------------------------- */ if( nBandCount == 0 || nGeomCount == 0 ) return CE_None; // prototype band. GDALRasterBand *poBand = poDS->GetRasterBand( panBandList[0] ); if (poBand == NULL) return CE_Failure; int bAllTouched = CSLFetchBoolean( papszOptions, "ALL_TOUCHED", FALSE ); const char *pszOpt = CSLFetchNameValue( papszOptions, "BURN_VALUE_FROM" ); GDALBurnValueSrc eBurnValueSource = GBV_UserBurnValue; if( pszOpt ) { if( EQUAL(pszOpt,"Z")) eBurnValueSource = GBV_Z; /*else if( EQUAL(pszOpt,"M")) eBurnValueSource = GBV_M;*/ }/* -------------------------------------------------------------------- *//* If we have no transformer, assume the geometries are in file *//* georeferenced coordinates, and create a transformer to *//* convert that to pixel/line coordinates. *//* *//* We really just need to apply an affine transform, but for *//* simplicity we use the more general GenImgProjTransformer. *//* -------------------------------------------------------------------- */ int bNeedToFreeTransformer = FALSE; if( pfnTransformer == NULL ) { bNeedToFreeTransformer = TRUE; pTransformArg = GDALCreateGenImgProjTransformer( NULL, NULL, hDS, NULL, FALSE, 0.0, 0); pfnTransformer = GDALGenImgProjTransform; }/* -------------------------------------------------------------------- *//* Establish a chunksize to operate on. The larger the chunk *//* size the less times we need to make a pass through all the *//* shapes. *//* -------------------------------------------------------------------- */ if( poBand->GetRasterDataType() == GDT_Byte ) eType = GDT_Byte; else eType = GDT_Float32; nScanlineBytes = nBandCount * poDS->GetRasterXSize() * (GDALGetDataTypeSize(eType)/8); nYChunkSize = 10000000 / nScanlineBytes; if( nYChunkSize > poDS->GetRasterYSize() ) nYChunkSize = poDS->GetRasterYSize(); pabyChunkBuf = (unsigned char *) VSIMalloc(nYChunkSize * nScanlineBytes); if( pabyChunkBuf == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Unable to allocate rasterization buffer." ); return CE_Failure; }/* ==================================================================== *//* Loop over image in designated chunks. *//* ==================================================================== */ CPLErr eErr = CE_None; pfnProgress( 0.0, NULL, pProgressArg ); for( iY = 0; iY < poDS->GetRasterYSize() && eErr == CE_None; iY += nYChunkSize ) { int nThisYChunkSize; int iShape;//.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例26: GDALRasterizeLayersCPLErr GDALRasterizeLayers( GDALDatasetH hDS, int nBandCount, int *panBandList, int nLayerCount, OGRLayerH *pahLayers, GDALTransformerFunc pfnTransformer, void *pTransformArg, double *padfLayerBurnValues, char **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg ){ GDALDataType eType; unsigned char *pabyChunkBuf; GDALDataset *poDS = (GDALDataset *) hDS; if( pfnProgress == NULL ) pfnProgress = GDALDummyProgress;/* -------------------------------------------------------------------- *//* Do some rudimentary arg checking. *//* -------------------------------------------------------------------- */ if( nBandCount == 0 || nLayerCount == 0 ) return CE_None; // prototype band. GDALRasterBand *poBand = poDS->GetRasterBand( panBandList[0] ); if (poBand == NULL) return CE_Failure; int bAllTouched = CSLFetchBoolean( papszOptions, "ALL_TOUCHED", FALSE ); const char *pszOpt = CSLFetchNameValue( papszOptions, "BURN_VALUE_FROM" ); GDALBurnValueSrc eBurnValueSource = GBV_UserBurnValue; if( pszOpt ) { if( EQUAL(pszOpt,"Z")) eBurnValueSource = GBV_Z; /*else if( EQUAL(pszOpt,"M")) eBurnValueSource = GBV_M;*/ }/* -------------------------------------------------------------------- *//* Establish a chunksize to operate on. The larger the chunk *//* size the less times we need to make a pass through all the *//* shapes. *//* -------------------------------------------------------------------- */ int nYChunkSize, nScanlineBytes; const char *pszYChunkSize = CSLFetchNameValue( papszOptions, "CHUNKYSIZE" ); if( poBand->GetRasterDataType() == GDT_Byte ) eType = GDT_Byte; else eType = GDT_Float32; nScanlineBytes = nBandCount * poDS->GetRasterXSize() * (GDALGetDataTypeSize(eType)/8); if ( pszYChunkSize && (nYChunkSize = atoi(pszYChunkSize)) ) ; else nYChunkSize = GDALGetCacheMax() / nScanlineBytes; if( nYChunkSize < 1 ) nYChunkSize = 1; if( nYChunkSize > poDS->GetRasterYSize() ) nYChunkSize = poDS->GetRasterYSize(); pabyChunkBuf = (unsigned char *) VSIMalloc(nYChunkSize * nScanlineBytes); if( pabyChunkBuf == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Unable to allocate rasterization buffer." ); return CE_Failure; }/* -------------------------------------------------------------------- *//* Read the image once for all layers if user requested to render *//* the whole raster in single chunk. *//* -------------------------------------------------------------------- */ if ( nYChunkSize == poDS->GetRasterYSize() ) { if ( poDS->RasterIO( GF_Read, 0, 0, poDS->GetRasterXSize(), nYChunkSize, pabyChunkBuf, poDS->GetRasterXSize(), nYChunkSize, eType, nBandCount, panBandList, 0, 0, 0 ) != CE_None ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Unable to read buffer." ); CPLFree( pabyChunkBuf ); return CE_Failure; } }/* ==================================================================== *//* Read the specified layers transfoming and rasterizing *//* geometries. *//* ==================================================================== */ CPLErr eErr = CE_None; int iLayer;//.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例27: CPLError//.........这里部分代码省略......... return NULL; / } / } /} FETCH_AND_SET_OPTION_INT("TARGETSIZE", target_size, 0, INT_MAX); const char* pszPSNR = CSLFetchNameValue(papszOptions, "PSNR"); if (pszPSNR) { sConfig.target_PSNR = CPLAtof(pszPSNR); if (sConfig.target_PSNR < 0) { CPLError( CE_Failure, CPLE_IllegalArg, "PSNR=%s is not a legal value.", pszPSNR ); return NULL; } } FETCH_AND_SET_OPTION_INT("METHOD", method, 0, 6); FETCH_AND_SET_OPTION_INT("SEGMENTS", segments, 1, 4); FETCH_AND_SET_OPTION_INT("SNS_STRENGTH", sns_strength, 0, 100); FETCH_AND_SET_OPTION_INT("FILTER_STRENGTH", filter_strength, 0, 100); FETCH_AND_SET_OPTION_INT("FILTER_SHARPNESS", filter_sharpness, 0, 7); FETCH_AND_SET_OPTION_INT("FILTER_TYPE", filter_type, 0, 1); FETCH_AND_SET_OPTION_INT("AUTOFILTER", autofilter, 0, 1); FETCH_AND_SET_OPTION_INT("PASS", pass, 1, 10); FETCH_AND_SET_OPTION_INT("PREPROCESSING", preprocessing, 0, 1); FETCH_AND_SET_OPTION_INT("PARTITIONS", partitions, 0, 3);#if WEBP_ENCODER_ABI_VERSION >= 0x0002 FETCH_AND_SET_OPTION_INT("PARTITION_LIMIT", partition_limit, 0, 100);#endif#if WEBP_ENCODER_ABI_VERSION >= 0x0100 sConfig.lossless = CSLFetchBoolean(papszOptions, "LOSSLESS", FALSE); if (sConfig.lossless) sPicture.use_argb = 1;#endif if (!WebPValidateConfig(&sConfig)) { CPLError(CE_Failure, CPLE_AppDefined, "WebPValidateConfig() failed"); return NULL; }/* -------------------------------------------------------------------- *//* Allocate memory *//* -------------------------------------------------------------------- */ GByte *pabyBuffer; pabyBuffer = (GByte *) VSIMalloc( nBands * nXSize * nYSize ); if (pabyBuffer == NULL) { return NULL; }/* -------------------------------------------------------------------- *//* Create the dataset. *//* -------------------------------------------------------------------- */ VSILFILE *fpImage; fpImage = VSIFOpenL( pszFilename, "wb" ); if( fpImage == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to create WEBP file %s./n", pszFilename );
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:67,
示例28: CPLError//.........这里部分代码省略......... char abyNoData[8]; double dfNoDataVal = 0.0; const char* pszNoDataValue = CSLFetchNameValue(papszParmList, "NODATA_VALUE"); if (pszNoDataValue) { dfNoDataVal = CPLAtofM(pszNoDataValue); } else { switch (eType) /* GDT_Byte, GDT_UInt16, GDT_Int16, GDT_UInt32 */ { /* GDT_Int32, GDT_Float32, GDT_Float64 */ case (GDT_Byte): { dfNoDataVal = SG_NODATA_GDT_Byte; break; } case (GDT_UInt16): { dfNoDataVal = SG_NODATA_GDT_UInt16; break; } case (GDT_Int16): { dfNoDataVal = SG_NODATA_GDT_Int16; break; } case (GDT_UInt32): { dfNoDataVal = SG_NODATA_GDT_UInt32; break; } case (GDT_Int32): { dfNoDataVal = SG_NODATA_GDT_Int32; break; } default: case (GDT_Float32): { dfNoDataVal = SG_NODATA_GDT_Float32; break; } case (GDT_Float64): { dfNoDataVal = SG_NODATA_GDT_Float64; break; } } } GDALCopyWords(&dfNoDataVal, GDT_Float64, 0, abyNoData, eType, 0, 1); CPLString osHdrFilename = CPLResetExtension( pszFilename, "sgrd" ); CPLErr eErr = WriteHeader( osHdrFilename, eType, nXSize, nYSize, 0.0, 0.0, 1.0, dfNoDataVal, 1.0, false ); if( eErr != CE_None ) { VSIFCloseL( fp ); return NULL; } if (CSLFetchBoolean( papszParmList , "FILL_NODATA", TRUE )) { int nDataTypeSize = GDALGetDataTypeSize(eType) / 8; GByte* pabyNoDataBuf = (GByte*) VSIMalloc2(nDataTypeSize, nXSize); if (pabyNoDataBuf == NULL) { VSIFCloseL( fp ); return NULL; } for( int iCol = 0; iCol < nXSize; iCol++) { memcpy(pabyNoDataBuf + iCol * nDataTypeSize, abyNoData, nDataTypeSize); } for( int iRow = 0; iRow < nYSize; iRow++ ) { if( VSIFWriteL( pabyNoDataBuf, nDataTypeSize, nXSize, fp ) != (unsigned)nXSize ) { VSIFCloseL( fp ); VSIFree(pabyNoDataBuf); CPLError( CE_Failure, CPLE_FileIO, "Unable to write grid cell. Disk full?/n" ); return NULL; } } VSIFree(pabyNoDataBuf); } VSIFCloseL( fp ); return (GDALDataset *)GDALOpen( pszFilename, GA_Update );}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,
示例29: CPLErrorGDALDataset *NTv2Dataset::Create( const char * pszFilename, int nXSize, int nYSize, CPL_UNUSED int nBands, GDALDataType eType, char ** papszOptions ){ if( eType != GDT_Float32 ) { CPLError(CE_Failure, CPLE_AppDefined, "Attempt to create NTv2 file with unsupported data type '%s'.", GDALGetDataTypeName( eType ) ); return NULL; }/* -------------------------------------------------------------------- *//* Are we extending an existing file? *//* -------------------------------------------------------------------- */ VSILFILE *fp; GUInt32 nNumFile = 1; int bAppend = CSLFetchBoolean(papszOptions,"APPEND_SUBDATASET",FALSE); /* -------------------------------------------------------------------- *//* Try to open or create file. *//* -------------------------------------------------------------------- */ if( bAppend ) fp = VSIFOpenL( pszFilename, "rb+" ); else fp = VSIFOpenL( pszFilename, "wb" ); if( fp == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Attempt to open/create file `%s' failed./n", pszFilename ); return NULL; }/* -------------------------------------------------------------------- *//* Create a file level header if we are creating new. *//* -------------------------------------------------------------------- */ char achHeader[11*16]; const char *pszValue; if( !bAppend ) { memset( achHeader, 0, sizeof(achHeader) ); memcpy( achHeader + 0*16, "NUM_OREC", 8 ); achHeader[ 0*16 + 8] = 0xb; memcpy( achHeader + 1*16, "NUM_SREC", 8 ); achHeader[ 1*16 + 8] = 0xb; memcpy( achHeader + 2*16, "NUM_FILE", 8 ); achHeader[ 2*16 + 8] = 0x1; memcpy( achHeader + 3*16, "GS_TYPE ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "GS_TYPE", "SECONDS"); memcpy( achHeader + 3*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 4*16, "VERSION ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "VERSION", "" ); memcpy( achHeader + 4*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 5*16, "SYSTEM_F ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "SYSTEM_F", "" ); memcpy( achHeader + 5*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 6*16, "SYSTEM_T ", 16 ); pszValue = CSLFetchNameValueDef( papszOptions, "SYSTEM_T", "" ); memcpy( achHeader + 6*16+8, pszValue, MIN(16,strlen(pszValue)) ); memcpy( achHeader + 7*16, "MAJOR_F ", 8); memcpy( achHeader + 8*16, "MINOR_F ", 8 ); memcpy( achHeader + 9*16, "MAJOR_T ", 8 ); memcpy( achHeader + 10*16, "MINOR_T ", 8 ); VSIFWriteL( achHeader, 1, sizeof(achHeader), fp ); }/* -------------------------------------------------------------------- *//* Otherwise update the header with an increased subfile count, *//* and advanced to the last record of the file. *//* -------------------------------------------------------------------- */ else { VSIFSeekL( fp, 2*16 + 8, SEEK_SET ); VSIFReadL( &nNumFile, 1, 4, fp ); CPL_LSBPTR32( &nNumFile ); nNumFile++; CPL_LSBPTR32( &nNumFile ); VSIFSeekL( fp, 2*16 + 8, SEEK_SET ); VSIFWriteL( &nNumFile, 1, 4, fp ); vsi_l_offset nEnd; VSIFSeekL( fp, 0, SEEK_END );//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,
注:本文中的CSLFetchBoolean函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CSLFetchNameValue函数代码示例 C++ CSLDuplicate函数代码示例 |