1

I am working with c++/QT and c++api gqis 2.8.2

I want to change the geometry of a feature, I have this code :

QgsVectorLayer * lLayer = mMapLayer.value(TRACKS);
QgsVectorDataProvider * lDataProvider;
lDataProvider = lLayer->dataProvider();
//create point
gsGeometry * MyPoint;
MyPoint = QgsGeometry::fromPoint(QgsPoint(PosX,PosY));
QgsGeometryMap MyGeometryMap;
QgsFeatureId MyFeatureId;

MyGeometryMap.insert(MyFeatureId,MyPoint);

lDataProvider->changeGeometryValues(MyGeometryMap);

I don't understand why i have an error on the insert :

error: no matching function for call to ‘QMap::insert(QgsFeatureId&, QgsGeometry*&)’ MyGeometryMap.insert(MyFeatureId,MyPoint); ^ src/IHM/mainwindow.cpp:599:42: note: candidate is: In file included from /usr/local/Trolltech/Qt-4.8.5/include/QtCore/qvariant.h:49:0, from /usr/local/Trolltech/Qt-4.8.5/include/QtCore/QVariant:1, from /usr/local/include/qgis/qgis.h:25, from src/Core/common.h:13, from src/Core/libcarto.h:12, from src/IHM/mainwindow.h:24, from src/IHM/mainwindow.cpp:20:

Any idea ?

1 Answer 1

1

Here is the solution

gsGeometry * MyPoint;
MyPoint = QgsGeometry::fromPoint(QgsPoint(PosX,PosY));
QgsGeometryMap MyGeometryMap;
QgsFeatureId MyFeatureId;

MyGeometryMap.insert(MyFeatureId,*MyPoint);

or this way

gsGeometry MyPoint;
MyPoint.fromPoint(QgsPoint(PosX,PosY));
QgsGeometryMap MyGeometryMap;
QgsFeatureId MyFeatureId;

MyGeometryMap.insert(MyFeatureId,MyPoint);

sorry for this stupid error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.