Skip to content
Permalink
Browse files

Make insertVertex/moveVertex/deleteVertex work without cache

  • Loading branch information
wonder-sk committed Jan 14, 2014
1 parent 47d09fe commit 680ffe0a4ee6881813ff8aabd30e52210a8348c3
Showing with 24 additions and 3 deletions.
  1. +24 −3 src/core/qgsvectorlayereditutils.cpp
@@ -34,7 +34,14 @@ bool QgsVectorLayerEditUtils::insertVertex( double x, double y, QgsFeatureId atF

QgsGeometry geometry;
if ( !cache()->geometry( atFeatureId, geometry ) )
return false; // TODO: support also uncached geometries
{
// it's not in cache: let's fetch it from layer
QgsFeature f;
if ( !L->getFeatures( QgsFeatureRequest().setFilterFid( atFeatureId ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( f ) || !f.geometry() )
return false; // geometry not found

geometry = *f.geometry();
}

geometry.insertVertex( x, y, beforeVertex );

@@ -50,7 +57,14 @@ bool QgsVectorLayerEditUtils::moveVertex( double x, double y, QgsFeatureId atFea

QgsGeometry geometry;
if ( !cache()->geometry( atFeatureId, geometry ) )
return false; // TODO: support also uncached geometries
{
// it's not in cache: let's fetch it from layer
QgsFeature f;
if ( !L->getFeatures( QgsFeatureRequest().setFilterFid( atFeatureId ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( f ) || !f.geometry() )
return false; // geometry not found

geometry = *f.geometry();
}

geometry.moveVertex( x, y, atVertex );

@@ -66,7 +80,14 @@ bool QgsVectorLayerEditUtils::deleteVertex( QgsFeatureId atFeatureId, int atVert

QgsGeometry geometry;
if ( !cache()->geometry( atFeatureId, geometry ) )
return false; // TODO: support also uncached geometries
{
// it's not in cache: let's fetch it from layer
QgsFeature f;
if ( !L->getFeatures( QgsFeatureRequest().setFilterFid( atFeatureId ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( f ) || !f.geometry() )
return false; // geometry not found

geometry = *f.geometry();
}

if ( !geometry.deleteVertex( atVertex ) )
return false;

0 comments on commit 680ffe0

Please sign in to comment.
You can’t perform that action at this time.