[FWTools] Problem with the GetGCPCount of GDAL wrongly returning 0for a JPG file

Frank Warmerdam warmerdam at pobox.com
Thu Nov 20 11:19:21 EST 2008

Mikael Rittri wrote:
> Thanks for the info, Frank. That explains why gdalinfo succeeds. 
> But I still don't see why our usage of GDAL in Carmenta Engine fails 
> in this case.  
> I think there is no code to read TAB-files in the frmts\jpeg folder, 


That is incorrect.  The JPGDataset::Open() method includes this code
segment responsible for reading .tab files.

     if( !poDS->bGeoTransformValid )
         int bTabFileOK =
             GDALReadTabFile( poOpenInfo->pszFilename, poDS->adfGeoTransform,
                              &poDS->nGCPCount, &poDS->pasGCPList );

         if( bTabFileOK && poDS->nGCPCount == 0 )
             poDS->bGeoTransformValid = TRUE;

> so I guess that this is handled by the parent class, GDALPamDataset 
> in the gcore folder.  This class seems to store the TAB-file information
> in a file with the extension JPG.aux.xml, but no such file is created
> when I try to read my JPG-file from Carmenta Engine.  
> When GDALPamDataset::GetGPCCount() is called, the struct psPam contains
>   pszPamFilename	  "C:/temp/case40894/MAL5C5MB.JPG.aux.xml" 
>   pszProjection	  <Bad Ptr>	
>   bHaveGeoTransform	  0
>   adfGeoTransform	  <unitialized values>
>   nGCPCount		  0x00000000
>   pasGCPList		  0x00000000
>   ... 
> So I guess the GDALPamDataset has failed to create the file *.JPG.aux.xml.

Are you talking about after doing a CreateCopy() to JPEG format from
another jpeg file?  Normally .aux.xml files are only written when
there is information that cannot be written in a given format.  But
it should only be written for files being written out - not just when
reading an existing file.

Returning to the core of the problem - is it that gdalinfo reports the
GCPs from the tab file, but the Carmenta engine is not finding the gCPs
when calling GetGCPCount()?

If this is the problem you see, then I'd suggest tracing through the
part of the Open() call that should call GDALReadTabFile().  Perhaps it
isn't getting called for some reason, or perhaps reading of the tab file
is failing because of a different format for the base file path (one with
a full path and one without a path for instance).

Best regards,
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    | Geospatial Programmer for Rent

More information about the FWTools mailing list