本文整理汇总了C++中CPLSetConfigOption函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLSetConfigOption函数的具体用法?C++ CPLSetConfigOption怎么用?C++ CPLSetConfigOption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLSetConfigOption函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
CPLJoinableThread* hThread;
printf("main thread %p\n", (void*)CPLGetPID());
argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 );
CPLSetConfigOption("GDAL_CACHEMAX", "0");
CPLSetConfigOption("GDAL_DEBUG_BLOCK_CACHE", "ON");
MyDataset* poDS = new MyDataset();
char buf1[] = { 1 } ;
CPL_IGNORE_RET_VAL(GDALRasterIO(GDALGetRasterBand(poDS, 1), GF_Write, 0, 0, 1, 1, buf1, 1, 1, GDT_Byte, 0, 0));
hThread = CPLCreateJoinableThread(thread_func, NULL);
CPLSleep(0.3);
CPL_IGNORE_RET_VAL(GDALRasterIO(GDALGetRasterBand(poDS, 1), GF_Write, 1, 0, 1, 1, buf1, 1, 1, GDT_Byte, 0, 0));
GDALFlushCacheBlock();
CPLJoinThread(hThread);
delete poDS;
GDALDestroyDriverManager();
CSLDestroy( argv );
return 0;
}
示例2: EarlySetConfigOptions
void EarlySetConfigOptions( int argc, char ** argv )
{
// Must process some config options before GDALAllRegister() or
// OGRRegisterAll(), but we can't call GDALGeneralCmdLineProcessor() or
// OGRGeneralCmdLineProcessor(), because it needs the drivers to be
// registered for the --format or --formats options.
for( int i = 1; i < argc; i++ )
{
if( EQUAL(argv[i],"--config") && i + 2 < argc &&
(EQUAL(argv[i + 1], "GDAL_SKIP") ||
EQUAL(argv[i + 1], "GDAL_DRIVER_PATH") ||
EQUAL(argv[i + 1], "OGR_SKIP") ||
EQUAL(argv[i + 1], "OGR_DRIVER_PATH")) )
{
CPLSetConfigOption( argv[i+1], argv[i+2] );
i += 2;
}
else if( EQUAL(argv[i],"--debug") && i + 1 < argc )
{
CPLSetConfigOption( "CPL_DEBUG", argv[i+1] );
i += 1;
}
}
}
示例3: simplet_init
// Initialize libraries, register the atexit handler and set up error reporting.
void simplet_init() {
if (initialized) return;
CPLSetConfigOption("OGR_ENABLE_PARTIAL_REPROJECTION", "ON");
#ifdef DEBUG
CPLSetConfigOption("CPL_DEBUG", "ON");
#endif
OGRRegisterAll();
GDALAllRegister();
atexit(cleanup);
initialized = 1;
};
示例4: update
void update() const
{
QSettings settings;
/// \todo Build from driver list in GDAL/OGR >= 2.0
static const std::vector<QByteArray> default_extensions = { "shp", "shx" };
enabled_vector_extensions.reserve(default_extensions.size() + 3);
enabled_vector_extensions = default_extensions;
settings.beginGroup(gdal_manager_group);
if (settings.value(gdal_dxf_key).toBool())
enabled_vector_extensions.push_back("dxf");
if (settings.value(gdal_gpx_key).toBool())
enabled_vector_extensions.push_back("gpx");
if (settings.value(gdal_osm_key).toBool())
enabled_vector_extensions.push_back("osm");
settings.endGroup();
auto gdal_data = MapperResource::locate(MapperResource::GDAL_DATA);
if (!gdal_data.isEmpty())
{
// The user may overwrite this default in the settings.
CPLSetConfigOption("GDAL_DATA", gdal_data.toLatin1().constData());
}
settings.beginGroup(gdal_configuration_group);
QStringList new_parameters = settings.childKeys();
if (new_parameters.isEmpty())
{
// Default options for debugging and for some drivers
settings.setValue(QString::fromLatin1("CPL_DEBUG"), QVariant{QLatin1String("OFF")});
settings.setValue(QString::fromLatin1("USE_PROJ_480_FEATURES"), QVariant{QLatin1String("YES")});
settings.setValue(QString::fromLatin1("OSM_USE_CUSTOM_INDEXING"), QVariant{QLatin1String("NO")});
new_parameters = settings.childKeys();
}
new_parameters.sort();
for (auto parameter : new_parameters)
{
CPLSetConfigOption(parameter.toLatin1().constData(), settings.value(parameter).toByteArray().constData());
}
for (auto parameter : static_cast<const QStringList&>(applied_parameters))
{
if (!new_parameters.contains(parameter)
&& parameter != QLatin1String{ "GDAL_DATA" })
{
CPLSetConfigOption(parameter.toLatin1().constData(), nullptr);
}
}
applied_parameters.swap(new_parameters);
dirty = false;
}
示例5: wxString
bool wxGISApplicationEx::SetupSys(const wxString &sSysPath)
{
if(!wxGISApplication::SetupSys(sSysPath))
return false;
#ifdef __WINDOWS__
wxString sGdalDataDir = sSysPath + wxFileName::GetPathSeparator() + wxString(wxT("gdal")) + wxFileName::GetPathSeparator();
CPLSetConfigOption("GDAL_DATA", sGdalDataDir.ToUTF8() );
#ifdef wxGIS_USE_PROJ
sGdalDataDir = sSysPath + wxFileName::GetPathSeparator() + wxString(wxT("proj")) + wxFileName::GetPathSeparator();
//CPLSetConfigOption("PROJ_LIB", sGdalDataDir.mb_str(wxConvUTF8) );
CPLString pszPROJ_LIB(sGdalDataDir.mb_str(wxConvUTF8));
const char *path = pszPROJ_LIB.c_str();
pj_set_searchpath(1, &path);
#endif // wxGIS_USE_PROJ
#endif // __WINDOWS__
#ifdef __UNIX__
wxString sGdalDataGCS = wxString::Format(wxT("/usr/share/gdal/%s/gcs.csv"), GDALVersionInfo("RELEASE_NAME"));
if(!wxFileName::FileExists(sGdalDataGCS))
{
sGdalDataGCS = wxString(wxT("/usr/share/gdal/gcs.csv"));
if(!wxFileName::FileExists(sGdalDataGCS))
{
sGdalDataGCS = wxString::Format(wxT("/usr/local/share/gdal/%s/gcs.csv"), GDALVersionInfo("RELEASE_NAME"));
if(!wxFileName::FileExists(sGdalDataGCS))
{
sGdalDataGCS = wxString(wxT("/usr/local/share/gdal/gcs.csv"));
if(!wxFileName::FileExists(sGdalDataGCS))
{
return false;
}
}
}
}
wxFileName Name(sGdalDataGCS);
CPLSetConfigOption("GDAL_DATA", Name.GetPath().ToUTF8() );
//TODO: set path to proj lib
#ifdef wxGIS_USE_PROJ
#endif // wxGIS_USE_PROJ
#endif //__UNIX__
#ifndef CPL_RECODE_ICONV
//the gdal compiled without iconv support
//we should recode string by ourselthes
CPLSetConfigOption("SHAPE_ENCODING", CPL_ENC_ASCII);
CPLSetConfigOption("DXF_ENCODING", CPL_ENC_ASCII);
#endif //CPL_RECODE_ICONV
return true;
}
示例6: CPLSetConfigOption
QgsShapeFile::QgsShapeFile( QString name, QString encoding )
{
fileName = name;
features = 0;
QgsApplication::registerOgrDrivers();
QSettings settings;
CPLSetConfigOption( "SHAPE_ENCODING", settings.value( "/qgis/ignoreShapeEncoding", true ).toBool() ? "" : 0 );
ogrDataSource = OGROpen( TO8F( fileName ), false, NULL );
if ( ogrDataSource != NULL )
{
valid = true;
ogrLayer = OGR_DS_GetLayer( ogrDataSource, 0 );
features = OGR_L_GetFeatureCount( ogrLayer, true );
}
else
valid = false;
setDefaultTable();
// init the geometry types
geometries << "NULL" << "POINT" << "LINESTRING" << "POLYGON" << "MULTIPOINT"
<< "MULTILINESTRING" << "MULTIPOLYGON" << "GEOMETRYCOLLECTION";
codec = QTextCodec::codecForName( encoding.toLocal8Bit().constData() );
if ( !codec )
codec = QTextCodec::codecForLocale();
Q_ASSERT( codec );
}
示例7: msApplyMapConfigOptions
void msApplyMapConfigOptions( mapObj *map )
{
const char *key;
for( key = msFirstKeyFromHashTable( &(map->configoptions) );
key != NULL;
key = msNextKeyFromHashTable( &(map->configoptions), key ) )
{
const char *value = msLookupHashTable( &(map->configoptions), key );
if( strcasecmp(key,"PROJ_LIB") == 0 )
{
msSetPROJ_LIB( value, map->mappath );
}
else if( strcasecmp(key,"MS_ERRORFILE") == 0 )
{
msSetErrorFile( value, map->mappath );
}
else
{
#if defined(USE_GDAL) && GDAL_RELEASE_DATE > 20030601
CPLSetConfigOption( key, value );
#endif
}
}
}
示例8: GDALAllRegister
void SmallpatchSieveFilter::SieveFilter(const char* Src_path, const char* Dst_Path, int SizeThresthod, int Connectedness)
{
GDALAllRegister();
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8","NO");
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTIFF");
if (poDriver == NULL)
{
cout << "不能创建指定类型的文件:" << endl;
}
GDALDataset* poSrc = (GDALDataset*)GDALOpen(Src_path,GA_ReadOnly);
int NewBandXsize = poSrc->GetRasterXSize();
int NewBandYsize = poSrc->GetRasterYSize();
GDALDataType Type = poSrc->GetRasterBand(1)->GetRasterDataType();
GDALDataset* poDstDS = poDriver->Create(Dst_Path, NewBandXsize, NewBandYsize, 1, Type, NULL);
double GeoTrans[6] = { 0 };
poSrc->GetGeoTransform(GeoTrans);
poDstDS->SetGeoTransform(GeoTrans);
poDstDS->SetProjection(poSrc->GetProjectionRef());
GDALRasterBandH HImgBand = (GDALRasterBandH)poSrc->GetRasterBand(1);
GDALRasterBandH HPDstDSBand = (GDALRasterBandH)poDstDS->GetRasterBand(1);
GDALSetRasterColorTable(HPDstDSBand, GDALGetRasterColorTable(HImgBand));
GDALSieveFilter(HImgBand, NULL, HPDstDSBand, SizeThresthod, Connectedness, NULL, NULL, NULL);
GDALClose((GDALDatasetH)poDstDS);
};
示例9: CreateFile
void CreateFile(const char *srcfile,const char *dstfile)
{
GDALAllRegister();
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8","NO");
GDALDataset *pDataset=(GDALDataset *) GDALOpen( srcfile, GA_ReadOnly );
int bandNum=pDataset->GetRasterCount();
GDALRasterBand *pBand=pDataset->GetRasterBand(1);
GDALDataType dataType=pBand->GetRasterDataType();
GDALDriver *pDriver=GetGDALDriverManager()->GetDriverByName("GTiff");
GDALDataset *dstDataset=pDriver->Create(dstfile,800,800,bandNum,dataType,NULL);
GDALRasterBand *dstBand;
//写入光栅数据
ushort *buf= new ushort[800*800];
for (int i=1;i<=bandNum;i++)
{
pBand=pDataset->GetRasterBand(i);
pBand->RasterIO(GF_Read,3388,2204,800,800,buf,800,800,dataType,0,0);
dstBand=dstDataset->GetRasterBand(i);
dstBand->RasterIO(GF_Write,0,0,800,800,buf,800,800,dataType,0,0);
}
delete []buf;
GDALClose(pDataset);
GDALClose(dstDataset);
}
示例10: init_ogr
void init_ogr(const std::string& outfile) {
OGRRegisterAll();
const char* driver_name = "SQLite";
OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driver_name);
if (driver == NULL) {
std::cerr << driver_name << " driver not available.\n";
exit(1);
}
CPLSetConfigOption("OGR_SQLITE_SYNCHRONOUS", "FALSE");
const char* options[] = { "SPATIALITE=TRUE", NULL };
m_data_source = driver->CreateDataSource(outfile.c_str(), const_cast<char**>(options));
if (m_data_source == NULL) {
std::cerr << "Creation of output file failed.\n";
exit(1);
}
m_layer_point = init_layer("planet_osm_point", m_fields_nodes, wkbPoint);
m_layer_line = init_layer("planet_osm_line", m_fields_ways, wkbLineString);
m_layer_polygon = init_layer("planet_osm_polygon", m_fields_areas, wkbMultiPolygon);
stringv fields_roads;
fields_roads.push_back("railway");
fields_roads.push_back("highway");
fields_roads.push_back("boundary");
m_layer_roads = init_layer("planet_osm_roads", fields_roads, wkbLineString);
}
示例11: QgsDebugMsg
void QgsApplication::applyGdalSkippedDrivers()
{
mGdalSkipList.removeDuplicates();
QString myDriverList = mGdalSkipList.join( " " );
QgsDebugMsg( "Gdal Skipped driver list set to:" );
QgsDebugMsg( myDriverList );
CPLSetConfigOption( "GDAL_SKIP", myDriverList.toUtf8() );
GDALAllRegister(); //to update driver list and skip missing ones
}
示例12: set_conf_value
static char* set_conf_value(const char* key, const char* value)
{
const char* old_val_const;
char* old_val = NULL;
old_val_const = CPLGetConfigOption(key, NULL);
if( old_val_const != NULL )
old_val = strdup(old_val_const);
/* Prevent a directory listing to be done */
CPLSetConfigOption(key, value);
return old_val;
}
示例13: CPLSetConfigOption
//辐射校正处理=====================================================================================================================================================================================
//绝对辐射校正
long QPDLevel1Process::Level1Proc_RadiationAbsolute(const char* pathImg, const char* pathImgRad, const char* pathAbsRegFile)
{
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO"); //中文路径
GDALAllRegister();
long lError = 0;
unsigned short *imgBuffer = NULL; //影像数据
float* parametersA = NULL, *parametersB = NULL, *parametersAux = NULL;//校正系数
GDALDatasetH m_dataset = GDALOpen(pathImg, GA_ReadOnly);
int xsize = GDALGetRasterXSize(m_dataset);
int ysize = GDALGetRasterYSize(m_dataset);
int bands = GDALGetRasterCount(m_dataset);
char **papszOptions = NULL;
papszOptions = CSLSetNameValue(papszOptions, "INTERLEAVE", "BAND");
GDALDatasetH m_datasetdst = GDALCreate(GDALGetDriverByName("GTiff"), pathImgRad, xsize, ysize, bands, GDT_UInt16, papszOptions);
//int nSamples, nLines, nLevels;
//LevelProc_GetParameterInfo(pathImgRad, nSamples, nLines, nLevels);
try
{
parametersA = new float[bands];
parametersB = new float[bands];
imgBuffer = new unsigned short[xsize*ysize];
}
catch (bad_alloc)
{
printf("allocate memory error\n");
exit(-1);
}
Level1Proc_AbsoluteParameters(pathAbsRegFile, parametersA, parametersB);
for (int i = 0; i < bands; i++)
{
GDALRasterIO(GDALGetRasterBand(m_dataset, i + 1), GF_Read, 0, 0, xsize, ysize, imgBuffer, xsize, ysize, GDT_UInt16, 0, 0);
for (int j = 0; j < ysize; j++)
{
for (int k = 0; k < xsize; k++)
{
//扩大100倍精度为0.01
imgBuffer[k] = (unsigned short)((imgBuffer[j*xsize + k] * parametersA[i] + parametersB[i]) * 100);
}
}
GDALRasterIO(GDALGetRasterBand(m_datasetdst, i + 1), GF_Write, 0, 0, xsize, ysize, imgBuffer, xsize, ysize, GDT_UInt16, 0, 0);
}
delete[]parametersA; parametersA = NULL;
delete[]parametersB; parametersB = NULL;
delete[]imgBuffer; imgBuffer = NULL;
GDALClose(m_dataset);
GDALClose(m_datasetdst);
return lError;
}
示例14: GetConfig
bool wxGISApplicationBase::CreateApp(void)
{
wxGISAppConfig oConfig = GetConfig();
if(!oConfig.IsOk())
return false;
//load GDAL defaults
wxString sGDALCacheMax = oConfig.Read(enumGISHKCU, wxString(wxT("wxGISCommon/GDAL/cachemax")), wxString(wxT("128")));
CPLSetConfigOption("GTIFF_REPORT_COMPD_CS", "YES");
CPLSetConfigOption("GTIFF_ESRI_CITATION", "YES");
CPLSetConfigOption("GDAL_CACHEMAX", sGDALCacheMax.mb_str());
CPLSetConfigOption("LIBKML_USE_DOC.KML", "no");
CPLSetConfigOption("GDAL_USE_SOURCE_OVERVIEWS", "ON");
CPLSetConfigOption("OSR_USE_CT_GRAMMAR", "FALSE");
//GDAL_MAX_DATASET_POOL_SIZE
//OGR_ARC_STEPSIZE
//load commands
wxXmlNode* pCommandsNode = oConfig.GetConfigNode(enumGISHKCU, GetAppName() + wxString(wxT("/commands")));
if(pCommandsNode)
LoadCommands(pCommandsNode);
return true;
}
示例15: CPLSetConfigOption
ERMsg COGRBaseOption::ParseOption(int argc, char* argv[])
{
ERMsg msg;
// 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 (int i = 1; i < argc; i++)
{
if (IsEqual(argv[i], "--config") && i + 2 < argc && IsEqual(argv[i + 1], "GDAL_SKIP"))
{
CPLSetConfigOption(argv[i + 1], argv[i + 2]);
i += 2;
}
}
// --------------------------------------------------------------------
// Register standard GDAL drivers, and process generic GDAL
// command options.
// --------------------------------------------------------------------
OGRRegisterAll();
argc = OGRGeneralCmdLineProcessor(argc, &argv, 0);
if (argc < 1)
exit(-argc);
// --------------------------------------------------------------------
// Parse arguments.
// --------------------------------------------------------------------
for (int i = 1; i < argc; i++)
{
msg += ProcessOption(i, argc, argv);
}
if (m_bVersion)
{
string error = Format("%s was compiled against GDAL %s and is running against GDAL %s\n",
argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));
msg.ajoute(error);
//return msg;
}
if (m_bNeedHelp)
{
msg.ajoute(GetUsage());
msg.ajoute(GetHelp());
//return msg;
}
return msg;
}