Class expression and PostGIS

Nigel Gilbert n.gilbert at SURREY.AC.UK
Fri Jun 23 19:10:22 EDT 2006


[Many thanks to those who helped me yesterday overcome a problem with
creating an oid index, now solved as a result of their advice]

I have a PostGIS database including a table, world, with columns,
object_type (containing either one of the strings, 'plants' or 'agents') and
'geom', containing points.  In my map file I have:

LAYER
    NAME World
    CONNECTIONTYPE    postgis
    CONNECTION    "user=..... dbname=...."
    DATA                "geom from world"
    STATUS            ON
    TYPE                POINT

    CLASS
        NAME            Agents
        EXPRESSION    ([object_type] = 'agents')
        STYLE
            COLOR        255 111 207    # pink
        END
    END

    CLASS
        NAME            Plants
        EXPRESSION ([object_type] = 'plants')
        STYLE
            COLOR        0 128 64        # green
        END
    END
END

This gives a map displaying nothing, although if I comment out the
expressions, I get the points I would then expect.  In other words, the
expressions are always returning false.  But getting the data directly:

 select object_type, AsText(geom) from world limit 3;
                                             object_type
|     astext     
----------------------------------------------------------------------------
--------------------------+----------------
 plants            
| POINT(13 19)
 plants            
| POINT(228 840)
 plants            
| POINT(694 674)
(3 rows)           

is fine.  What's wrong??

Thanks again!

Nigel



More information about the mapserver-users mailing list