We have a table "Shapes" in
PostGIS that consists of (among other things) a geometry column (
the_geom) and an ID column (
type_id) which is a foreign key to another table called "
A given row in the Shapes table may have a Type ID value or it may be
NULL. If it does have a Type ID, then we want to style the feature based on that. The issue is that we don't know how many different values there may be for Type ID, so we can't just add a fixed number of CLASS entries into the
mapfile. Our goal for these shapes (polygons) is to set the fill color... and we can estimate that there will be between 3 and 10 – a color range would be fine. We can also do a SQL JOIN to get the name for each Type, so our query results are essentially the geometry, the type ID, and the corresponding type name. The name is important to the end-user who don't see the IDs elsewhere in the application.
Is it possible to color the shapes based on that Type ID and have the legend display the type name - even though we don't know in advance how many types there will be?