[Qgis-developer] Fwd: Using api to move features

Jordi Torres jtorresfabra at gmail.com
Fri Jun 14 03:50:48 PDT 2013


OOPs forgot to send it to the list.


Hi Marco,

This is working for me, don't know if is the best option:

//_vector Layer is a point layer in memory
 _vectorLayer->startEditing();
 QgsGeometryMap m;
//Pass the feature id and the new x,y
 m.insert(feature.id(),*QgsGeometry::fromPoint(QgsPoint(x,y)));
 _vectorLayer->dataProvider()->changeGeometryValues(m);
 _contactLayer->updateExtents();
 _contactLayer->commitChanges();
 _contactLayer.triggerRepaint();

Hope it helps.


2013/6/14 Marco Gomes <marco.gomes at edisoft.pt>

> I am trying to move features in a Qt timer without success. What it is
> missing?****
>
> ** **
>
> Below all my trials to make this work.  ****
>
> ** **
>
>        //pointMarkersLayer->dataProvider()->changeGeometryValues(geomMap);
> ****
>
>        //pointMarkersLayer->updateFeature(featureRoute_p);****
>
>                     ****
>
> ** **
>
>        //pointMarkersLayer->changeGeometry(featureRoute_p.id(), geometry);
> ****
>
>        //pointMarkersLayer->moveVertex(finalPoint.x(), finalPoint.y(),
> featureRoute_p.id(), 0);****
>
> ** **
>
>        //pointMarkersLayer->changeGeometry(featureRoute_p.id(), geometry);
> ****
>
>        //pointMarkersLayer->updateFeature(featureRoute_p);****
>
>        //categorizedSymbolRendererV2->renderFeature(featureRoute_p,
> QgsRenderContext(), pointMarkersLayer->id().toInt(), false, false);****
>
> ** **
>
>        //pointMarkersLayer->startEditing();****
>
>        //pointMarkersLayer->select(featureRoute_p.id(), false);****
>
> ** **
>
>        //featureRoute_p.setGeometry(QgsGeometry::fromPoint(finalPoint));**
> **
>
>        //pointMarkersLayer->updateFeature(featureRoute_p);****
>
> ** **
>
>        //float dx = finalPoint.x() -
> featureRoute_p.geometry()->asPoint().x();****
>
>        //float dy = finalPoint.y() -
> featureRoute_p.geometry()->asPoint().y();****
>
> ** **
>
>        //pointMarkersLayer->translateFeature(featureRoute_p.id(), dx, dy);
> ****
>
> ** **
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>


-- 
Jordi Torres





-- 
Jordi Torres
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130614/9aac99e7/attachment-0001.html>


More information about the Qgis-developer mailing list