[mapserver-users] create attributes for dynamic polygon layer

Pietro Giannini pgiannini at bytewise.it
Wed Jan 28 05:14:37 EST 2009


I was engaged in a similar question.
It is not possible, you must to try a different method.
Read this thread:
http://lists.osgeo.org/pipermail/mapserver-users/2009-January/059537.html

ciao  .........pg

-- 
Pietro Giannini
Bytewise srl - Area GIS
41°50'38.58"N 12°29'13.39"E



On Mar, Gennaio 27, 2009 16:37, Mathias Tobler wrote:
> <html>
> <body>
> <font size=3>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.<br><br>
> 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-&gt;set(&quot;text&quot;,$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. <br><br>
> Mathias<br><br>
> <br>
> # Create a layer to hold density polygons<br>
> $oLayerPoly = ms_newLayerObj($oMap);<br>
> $oLayerPoly-&gt;set( &quot;name&quot;, &quot;ColDensity&quot;);<br>
> $oLayerPoly-&gt;set( &quot;type&quot;, MS_LAYER_POLYGON);<br>
> $oLayerPoly-&gt;set( &quot;status&quot;, MS_DEFAULT);<br><br>
> foreach($summary_rows as $row)<br>
> {<br>
> $oNewLine = ms_newLineObj();<br>
> $oNewLine-&gt;addXY($row['minLong'],$row['minLat']);<br>
> $oNewLine-&gt;addXY($row['minLong']+1,$row['minLat']);<br>
> $oNewLine-&gt;addXY($row['minLong']+1,$row['minLat']+1);<br>
> $oNewLine-&gt;addXY($row['minLong'],$row['minLat']+1);<br>
> $oNewLine-&gt;addXY($row['minLong'],$row['minLat']);<br>
> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;
> <br>
> $oNewShape = ms_newShapeObj(MS_SHAPE_POLYGON);<br>
> $oNewShape-&gt;add($oNewLine);<br>
> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
> $label = $row['Count'];<br>
> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
> $oNewShape-&gt;set(&quot;text&quot;,$label);<br>
> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
> $oLayerPoly-&gt;AddFeature($oNewShape);<br>
> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
> } </font></body>
> </html>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>





More information about the mapserver-users mailing list