I am trying to create isolines using Delphi and GDAL18. For that I am using the following code:
layer:= OGRCreateLayer( ogr_ds, PAnsiChar(WideStringToString('contour')), nil, ogr.wkbLineString, nil);
err:= GDALContourGenerate(band, 1, 0, 0, aFixedLevel, 0, 0, layer, 0, 1, nil, nil);
The GDALContourGenerate command returns an “Unnsupported Geometry Type” – error.
I included the gdal18.dll the following way:
function GDALContourGenerate(srcBand: TGDALRasterBandH; contourInterval: double;
contourBase: double; fixedLevelCount: longint; fixedLevel: TDoubleArray2;
useNoData: longint; noDataValue: double;
layer: TOGRLayerH; idField: longint; elevField: longint;
pfnProgress: TGDALProgressFunc; pProgressArg : POINTER): TOGRErr; external External_Lib name 'GDALContourGenerate';
I’ve also tried other geometry types (e.g. wkbLineString25D) but this did not help.
I would be glad if you’ld have any suggestions.
Thnaks a lot,
Mario
[edit]I found out that the same error occurs when I replaye “layer” (in GDALContourGenerate) with “nil”. So maybe the problem is somewhere else.[/edit]
You should probably add
cdeclafter the external declarations, as such (the name matches the function declaration in Delphi, so it can be ignored):Or the
stdcallword depending how the dll was compiled.And for the string parameters, since gdal uses
*charparameters AFAIK in its C flat API, you can use aPAnsiChardirectly, as such:Before Delphi 2009, you can use
pointer(aString)for such parameters, and since Delphi 2009, just apointer(AnsiString(aString))to typecast aaString: stringvalue.How did you convert the .h header?