New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WMS blank for classified raster with NaN #5289

Closed
blazek opened this Issue Jun 3, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@blazek
Contributor

blazek commented Jun 3, 2016

In 7.0.1, WMS renders blank image if a classified raster has NaN values and SCALE is not specified even if GDAL gives correctly NaN as nodata value.

The problem is that when min/max is calculated in mapdrawgdal.c, it skips nodata:

if( bGotNoData && pafRawData[i] == fNoDataValue )
    continue;

but not NaN which must be tested with isnan(). The result is min = max = NaN and blank image.
Here is my simple quick fix:

--- mapdrawgdal.c.orig  2016-06-03 09:42:03.007425561 +0200
+++ mapdrawgdal.c       2016-06-03 09:41:35.923290945 +0200
@@ -1270,6 +1270,9 @@
         if( bGotNoData && pafRawData[i] == fNoDataValue )
           continue;

+        if isnan( pafRawData[i] )
+            continue;
+
         if( !bMinMaxSet ) {
           dfScaleMin = dfScaleMax = pafRawData[i];
           bMinMaxSet = TRUE;
@@ -1764,6 +1767,9 @@
     if( bGotNoData && pafRawData[i] == fNoDataValue )
       continue;

+    if isnan( pafRawData[i] )
+        continue;
+
     if( !bGotFirstValue ) {
       fDataMin = fDataMax = pafRawData[i];
       bGotFirstValue = TRUE;

but a macro/function which tests both nodata value and NaN would be better. There are probably more places in mapserver where NaN is not correctly handled.

@rouault

This comment has been minimized.

Show comment
Hide comment
@rouault

rouault Jun 26, 2016

Contributor

That's reasonable. Would you mind making a pull request for this ? I'd suggest using CPLIsNan(), from GDAL headers, for portability.

Contributor

rouault commented Jun 26, 2016

That's reasonable. Would you mind making a pull request for this ? I'd suggest using CPLIsNan(), from GDAL headers, for portability.

@blazek

This comment has been minimized.

Show comment
Hide comment
@blazek

blazek Jun 27, 2016

Contributor

But GDAL is not requirement, it is optional.

Contributor

blazek commented Jun 27, 2016

But GDAL is not requirement, it is optional.

@rouault

This comment has been minimized.

Show comment
Hide comment
@rouault

rouault Jun 27, 2016

Contributor

All code in mapdrawgdal.c is after #if defined(USE_GDAL) so no problem using CPLIsNan()

Contributor

rouault commented Jun 27, 2016

All code in mapdrawgdal.c is after #if defined(USE_GDAL) so no problem using CPLIsNan()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment