Ticket #1021 (closed defect: fixed)

Opened 7 years ago

Last modified 22 months ago

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) (diff)

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

Changed 7 years ago by fwarmerdam

  • status changed from new to closed
  • resolution set to fixed
  • summary changed from Raster Query ignores some classification methods. to 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. 


Changed 7 years ago by fwarmerdam

  • status changed from closed to reopened
  • resolution fixed deleted
Ignore last comment, it belonged in bug 1021.  *This* bug is not fixed.

Changed 22 months ago by warmerdam

  • keywords raster query classified added
  • status changed from reopened to closed
  • resolution set to fixed
  • description modified (diff)

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.