[Mapserver-users] dinamic class using a MapScript loop.
Eduardo Patto Kanegae
eduardo at consultoria.eti.br
Wed May 26 13:50:29 PDT 2004
I'm setting a set of classes of a given layer using definitions from a database table. so, I make a while-loop against a recordset and for each recordset I create a new class object using PHP variable-variables.
the code I made is:
----------
while (!$vwCommPlaceTypes->EOF){
$stClass = "hTmpClass".$vwCommPlaceTypes->fields["tip_codigo"];//define the class var name
$$stClass = ms_newClassObj($hTmpLayer);// htmpLayer is my layer
$$stClass->set("name",$vwCommPlaceTypes->fields["tip_descricao"]);
$$stClass->setexpression(trim($vwCommPlaceTypes->fields["tip_codigo"]));
$stStyle = "hTmpStyle".$vwCommPlaceTypes->fields["tip_codigo"];//define the style var name
$$stStyle = ms_newStyleObj($$stClass);
$$stStyle->set("minsize",5);
$$stStyle->set("maxsize",10);
$$stStyle->set("size",10);
$$stStyle->set("symbolname",$vwCommPlaceTypes->fields["tip_symname"]);
$stColor = "hTmpColor".$vwCommPlaceTypes->fields["tip_codigo"];//define the color var name
$$stColor = $$stStyle->color;
$aColors = explode(" ", $vwCommPlaceTypes->fields["tip_symcolor"]);
$$stColor->setRGB((int)$aColors[0], (int)$aColors[1], (int)$aColors[2]);
$vwCommPlaceTypes->MoveNext();
}
and, suposing I have 2 reccords, as result I got:
========
...
CLASS
NAME "Bar"
EXPRESSION "13"
STYLE
COLOR 92 192 252
MAXSIZE 10
MINSIZE 5
SIZE 10
SYMBOL "SYM_BAR"
END
END
CLASS
NAME "Farmácia"
EXPRESSION "07"
STYLE
COLOR 64 23 0
MAXSIZE 10
MINSIZE 5
SIZE 10
SYMBOL "SYM_FARMACIA"
END
END
...
========
and it's ok.
But, my question is: if I try to run a code like....
while (!$vwCommPlaceTypes->EOF){
$tmpClass = ms_newClassObj($hTmpLayer);// htmpLayer is my layer
$tmpClass->set("name",$vwCommPlaceTypes->fields["tip_descricao"]);
$tmpClass->setexpression(trim($vwCommPlaceTypes->fields["tip_codigo"]));
$tmpStyle = ms_newStyleObj($tmpClass);
$tmpStyle->set("minsize",5);
$tmpStyle->set("maxsize",10);
$tmpStyle->set("size",10);
$tmpStyle->set("symbolname",$vwCommPlaceTypes->fields["tip_symname"]);
$tmpColor = $tmpStyle->color;
$aColors = explode(" ", $vwCommPlaceTypes->fields["tip_symcolor"]);
$tmpColor->setRGB((int)$aColors[0], (int)$aColors[1], (int)$aColors[2]);
$vwCommPlaceTypes->MoveNext();
}
will it work?
or it will set only 1 class?
thanks
Eduardo Patto Kanegae
http://www.consultoria.eti.br
UIN: 303747254
I Encontro Nacional de Usuários MapServer - http://mapserver.cttmar.univali.br/encontro2004
Projeto MapServer Brasil - http://mapserver.cttmar.univali.br
***Fim da Mensagem / End of Message ***
More information about the MapServer-users
mailing list