Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
optimize request by fetching the required extend
  • Loading branch information
3nids committed Oct 25, 2018
1 parent 80d0c33 commit d1f0ae4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -995,8 +995,9 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer *layer )
// also check that rect is empty, as it might not in case of multi points
if ( layer->geometryType() == QgsWkbTypes::PointGeometry && rect.isEmpty() )
{
int scaleFactor = 5;
QgsPointXY center = mSettings.mapToLayerCoordinates( layer, rect.center() );
QgsRectangle extentRect = mSettings.mapToLayerCoordinates( layer, extent() );
QgsRectangle extentRect = mSettings.mapToLayerCoordinates( layer, extent() ).scaled( 1.0 / scaleFactor );
QgsFeatureRequest req = QgsFeatureRequest().setFilterRect( extentRect ).setLimit( 1000 ).setNoAttributes();
QgsFeatureIterator fit = layer->getFeatures( req );
QgsFeature f;
Expand All @@ -1017,7 +1018,7 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer *layer )
{
// combine selected point with closest point and scale this rect
rect.combineExtentWith( mSettings.layerToMapCoordinates( layer, closestPoint ) );
rect.scale( 5, &center );
rect.scale( scaleFactor, &center );
}
}

Expand Down

0 comments on commit d1f0ae4

Please sign in to comment.