[Mapserver-west] php/mapserver & wms

percy percyd at pdx.edu
Thu Nov 2 13:26:43 EST 2006


Nelson, Here is some sample PHP/Mapscript code from one of our apps here 
at PSU. Others have found it useful, I hope you do, too :-)
Percy

//start sample code
    $cities=ms_newLayerObj($map);
    $cities->set("name", "Cities");
    $cities->set("data", "all_cities_dissolved");
    $cities->set("type", MS_LAYER_POLYGON);
    $cities->set("status", MS_OFF);
    $cities->set("transparency", 20);
    $cities->set("classitem", "NAME");
    $cities->setProjection($projection);
    //next few lines are to enable querry
    $cities->set("group", "Selectable Layers");
    $cities->setMetaData("Description", "City");
    $cities->setMetaData("Result_Fields", "NAME");
    $cities->setMetaData("Group", "Selectable Layers");
    $cities->setMetaData("Layer", "cities");

    $class_cities_lrg=ms_newClassObj($cities);
    $class_cities_lrg->set("name", "Large Cities");
    $class_cities_lrg->setExpression("/Metro Area/");
    $class_cities_lrg->set("maxscale", 10000000);
    $class_cities_lrg->set("minscale", 5000001);
    $style_cities_lrg=ms_newStyleObj($class_cities_lrg);
    $style_cities_lrg->color->setRGB(255,255,255);
    $class_cities_lrg->set("template", "ttt_query.html");

    $class_cities_med=ms_newClassObj($cities);
    $class_cities_med->set("name", "Medium & Large Cities");
    $class_cities_med->setExpression("([AREA] > 0.01)");
    $class_cities_med->set("maxscale", 5000000);
    $class_cities_med->set("minscale", 500001);
    $style_cities_med=ms_newStyleObj($class_cities_med);
    $style_cities_med->color->setRGB(255,255,255);
    $class_cities_med->set("template", "ttt_query.html");
//end sample code

-- 
David Percy
Geospatial Data Manager
Geology Department
Portland State University
http://gisgeek.pdx.edu
503-725-3373

> Date: Thu, 2 Nov 2006 08:43:54 -0600
> From: Nelson Guda <nelsong at mail.utexas.edu>
> Subject: [Mapserver-west] php/mapserver & wms
> To: mapserver-west at lists.maptools.org
> Message-ID: <8E4F4C8A-C28A-4F70-917F-5A199DE19415 at mail.utexas.edu>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Hi all,
>
> I have a site that uses mapserver wms to generate tiles which overlay  
> on top of a google map.  I would like to make the mapserver tiles  
> user-customizable, so that the wms call can return a map that  
> reflects a query (for example a map that shows several but not all of  
> the species in the postgre database, or just records from specific  
> years).  The reason I am overlaying the mapserver tiles on the google  
> map is that we have too many points for the google api to plot, and  
> it is much faster this way.
>
> Can php/mapserver be used to generate custom wms such as this?  If  
> so, is there a good tutorial on how to do it?
>
> If not, does anyone have any better suggestions of how to generate  
> customized wms layers from a postgre database?
>
> many thanks,
> nelson
>
>
>   



More information about the Mapserver-west mailing list