MCPcopy Index your code
hub / github.com/MapServer/MapServer / msDrawRasterLayerGDAL_16BitClassification

Function msDrawRasterLayerGDAL_16BitClassification

mapdrawgdal.c:2209–2511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2207/************************************************************************/
2208
2209static int
2210msDrawRasterLayerGDAL_16BitClassification(
2211 mapObj *map, layerObj *layer, rasterBufferObj *rb,
2212 GDALDatasetH hDS, GDALRasterBandH hBand,
2213 int src_xoff, int src_yoff, int src_xsize, int src_ysize,
2214 int dst_xoff, int dst_yoff, int dst_xsize, int dst_ysize )
2215
2216{
2217 float *pafRawData;
2218 double dfScaleMin=0.0, dfScaleMax=0.0, dfScaleRatio;
2219 int nPixelCount = dst_xsize * dst_ysize, i, nBucketCount=0;
2220 GDALDataType eDataType;
2221 float fDataMin=0.0, fDataMax=255.0, fNoDataValue;
2222 const char *pszScaleInfo;
2223 const char *pszBuckets;
2224 int bUseIntegers = FALSE;
2225 int *cmap, c, j, k, bGotNoData = FALSE, bGotFirstValue;
2226 unsigned char *rb_cmap[4];
2227 CPLErr eErr;
2228
2229 assert( rb->type == MS_BUFFER_GD || rb->type == MS_BUFFER_BYTE_RGBA );
2230
2231/* ==================================================================== */
2232/* Read the requested data in one gulp into a floating point */
2233/* buffer. */
2234/* ==================================================================== */
2235 pafRawData = (float *) malloc(sizeof(float) * dst_xsize * dst_ysize );
2236 if( pafRawData == NULL )
2237 {
2238 msSetError( MS_MEMERR, "Out of memory allocating working buffer.",
2239 "msDrawRasterLayerGDAL_16BitClassification()" );
2240 return -1;
2241 }
2242
2243 eErr = GDALRasterIO( hBand, GF_Read,
2244 src_xoff, src_yoff, src_xsize, src_ysize,
2245 pafRawData, dst_xsize, dst_ysize, GDT_Float32, 0, 0 );
2246
2247 if( eErr != CE_None )
2248 {
2249 free( pafRawData );
2250 msSetError( MS_IOERR, "GDALRasterIO() failed: %s",
2251 "msDrawRasterLayerGDAL_16BitClassification()",
2252 CPLGetLastErrorMsg() );
2253 return -1;
2254 }
2255
2256 fNoDataValue = (float) msGetGDALNoDataValue( layer, hBand, &bGotNoData );
2257
2258/* ==================================================================== */
2259/* Determine scaling. */
2260/* ==================================================================== */
2261 eDataType = GDALGetRasterDataType( hBand );
2262
2263/* -------------------------------------------------------------------- */
2264/* Scan for absolute min/max of this block. */
2265/* -------------------------------------------------------------------- */
2266 bGotFirstValue = FALSE;

Callers 1

msDrawRasterLayerGDALFunction · 0.85

Calls 6

msSetErrorFunction · 0.85
msGetGDALNoDataValueFunction · 0.85
msDebugFunction · 0.85
msSmallCallocFunction · 0.85
msGetClass_FloatRGBFunction · 0.85
msValueToRangeFunction · 0.85

Tested by

no test coverage detected