Skip to content
Permalink
Browse files

Fix #651 (zoom to layer with one point does not work)

  • Loading branch information
wonder-sk committed Jun 9, 2014
1 parent 48b099c commit bca35539b630baf25d10d373a9c5aa09f1b67fd4
@@ -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

0 comments on commit bca3553

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