I sent this (probably wrongly) to the mapserver-dev list a couple about a week ago and have not heard back from anyone. So I am trying my luck here.

I am using PHP MapScript to create a polygon layer based on data stored in a MySQL database. The layer will show 1x1 degree grid cells and each cell should be colored according to the number of point records it contains. The summary is don in SQL and the query returns the coordinates of the lower left corner of each cell as well as a column 'Count' with the number of recrods in each cell. The geometry part work fine but I would like to add an attribute so I can assign different collors to the polygons. While $oNewShape->set("text",$label); works great for labeling polygons I wonder if there was a similar methods that will work with the _expression_ statement so that I can define different classes for the layer. Using MySQL is given by our application and I won't be able to switch to PostGIS. Any suggestions are wellcome.

Mathias


# Create a layer to hold density polygons
$oLayerPoly = ms_newLayerObj($oMap);
$oLayerPoly->set( "name", "ColDensity");
$oLayerPoly->set( "type", MS_LAYER_POLYGON);
$oLayerPoly->set( "status", MS_DEFAULT);

foreach($summary_rows as $row)
{
$> $oNewLine->addXY($row['minLong'],$row['minLat']);
$oNewLine->addXY($row['minLong']+1,$row['minLat']);
$oNewLine->addXY($row['minLong']+1,$row['minLat']+1);
$oNewLine->addXY($row['minLong'],$row['minLat']+1);
$oNewLine->addXY($row['minLong'],$row['minLat']);
                   
$> $oNewShape->add($oNewLine);
                                                     
$label = $row['Count'];
                                                     
$oNewShape->set("text",$label);
                                                     
$oLayerPoly->AddFeature($oNewShape);
                 
}
_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to