[Gdal-dev] gdal_translate segfaults at tiff->envi
Frank Warmerdam
warmerdam at pobox.com
Thu Jun 5 11:09:48 EDT 2003
Vincent Schut wrote:
> Replying my own post...
>
> The problem appeared to be that my tiff files were *not* geotiff files, and
> thus contained no projection info. This resulting in an empty pszProjName and
> thus a segfaulting strstr(pszProjName, "UTM") (line 363 in envidataset.cpp).
> If we want gdal_translate to export projection-less envi files, I suggest
> changing line 363 in something like:
> if ( ( pszProjName != NULL ) && ( strstr( pszProjName, "UTM" ) ) )
> which resolved the problem.
>
> If we don't want it to write envi files without proj info, I suppose it should
> generate an error message and quit. Maybe a 'bin' or 'raw' output format
> could be added then to have envi-like (simple binary) files?
Vincent,
Thanks for tracking this down.
Andrey, could you look into a robust solution to this?
I see in the code you do this to check the projection name to see
if it contains UTM. This is not a robust way of determining if a projection
is UTM. Instead just call oSRS.GetUTMZone() and check that the result is
non-zero. If so, then the coordinate system is UTM otherwise not.
if ( strstr( pszProjName, "UTM" ) )
{
iUTMZone = oSRS.GetUTMZone( &bNorth );
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 Gdal-dev
mailing list