mapscript - php equivalent of symbolSetObj ?
oliver
oliver.christen at CAMPTOCAMP.COM
Wed Nov 23 03:00:07 PST 2005
After having toyed with the available functions of php/mapscript, i seem to
have found a way to create icon on-the-fly from the symbol file.
Im pasting here the code so it may help other people.
If you think you know a better way to do it, let me know, im always
interessed :)
// $msMapObj is a valid mapObj
$newLayer = ms_newLayerObj($msMapObj); // create new layer
$newLayer->set('type', 0); // set layer type, important, cause error if not
set
$newClass = ms_newClassObj($newLayer); // create new classe
$newStyle = ms_newStyleObj($newClass); // create new style
$newStyle->color->setRGB(255,0,0); // important, display white on white
otherwise
$newStyle->set('size', 30); // important, size 0 for a symbol point will
display nothing
// loop through all the symbols in the symbol file
for($ii=0; $ii<$msMapObj->getNumSymbols(); $ii++) {
$symbolName = $msMapObj->getSymbolObjectById($ii)->name;
$newStyle->set('symbolname', $symbolName);
$newIcon = $newClass->createLegendIcon(30,30);
$iconPath =
'/the/Path/To/The/Folder/Where/You/Want/To/Save/The/Icons/'.$symbolName.'.jp
g';
$check = $newIcon->saveImage($iconPath);
$newIcon->free(); // free resources
// if the icons are not created, check if the script has the writing
right in the target folder
}
// remove the layer, is this really working ???
$newLayer->set("status", MS_DELETE);
> It seems i asked my question too quickly.
> By using getNumSymbols() in a loop with getSymbolObjectById i was able to
> get all the symbols properties.
>
> But now, how do i create images off these symbols (php equivalent to the
> SWIGMapScript function getImage()) ?
>
> Thank you very much in advance for any info.
> Oliver
>
> > Hi,
> >
> > Im currently trying to recover the list of symbols of a symbol file via
> > php/mapscript but i cant find any way to do so.
> > I noticed in the SWIGMapScript references the presence of an object:
> > symbolSetObj, and i wondered what was the equivalent in php?
> >
> > Thank you very much in advance for any info.
> >
> > Regards
> > Oliver
> >
>
More information about the MapServer-users
mailing list