0

I've got a spatial table in Oracle and a WMS-T in Mapserver, defined in a layer that query that table. The table has several columns and I pass the column to select as a parameter in OpenLayers, so the layer definition in mapserver is the following:

LAYER
    NAME "layer_example"
    CONNECTION "oracle/user@oracleservice/oracle"
    CONNECTIONTYPE ORACLESPATIAL
    DATA "geom FROM  (SELECT E.%type% as value, E.YEAR as YEAR, E.SHAPE_60M as geom FROM EMISSIONS E
                      WHERE E.level=%level% ) USING NONE"

    TYPE POLYGON

    STATUS OFF
    TRANSPARENCY 100

    VALIDATION
        'level' '^[0-9]$'
        'type'       '^[a-zA-Z0-9]+$' #column name
    END

    PROJECTION
            "init=epsg:4326"
    END
    UNITS METERS
    SIZEUNITS PIXELS
    TOLERANCE 0
    TOLERANCEUNITS PIXELS
    CLASSITEM value
    ### LEGEND DEFINITION HERE ###

    METADATA
            "ows_title" "emissions"
        "ows_srs" "EPSG:3035 EPSG:4326 EPSG:900913"
        "ows_timeformat" "YYYY"
        "ows_timeextent" "2000/2011"
        "ows_timeitem" "YEAR"
            "ows_timedefault" "2000"
        "wms_enable_request" "*"
        "wms_metadataurl_format" "text/xml"
        "wms_metadataurl_type" "ISO19115:2003"

    END
END

The problem is the legend! Since the columns in the table has got different classes of values for their legends, how can I define the legend on fly? I tried to define legends in different files and then INCLUDE "legend_%type%.map", but the variable substitution doesn't work for INCLUDE. Actually, it would be great if Mapserver had this feature.

Anyway, some ideas and suggestions? Hope the question is clear!

1 Answer 1

1

I was able to define legend on fly (i.e. definition of boundaries are made on fly) using the following trick:

DATA "geom FROM  (SELECT E.%type% as value, (select max(%type%)/5 from EMISSIONS) as fifth_of_max_value, E.YEAR as YEAR, E.SHAPE_60M as geomFROM EMISSIONS E
        WHERE e.level=%level% ) USING NONE"

Then, in the classes definition, I use the [fifth_of_max_value] value to define thresholds of five classes:

CLASSITEM value
    CLASS
        NAME 'Absent'
        EXPRESSION ([value]==0)
        STYLE
            ANGLE 360
            OUTLINECOLOR 95 95 95
            COLOR 192 255 255
            SYMBOL 0
        END
    END
    CLASS
        NAME 'Moderate'
        EXPRESSION ([value]>0  AND [value]<=[fifth_of_max_value])
        STYLE
            ANGLE 360
            OUTLINECOLOR 95 95 95
            COLOR 0 255 255
            SYMBOL 0
        END
    END
    CLASS
        NAME 'Medium'
        EXPRESSION ([value]>[fifth_of_max_value]  AND [value]<=[fifth_of_max_value]*2)
        STYLE
            ANGLE 360
            OUTLINECOLOR 95 95 95
            COLOR 0 255 0
            SYMBOL 0
        END
    END
    CLASS
        NAME 'Strong'
        EXPRESSION ([value]>[fifth_of_max_value]*2  AND [value]<=[fifth_of_max_value]*3)
        STYLE
            ANGLE 360
            OUTLINECOLOR 95 95 95
            COLOR 255 176 0
            SYMBOL 0
        END
    END
    CLASS
        NAME 'Very strong'
        EXPRESSION ([value]>[fifth_of_max_value]*3  AND [value]<=[fifth_of_max_value]*4)
        STYLE
            ANGLE 360
            OUTLINECOLOR 95 95 95
            COLOR 255 0 0
            SYMBOL 0
        END
    END
    CLASS
        NAME 'Excessive'
        EXPRESSION ([value]>[fifth_of_max_value]*4 AND [value]<=[fifth_of_max_value]*5)
        STYLE
            ANGLE 360
            OUTLINECOLOR 95 95 95
            COLOR 128 0 0
            SYMBOL 0
        END
    END

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.