From: Bborie Park Date: Fri, 3 Aug 2012 00:19:20 +0000 (+0000) Subject: Added rt_util_gdal_register_all() to prevent multiple calls to X-Git-Tag: 2.1.0beta2~717 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2aced9fb9f49244cf3baa200e636e5f37d01b621;p=postgis Added rt_util_gdal_register_all() to prevent multiple calls to GDALAllRegister() git-svn-id: http://svn.osgeo.org/postgis/trunk@10155 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index 183cc27d9..b350fad06 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -374,6 +374,20 @@ int rt_util_gdal_configured(void) { return 1; } +/* + register all GDAL drivers +*/ +void +rt_util_gdal_register_all(void) { + static int registered = 0; + + if (registered) + return; + + GDALAllRegister(); + registered = 1; +} + /* is the driver registered? */ @@ -1554,7 +1568,7 @@ rt_band_load_offline_data(rt_band band) { return 1; } - GDALAllRegister(); + rt_util_gdal_register_all(); hdsSrc = GDALOpenShared(band->data.offline.path, GA_ReadOnly); if (hdsSrc == NULL) { rterror("rt_band_load_offline_data: Cannot open offline raster: %s", band->data.offline.path); @@ -8184,7 +8198,7 @@ rt_raster_to_gdal(rt_raster raster, const char *srs, assert(NULL != raster); /* any supported format is possible */ - GDALAllRegister(); + rt_util_gdal_register_all(); RASTER_DEBUG(3, "rt_raster_to_gdal: loaded all supported GDAL formats"); /* output format not specified */ @@ -8270,7 +8284,7 @@ rt_raster_gdal_drivers(uint32_t *drv_count, uint8_t cancc) { int i; uint32_t j; - GDALAllRegister(); + rt_util_gdal_register_all(); count = GDALGetDriverCount(); rtn = (rt_gdaldriver) rtalloc(count * sizeof(struct rt_gdaldriver_t)); if (NULL == rtn) { diff --git a/raster/rt_core/rt_api.h b/raster/rt_core/rt_api.h index 26e72a3f8..a1516556f 100644 --- a/raster/rt_core/rt_api.h +++ b/raster/rt_core/rt_api.h @@ -1824,6 +1824,12 @@ rt_util_gdal_supported_sr(const char *srs); int rt_util_gdal_configured(void); +/* + register all GDAL drivers +*/ +void +rt_util_gdal_register_all(void); + /* is the driver registered? */