[Gdal-dev] Using GDAL in Linux ANSI C

Brian S. Dixon bdixon at asf.alaska.edu
Mon Sep 25 14:18:21 EDT 2006


Hi Frank,

  Our s/w is ANSI C, compiled with gcc ...Like I mentioned before, GDAL is
all new to me so I have some basic questions.  It looks like GDAL is written
in C++ ...I've never tried to utilize C++ libraries from a C program before
(usually the other way around).  Is this possible?  Porting our code to C++
is a much larger project...

Thanks,

Brian

-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: Friday, September 22, 2006 2:03 PM
To: Brian S. Dixon
Subject: Re: GeoTIFF v. ERDAS/ARCGIS .aux files

Brian S. Dixon wrote:
> Very good news!  So, the scenario that I'm imagining then is to consider
> using gdal, or part of the gdal code, to read the ERDAS tif/aux
> TIFF/GeoTIFF/GeoKey information into some internal data structure that
> you've already produced, then use our code to convert this info (and the
tif
> image) to our internal image file format (the combination of an image
file,
> .img, and a meta data file, .meta.)  Since we want to keep the conversion
> process fairly simple for our users, we'll likely read a GeoTIFF file and
if
> it has missing information then automatically look for an aux file and use
> it ...only asserting if we fail after that step.  I'd probably take this
> approach rather than have users figure it out and have to execute
> intermediate steps in order to make the conversion work, e.g. somehow
> produce a 'complete' GeoTIFF file first.
> 
> Since I'm fairly new to the Alaska Satellite Facility and GIS type stuff
in
> general, GDAL is new to me.  I'll go take a look at the gdal_translate
> utility and see if I can dig into the code a bit...

Brian,

OK, sounds good.

By the way, the logic in GDAL where it decides to go looking for an .aux
file
if projection info is missing in a TIFF file is in the
GTiffDataset::GetProjectionRef() method in gdal/frmts/gtiff/geotiff.cpp.

It looks like this:

char *GTiffDataset::GetProjectionRef()

{
     if( nGCPCount == 0 )
     {
         if( EQUAL(pszProjection,"") )
             return GDALPamDataset::GetProjectionRef();
         else
             return( pszProjection );
     }
     else
         return "";
}

The GDALPamDataset::GetProjectionRef() will look for an .aux file.
So, you might want to short-circuit this code somehow.  Perhaps altering
it to try the GDALPamDataset::GetProjectionRef(), and then only using
the local pszProjection if the pam method returns an empty string. That
would essentially mean that the .aux code would take precidence over
the geotiff info.

Good luck,
-- 
---------------------------------------+------------------------------------
--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org





More information about the Gdal-dev mailing list