On Sun, May 2, 2010 at 2:26 AM,  <fedesanchez...@gmail.com> wrote:
> Hi!
> I'm trying to create layers dynamically, but i do not know much about 
> mapscript or how to use it with openlayers and mapserver...
>
> so i found your comment in -> 
> http://osgeo-org.1803224.n2.nabble.com/mergeNewParams-and-MapServer-DATA-td2559417.html#a2560730
> where at the end you wrote "I just use Mapscript server-side to change the 
> datapath for dynamically generated layers--seems to work, that's what 
> mapscript is for. " and that is pretty much exactly what i need to do
>
> I was not able to find examples or any clear documentation about it and i was 
> hoping you can point me to the right direction in order to be able to create 
> layers dynamically, so any tip would be very helpfull and really appreciated.
>
> Thanks!! and sorry for mi english!!
>
> Federico
>

Hi Feredico:

Essentially, a server side php script
1. Parses the request,
2. Uses mapscript to load the map file,
3. Find the layer with dynamic data,
4. Change the data path for that layer and
5. Executes the request

//generate path:
$outputImg = '/tmp/' . 'some_dynamically_generated_name' . '.tif';


if (!file_exists($outputImg)){
        print "File doesn't exist<br>";
} //end if
$request = ms_newowsrequestobj();

foreach ($_REQUEST as $k=>$v) {
$request->setParameter($k, $v);
}

ms_ioinstallstdouttobuffer();

$oMap = ms_newMapobj("path_to your_map_file.map");

$oMapLayer = $oMap->getLayerByName('dynamic_layer');
//this sets the data path for 'dynamic_layer':
$oMapLayer->set("data", $outputImg);
$oMap->owsdispatch($request);

$contenttype = ms_iostripstdoutbuffercontenttype();

if ($contenttype == 'image/gif')
   header('Content-type: image/gif');
if ($contenttype == 'image/tiff')
   header('Content-type: image/tiff');
ms_iogetStdoutBufferBytes();

ms_ioresethandlers();

Note that I had defined a layer named 'dynamic_layer' , for which I
just changed the value for the 'data' member of the LayerObj class.
Here is the reference documentation:
http://mapserver.org/mapscript/php/index.html#layerobj
_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to