[Qgis-developer] Plotting Moving Points on a map

Luca Pascale pascale.luca.it at gmail.com
Thu Jun 11 06:41:15 EDT 2009


I am trying to develop a "proof of concept" apps that read some points
position (lat,lon) from a DB and plot it over a map (vector or raster or
something other) at 1 time per second rate.

To do that I make a QGIS python plugin that add a Point Vector Layer to the
mapcanvas,
add a Feature (1 point) using the following code:

    vl = QgsVectorLayer("Point", "provaLayer", "memory")

#Create Layer
    QgsMapLayerRegistry.instance().addMapLayer(vl)
    pr = vl.dataProvider()

# add a feature
    x=12.108
    y=42.066
    point = QgsPoint()
    point.setX(x)
    point.setY(y)
    geom = QgsGeometry()

    fet = QgsFeature()
    fet.setGeometry(geom.fromPoint(point))
    pr.addFeatures( [ fet ] )
    vl.updateExtents()

It works.

After that I want to wait 1 second (for example) and replot the same Feature
on an update coordinate (x1,y1)= (x,y+something).

I have tried vl.changeGeometry(.....) but don't works. Any suggestions ?


Moreover I need that only the Point Vector Layer being refreshed and not
also the underlying map. Otherway while refresh has done I'll see a white
screen without any map.



Please Help me...
Tanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090611/d3944bb0/attachment.html


More information about the Qgis-developer mailing list