Skip to content
Permalink
Browse files

Use constGeometry() instead of geometry() where possible

  • Loading branch information
mhugent committed Jul 22, 2015
1 parent c592d9e commit a972a3020ce45dc03c7e17c68fc39c86e9573e21
@@ -410,25 +410,25 @@ void QgsMapToolNodeTool::createTopologyRubberBands()
}
// Get VertexId of snapped vertex
QgsVertexId vid;
if ( !feature.geometry()->vertexIdFromVertexNr( snapResult.snappedVertexNr, vid ) )
if ( !feature.constGeometry()->vertexIdFromVertexNr( snapResult.snappedVertexNr, vid ) )
{
continue;
}
// Add rubberband if not already added
if ( !mMoveRubberBands.contains( snapFeatureId ) )
{
QgsGeometryRubberBand* rb = new QgsGeometryRubberBand( mCanvas, feature.geometry()->type() );
QgsGeometryRubberBand* rb = new QgsGeometryRubberBand( mCanvas, feature.constGeometry()->type() );
rb->setOutlineColor( Qt::blue );
rb->setBrushStyle( Qt::NoBrush );
rb->setOutlineWidth( 2 );
QgsAbstractGeometryV2* rbGeom = feature.geometry()->geometry()->clone();
QgsAbstractGeometryV2* rbGeom = feature.constGeometry()->geometry()->clone();
if ( mCanvas->mapSettings().layerTransform( vlayer ) )
rbGeom->transform( *mCanvas->mapSettings().layerTransform( vlayer ) );
rb->setGeometry( rbGeom );
mMoveRubberBands.insert( snapFeatureId, rb );
}
// Add to list of vertices to be moved
mMoveVertices[snapFeatureId].append( qMakePair( vid, toMapCoordinates( vlayer, feature.geometry()->geometry()->vertexAt( vid ) ) ) );
mMoveVertices[snapFeatureId].append( qMakePair( vid, toMapCoordinates( vlayer, feature.constGeometry()->geometry()->vertexAt( vid ) ) ) );
}
}
}
@@ -79,7 +79,7 @@ void QgsSelectedFeature::updateGeometry( QgsGeometry *geom )
QgsFeature f;
if ( mVlayer->getFeatures( QgsFeatureRequest().setFilterFid( mFeatureId ) ).nextFeature( f ) )
{
mGeometry = new QgsGeometry( *f.geometry() );
mGeometry = new QgsGeometry( *f.constGeometry() );
}
}
else
@@ -66,7 +66,7 @@ bool QgsVectorLayerEditUtils::moveVertex( const QgsPointV2& p, QgsFeatureId atFe
{
// 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() )
if ( !L->getFeatures( QgsFeatureRequest().setFilterFid( atFeatureId ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( f ) || !f.constGeometry() )
return false; // geometry not found

geometry = *f.geometry();

0 comments on commit a972a30

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