mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Fix #651 (zoom to layer with one point does not work)
This commit is contained in:
parent
48b099c8b6
commit
bca35539b6
@ -77,7 +77,11 @@ class QgsRectangle
|
||||
//! expand the rectangle so that covers both the original rectangle and the given point
|
||||
void combineExtentWith( double x, double y );
|
||||
//! test if rectangle is empty
|
||||
//! Empty rectangle may still be non-null if it contains valid information (e.g. bounding box of a point)
|
||||
bool isEmpty() const;
|
||||
//! test if the rectangle has all coordinates zero. Null rectangle is also an empty rectangle.
|
||||
//! @note added in 2.4
|
||||
bool isNull() const;
|
||||
//! returns string representation in Wkt form
|
||||
QString asWktCoordinates() const;
|
||||
//! returns string representation as WKT Polygon
|
||||
|
@ -929,7 +929,7 @@ void QgsMapRenderer::updateFullExtent()
|
||||
QgsDebugMsg( "Updating extent using " + lyr->name() );
|
||||
QgsDebugMsg( "Input extent: " + lyr->extent().toString() );
|
||||
|
||||
if ( lyr->extent().isEmpty() )
|
||||
if ( lyr->extent().isNull() )
|
||||
{
|
||||
++it;
|
||||
continue;
|
||||
|
@ -430,7 +430,7 @@ QgsRectangle QgsMapSettings::fullExtent() const
|
||||
QgsDebugMsg( "Updating extent using " + lyr->name() );
|
||||
QgsDebugMsg( "Input extent: " + lyr->extent().toString() );
|
||||
|
||||
if ( lyr->extent().isEmpty() )
|
||||
if ( lyr->extent().isNull() )
|
||||
{
|
||||
it++;
|
||||
continue;
|
||||
|
@ -194,6 +194,11 @@ bool QgsRectangle::isEmpty() const
|
||||
return xmax <= xmin || ymax <= ymin;
|
||||
}
|
||||
|
||||
bool QgsRectangle::isNull() const
|
||||
{
|
||||
return xmin == 0 && xmax == 0 && ymin == 0 && ymax == 0;
|
||||
}
|
||||
|
||||
QString QgsRectangle::asWktCoordinates() const
|
||||
{
|
||||
QString rep =
|
||||
|
@ -99,8 +99,12 @@ class CORE_EXPORT QgsRectangle
|
||||
void combineExtentWith( QgsRectangle *rect );
|
||||
//! expand the rectangle so that covers both the original rectangle and the given point
|
||||
void combineExtentWith( double x, double y );
|
||||
//! test if rectangle is empty
|
||||
//! test if rectangle is empty.
|
||||
//! Empty rectangle may still be non-null if it contains valid information (e.g. bounding box of a point)
|
||||
bool isEmpty() const;
|
||||
//! test if the rectangle has all coordinates zero. Null rectangle is also an empty rectangle.
|
||||
//! @note added in 2.4
|
||||
bool isNull() const;
|
||||
//! returns string representation in Wkt form
|
||||
QString asWktCoordinates() const;
|
||||
//! returns string representation as WKT Polygon
|
||||
|
@ -200,6 +200,9 @@ void QgsLayerTreeViewDefaultActions::zoomToLayers( QgsMapCanvas* canvas, const Q
|
||||
|
||||
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( layer );
|
||||
|
||||
if ( vLayer->geometryType() == QGis::NoGeometry )
|
||||
continue;
|
||||
|
||||
if ( layerExtent.isEmpty() && layer->type() == QgsMapLayer::VectorLayer )
|
||||
{
|
||||
qobject_cast<QgsVectorLayer*>( layer )->updateExtents();
|
||||
@ -216,7 +219,7 @@ void QgsLayerTreeViewDefaultActions::zoomToLayers( QgsMapCanvas* canvas, const Q
|
||||
extent.combineExtentWith( &layerExtent );
|
||||
}
|
||||
|
||||
if ( extent.isEmpty() )
|
||||
if ( extent.isNull() )
|
||||
return;
|
||||
|
||||
// Increase bounding box with 5%, so that layer is a bit inside the borders
|
||||
|
Loading…
x
Reference in New Issue
Block a user