[Qgis-developer] updateExtents()

Martin Dobias wonder.sk at gmail.com
Thu Dec 4 09:52:38 EST 2008


Hi Mauricio

On Wed, Dec 3, 2008 at 6:46 PM, Maurício de Paulo
<mauricio.dev at gmail.com> wrote:
> Hi developpers,
> Ok, I have no idea how to really update the extents in a shapefile. Is
> QgsVectorDataProvider::updateExtents() working properly?

I think normally you shouldn't need to call updateExtents() explicitly.

> It's still unknown to me if by editing features using addFeatures() and
> updateFeatureGeometry() I must be in startEditing().
> Nonetheless I tryed the startEditing(), changeGeometryValues(),
> updateExtents(), commitChanges() and it was no different than when I used
> changeGeometryValues() alone.

if you use QgsVectorDataProvider, everytime an editing function is
called, the change is immediately written to storage.

But editing functions of QgsVectorLayer are used this way:
1. startEditing() is called
2. editing functions (add feature / delete feature / modify geometry /
modify attributes) are called, the changes are stored temporarily in
QgsVectorLayer structures
3. rollback() or commitChanges() is called meaning that all changes
are either commited to QgsVectorDataProvider or rolled back (i.e. not
applied).

> How is the best way to change gemetries inside a QgsVectorLayer?

It's up to you which mode suits better to you. If you want to modify a
layer just temporarily giving the user possibility to apply/revert the
changes, using QgsVectorLayer might be better. Otherwise I would use
directly QgsVectorDataProvider to change geometry as this avoids
overhead in QgsVectorLayer that is caching the editations.

Hope that helps,

Martin


More information about the Qgis-developer mailing list