GDAL and OGR latest -> compilation changes

Topics: SharpMap v0.9 / v1.x
Sep 23, 2007 at 12:25 PM
Hello all,

I am trying to compile the sharpmap extenstions to the latest GDAL-OGR.

There are some changes:

- Namespace GDAL is replaced by OSGeo.GDAL
- GDAL.gdal is replaced by GDAL.Gdal
- OGR.ogr is replaced by OGR.Ogr (be carefull for namespace conflicts with the Ogr namespace from the extensions itself!)
Integer values have been replaced by enum.

I am stuck with the following piece of code in GdalRasterLayer.cs;

if (band.GetRasterColorInterpretation() == 5) ch = 0;
if (band.GetRasterColorInterpretation() == 4) ch = 1;
if (band.GetRasterColorInterpretation() == 3) ch = 2;
if (band.GetRasterColorInterpretation() != 2)

I will probably not be using this function, for now I replaced it with:

if (band.GetRasterColorInterpretation() == OSGeo.GDAL.ColorInterp.GCI_RedBand) ch = 0;
if (band.GetRasterColorInterpretation() == OSGeo.GDAL.ColorInterp.GCI_GreenBand) ch = 1;
if (band.GetRasterColorInterpretation() == OSGeo.GDAL.ColorInterp.GCI_BlueBand) ch = 2;
if (band.GetRasterColorInterpretation() != OSGeo.GDAL.ColorInterp.GCI_AlphaBand)

But I would like to know what the real values need to be, can anybody tell me that?

The options available in the ColorInterp enum are:
GCI_AlphaBand
GCI_BlackBand
GCI_BlueBand
GCI_CyanBand
GCI_GrayIndex
GCI_GreenBand
GCI_HueBand
GCI_LightnessBand
GCI_MagentaBand
GCI_Max
GCI_PalletIndex
GCI_RedBand
GCI_SaturationBand
GCI_Undefined
GCIYCbCrCbBand
GCIYCbCrCrBand
GCIYCbCrYBand
GCI_YellowBand
Sep 23, 2007 at 12:39 PM
In OGRProvider.cs

change

case OSGeo.OGR.FieldType.OFTInteger:
fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.Int32"));
break;
case OSGeo.OGR.FieldType.OFTReal:
fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.Double"));
break;
case OSGeo.OGR.FieldType.OFTString:
fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.String"));
break;
case OSGeo.OGR.FieldType.OFTWideString:
fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.String"));
break;
Coordinator
Sep 23, 2007 at 10:33 PM
Thanks for the info!