| 1974 | /************************************************************************/ |
| 1975 | |
| 1976 | static int |
| 1977 | msDrawRasterLayerGDAL_RawMode( |
| 1978 | mapObj *map, layerObj *layer, imageObj *image, GDALDatasetH hDS, |
| 1979 | int src_xoff, int src_yoff, int src_xsize, int src_ysize, |
| 1980 | int dst_xoff, int dst_yoff, int dst_xsize, int dst_ysize ) |
| 1981 | |
| 1982 | { |
| 1983 | void *pBuffer; |
| 1984 | GDALDataType eDataType; |
| 1985 | int *band_list, band_count; |
| 1986 | int i, j, k, band; |
| 1987 | CPLErr eErr; |
| 1988 | float *f_nodatas = NULL; |
| 1989 | unsigned char *b_nodatas = NULL; |
| 1990 | GInt16 *i_nodatas = NULL; |
| 1991 | int got_nodata=FALSE; |
| 1992 | |
| 1993 | if( image->format->bands > 256 ) |
| 1994 | { |
| 1995 | msSetError( MS_IMGERR, "Too many bands (more than 256).", |
| 1996 | "msDrawRasterLayerGDAL_RawMode()" ); |
| 1997 | return -1; |
| 1998 | } |
| 1999 | |
| 2000 | /* -------------------------------------------------------------------- */ |
| 2001 | /* We need at least GDAL 1.2.0 for the DatasetRasterIO */ |
| 2002 | /* function. */ |
| 2003 | /* -------------------------------------------------------------------- */ |
| 2004 | #if !defined(GDAL_VERSION_NUM) || GDAL_VERSION_NUM < 1200 |
| 2005 | msSetError(MS_IMGERR, |
| 2006 | "RAWMODE raster support requires GDAL 1.2.0 or newer.", |
| 2007 | "msDrawRasterLayerGDAL_RawMode()" ); |
| 2008 | free( pBuffer ); |
| 2009 | return -1; |
| 2010 | #endif |
| 2011 | |
| 2012 | /* -------------------------------------------------------------------- */ |
| 2013 | /* What data type do we need? */ |
| 2014 | /* -------------------------------------------------------------------- */ |
| 2015 | if( image->format->imagemode == MS_IMAGEMODE_INT16 ) |
| 2016 | eDataType = GDT_Int16; |
| 2017 | else if( image->format->imagemode == MS_IMAGEMODE_FLOAT32 ) |
| 2018 | eDataType = GDT_Float32; |
| 2019 | else if( image->format->imagemode == MS_IMAGEMODE_BYTE ) |
| 2020 | eDataType = GDT_Byte; |
| 2021 | else |
| 2022 | return -1; |
| 2023 | |
| 2024 | /* -------------------------------------------------------------------- */ |
| 2025 | /* Work out the band list. */ |
| 2026 | /* -------------------------------------------------------------------- */ |
| 2027 | band_list = msGetGDALBandList( layer, hDS, image->format->bands, |
| 2028 | &band_count ); |
| 2029 | if( band_list == NULL ) |
| 2030 | return -1; |
| 2031 | |
| 2032 | if( band_count != image->format->bands ) |
| 2033 | { |
no test coverage detected