[Qgis-developer] Using api to move features

Jordi Torres jtorresfabra at gmail.com
Fri Jun 14 03:54:21 PDT 2013


One more thing:

It should be _vectorLayer instead of _contactLayer in the last three lines.

Cheers.


2013/6/14 Jordi Torres <jtorresfabra at gmail.com>

> 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
>
>
>


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


More information about the Qgis-developer mailing list