Can't read long expressions with MapScript
B. Veldkamp (Berend)
b.veldkamp at ZONNET.NL
Tue Aug 29 00:01:02 PDT 2006
Hi,
I wrote some code in PHP MapScript that generates expressions for
classes in a layer. Basically the expressions look like: ( "[RIKZCODE]"
IN "ID1,ID2,ID3" )
where IDx are feature IDs. Most of the time this works without any
problem, but it looks like there's a limit to the number of ID's I can
add. At least, I can /set/ the expression, but I can't /read/ it with
$class->getExpression(). I did some testing, and it looks like
getExpression() fails when the expression set in the map is over 512
characters.
Here's what the code looks like:
// All expressions are initially set to "empty"
while(odbc_fetch_row($records))
{ $rikzcode = odbc_result ($records, odbc_field_name ($records, 1));
$value = odbc_result ($records, odbc_field_name ($records, 2));
// Determine class to which this ID belongs
$classID = GetClassIDByValue($value);
if ($classID > -1)
{
$cls = $layer->getClass($classID);
$exp = $cls->getExpression(); // <== Crash here
if ($exp == "\"empty\"") $exp = "( \"[RIKZCODE]\" IN
\"$rikzcode\" )"; // initial value
else
$exp = substr($exp, 0, -3) . ",$rikzcode\" )"; // append value
$cls->setExpression($exp);
}
}
--
Berend Veldkamp
Havikstraat 45C
3514 TM Utrecht
More information about the MapServer-users
mailing list