Controlling classitems through PHP? (Tanzanian protected areas)

Ragnvald ragnvald at MINDLAND.COM
Thu Mar 17 01:01:47 PST 2005


I have a layer of Tanzanian protected areas (National parks, Game Reserves,
Conservation areas, etc). My goal is to be able to control the visual
appearances of the separate parks based on numerical data in an animal
survey database using PHP.



I am really struggling with this and have not been able to figure it out. I
have done several searches, and to be honest working with classes through
PHP is a bit new to me. If I manage to do this it will be VERY helpful for
us here at TAWIRI.



The planned script should generate different maps for different estimated
species concentrations in these protected areas. The first step is to be
able to control the different parks appearances by referring to their names.
(Currently the developed solution will only be for testing purposes and
internal use at my department.)



This is what I can do by using a simple map-file:



http://www.mindland.com/test/tanzania_parks_pres_1.gif



The code for the "Parks" layer is like this:



            LAYER

                        NAME "Parks"

                        TYPE POLYGON

                        STATUS ON

                        DATA "TZ_PAs_2002_Poly"

                        PROJECTION

                                   "proj=latlong"

                                   "ellps=GRS80"

                                   "datum=NAD83"

                        END



                        CLASSITEM 'NAME'

                                   CLASS

                                               COLOR 190 190 190

                                               SYMBOL 0

                                               EXPRESSION "Serengeti"

                                               NAME "Serengeti"

                                   END

                                   CLASS

                                               COLOR 210 210 210

                                               SYMBOL 0

                                               EXPRESSION "Ikorongo"

                                               NAME "Ikorongo"

                                   END

                                   CLASS

                                               COLOR 220 220 220

                                               SYMBOL 0

                                               EXPRESSION "Grumeti"

                                               NAME "Grumeti"

                                   END

                                   CLASS

                                               COLOR 220 220 220

                                               SYMBOL 0

                                               EXPRESSION "Masawa"

                                               NAME "Masawa"

                                   END

                                   CLASS

                                               COLOR 220 220 220

                                               SYMBOL 0

                                               EXPRESSION "Ngorongoro"

                                               NAME "Ngorogoro"

                                   END

                        END

            END



The question is then how to control the CLASSITEM color appearance and also
selection of which classitems to show - through PHP. In the end I will use
database queries, but for now I will be happy to do this by hard coding it
in PHP.  I am able to do changes on the other parks (not displayed as
classitems). This code is added before the map is drawn:



$layerObj = $map->getlayerbyname("Parks");

$class = ms_newClassObj($layerObj);

$style = ms_newStyleObj($class);

$style->color->setRGB(200,200,0);





Resulting image is then:



http://www.mindland.com/test/tanzania_parks_pres_2.gif



Suggestions and references to relevant postings would be fine. I re





Ragnvald Larsen

Geographer / data systems developer



Conservation Information and Monitoring Unit,

Tanzania Wildlife Researc Institute,

Tanzania

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050317/7a1262ae/attachment.htm>


More information about the MapServer-users mailing list