[Mapserver-users] mapscript - strange behavior

Christoph Spoerri spoerri at duke.edu
Tue Jan 13 09:38:52 PST 2004


Hi there,

I'm writing an application that let's user add point features to the map by 
clicking on any location of the map. For this purpose I'm using the attached 
code (Note: each click on the map results in a request to the server for a 
new image).

The problem is that the first point (to be mapped) is not displayed on the 
map. Yet when the user clicks on the map for the second time (to add a new 
point) both points show up. When checking the .map files everything looks 
fine: acetate layer is there, class definition looks fine and point 
coordinates are there.

In case a predefine the acetate layer (w/ class def) in the base .map file, 
the first point shows up just fine. Note: this solution is not an option 
thought :(

any ideas? Thanks in advance,
Christoph


*********** code ********************

	x = atof(param['x'])
	y = atof(param['y'])
	# create point object
 	ptCoord = getMapPoint([x,y],self._map)
 	ptObj = pointObj()
 	ptObj.x=ptCoord[0]
 	ptObj.y=ptCoord[1]
	lnObj = lineObj()
	lnObj.add(ptObj)

	# create new point layer with class and add shape
	mapImg=self._map.prepareImage()
		lyrAcetate = self._map.getLayerByName('acetate')
	if (not isinstance(lyrAcetate,layerObj)):
		color = colorObj()
		color.red = 255
		color.green = 255
		color.blue = 255
		lyrAcetate = layerObj(self._map)
		lyrAcetate.name = "acetate"
		lyrAcetate.type = MS_LAYER_POINT
		classTemp = classObj(lyrAcetate)
		styl = styleObj()
		styl.symbolname = "pin"
		styl.size = 1
		styl.maxsize = 1
		styl.minsize = 1
		styl.color = color
		styl.backgroundcolor = color
		styl.outlinecolor = color
		classTemp.numstyles=1
		classTemp.styles = styl

	# create shape object and add point to shape object
	shpObj = shapeObj(MS_SHAPE_POINT)
	shpObj.add(lnObj)
	shpObj.setBounds();
	shpObj.index = 1

	lyrAcetate.status = MS_ON
	lyrAcetate.addFeature(shpObj)
	lyrAcetate.draw(self._map,mapImg)

	imagename =   \ 
self._map.name+mapSession.id()+"_"+str(int(time()))+"."+mapImg.format.extension
	mapImg.save(mapImg.imagepath+imagename)




More information about the MapServer-users mailing list