Opened 11 years ago
Closed 11 years ago
#4956 closed defect (fixed)
ENVI header file is written incompletely if geotransform not set.
Reported by: | robintw | Owned by: | Even Rouault |
---|---|---|---|
Priority: | normal | Milestone: | 1.10.0 |
Component: | GDAL_Raster | Version: | svn-trunk |
Severity: | normal | Keywords: | gdal envi raster |
Cc: |
Description
It seems that there is a bug in the code that writes the ENVI header file which means that the header file isn't written out completely if a geotransform is not set.
The attached file demonstrates this by creating two ENVI-format files that are exactly the same. They both have a single 10 x 10 band, and both have a description (set using SetDescription). However, one of them has a simple (nonsense) geotransform and the other doesn't.
Looking at the output header files:
test_nogeotrans.hdr:
ENVI samples = 10 lines = 10 bands = 1 header offset = 0 file type = ENVI Standard data type = 1 interleave = bsq byte order = 0
test_withgeotrans.hdr
ENVI description = { Description here!} samples = 10 lines = 10 bands = 1 header offset = 0 file type = ENVI Standard data type = 1 interleave = bsq byte order = 0 map info = {Unknown, 1, 1, 1, 4, 2, 6, 0, North} band names = { Band 1}
The only difference between these should be that test_withgeotrans.hdr has the map info line in it. However, it seems that when there is no geotransform set, the 'description' and 'band names' lines are not written out properly.
The relevant code seems to be void ENVIDataset::FlushCache() starting at line 333 of envidataset.cpp. However, I can't see where this bug is in the code - it seems like the description should be written out near the top of that function, and the bits around it get written out fine, but not the description (unless there is a geotransform, in which case it works properly). The other area that may be causing problems is the if statements around line 453 as this deals with writing the geotransform, and if there is no geotransform then nothing under this seems to be written out.
I would try and submit a patch to fix this, but my C++ isn't really up to it, and I can't quite see where the bug is.
Attachments (1)
Change History (3)
by , 11 years ago
Attachment: | gdal_envi_issue.py added |
---|
comment:1 by , 11 years ago
Owner: | changed from | to
---|
The issue is with the bHeaderDirty mechanism. It isn't set at some places where it should be. We should override the SetDescription() method to set it for example, and likely other ones.
comment:2 by , 11 years ago
Milestone: | → 1.10.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Python code to demonstrate issue with ENVI header files