[Qgis-developer] How to use intersects and difference using API c++?

Marco Gomes marco.gomes at edisoft.pt
Mon Sep 23 02:08:27 PDT 2013


Hi,

 

I am using the code below to test for geometry intersection and in case
of success remove the intersection part from another geometry, but it is
not working.

 

The polygonCoverageAreasLayer is a memory polygon layer, and feature is
circle built using rubberBand and the final result is still a circle and
not the difference with my base map costalLineLayer.

 

                           polygonCoverageAreasLayer->startEditing();

                           attrListCL =
costalLineLayer->dataProvider()->attributeIndexes();

 
costalLineLayer->dataProvider()->select(attrListCL);

 
while(costalLineLayer->dataProvider()->nextFeature(featureCL))

                           {

                                  if
(feature.geometry()->intersects(featureCL.geometry()))

                                  {

                                        QgsGeometry *geom =
feature.geometry()->difference(featureCL.geometry());

                                        feature.setGeometry(geom);
//applying new geometry

 
polygonCoverageAreasLayer->updateFeature(feature);


                                  }

                           }

                           polygonCoverageAreasLayer->commitChanges();

 

 

Any clue, for what I am doing wrong?

 

Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130923/a92fa975/attachment.html>


More information about the Qgis-developer mailing list