[Qgis-developer] Editing the geometry of a feature

Tim Sutton tim at linfiniti.com
Tue Oct 23 20:50:38 EDT 2007


Hi Roger

Which provider and data format are you using? Not all formats support
write operations. I suspect you need to indicate to the layer that
editing is started and then commit your changes when editing is done.
Take a look at the code behind the start and stop editing options in
the legend it may give you some hints.

Regards

Tim

2007/10/22, Tait, Roger <roger.tait at ntu.ac.uk>:
> Hi,
>
>
>
> I have a QGis::WKBPoint based vector layer containing a single feature.
>
> I want to change the position of the feature using a single click of a button embedded in the tool bar.
>
> I have unsuccessfully tried to change the position using the following:
>
>
>
>
>
> void QgisApp::trackWayPoint()
>
> {
>
>
>
>    ...
>
>    ...
>
>
>
>    QgsFeature *feature = pointLayer->getFirstFeature(true,false);
>
>    QgsGeometry *geometry = feature->geometry();
>
>
>
>    unsigned char *wkb = geometry->wkbBuffer();
>
>
>
>    memcpy(&wkb[5], &newPosX, sizeof(double));
>
>    memcpy(&wkb[5]+sizeof(double), &newPosY, sizeof(double));
>
>
>
> }
>
>
>
>
>
>
>
> The correct feature and geometry are referenced however for some reason the new position is lost before the feature is drawn to screen.
>
> I have also tried commitAttributeChanges(const std::set<QString>& deleted, ... ,std::map<QString,QString> >& changed); without success.
>
>
>
> Please tell me how I can change the position of a feature?
>
>
>
> Thanks Roger
>
> This email is intended solely for the addressee.  It may contain private and confidential information.  If you are not the intended addressee, please take no action based on it nor show a copy to anyone.  In this case, please reply to this email to highlight the error.  Opinions and information in this email that do not relate to the official business of Nottingham Trent University shall be understood as neither given nor endorsed by the University.
> Nottingham Trent University has taken steps to ensure that this email and any attachments are virus-free, but we do advise that the recipient should check that the email and its attachments are actually virus free.  This is in keeping with good computing practice.
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>


-- 
Tim Sutton
QGIS Project Steering Committee Member - Release  Manager
Visit http://qgis.org for a great open source GIS
openModeller Desktop Developer
Visit http://openModeller.sf.net for a great open source ecological
niche modelling tool
Home Page: http://tim.linfiniti.com
Skype: timlinux
Irc: timlinux on #qgis at freenode.net



More information about the Qgis-developer mailing list