[Mapserver-users] Mapscript: SOLVED: Display points on the fly

Bjoern Platzen bplatzen at sosnetz.de
Wed Jul 9 10:59:00 EDT 2003


Hi,

After trying some other Keywords on the listarchive I found a message, 
that could help me...

I didn't recognize, that I'll have to add a new Feature to the shape...

This way, it works:
def _drawPoint(self, point):
        myLayer = self.mymap.getLayerByName('onthefly')
        newShape = mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
        part = mapscript.lineObj()
        newPoint = mapscript.pointObj()
        newPoint.x = point[0]
        newPoint.y = point[1]
        part.add(newPoint)
        newShape.add(part);
        myLayer.addFeature(newShape)
        myLayer.status = mapscript.MS_ON
        self.layers.append('onthefly')

If you think, it would make sense, we could put the map-class, that I'm 
building into the Wiki. There is not much about PythonMapScript and I 
think there may be more Newbies like me (who are not able to understand 
100% of the perl-examples )... 8~)

Bye,

Bjoern

Am Mittwoch, 9. Juli 2003 16:01 schrieb Bjoern Platzen:
> Hi,
>
> I'm trying to display a point at the last klickpoint in the map, but
> it doesn't appear on the map. I know that this has been discussed on
> the list a few times, but all the Examples I found were in Perl and
> I'm not really a Perl-programmer...
>
> First of all, the mapObj (self.mymap) is defined and the image is
> prepared with
>
> self.myimage=self.mymap.prepareImage()
>
> My function to draw the point looks like that:
>
> def _drawPoint(self, point):
>
>     pLayer = self.mymap.getLayerByName('onthefly')
>     pLayer.status = mapscript.MS_ON
>     newPoint = mapscript.pointObj()
>     newPoint.x, newPoint.x = point[0], point[1]
>     newPoint.draw(self.mymap, pLayer, self.myimage, 0, 'Klick')
>     self.layers.append('onthefly')
>
> point is a tuple of the map-coordinates (eg. (2548085.3064984209,
> 5674031.5200534584).
>
> After _drawPoint, the function _drawLayers is called:
>
> def _drawLayers(self):
>     for l in self.layers:
>         ll = self.mymap.getLayerByName(l)
>         str(ll)
>         ll.draw(self.mymap, self.myimage)
>
> self.layers contains the layer-names
>
> After that, the image is saved with
>
> def makemap(self):
>     self.mymap.drawLabelCache(self.myimage)
>     out =
> self.myimage.saveImage(self.imgpath+self.outname,mapscript.MS_PNG,0,0
>,50) self.mapimg = self.imgpath+self.outname
>
> In my mapfile, Ive got a layer 'onthefly':
>
> LAYER
>   NAME 'onthefly'
>   TYPE POINT
>   STATUS OFF
>   CLASS
>     Symbol 'phk'#Image-Symbol
>   END
> END
>
> What am I missing?
>
> Bye, Bjoern

-- 
small office solutions
info at sosnetz.de  -  http://www.sosnetz.de




More information about the mapserver-users mailing list