Skip to content
Permalink
Browse files

Fix for #707. When there were no features in provider, calculation st…

…arted

with extent with null coordinates and extended it - that's reason of wrong extent


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7128 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Aug 6, 2007
1 parent d2e1e22 commit 7f5264dada9b4fefae3669d66917137b73eb8a11
Showing with 14 additions and 12 deletions.
  1. +14 −12 src/core/qgsvectorlayer.cpp
@@ -1131,23 +1131,25 @@ long QgsVectorLayer::updateFeatureCount() const

void QgsVectorLayer::updateExtents()
{
mLayerExtent.setMinimal();

if(mDataProvider)
{
if(mDeletedFeatureIds.isEmpty())
{
// get the extent of the layer from the provider
QgsRect r = mDataProvider->extent();
mLayerExtent.setXmin(r.xMin());
mLayerExtent.setYmin(r.yMin());
mLayerExtent.setXmax(r.xMax());
mLayerExtent.setYmax(r.yMax());
// but only when there are some features already
if (mDataProvider->featureCount() != 0)
{
QgsRect r = mDataProvider->extent();
mLayerExtent.combineExtentWith(&r);
}
}
else
{
QgsFeature fet;
QgsRect bb;

mLayerExtent.setMinimal();
mDataProvider->select();
while (mDataProvider->getNextFeature(fet))
{
@@ -1173,6 +1175,12 @@ void QgsVectorLayer::updateExtents()
QgsRect bb = iter->geometry()->boundingBox();
mLayerExtent.combineExtentWith(&bb);
}

if (mLayerExtent.xMin() > mLayerExtent.xMax() && mLayerExtent.yMin() > mLayerExtent.yMax())
{
// special case when there are no features in provider nor any added
mLayerExtent = QgsRect(); // use rectangle with zero coordinates
}

// Send this (hopefully) up the chain to the map canvas
emit recalculateExtents();
@@ -1201,12 +1209,6 @@ void QgsVectorLayer::setSubsetString(QString subset)
mDataSource = mDataProvider->dataSourceUri();
updateExtents();

//trigger a recalculate extents request to any attached canvases
QgsDebugMsg("Subset query changed, emitting recalculateExtents() signal");

// emit the signal to inform any listeners that the extent of this
// layer has changed
emit recalculateExtents();
}


0 comments on commit 7f5264d

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