[Mapserver-users] mapscript - strange behavior

Christoph Spoerri spoerri at duke.edu
Wed Jan 14 08:50:24 PST 2004


One thing I wanted to add: the reason I need to create the 'acetate' layer on 
the fly is that I'm mapping different layer types (point, line, polygon) and 
therefore the classes change. I'm using a pin as point marker, and red lines 
for lines/polygons.

BTW, when mapping lines, the first feature (line) does not display with the 
correct class either (at least it shows though). So does anybody know what 
the problem actually is with not showing the first feature correctly or not 
at all? 

Thanks, Christoph

On Tuesday 13 January 2004 02:28 pm, Sean Gillies wrote:
> On Jan 13, 2004, at 10:38 AM, Christoph Spoerri wrote:
> > 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.e
> > xtension
> > 	mapImg.save(mapImg.imagepath+imagename)
>
> Christoph,
>
> Do I remember correctly that you are using mod_python?  Is this a reason
> why you say that you cannot predefine your acetate layer?  I hope you
> are
> not trying to persist a mapObj in the same way that mod_python users use
> persistent database connections.  MapServer is not fully thread-safe
> (yet)
> and so you will certainly encounter some trouble with a persistent
> mapObj.
>
> I don't see _anything_ in your code that would prevent the acetate layer
> from being predefined in your map file.  If it is only a matter of
> colors and styles, I strongly recommend that you predefine the acetate
> layer and then modify its classes and styles during the script
> execution.
>
> cheers,
> Sean
>
> --
> Sean Gillies
> sgillies at frii dot com
> http://users.frii.com/sgillies




More information about the MapServer-users mailing list