Skip to content

Commit 2a20064

Browse files
author
g_j_m
committedMar 13, 2007
Fix for ticket #651 (zoom to full extent doesn't work for a single point
layer) git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6800 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1322743 commit 2a20064

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
 

‎src/gui/qgsmaplayerset.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,29 @@ void QgsMapLayerSet::updateFullExtent()
7878
}
7979
it++;
8080
}
81+
82+
if (mFullExtent.width() == 0.0 || mFullExtent.height() == 0.0)
83+
{
84+
// If all of the features are at the one point, buffer the
85+
// rectangle a bit. If they are all at zero, do something a bit
86+
// more crude.
87+
88+
if (mFullExtent.xMin() == 0.0 && mFullExtent.xMax() == 0.0 &&
89+
mFullExtent.yMin() == 0.0 && mFullExtent.yMax() == 0.0)
90+
{
91+
mFullExtent.set(-1.0, -1.0, 1.0, 1.0);
92+
}
93+
else
94+
{
95+
const double padFactor = 1e-8;
96+
double widthPad = mFullExtent.xMin() * padFactor;
97+
double heightPad = mFullExtent.yMin() * padFactor;
98+
double xmin = mFullExtent.xMin() - widthPad;
99+
double xmax = mFullExtent.xMax() + widthPad;
100+
double ymin = mFullExtent.yMin() - heightPad;
101+
double ymax = mFullExtent.yMax() + heightPad;
102+
mFullExtent.set(xmin, ymin, xmax, ymax);
103+
}
104+
}
105+
81106
}

0 commit comments

Comments
 (0)
Please sign in to comment.