[Mapserver-users] python mapscript 4.0.1, style, symbol...

Romain Chantereau romain at mezimail.com
Thu Feb 19 03:39:52 PST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

I want to display a symbol (pixmap, or vector) on a map where the user
clicked.

I'm very confused with the interaction between style/class/layer/symbol
etc...

In fact, I was able to set symbol and draw them with the example here:
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PythonMapScriptExamples401ex1

But in my code, I have to create this point layer from scratch (and use
the feature function).

Everything went ok... Except the symbol drawing.

Il have only the point (in any color I want), I cannot draw a vector
netheir a pixmap symbol...


When I do a symbolset.getSymbolByName with the name of the symbol I got
the correct instanciated symbol Object.

This raised another problem, during my investigation, I wanted to create
a map from scratch and just display a symbol in the middle of nowhere.

I don't understand how to add symbol to the map symbol set on the fly.

(in python mapscript, of course, I think in C, I would increase the
numstyle +1 and alloc mem + size(symbolObj))

Here the piece of code and the generated section of the mapfile.
It will make about 5 days I am on this problem now, I begin to become
insane, please save my neigbour from a certain death.

Here the piece of code:
~        map = self.getMapObject(mapId)
~        map.resetMap()
~        mapObj = map.mapObj
~        layerObj = mapscript.layerObj(mapObj)
	layerObj.status =  mapscript.MS_ON
	layerObj.type = mapscript.MS_LAYER_POINT
	layerObj.name = "Point de Saisie"
~        layerObj.template = "bogus.html"
~        layerObj.tolerance = 10
	classObj = mapscript.classObj(layerObj)
~        #styleObj = mapscript.styleObj()
~        styleObj = classObj.styles
~        colorObj = styleObj.color
~        colorObj.red, colorObj.green, colorObj.blue = (0,0,0)
~        #styleObj.outlinecolor.red = 255
~        #styleObj.backgroundcolor.red = 255
~        styleObj;symbol = 2
~        #styleObj.symbolname = "flag2"
~        styleObj.symbolname = "plus"
~        #classObj.size = 50
~        styleObj.size = 10
~        #styleObj.minsize = 50
~        #styleObj.maxsize = 100
~        #classObj.styles = styleObj
~        classObj.name = 'saisie'
~        classObj.numstyles = 1
	classObj.status = mapscript.MS_ON
~        labelObj = classObj.label
~        labelObj.color.red = 255
~        labelObj.type = mapscript.MS_BITMAP
~        labelObj.size = mapscript.MS_MEDIUM
~        labelObj.offsetx = 10
~        labelObj.offsety = 10

~        pointObj = mapscript.pointObj()
~        pointObj.x = x
~        pointObj.y = y


	lineObj = mapscript.lineObj()
~        lineObj.add(pointObj)
~        shapeObj = mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
	shapeObj.add(lineObj)
~        shapeObj.setBounds()
~        layerObj.addFeature(shapeObj)

~        mapObj.outputformat.transparent = 0
~        imageObj = mapObj.prepareImage()
~        #symbol = mapObj.symbolset.getSymbolByName('flag2')
~        #symbol = mapObj.symbolset.getSymbol(2)

~        imageObj = mapObj.draw()
~        #shapeObj.draw(mapObj, layerObj, imageObj)
~        pointObj.draw(mapObj, layerObj, imageObj, 0, 'saisie')
~        mapObj.drawLabelCache(imageObj)
~        mapObj.save('/tmp/map.map')
~        tmp = open('/tmp/map.png','w')
~        tmp.write(imageObj.saveToString())
~        tmp.close()

Mapfile Section:

~  LAYER
~    NAME "Point de Saisie"
~    SIZEUNITS PIXELS
~    STATUS ON
~    TEMPLATE "bogus.html"
~    TOLERANCE 10
~    TOLERANCEUNITS PIXELS
~    TYPE POINT
~    UNITS METERS
~    CLASS
~      NAME "saisie"
~      LABEL
~        SIZE MEDIUM
~        TYPE BITMAP
~        BUFFER 0
~        COLOR 255 0 0
~        FORCE FALSE
~        MINDISTANCE -1
~        MINFEATURESIZE -1
~        OFFSET 10 10
~        PARTIALS TRUE
~        POSITION CC
~      END
~      STYLE
~          COLOR 0 0 0
~        MAXSIZE 100
~        MINSIZE 1
~        SIZE 10
~        SYMBOL "plus"
~      END
~    END
~    FEATURE
~      POINTS
~        600636 2.4273e+06
~      END
~    END
~  END



- --
Romain Chantereau
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFANKCH9uawmXu5rjARAvHhAJ0TQRxFNKrhTwQfjMRY24VybL5gNACfXMuX
BdQr8GNUtjslIBHPwqC8+YM=
=NZmj
-----END PGP SIGNATURE-----



More information about the MapServer-users mailing list