wiki:rfc59_utilities_as_a_library

Version 10 (modified by faza, 9 years ago) ( diff )

--

RFC 59 : GDAL/OGR utilities as a library

Authors: Faza Mahamood

Contact: fazamhd at gmail dot com

Status: Development

Implementation version: 2.1

Summary

This RFC defines new function for each GDAL utility. The new utility functions can be used to work on in-memory datasets. The utility code is modified to call the new function. This RFC gives a general frame and principles, demonstrated with gdalinfo, but aimed at being extended with other utilities.

Rationale

There is need for calling GDAL utilities from the code. But this involves using system calls and cannot work on in-memory datasets.

Changes

New library libgdalutils is created. Both Unix and Windows build have been modified to take into account the new lib. The GDAL utilities are modified to use the new functions. New header file gdal_utils.h is created which contains the public declarations of GDAL utilities. The current header(still in progress) can be found here.

    char CPL_DLL *GDALInfo( GDALDatasetH hDataset, GDALInfoOptions *psOptions );

    GDALInfoOptions CPL_DLL *GDALInfoOptionsNew( void );

    void CPL_DLL GDALInfoOptionsAddExtraMDDomains( GDALInfoOptions *psOptions,
                                                   const char *pszDomain );

    void CPL_DLL GDALInfoOptionsSetExtraMDDomains( GDALInfoOptions *psOptions,
                                                   char **papszExtraMDDomains );

    void CPL_DLL GDALInfoOptionsFree( GDALInfoOptions *psOptions );

SWIG bindings (Python / Java / C# / Perl) changes

For Python bindings only, new function Info() is added in the gdal module which uses the new GDALInfo() function.

It can be used either with setting the attributes of gdal.InfoOptions() or inlined arguments of gdal.Info().

    options = gdal.InfoOptions()
    
    options.format = gdal.INFO_FORMAT_TEXT
    options.deserialize = True
    options.computeMinMax = False
    options.reportHistograms = False
    options.reportProj4 = True
    options.stats = False
    options.approxStats = True
    options.sample = False
    options.computeChecksum = False
    options.showGCPs = True
    options.showMetadata = True
    options.showRAT = False
    options.showColorTable = True
    options.listMDD = False
    options.showFileList = True
    options.allMetadata = TRUE
    options.extraMDDomains = ['TRE']
    
    gdal.Info(ds, options, deserialize = True)

    gdal.Info(ds, format = _gdal.INFO_FORMAT_TEXT, deserialize = True,
              computeMinMax = False, reportHistograms = False, reportProj4 = False,
              stats = False, approxStats = True, sample = False, computeChecksum = False,
              showGCPs = True, showMetadata = True, showRAT = True, showColorTable = True,
              listMDD = False, showFileList = True, allMetadata = False,
              extraMDDomains = None)
    

Utilities

Utilities are modified to call the respective function.

Documentation

All new methods/functions are documented.

Test Suite

GDALInfo method is tested in test_gdalinfo_lib.py

Compatibility Issues

None expected. Command line utilities will keep the same interface. It will be checked by ensuring their tests in autotest/utilities still pass.

Related ticket

Implementation

Implementation will be done by Faza Mahamood.

The proposed implementation lies in the "gdalinfo" branch of the https://github.com/fazam/gdal/tree/gdalinfo.

The list of changes : https://github.com/fazam/gdal/compare/gdalinfo

Voting history

Note: See TracWiki for help on using the wiki.