Opened 19 years ago

Closed 14 years ago

#1021 closed defect (fixed)

Raster Query ignores some classification methods.

Reported by: warmerdam Owned by: warmerdam
Priority: high Milestone:
Component: MapServer C Library Version: 4.3
Severity: normal Keywords: raster query classified
Cc:

Description (last modified by warmerdam)

The raster query stuff tries to apply classification to the raw raster values,
but does not take in account query expressions on [red], [green] and [blue], only
those that are based on the raw value. 

For an example look at the result of msautotest/mspython/rqtest - test 
rqtest_13. Currently it finds no results to the point query on the grid 
line because the grid line is classified in msautotest/gdal/classtest1.map
as follows:

  CLASS 
    NAME "Grid"
    EXPRESSION ([red] == 96 and [green] == 32 and [blue] == 32)
    COLOR 255 0 0
  END

As opposed to the text for instance, which does work fine:

  CLASS 
    NAME "Text"
    EXPRESSION ([pixel] == 0)
    COLOR -255 -255 -255
  END

The problem is that the classification handling code in maprasterquery.c
is overly simplistic:

/* -------------------------------------------------------------------- */
/*      Handle classification.                                          */
/* -------------------------------------------------------------------- */
    if( rlinfo->qc_class != NULL )
    {
        int p_class = msGetClass_Float(layer, values[0] );

        if( p_class == -1 )
            nodata = TRUE;
        else
        {
            rlinfo->qc_class[rlinfo->query_results] = p_class;
            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;
        }
    }

However the solution will be pretty involved I think, so I am just submitting
this bug report for now to keep track of the issue. 

In particular, I am not keen on trying to fix this for the 4.4 release.

Change History (3)

comment:1 by fwarmerdam, 19 years ago

Resolution: fixed
Status: newclosed
Summary: Raster Query ignores some classification methods. Raster Query ignores some classification methods.
Committed changes to reproject points back to the map projection before
doing distance testing needed by querybypoint case.  (maprasterquery.c)

This also ensures that results are returned in the map coordinate system, 
not the layer coordinate system. 

Also added tests to rqtest.py that verify the reprojection case. 


comment:2 by fwarmerdam, 19 years ago

Resolution: fixed
Status: closedreopened
Ignore last comment, it belonged in bug 1021.  *This* bug is not fixed.

comment:3 by warmerdam, 14 years ago

Description: modified (diff)
Keywords: raster query classified added
Resolution: fixed
Status: reopenedclosed

I have implemented support for extracting and using red/green/blue if available from a color table (as in this case) in trunk (r10075). msautotest also updated (r10076).

Note: See TracTickets for help on using tickets.