[mapserver-commits] r10075 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Apr 7 17:21:29 EDT 2010
Author: warmerdam
Date: 2010-04-07 17:21:27 -0400 (Wed, 07 Apr 2010)
New Revision: 10075
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapdrawgdal.c
trunk/mapserver/mapraster.c
trunk/mapserver/maprasterquery.c
trunk/mapserver/mapserver.h
Log:
improve support for [red/green/blue] classification in raster query (#1021)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2010-04-07 21:05:03 UTC (rev 10074)
+++ trunk/mapserver/HISTORY.TXT 2010-04-07 21:21:27 UTC (rev 10075)
@@ -14,6 +14,9 @@
Current Version (SVN trunk):
----------------------------
+- Improve support for [red/green/blue] classification expressions for
+ raster query (#1021)
+
- Fixed imageObj->saveImage() sends unnecessary headers (#3418)
- Avoid automatically regenerating maplexer.c (#2310)
Modified: trunk/mapserver/mapdrawgdal.c
===================================================================
--- trunk/mapserver/mapdrawgdal.c 2010-04-07 21:05:03 UTC (rev 10074)
+++ trunk/mapserver/mapdrawgdal.c 2010-04-07 21:21:27 UTC (rev 10075)
@@ -2515,7 +2515,7 @@
dfOriginalValue = (i+0.5) / dfScaleRatio + dfScaleMin;
- c = msGetClass_Float(layer, (float) dfOriginalValue);
+ c = msGetClass_FloatRGB(layer, (float) dfOriginalValue, -1, -1, -1);
if( c != -1 )
{
int s;
Modified: trunk/mapserver/mapraster.c
===================================================================
--- trunk/mapserver/mapraster.c 2010-04-07 21:05:03 UTC (rev 10074)
+++ trunk/mapserver/mapraster.c 2010-04-07 21:21:27 UTC (rev 10075)
@@ -129,13 +129,14 @@
}
/************************************************************************/
-/* msGetClass_Float() */
+/* msGetClass_FloatRGB() */
/* */
/* Returns the class based on classification of a floating */
/* pixel value. */
/************************************************************************/
-int msGetClass_Float(layerObj *layer, float fValue)
+int msGetClass_FloatRGB(layerObj *layer, float fValue,
+ int red, int green, int blue )
{
int i;
char *tmpstr1=NULL;
@@ -171,6 +172,16 @@
case(MS_EXPRESSION):
tmpstr1 = strdup(layer->class[i]->expression.string);
+ if( red != -1 && green != -1 && blue != -1 )
+ {
+ sprintf(tmpstr2, "%d", red);
+ tmpstr1 = msReplaceSubstring(tmpstr1, "[red]", tmpstr2);
+ sprintf(tmpstr2, "%d", green);
+ tmpstr1 = msReplaceSubstring(tmpstr1, "[green]", tmpstr2);
+ sprintf(tmpstr2, "%d", blue);
+ tmpstr1 = msReplaceSubstring(tmpstr1, "[blue]", tmpstr2);
+ }
+
sprintf(tmpstr2, "%18g", fValue);
tmpstr1 = msReplaceSubstring(tmpstr1, "[pixel]", tmpstr2);
Modified: trunk/mapserver/maprasterquery.c
===================================================================
--- trunk/mapserver/maprasterquery.c 2010-04-07 21:05:03 UTC (rev 10074)
+++ trunk/mapserver/maprasterquery.c 2010-04-07 21:21:27 UTC (rev 10075)
@@ -301,39 +301,9 @@
}
/* -------------------------------------------------------------------- */
-/* Handle classification. */
-/* */
-/* NOTE: The following is really quite inadequate to deal with */
-/* classifications based on [red], [green] and [blue] as */
-/* described in: */
-/* http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1021 */
-/* -------------------------------------------------------------------- */
- if( rlinfo->qc_class != NULL )
- {
- p_class = msGetClass_Float(layer, values[0] );
-
- if( p_class == -1 )
- nodata = TRUE;
- else
- {
- rlinfo->qc_class[rlinfo->query_results] = p_class;
- if( layer->class[p_class]->numstyles > 0 )
- {
- red = layer->class[p_class]->styles[0]->color.red;
- green = layer->class[p_class]->styles[0]->color.green;
- blue = layer->class[p_class]->styles[0]->color.blue;
- }
- else
- {
- red = green = blue = 0;
- }
- }
- }
-
-/* -------------------------------------------------------------------- */
/* Handle colormap */
/* -------------------------------------------------------------------- */
- else if( rlinfo->hCT != NULL )
+ if( rlinfo->hCT != NULL )
{
int pct_index = (int) floor(values[0]);
GDALColorEntry sEntry;
@@ -369,6 +339,38 @@
}
/* -------------------------------------------------------------------- */
+/* Handle classification. */
+/* */
+/* NOTE: The following is really quite inadequate to deal with */
+/* classifications based on [red], [green] and [blue] as */
+/* described in: */
+/* http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1021 */
+/* -------------------------------------------------------------------- */
+ if( rlinfo->qc_class != NULL )
+ {
+ p_class = msGetClass_FloatRGB(layer, values[0],
+ red, green, blue );
+
+ if( p_class == -1 )
+ nodata = TRUE;
+ else
+ {
+ nodata = FALSE;
+ rlinfo->qc_class[rlinfo->query_results] = p_class;
+ if( layer->class[p_class]->numstyles > 0 )
+ {
+ red = layer->class[p_class]->styles[0]->color.red;
+ green = layer->class[p_class]->styles[0]->color.green;
+ blue = layer->class[p_class]->styles[0]->color.blue;
+ }
+ else
+ {
+ red = green = blue = 0;
+ }
+ }
+ }
+
+/* -------------------------------------------------------------------- */
/* Record the color. */
/* -------------------------------------------------------------------- */
rlinfo->qc_red[rlinfo->query_results] = red;
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2010-04-07 21:05:03 UTC (rev 10074)
+++ trunk/mapserver/mapserver.h 2010-04-07 21:21:27 UTC (rev 10075)
@@ -2176,7 +2176,8 @@
MS_DLL_EXPORT int msAddColorAGG(mapObj *map, gdImagePtr img, int cmt, int r, int g, int b);
#endif
MS_DLL_EXPORT int msGetClass(layerObj *layer, colorObj *color);
-MS_DLL_EXPORT int msGetClass_Float(layerObj *layer, float fValue);
+MS_DLL_EXPORT int msGetClass_FloatRGB(layerObj *layer, float fValue,
+ int red, int green, int blue );
/* in mapdrawgdal.c */
MS_DLL_EXPORT int msDrawRasterLayerGDAL(mapObj *map, layerObj *layer, imageObj *image, rasterBufferObj *rb, void *hDSVoid );
More information about the mapserver-commits
mailing list