Skip to content

Commit

Permalink
Fix for ticket #651 (zoom full doesn't work on a single point)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6799 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Mar 13, 2007
1 parent fc357ca commit b97db39
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/core/qgsmaprender.cpp
Expand Up @@ -579,6 +579,31 @@ void QgsMapRender::updateFullExtent()
}
it++;
}

if (mFullExtent.width() == 0.0 || mFullExtent.height() == 0.0)
{
// If all of the features are at the one point, buffer the
// rectangle a bit. If they are all at zero, do something a bit
// more crude.

if (mFullExtent.xMin() == 0.0 && mFullExtent.xMax() == 0.0 &&
mFullExtent.yMin() == 0.0 && mFullExtent.yMax() == 0.0)
{
mFullExtent.set(-1.0, -1.0, 1.0, 1.0);
}
else
{
const double padFactor = 1e-8;
double widthPad = mFullExtent.xMin() * padFactor;
double heightPad = mFullExtent.yMin() * padFactor;
double xmin = mFullExtent.xMin() - widthPad;
double xmax = mFullExtent.xMax() + widthPad;
double ymin = mFullExtent.yMin() - heightPad;
double ymax = mFullExtent.yMax() + heightPad;
mFullExtent.set(xmin, ymin, xmax, ymax);
}
}

QgsDebugMsg("Full extent: " + mFullExtent.stringRep());
}

Expand Down

0 comments on commit b97db39

Please sign in to comment.