[mapserver-commits] r10844 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Jan 6 17:27:40 EST 2011


Author: warmerdam
Date: 2011-01-06 14:27:40 -0800 (Thu, 06 Jan 2011)
New Revision: 10844

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapdrawgdal.c
Log:
exclude nodata values from scaling min/max computation (#3650)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-01-06 22:26:30 UTC (rev 10843)
+++ trunk/mapserver/HISTORY.TXT	2011-01-06 22:27:40 UTC (rev 10844)
@@ -14,6 +14,9 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- NODATA values now excluded from autoscaling min/max for non-eight 
+  scaling computations (#3650)
+
 - Fixed missing time in msDrawMap logging (#3651)
 
 - Fixed Auto Angle - incorrectly placed Labels (#3648)

Modified: trunk/mapserver/mapdrawgdal.c
===================================================================
--- trunk/mapserver/mapdrawgdal.c	2011-01-06 22:26:30 UTC (rev 10843)
+++ trunk/mapserver/mapdrawgdal.c	2011-01-06 22:27:40 UTC (rev 10844)
@@ -1563,15 +1563,31 @@
 /* -------------------------------------------------------------------- */
 	pafRawData = pafWholeRawData + iColorIndex * dst_xsize * dst_ysize;
 
+        dfNoDataValue = msGetGDALNoDataValue( layer, hBand, &bGotNoData );
+
 	if( dfScaleMin == dfScaleMax )
         {
-	    dfScaleMin = dfScaleMax = pafRawData[0];
-	    
-	    for( i = 1; i < nPixelCount; i++ )
+            int bMinMaxSet = 0;
+            
+            /* we force assignment to a float rather than letting pafRawData[i]
+               get promoted to double later to avoid float precision issues. */
+            float fNoDataValue = (float) dfNoDataValue; 
+
+	    for( i = 0; i < nPixelCount; i++ )
             {
+                if( bGotNoData && pafRawData[i] == fNoDataValue )
+                    continue;
+
+                if( !bMinMaxSet )
+                {
+                    dfScaleMin = dfScaleMax = pafRawData[i];
+                    bMinMaxSet = TRUE;
+                }
+
 		dfScaleMin = MIN(dfScaleMin,pafRawData[i]);
 		dfScaleMax = MAX(dfScaleMax,pafRawData[i]);
             }
+
 	    if( dfScaleMin == dfScaleMax )
                 dfScaleMax = dfScaleMin + 1.0;
         }
@@ -1603,11 +1619,11 @@
 /*      unable to utilize it since we can't return any pixels marked    */
 /*      as nodata from this function.  Need to fix someday.             */
 /* -------------------------------------------------------------------- */
-	dfNoDataValue = msGetGDALNoDataValue( layer, hBand, &bGotNoData );
 	if( bGotNoData )
             msDebug( "LoadGDALImage(%s): NODATA value %g in GDAL\n"
-                     "file or PROCESSING directive ignored.  Not yet supported for\n"
-                     "unclassified scaled data.\n",
+                     "file or PROCESSING directive largely ignored.  Not yet fully supported for\n"
+                     "unclassified scaled data.  The NODATA value is excluded from auto-scaling\n"
+                     "min/max computation, but will not be transparent.\n",
                      layer->name, dfNoDataValue );
 	
 /* -------------------------------------------------------------------- */



More information about the mapserver-commits mailing list