Skip to content
Permalink
Browse files

optimize request by fetching the required extend

  • Loading branch information
3nids committed Oct 25, 2018
1 parent 80d0c33 commit d1f0ae4740b4d8345a18284841ec94c09ba341fd
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/gui/qgsmapcanvas.cpp
@@ -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;
@@ -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 );
}
}

0 comments on commit d1f0ae4

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