Search code examples
mfcgdal

where should we use GDALAllRegister() when implementing a class


I'm implementing a class named FilesWorkFlow. It's task is to open a file dialog and then if the file's extention is geotiff, some other member functions will be implemented to work with it. As you know before working with GDAL files , you have to call GDALAllRegister() so I need to call this function somewhere in the class that all of the member functions will suppose GDAL drivers as registered. Where should I call it?


Solution

  • The documentation for GDALAllRegister states:

    This function should generally be called once at the beginning of the application.

    Given that requirement I assume there's nothing wrong with calling it from your CWinApp::InitInstance override.

    As an alternative you can encapsulate the GDAL functionality into a Singleton and use Lazy Initialization.