Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Within classes I'm able to match strings using CLASSITEM, but not when including the field name in the expression, for example (inside a layer declaration):

CLASSITEM "myfieldname"
CLASS
    EXPRESSION "sometext"
END

Works fine, but

CLASS
    EXPRESSION ([myfieldname] = "sometext")
END

Doesn't return any data

The second method is fine when working with integers, e.g.

CLASS
    EXPRESSION ([myintegerfieldname] = 10)
END

I've tried enclosing the strings with single quotes, double quotes, using a regex instead. The same behaviour occurs when the source data is a shapefile or a postgis layer.

Using CLASSITEM is obviously a good work-around, but it would be useful to know what I'm doing wrong with the direct comparison.

Thanks!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Try:

CLASS
   EXPRESSION ("[myfieldname]" = "sometext")
END

this should force mapserver to use the string equality operator on both fields and explains why it does work with numbers.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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