Opened 17 years ago

Closed 14 years ago

#2026 closed defect (wontfix)

mapObj.setSymbolSet fails if setExpression has been called previously on a classObj

Reported by: kobold@… Owned by: hobu
Priority: high Milestone: 5.6 release
Component: MapScript-Python Version: 4.10
Severity: normal Keywords:
Cc: sdlime

Description (last modified by hobu)

The following python script shows the problem, which is unrelated to the content
of the symbolset file. Just comment-out the setExpression on the row before the
last line and the script works nicely.

import mapscript
mapobj=mapscript.mapObj()
outputFormat=mapscript.outputFormatObj("GD/PNG")
outputFormat.name="png24"
outputFormat.setMimetype("image/png")
outputFormat.imagemode=1
outputFormat.setExtension("png")
mapobj.legend.status=1
mapobj.legend.keysizex=100
mapobj.legend.keysizey=30
mapobj.legend.keyspacingy=20
mapobj.legend.width=100
mapobj.setSize(600,1200)
mapobj.setExtent(132771,447652,134477,451064)
mapobj.setOutputFormat(outputFormat)
style=mapscript.styleObj()
style.symbolname="point5"
style.color=mapscript.colorObj(225,0,0)
cls=mapscript.classObj()
cls.insertStyle(style)
cls.name="testclass"
cls.setExpression("(4 + 4)")
mapobj.setSymbolSet('test_symbols.set')

This is the error:

Traceback (most recent call last):
  File "test.py", line 23, in ?
    mapobj.setSymbolSet('test_symbols.set')
  File "/usr/lib/python2.4/site-packages/mapscript.py", line 1382, in setSymbolSet
    def setSymbolSet(*args): return _mapscript.mapObj_setSymbolSet(*args)
_mapscript.MapServerError: loadSymbolSet(): Unknown identifier. Parsing error
near ():(line 0)

Change History (8)

comment:1 by hobu, 17 years ago

Cc: sdlime added
Description: modified (diff)
Milestone: 5.0 release

Two things:

1) Is (4+4) a valid expression? I thought we didn't allow math/operators except for simple things like string length.

2) MapServer 5.0 only exhibits the complaint about the symbolset

    mapobj.setSymbolSet('test_symbols.set')
IOError: loadSymbolSet(): Unable to access file. (test_symbols.set

I think what was happening is setExpression was throwing an error but not returning NULL. The error sticks around until another error that *did* return NULL was made (the complaint about not finding the symbolset). If I'm not mistaken, this expression is now valid in 5.0, and MapScript properly throws the error for the missing symbolset. Declaring this one fixed and cc'ing Steve to see if he has any comment.

comment:2 by hobu, 17 years ago

Steve,

loadExpressionString looks like it always returns 0 at the bottom of the function, which means MapScript is never going to throw an exception. Is this what we want? I assume this is because the evaluation of the expression is held off until render time, right?

comment:3 by sdlime, 17 years ago

All loadExpressionString does is set the stage for parsing. It doesn't (and can't) evaluate the validity of the expression until runtime. loadExpressionString is actually very lax about what is passed. If I recall, it looks for logical and regular expressions and if those don't match it just assumes a string expression. Basically it can't fail. An expression like (4+4) should evaluate to true all the time so would be legit, but useless. Try it in a mapfile to see.

Steve

in reply to:  3 comment:4 by kobold, 17 years ago

Just for your information: if I move the call to setExpression after the call to setSymbolSet, the error goes away. Even if I call setExpression multiple times, nothing happens: it seems to me that setExpression leaves some sort of "state" around that setSymbolSet doesn't like.

I don't think that the expression itself is a problem.

Thanks, Fabio

comment:5 by hobu, 17 years ago

I'm not convinced there's any sort of problem here. setExpression indeed sets up the an expression that is not used or verified until render time. I am not able to reproduce the complaint about setSymbolSet not being able to be opened if a call to setExpression is not there, however.

in reply to:  5 comment:6 by kobold, 17 years ago

Well, non-deterministic behaviour is something I would call a bug: the symbolset file is right, otherwise mapserver would complain about it even without the setExpression method.

comment:7 by hobu, 17 years ago

Milestone: 5.0 release5.2 release

I can't replicate this. Pushing it ahead to 5.2 for now.

comment:8 by dmorissette, 14 years ago

Resolution: wontfix
Status: newclosed

Closing WONTFIX since this could not be reproduced and has not been touched in over 2 years.

Note: See TracTickets for help on using tickets.