- Main Page
- Classes
- Files
- Related Pages

# RFC 9: ATL Based COM Interface

Author: Ivan Lucena
Contact: ivan@ilucena.net
Status: Proposed

## Summary

It is proposed to include a COM Interface to GDAL by adding a source tree containing the Microsoft Visual Studio solution and its related projects and C++ code.

The goal is to provide a GDAL interface for programming languages that support Component Object Model (COM).

Sub-folders with examples of use, test suit and documentation will be included under the same source tree.

## Details

1. The solution is based on Active Template Library and implements Dynamic-link library (in-process COM server).

2. The building process of the GDAL-COM Dll is independent from the GDAL standard Dll, not imposing any changes to “nmake.opt”.

3. The programming interface will be as close as possible to the original GDAL C++ API keeping method and parameter names, enumerators and structures, so that the documentation will refer to the original.

4. Lucena will be responsible for support and implementation.

5. Examples and test application will be provided in a few different programming languages.

## Notes

The GDAL-COM Interface exposes GDAL to every programming or scripting environment that support COM and because the .Net Framework can interface unmanaged COM libraries, the GDAL-COM Interface is also accessible through .NET programming environment.

## Usage

The following pieces of code exemplify the use of GDAL-COM Interface:

## Delphi

    Uses GDALLib_TLB;
    Var
      Dataset : IDataset;
      Projection : string;
    Begin
      Dataset := CoDataset.Create();
      try
        Dataset.Open('Ikonos1.tif', atReadOnly);
        (* Test Get/Set Projection string *)
        Projection := Dataset.GetProjectionRef();
        Dataset.SetProjection(lProjection);
      finally
        Dataset := nil;
      end;
    End;

## CSharp

    using GDALLib;
    {
      IDataset pDataset;
      IRasterBand pRasterBand;
      pDataset = new DatasetClass();
      pDataset.Open(”Ikonos1.tif”, atReadOnly);
      pRasterBand = pDataset.GetRasterBand(1);
      pDataset = null;
    }

## PythonWin

    From GDALLib import *
    pDataset = Dataset()
    pDataset.Open(”Ikonos1.tif”, constants.atReadOnly)
    pRasterband = pDataset.GetRasterBand(1)
    pRataset = None

Notes: The interface was generated automatically by “makepy.py” and it does not provide sufficient support to pointers and arrays in function arguments.

## VB.NET

    Imports GDALLib
    Private Sub
      Dim pDataset As IDataset
      Dim pRasterBand As IRasterBand
      pDataset = New Dataset()
      pDataset.Open('Ikonos1.tif', AccessTypeEnum.atReadOnly)
      pRasterBand = pDataset.GetRasterBand(1)
      pRasterBand = Nothing
    End Sub

Generated for GDAL by 1.5.1.