Can't read long expressions with MapScript

Steve Lime Steve.Lime at DNR.STATE.MN.US
Tue Aug 29 19:08:44 PDT 2006


This is a known issue that has been very difficult to track down.
There's a bug already
filed. It seems to be a lexer issue but I've not been able to find any
hard limits on token
size in flex generate code. I suppose I'll need to roll those sleeves up
again. Could
you tag your information onto bug 1428?

Steve

>>> "B. Veldkamp (Berend)" <b.veldkamp at ZONNET.NL> 08/29/06 2:01 AM >>>
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