[QGIS-trac] Re: [Quantum GIS] #1822: Zoom to point: exaggerated zoom

Quantum GIS qgis at qgis.org
Sun Aug 2 21:11:33 EDT 2009


#1822: Zoom to point: exaggerated zoom
-----------------------------------------------------+----------------------
        Reporter:  alobo                             |         Owner:  gsherman     
            Type:  bug                               |        Status:  new          
        Priority:  major: does not work as expected  |     Milestone:  Version 1.2.0
       Component:  Python plugins and bindings       |       Version:  HEAD         
      Resolution:                                    |      Keywords:               
Platform_version:                                    |      Platform:  Linux        
        Must_fix:  Yes                               |   Status_info:  0            
-----------------------------------------------------+----------------------
Comment (by gcarrillo):

 I think the exaggerated zoom depends on what scale are your data.

 Maybe the scale factor could be a relative factor with the canvas
 fullExtent as base extent.

 Something like this can be useful (zoomtopoint.py file, run() method):

     mc=self.iface.mapCanvas()[[BR]]
     extent = mc.fullExtent()[[BR]]
     xmin = float(x) - extent.width() / ( 2 * ( 100-scale ) )[[BR]]
     xmax = float(x) + extent.width() / ( 2* ( 100-scale ) )[[BR]]
     ymin = float(y) - extent.height() / (2 * ( 100-scale ) )[[BR]]
     ymax = float(y) + extent.height() / ( 2 *( 100-scale ) )[[BR]]
     rect = QgsRectangle( xmin, ymin, xmax, ymax )[[BR]]
     mc.setExtent(rect)[[BR]]

 x, y are the point coordinates to center[[BR]]
 scale is the factor (1 to detailed scale, 99 to general scale)

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/1822#comment:5>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list