[Qgis-developer] Trouble with QgsGeometry contains(QgsPoint *p)
function
Matthew Denno
mgdenno at gmail.com
Fri Jul 31 01:02:52 EDT 2009
Hello Developers,
I am working on a little application using QGIS and am having trouble using
the QgsGeometry contains(QgsPoint *p) function. I have included the section
of code that is not working for me as well as the error message I am
getting. It appears that currentGeometry2 is not of type QgsGeometry*, but I
can't figure out why. This is the first application I have tried to write
using C++ so the solution may be more of a C++ question than a QGIS
problem...not sure.
Any help or pointers would be greatly appreciated.
Thanks,
Matt
CODE:
// Instantiate Provider Register
QgsProviderRegistry::instance(myPluginsDir);
//Open the shapefile vector layer from file
QgsVectorLayer * mypVectorLayer = new QgsVectorLayer(myLayerPath,
myLayerBaseName, myProviderName);
QgsVectorLayer * mypVectorLayer2 = new QgsVectorLayer(myLayerPath3,
myLayerBaseName, myProviderName);
//create a holder for retrieving point features from the provider
QgsFeature currentFeature;
QgsVectorDataProvider * dataProvider = mypVectorLayer->dataProvider();
mypVectorLayer->select(dataProvider->attributeIndexes());
//create a holder for retrieving mask features from the provider
QgsFeature currentFeature2;
QgsVectorDataProvider * dataProvider2 = mypVectorLayer2->dataProvider();
mypVectorLayer2->select(dataProvider2->attributeIndexes());
//now iterate through each point feature
while (mypVectorLayer->nextFeature(currentFeature))
{
//get point geometry for current feature
QgsGeometry * currentGeometry = currentFeature.geometry();
QgsPoint currentPoint = currentGeometry->asPoint();
//now interate through each polygon feature
while (mypVectorLayer2->nextFeature(currentFeature2))
{
//get polygon geometry for current feature
QgsGeometry * currentGeometry2 = currentFeature2.geometry();
QgsPolygon currentPolygon = currentGeometry2->asPolygon();
//check if point is contained in polygon
if(currentGeometry2.contains(currentPoint))
{
//do something with points that are within the current polygon
}
}
}
ERROR:
/home/matt/Programming/TestingCreator/delaunay_intersect.h:87:
error: request for member ‘contains’ in ‘currentGeometry2’, which is of
non-class type ‘QgsGeometry*’
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090731/dc13317e/attachment.html
More information about the Qgis-developer
mailing list