MapScript: Altering classes
Stephen Lime
steve.lime at dnr.state.mn.us
Fri Jul 28 07:53:36 PDT 2000
Problem (i think) is the expression setting. You need to use a special method (nuts, forgot
to update the website on this). Because several types of expressions are supported it wasn't
possible to use the standard way of setting values so a helper function was written.
The syntax is cl0.setExpression('N'). Basically the value for setExpression *must* conform to
the rules for expressions set in the map file docs. That may mean in certain cirumstances
that you may need to include a second set of quotes with strings with spaces or special chars
or just numbers (i.e. $class->setExpression("\"100\"")). I'll update the website ASAP.
Steve
Stephen Lime
Internet Applications Analyst
Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> "Michael Anderson" <m_anderson14 at hotmail.com> 07/28/00 09:45AM >>>
Hello,
I am trying to change the classification of a layer using MapScript. I
change the colors in an existing classes with no problems, but if I try to
set a new classitem and create new classes I get a segmentation error. Here
is my code.
map = mapObj("soils.map")
soilsL = map.getLayerByName('soils')
soilsL.classitem = 'Hydric_c'
cl0 = classObj(soilsL)
cl1 = classObj(soilsL)
green = map.addColor(0,255,0)
blue = map.addColor(0,0,255)
black = map.addColor(0,0,0)
cl0.expression = 'N'
cl1.expression = 'Y'
cl0.color = green
cl1.color = blue
cl0.outlinecolor = black
cl1.outlinecolor = black
soilsL.status = 1
img = map.prepareImage()
soilsL.draw(map,img)
Segmentation fault -- kicked out of Python.
I checked along the way to make sure my variables are referencing valid
objects and everything looks OK. Can someone tell what I am doing wrong. I
am guessing it has something to do with the expression, but it's only a
guess. I can post a Perl version, but I think Python's syntax is clear
enough to express what I am trying to do.
Thanks,
Mike
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
More information about the MapServer-users
mailing list