[Chameleon] changing class name and expression programmatically
Normand Savard
nsavard at mapgears.com
Tue May 29 09:39:31 EDT 2007
Anand Akmanchi wrote:
> Hi members
>
> thanks Norm for your help,..it worked out wonderfully fine
>
> I have been able to query, retrieve and display a postgis layer
> and now would like to style it
>
> the classitem is a column containing integer values in the database table
> I want to break it up into five equal or natural breaks interval classes
> I am able to compute statistics like mean, stdev etc. on the column
> using PHP
>
> how do I manipulate the layer's classitem containing five classes
> I want to access them using the class name
> then set the class name to something meaningful like upper/lower
> limits of interval
> and set the expression for that class
>
> thanks in advance
>
>
Anand,
Do you classes already exist in your layer? I don't know if I
understand well all you want to accomplish but I give it a try (see below).
Norm
$szMyClassName = set this value to whatever your class name is
$oMap = $this->moMapObject->oMap;
$oLayer = @$oMap->getlayerbyname($this->mszLayerName);
$oClass =getClassByName($oLayer, $szMyClassName);
$oClass->setexpression(type in your expression here);
function getClassByName($oLayer, $szName)
{
$nClasses = $oLayer->numclasses;
for($j=0;$j<$nClasses;$j++)
{
$oClass = $oLayer->getClass($j);
if ( $oClass->name == trim( $szName) )
{
return $oClass;
}
}
}
More information about the Chameleon
mailing list