OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.93k stars 2.57k forks source link

GDALCreateOverviewDataset missing since gdal-2.2 #413

Closed vaclavblazek closed 6 years ago

vaclavblazek commented 6 years ago

We're using warping in GDAL (via GDALWarpOperation) extensively in our vts-mapproxy server. Since this operation doesn't natively support overviews which are crucial for our server we had to write code similar to gdalwarp utility to choose and use proper overview. Sometimes, we also have to force coarser overview when memory requirements would be too high (this happens when warping near date line or poles where GDAL has problems with wrapped dataset).

It was kinda easy in gdal-2.1 because function GDALCreateOverviewDataset was exported from gdal.so. With the advent of new LTS Ubuntu (Bionic Beaver, 18.04) the gdal-2.2 will become the default gdal version. Unfortunately, this version doesn't export GDALCreateOverviewDataset function. The function was un-exported from the dynamic library in this particular commit gdal_priv.h:1576.

I've been looking around and the function is indirectly available through GDALWarp utility function. that encapsulates whole warp functionality. So far so good. However, this function expects its options from argv-style cmdline options, which means that our program whould have to serialize options into string only to let GDALWarp to decode them instead of simply filling them into the GDALWarpOptions struct.

There's a possibility to pass OVERVIEW_LEVEL option to the GDALOpenEx call. However, at the time of warp operation we have got an already open dataset. Re-opening of the dataset counts on the knowledge of the original dataset path and opens a full-fledged dataset.

Would it be too much to ask you to make GDALCreateOverviewDataset function available in the installed library again? What is the intended programatic use of overview functionality?

rouault commented 6 years ago

GDALCreateOverviewDataset was documented as / CPL_DLL exported, but only for gdalwarp / in a header called gdal_priv.h, and as gdalwarp is now part of libgdal the export was no longer needed. I'd suggest you go to the road of using the GDALWarp() utility function indeed

Another solution is to import gcore/gdaloverviewdataset.cpp in your own code (making sure to rename the class to avoid symbol name clashes)

vaclavblazek commented 6 years ago

I grabbed and integrated the code from gdaloverviewdata.cpp in our code base. Actually, I had been thinking about this option already when I posted this issue. GDALWarp() is way too heavyweight when you have everything at hand and tailored to use low-level API.