Opened 8 years ago

Closed 8 years ago

#3022 closed defect (fixed)

bad reading of AAIGRID dataset whose last line doesn't have a linebreak character

Reported by: onnovl Owned by: Even Rouault
Priority: normal Milestone: 1.6.2
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description

class file: aaigriddataset.cpp in frmts\aaigrid

Attachments (2)

test.asc (194 bytes) - added by onnovl 8 years ago.
gdal_problem.zip (5.2 KB) - added by onnovl 8 years ago.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by onnovl

Attachment: test.asc added

comment:1 Changed 8 years ago by Even Rouault

What is the error you get ? which GDAL version are you using ? It works just fine for me with GDAL 1.6.1

$ gdalinfo -checksum test.asc

Driver: AAIGrid/Arc/Info ASCII Grid
Files: test.asc
Size is 4, 6
Coordinate System is `'
Origin = (0.000000000000000,300.000000000000000)
Pixel Size = (50.000000000000000,-50.000000000000000)
Corner Coordinates:
Upper Left  (       0.000,     300.000) 
Lower Left  (   0.0000000,   0.0000000) 
Upper Right (     200.000,     300.000) 
Lower Right (     200.000,       0.000) 
Center      (     100.000,     150.000) 
Band 1 Block=4x1 Type=Int32, ColorInterp=Undefined
  Checksum=210
  NoData Value=-9999

comment:2 Changed 8 years ago by onnovl

Wow! That's quick, thanks!

I am using gdal version 1.6.1.1

I downloaded it from http://download.osgeo.org/gdal/gdal161.zip

================================================ I have build the libraries using the following commandline arguments call "c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\VCVARS32.BAT" nmake /f makefile.vc MSVC_VER=1500 cd swig nmake /f makefile.vc csharp MSVC_VER=1500 ================================================

I included the nmake.opt file (zipped) as well as the asc file.

If you can point me to a set of binaries that work with this asc file it would be great (I tried all day to fix the c++ file but I have not enough knowledge of c++ to change the source)

Kind regards Onno van Logchem

Changed 8 years ago by onnovl

Attachment: gdal_problem.zip added

comment:3 Changed 8 years ago by onnovl

Owner: changed from warmerdam to Even Rouault

when i call gdalinfo -mm test.asc i get the following result

c:\gdal\apps>gdalinfo -mm test.asc Driver: AAIGrid/Arc/Info ASCII Grid Files: test.asc Size is 4, 6 Coordinate System is `' Origin = (0.000000000000000,300.000000000000000) Pixel Size = (50.000000000000000,-50.000000000000000) Corner Coordinates: Upper Left ( 0.000, 300.000) Lower Left ( 0.0000000, 0.0000000) Upper Right ( 200.000, 300.000) Lower Right ( 200.000, 0.000) Center ( 100.000, 150.000) Band 1 Block=4x1 Type=Int32, ColorInterp?=Undefined

Computed Min/Max?=-999913.000,100.000

NoData? Value=-9999

it seems that the call VSIFReadL( achReadBuf, 1, sizeof(achReadBuf), fp ) in Getc of aaigriddataset starts to read at the beginning of the line when it does not find a linebreak

comment:4 Changed 8 years ago by Even Rouault

Milestone: 1.6.2
Priority: highnormal
Resolution: fixed
Status: newclosed
Summary: aaigriddataset.cpp: error reading asc file without lbad reading of AAIGRID dataset whose last line doesn't have a linebreak character

As no error message was issued by GDAL and your first comment didn't really describe the error, I missed the issue : the last value of the file isn't read correctly.

The error comes from the fact that the last line doesn't have a linebreak character. I've fixed the code to make it more tolerant in that case, in trunk (r17209) and in branches/1.6 (r17210). However I'm not sure that such file is considered as a valid AAIGRID dataset. Anyway, the workaround is trivial : just add a linebreak at the last line.

Note: See TracTickets for help on using tickets.