[mapserver-commits] r10099 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Apr 12 20:00:32 EDT 2010
Author: warmerdam
Date: 2010-04-12 20:00:31 -0400 (Mon, 12 Apr 2010)
New Revision: 10099
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapgdal.c
trunk/mapserver/maputil.c
trunk/mapserver/mapwcs.c
trunk/mapserver/mapwcs11.c
Log:
implement wcs_rangeset_nullvalue and NULLVALUE formatoption support (#1709, #655)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2010-04-12 23:58:05 UTC (rev 10098)
+++ trunk/mapserver/HISTORY.TXT 2010-04-13 00:00:31 UTC (rev 10099)
@@ -14,6 +14,12 @@
Current Version (SVN trunk):
----------------------------
+- Implement support for raw imagemodes to use NULLVALUE formatoption to set
+ the background value of result images, and to try and mark nodata (#1709)
+
+- Implement support for wcs_rangeset_nullvalue to set NULLVALUE and
+ return null value definition in describe coverage result (#655)
+
- Try to avoid exhausting the color table when rendering 24bit key
images into 8bit results (#1594)
Modified: trunk/mapserver/mapgdal.c
===================================================================
--- trunk/mapserver/mapgdal.c 2010-04-12 23:58:05 UTC (rev 10098)
+++ trunk/mapserver/mapgdal.c 2010-04-13 00:00:31 UTC (rev 10099)
@@ -398,6 +398,22 @@
}
/* -------------------------------------------------------------------- */
+/* Possibly assign a nodata value. */
+/* -------------------------------------------------------------------- */
+ if( msGetOutputFormatOption(format,"NULLVALUE",NULL) != NULL )
+ {
+ int iBand;
+ const char *nullvalue = msGetOutputFormatOption(format,
+ "NULLVALUE",NULL);
+
+ for( iBand = 0; iBand < nBands; iBand++ )
+ {
+ GDALRasterBandH hBand = GDALGetRasterBand( hMemDS, iBand+1 );
+ GDALSetRasterNoDataValue( hBand, atof(nullvalue) );
+ }
+ }
+
+/* -------------------------------------------------------------------- */
/* Try to save resolution in the output file. */
/* -------------------------------------------------------------------- */
if( image->resolution > 0 )
Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c 2010-04-12 23:58:05 UTC (rev 10098)
+++ trunk/mapserver/maputil.c 2010-04-13 00:00:31 UTC (rev 10099)
@@ -1468,7 +1468,36 @@
image->imagepath = strdup(imagepath);
if (imageurl)
image->imageurl = strdup(imageurl);
-
+
+ /* initialize to requested nullvalue if there is one */
+ if( msGetOutputFormatOption(image->format,"NULLVALUE",NULL) != NULL )
+ {
+ int i = image->width * image->height * format->bands;
+ const char *nullvalue = msGetOutputFormatOption(image->format,
+ "NULLVALUE",NULL);
+
+ if( atof(nullvalue) == 0.0 )
+ /* nothing to do */;
+ else if( format->imagemode == MS_IMAGEMODE_INT16 )
+ {
+ short nv = atoi(nullvalue);
+ for( ; i > 0; )
+ image->img.raw_16bit[--i] = nv;
+ }
+ else if( format->imagemode == MS_IMAGEMODE_FLOAT32 )
+ {
+ float nv = atoi(nullvalue);
+ for( ; i > 0; )
+ image->img.raw_float[--i] = nv;
+ }
+ else if( format->imagemode == MS_IMAGEMODE_BYTE )
+ {
+ unsigned char nv = (unsigned char) atoi(nullvalue);
+
+ memset( image->img.raw_byte, nv, i );
+ }
+ }
+
return image;
}
else if( MS_RENDERER_IMAGEMAP(format) )
Modified: trunk/mapserver/mapwcs.c
===================================================================
--- trunk/mapserver/mapwcs.c 2010-04-12 23:58:05 UTC (rev 10098)
+++ trunk/mapserver/mapwcs.c 2010-04-13 00:00:31 UTC (rev 10099)
@@ -940,8 +940,6 @@
msIO_printf(" </values>\n");
- /* TODO: add NullValues (optional) */
-
msIO_printf(" </AxisDescription>\n");
msIO_printf(" </axisDescription>\n");
@@ -1078,6 +1076,12 @@
msFreeCharArray(tokens, numtokens);
}
}
+
+ if((value = msOWSLookupMetadata(&(layer->metadata), "COM", "rangeset_nullvalue")) != NULL) {
+ msIO_printf(" <nullValues>\n");
+ msIO_printf(" <singleValue>%s</singleValue>\n", value);
+ msIO_printf(" </nullValues>\n");
+ }
msIO_printf(" </RangeSet>\n");
msIO_printf(" </rangeSet>\n");
@@ -1722,7 +1726,12 @@
for(i = 1; i < cm.bandcount; i++)
sprintf(bandlist+strlen(bandlist),",%d", i+1);
}
-
+
+ /* apply nullvalue to the output format object if we have it */
+ if((value = msOWSLookupMetadata(&(lp->metadata), "COM", "rangeset_nullvalue")) != NULL) {
+ msSetOutputFormatOption( map->outputformat, "NULLVALUE", value );
+ }
+
msLayerSetProcessingKey(lp, "BANDS", bandlist);
sprintf(numbands, "%d", msCountChars(bandlist, ',')+1);
msSetOutputFormatOption(map->outputformat, "BAND_COUNT", numbands);
Modified: trunk/mapserver/mapwcs11.c
===================================================================
--- trunk/mapserver/mapwcs11.c 2010-04-12 23:58:05 UTC (rev 10098)
+++ trunk/mapserver/mapwcs11.c 2010-04-13 00:00:31 UTC (rev 10099)
@@ -764,7 +764,15 @@
xmlNewChild(
xmlNewChild( psField, NULL, BAD_CAST "Definition", NULL ),
psOwsNs, BAD_CAST "AnyValue", NULL );
-
+
+ /* NullValue */
+ value = msOWSGetEncodeMetadata( &(layer->metadata), "COM",
+ "rangeset_nullvalue", NULL);
+ if( value )
+ xmlNewChild( psField, NULL, BAD_CAST "NullValue",
+ BAD_CAST value );
+
+ /* InterpolationMethods */
psInterpMethods =
xmlNewChild( psField, NULL, BAD_CAST "InterpolationMethods", NULL );
@@ -772,7 +780,6 @@
xmlNewChild( psInterpMethods, NULL,
BAD_CAST "Default", BAD_CAST "nearest neighbor" );
-
/* -------------------------------------------------------------------- */
/* Bands axis. */
/* -------------------------------------------------------------------- */
More information about the mapserver-commits
mailing list