Feature request #1040
[PATCH] qgis crashes when I try to add RPF A.TOC file (also: RasterLite support)
Status: | Closed | ||
---|---|---|---|
Priority: | Low | ||
Assignee: | Jürgen Fischer | ||
Category: | Rasters | ||
Pull Request or Patch supplied: | Resolution: | fixed | |
Easy fix?: | No | Copied to github as #: | 11100 |
Description
When I try to add a raster layer and select RPF>A.TOC file the entire program closes out without any warning or anything. This occurs on both the windows version and Linux version that I am using. This map data is good. It was download striaght from NGA website on a secret network.
History
#1 Updated by Even Rouault over 16 years ago
This still exists with 0.10.0, and this is not specifically due to the RPF A.TOC format, but the crash can happy with any raster format that declare subdatasets (HDF4, HDF5, OGDI raster, netCDF, RS2 and ADRG drivers are also concerned by this). The main raster has no data itself, but declares a list of subdatasets that can be opened by GDALOpen.
Here's the stack trace of the crash
Program received signal SIGABRT, Aborted. [Switching to Thread -1280899392 (LWP 14925)] 0xffffe410 in +kernel_vsyscall () (gdb) bt #0 0xffffe410 in +kernel_vsyscall () #3905 0xb59fc875 in raise () from /lib/tls/i686/cmov/libc.so.6 #3906 0xb59fe201 in abort () from /lib/tls/i686/cmov/libc.so.6 #3907 0xb62f462a in CPLErrorV (eErrClass=CE_Fatal, err_no=10, fmt=0xb69b7f44 "Pointer '%s' is NULL in '%s'.\ ", args=0xbfdd213c "<\\177\\233�\\205\\201\\233�4\\236\\"�����") at cpl_error.cpp:233 #3908 0xb62f46c4 in CPLError (eErrClass=CE_Fatal, err_no=10, fmt=0xb69b7f44 "Pointer '%s' is NULL in '%s'.\ ") at cpl_error.cpp:133 #3909 0xb62cff8d in GDALGetOverviewCount (hBand=0x0) at gdalrasterband.cpp:1855 #3910 0xb7165862 in [[QgsRasterLayer]]::readFile () from /usr/lib/libqgis_core.so.0.10 #3911 0xb716b572 in [[QgsRasterLayer]]::QgsRasterLayer () from /usr/lib/libqgis_core.so.0.10 #3912 0x080fccc6 in [[QgisApp]]::addRasterLayer () #3913 0x08104abf in [[QgisApp]]::openLayer () #10 0x080f9f5f in main ()
In fact, this is due to the following code snipet that makes the assumption that the return of GDALGetRasterBand(hDS, 1) will be non-NULL.
//check f this file has pyramids GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band if( GDALGetOverviewCount(myGDALBand) > 0 ) { hasPyramidsFlag=true; } else { hasPyramidsFlag=false; }
The quickest fix is to apply the attached patch. In a longer term, it may be good to support subdatasets, by displaying the list of subdatasets to the user, as OpenEV does.
#2 Updated by Even Rouault over 16 years ago
Frank,
I add you in CC as I don't know who to assign this. You might probably know better than me.
#3 Updated by Frank Warmerdam - over 16 years ago
I have incorporated a variation on this patch in trunk (r...) that also treats files without bands as invalid in the isValidRasterFileName().
Currently isValidRasterFileName() does not provide any mechanism to report an error to the user, so the user just sees "is not a supported dataset". I would also like to change this, but I will address this as a followup patch. Even is also quite right that some sort of subdataset selection dialog would be very desirable for datasets like this with subdatasets.
#4 Updated by Frank Warmerdam - over 16 years ago
Sorry, the last change was adfe7b81 (SVN r8694).
#5 Updated by Frank Warmerdam - over 16 years ago
- Status changed from Open to Closed
- Resolution set to fixed
I have commited a change in trunk () that improves error propagation for raster layer open failures. In particular isValidRasterFileName() now returns an error message if the filename is a raster, but just not supported for some particular reason.
I'd still like to do something about subdataset support, but this seems more involved and I'm not sure what to do. So I'm closing this particular ticket. Feel free to open a new ticket specifically requesting subdataset support as an enhancement.
#6 Updated by Paolo Cavallini over 14 years ago
- Status changed from Closed to Feedback
- Resolution deleted (
fixed)
The same problem makes it impossible to open a RasterLite db with more than one raster layer, see:
https://trac.osgeo.org/gdal/ticket/3568
For instance, this: http://www.gaia-gis.it/planet_earth.sqlite fails: /home/paolo/Desktop/planet_earth.sqlite is not a supported raster data source This raster file has no bands and is invalid as a raster layer.
Gdal can read it:
$ gdalinfo /media/disk/planet_earth.sqlite Driver: Rasterlite/Rasterlite Files: Size is 512, 512 Coordinate System is @' Subdatasets: SUBDATASET_1_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=elevation SUBDATASET_1_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=elevation SUBDATASET_2_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=population SUBDATASET_2_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=population SUBDATASET_3_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_color SUBDATASET_3_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_color SUBDATASET_4_NAME=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_gray SUBDATASET_4_DESC=RASTERLITE:/media/disk/planet_earth.sqlite,table=shaded_gray Corner Coordinates: Upper Left ( 0.0, 0.0) Lower Left ( 0.0, 512.0) Upper Right ( 512.0, 0.0) Lower Right ( 512.0, 512.0) Center ( 256.0, 256.0) $ gdalinfo RASTERLITE:/media/disk/planet_earth.sqlite,table=elevation Driver: Rasterlite/Rasterlite Files: /media/disk/planet_earth.sqlite Size is 43200, 18000 Coordinate System is: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY[[EPSG""7030]], AUTHORITY[[EPSG""6326]], PRIMEM["Greenwich",0, AUTHORITY[[EPSG""8901]], UNIT["degree",0.01745329251994328, AUTHORITY[[EPSG""9122]], AUTHORITY[[EPSG""4326]] Origin = (-180.000000000000000,89.999999999999972) Pixel Size = (0.008333333333300,-0.008333333333300) Metadata: TILE_FORMAT=JPEG Image Structure Metadata: INTERLEAVE=PIXEL COMPRESSION=JPEG Corner Coordinates: Upper Left (-180.0000000, 90.0000000) (180d 0'0.00"W, 90d 0'0.00"N) Lower Left (-180.0000000, -60.0000000) (180d 0'0.00"W, 60d 0'0.00"S) Upper Right ( 180.0000000, 90.0000000) (180d 0'0.00"E, 90d 0'0.00"N) Lower Right ( 180.0000000, -60.0000000) (180d 0'0.00"E, 60d 0'0.00"S) Center ( -0.0000000, 15.0000000) ( 0d 0'0.00"W, 15d 0'0.00"N) Band 1 Block=400x500 Type=Byte, [[ColorInterp]]=Red Overviews: 21600x9000, 10800x4500, 5400x2250, 2700x1125, 1350x563, 675x281, 338x141 Band 2 Block=400x500 Type=Byte, [[ColorInterp]]=Green Overviews: 21600x9000, 10800x4500, 5400x2250, 2700x1125, 1350x563, 675x281, 338x141 Band 3 Block=400x500 Type=Byte, [[ColorInterp]]=Blue Overviews: 21600x9000, 10800x4500, 5400x2250, 2700x1125, 1350x563, 675x281, 338x141
So this is a QGIS limitation : it cannot handle images with subdatasets.
#7 Updated by Jürgen Fischer over 14 years ago
- Status changed from Feedback to Open
#8 Updated by Jürgen Fischer over 14 years ago
- Status changed from Open to In Progress
#9 Updated by Jürgen Fischer over 14 years ago
- Status changed from In Progress to Closed
- Resolution set to fixed
applied in d72cfb4b (SVN r14065).
#10 Updated by Etienne Tourigny almost 13 years ago
Sub-layer selection does not work any more...
The problem is that QgsGdalProvider::QgsGdalProvider() deletes the dataset here:
GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band
if ( myGDALBand == NULL )
{
And when qgisapp.cpp calls layer->subLayers() the dataset is invalid, which results in the following error:
ERROR 10: Pointer 'hObject' is NULL in 'GDALGetMetadata'.
My suggestion is to check if dataset is null in subLayers_() and add code like in isValidRasterFileName() (i.e. create a new dataset with GDALOpen())
Attaching an example file.
I would be happy to help out if I can - cannot re-open this bug though.
I can prepare a patch although I am busy these days.
Thanks
Debug output below (some superflous "TMP ET..." messages added) Debug: src/app/qgisapp.cpp: 6398: (addRasterLayer) TMP ET addRasterLayer Debug: src/gui/qgisgui.cpp: 38: (openFilesRememberingFilter) Opening file dialog with filters: [GDAL] All files (*);;[GDAL] Virtual Raster (*.vrt *.VRT);;[GDAL] GeoTIFF (*.tif *.tiff *.TIF *.TIFF);;[GDAL] National Imagery Transmission Format (*.ntf *.NTF);;[GDAL] Raster Product Format TOC format (*.toc *.TOC);;[GDAL] ECRG TOC format (*.xml *.XML);;[GDAL] Erdas Imagine Images (*.img *.IMG);;[GDAL] Ground-based SAR Applications Testbed File Format (*.gff *.GFF);;[GDAL] Arc/Info Binary Grid (hdr.adf HDR.ADF);;[GDAL] Arc/Info ASCII Grid (*.asc *.ASC);;[GDAL] SDTS Raster (*.ddf *.DDF);;[GDAL] DTED Elevation Raster (*.dt0 *.dt1 *.dt2 *.DT0 *.DT1 *.DT2);;[GDAL] Portable Network Graphics (*.png *.PNG);;[GDAL] JPEG JFIF (*.jpg *.jpeg *.JPG *.JPEG);;[GDAL] Japanese DEM (*.mem *.MEM);;[GDAL] Graphics Interchange Format (*.gif *.GIF);;[GDAL] Graphics Interchange Format (*.gif *.GIF);;[GDAL] Envisat Image Format (*.n1 *.N1);;[GDAL] X11 PixMap Format (*.xpm *.XPM);;[GDAL] MS Windows Device Independent Bitmap (*.bmp *.BMP);;[GDAL] PCIDSK Database File (*.pix *.PIX);;[GDAL] PCRaster Raster File (*.map *.MAP);;[GDAL] ILWIS Raster Map (*.mpr *.mpl *.MPR *.MPL);;[GDAL] SGI Image File Format 1.0 (*.rgb *.RGB);;[GDAL] SRTMHGT File Format (*.hgt *.HGT);;[GDAL] Leveller heightfield (*.ter *.TER);;[GDAL] Terragen heightfield (*.ter *.TER);;[GDAL] GMT NetCDF Grid Format (*.nc *.NC);;[GDAL] Network Common Data Format (*.nc *.NC);;[GDAL] JPEG-2000 part 1 (*.jp2 *.j2k *.JP2 *.J2K);;[GDAL] GRIdded Binary (*.grb *.GRB);;[GDAL] Raster Matrix Format (*.rsw *.RSW);;[GDAL] EUMETSAT Archive native (*.nat *.NAT);;[GDAL] Idrisi Raster A.1 (*.rst *.RST);;[GDAL] Golden Software ASCII Grid (*.grd *.GRD);;[GDAL] Golden Software Binary Grid (*.grd *.GRD);;[GDAL] Golden Software 7 Binary Grid (*.grd *.GRD);;[GDAL] DRDC COASP SAR Processor Raster (*.hdr *.HDR);;[GDAL] R Object Data Store (*.rda *.RDA);;[GDAL] Portable Pixmap Format (*.pnm *.PNM);;[GDAL] ESRI .hdr Labelled (*.bil *.BIL);;[GDAL] Vexcel MFF Raster (*.hdr *.HDR);;[GDAL] VTP .bt (Binary Terrain) 1.3 Format (*.bt *.BT);;[GDAL] FARSITE v.4 Landscape File (*.lcp *.LCP);;[GDAL] NOAA Vertical Datum .GTX (*.gtx *.GTX);;[GDAL] NTv2 Datum Grid Shift (*.gsb *.GSB);;[GDAL] ACE2 (*.ace2 *.ACE2);;[GDAL] Snow Data Assimilation System (*.hdr *.HDR);;[GDAL] Swedish Grid RIK (*.rik *.RIK);;[GDAL] USGS Optional ASCII DEM (*.dem *.DEM);;[GDAL] GeoSoft Grid Exchange Format (*.gxf *.GXF);;[GDAL] Hierarchical Data Format Release 5 (*.hdf5 *.HDF5);;[GDAL] Northwood Numeric Grid Format .grd/.tab (*.grd *.GRD);;[GDAL] Northwood Classified Grid Format .grc/.tab (*.grc *.GRC);;[GDAL] ARC Digitized Raster Graphics (*.gen *.GEN);;[GDAL] Standard Raster Product (*.img *.IMG);;[GDAL] Magellan topo (*.blx *.BLX);;[GDAL] Rasterlite (*.sqlite *.SQLITE);;[GDAL] SAGA GIS Binary Grid (*.sdat *.SDAT);;[GDAL] ASCII Gridded XYZ (*.xyz *.XYZ);;[GDAL] HF2/HFZ heightfield raster (*.hf2 *.HF2);;[GDAL] Arc/Info Export E00 GRID (*.e00 *.E00);;[GDAL] ZMap Plus Grid (*.dat *.DAT);;[GDAL] NOAA NGS Geoid Height Grids (*.bin *.BIN);;[GDAL] MBTiles (*.mbtiles *.MBTILES) Debug: src/gui/qgisgui.cpp: 78: (openFilesRememberingFilter) Writing last used dir: /data/research/work/gdal/gdal-netcdf/narrcap Debug: src/app/qgisapp.cpp: 6411: (addRasterLayer) TMP ET addRasterLayer opendfiles Debug: src/app/qgisapp.cpp: 6593: (addRasterLayers) TMP ET addRasterLayers Debug: src/app/qgisapp.cpp: 6624: (addRasterLayers) TMP ET addRasterLayers calling isValidRasterFileName() Debug: src/core/raster/qgsrasterlayer.cpp: 2135: (loadProviderLibrary) theProviderKey = gdal Debug: src/core/raster/qgsrasterlayer.cpp: 2139: (loadProviderLibrary) myLibPath = /home/softdev/lib/qgis/plugins/libgdalprovider.so Debug: src/core/raster/qgsrasterlayer.cpp: 2161: (loadProviderLibrary) Library name is /home/softdev/lib/qgis/plugins/libgdalprovider.so Debug: src/core/raster/qgsrasterlayer.cpp: 2169: (loadProviderLibrary) Loaded data provider library Debug: src/providers/gdal/qgsgdalprovider.cpp: 1801: (isValidRasterFileName) TMP ET isValidRasterFileName() Debug: src/providers/gdal/qgsgdalprovider.cpp: 1250: (subLayers_) sublayers: NETCDF:"/data/research/work/gdal/gdal-netcdf/narrcap/orog_CRCM.nc":lon NETCDF:"/data/research/work/gdal/gdal-netcdf/narrcap/orog_CRCM.nc":lat NETCDF:"/data/research/work/gdal/gdal-netcdf/narrcap/orog_CRCM.nc":orog Debug: src/app/qgisapp.cpp: 6636: (addRasterLayers) TMP ET addRasterLayers - creating layer Debug: src/core/qgsmaplayer.cpp: 53: (QgsMapLayer) lyrname is 'orog_CRCM' Debug: src/core/qgsmaplayer.cpp: 59: (QgsMapLayer) layerName is 'orog_CRCM' Debug: src/core/raster/qgsrasterlayer.cpp: 98: (QgsRasterLayer) Entered Debug: src/core/raster/qgsrastershader.cpp: 25: (QgsRasterShader) called. Debug: src/core/raster/qgsrastershaderfunction.cpp: 24: (QgsRasterShaderFunction) entered. Debug: src/core/qgsmaplayer.cpp: 104: (setLayerName) new name is 'orog_CRCM' Debug: src/core/raster/qgsrastershader.cpp: 25: (QgsRasterShader) called. Debug: src/core/raster/qgsrastershaderfunction.cpp: 24: (QgsRasterShaderFunction) entered. Debug: src/core/raster/qgsrasterlayer.cpp: 2176: (loadProvider) Entered Debug: src/core/raster/qgsrasterlayer.cpp: 2135: (loadProviderLibrary) theProviderKey = gdal Debug: src/core/raster/qgsrasterlayer.cpp: 2139: (loadProviderLibrary) myLibPath = /home/softdev/lib/qgis/plugins/libgdalprovider.so Debug: src/core/raster/qgsrasterlayer.cpp: 2161: (loadProviderLibrary) Library name is /home/softdev/lib/qgis/plugins/libgdalprovider.so Debug: src/core/raster/qgsrasterlayer.cpp: 2169: (loadProviderLibrary) Loaded data provider library Debug: src/core/raster/qgsrasterlayer.cpp: 2178: (loadProvider) Library loaded Debug: src/core/raster/qgsrasterlayer.cpp: 2185: (loadProvider) Attempting to resolve the classFactory function Debug: src/core/raster/qgsrasterlayer.cpp: 2193: (loadProvider) Getting pointer to a mDataProvider object from the library Debug: src/providers/gdal/qgsgdalprovider.cpp: 92: (QgsGdalProvider) QgsGdalProvider: constructing with uri '/data/research/work/gdal/gdal-netcdf/narrcap/orog_CRCM.nc'. Debug: src/providers/gdal/qgsgdalprovider.cpp: 118: (QgsGdalProvider) GdalDataset opened Debug: src/app/qgscustomization.cpp: 778: (customizeWidget) objectName = event type = 17 Debug: src/app/qgscustomization.cpp: 780: (customizeWidget) QMessageBox x QDialog Debug: src/core/raster/qgsrasterlayer.cpp: 2207: (loadProvider) Data driver created Debug: src/core/raster/qgsrasterlayer.cpp: 2259: (setDataProvider) Instantiated the data provider plugin with layer list of and style list of and format of and CRS of Debug: src/providers/gdal/qgsgdalprovider.cpp: 1194: (isValid) valid = 0 Debug: src/app/qgisapp.cpp: 6638: (addRasterLayers) TMP ET addRasterLayers - calling subLayers() Debug: src/providers/gdal/qgsgdalprovider.cpp: 1570: (subLayers) TMP ET QgsGdalProvider::subLayers() ERROR 10: Pointer 'hObject' is NULL in 'GDALGetMetadata'. Debug: src/providers/gdal/qgsgdalprovider.cpp: 1250: (subLayers_) sublayers: Debug: src/app/qgisapp.cpp: 6640: (addRasterLayers) TMP ET addRasterLayers got Debug: src/providers/gdal/qgsgdalprovider.cpp: 329: (~QgsGdalProvider) QgsGdalProvider: deconstructing.