mateusz at loskot.net
Thu Jan 25 06:40:36 EST 2007
Gennady Khokhorin wrote:
> I'm debuging ogr2ogr and have couple questions about program structure.
> 1. Should --config "GDAL_DATA" be applyed in ogr2ogr command? If so I dont see
> args handling --config in ogr2ogr.cpp. How this variable gets into the code?
> 2. What the story with OGR_DRIVER_PATH, GDAL_DRIVER_PATH
> in OGRSFDriverREgistrar::AutoLoadDrivers()?
> Should I set it up at run time?
Generally, AFAIK all these options in GDAL/OGR can be set as:
- environment variable
- from command line using common --config option
Options passed with --config override those currently set as environment
All the set/get magic is implemented in CPLGetConfigOption() and
CPLSetConfigOption(). The CPLSetConfigOption() sets options on GDAL's
stack - not as environment variables.
The CPLGetConfigOption() behaves a bit differently because it tries to
read an option from GDAL's private collection and if it fails,
it tries to find given option in environment variables.
In OGR utilities, the --config option is processed by
OGRGeneralCmdLineProcessor() function defined in ogr/ogrutils.cpp.
As you can see, it's called from ogrinfo.cpp and ogr2ogr.cpp utilities.
User can use it passing option key and value as follows:
ogrinfo --config CPL_DEBUG ON ~/data/test/point.shp
In this example, if I have CPL_DEBUG=OFF set in my environment, I can
easily override it, switching OGR debug messages printing on,
using --config option as presented above.
Hope it helps.
More information about the Gdal-dev