Skip to content
Permalink
Browse files

Add checkbox to only load wfs features intersecting the current canva…

…s extent. Funded by Sourcepole QGIS Enterprise
  • Loading branch information
mhugent committed Apr 2, 2015
1 parent c3321e5 commit e4e4839823fad1b980cb815889c18edb9c4352b7
Showing with 97 additions and 83 deletions.
  1. +5 −0 src/providers/wfs/qgswfsprovider.cpp
  2. +3 −1 src/providers/wfs/qgswfssourceselect.cpp
  3. +89 −82 src/ui/qgswfssourceselectbase.ui
@@ -122,11 +122,16 @@ QgsWFSProvider::QgsWFSProvider( const QString& uri )
setDataSourceUri( bkUri );
}

#if 0 //non-cached mode is broken
mCached = !uri.contains( "BBOX=" );
if ( mCached )
{ //"Cache Features" option; get all features in layer immediately
reloadData();
} //otherwise, defer feature retrieval until layer is first rendered
#endif //0

mCached = true;
reloadData();

if ( mValid )
{
@@ -403,8 +403,10 @@ void QgsWFSSourceSelect::addLayer()
layerName = titleName;
}
QgsDebugMsg( "Layer " + typeName + " Filter is " + filter );

//is "cache features" checked?
if ( mModel->item( row, 3 )->checkState() == Qt::Checked )
//non-cached mode does not work anymore
if ( !cbxFeatureCurrentViewExtent->isChecked() && mModel->item( row, 3 )->checkState() == Qt::Checked )
{ //yes: entire WFS layer will be retrieved and cached
mUri = conn.uriGetFeature( typeName, pCrsString, filter );
}
@@ -14,7 +14,7 @@
<string>Add WFS Layer from a Server</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="0">
<item row="6" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -24,84 +24,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="gbCRS">
<property name="title">
<string>Coordinate reference system</string>
</property>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="labelCoordRefSys">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>441</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnChangeSpatialRefSys">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Change...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayoutFilter">
<item>
<widget class="QLabel" name="labelFilter">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Filter:</string>
</property>
<property name="buddy">
<cstring>lineFilter</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineFilter">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Display WFS FeatureTypes containing this word in the title, name or abstract</string>
</property>
<property name="whatsThis">
<string>Display WFS FeatureTypes containing this word in the title, name or abstract</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox1">
<property name="title">
@@ -191,6 +113,61 @@
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QGroupBox" name="gbCRS">
<property name="title">
<string>Coordinate reference system</string>
</property>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="labelCoordRefSys">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>441</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnChangeSpatialRefSys">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Change...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbxUseTitleLayerName">
<property name="text">
<string>Use title for layer name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QTreeView" name="treeView">
<property name="editTriggers">
@@ -210,10 +187,40 @@
</attribute>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbxUseTitleLayerName">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayoutFilter">
<item>
<widget class="QLabel" name="labelFilter">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Filter:</string>
</property>
<property name="buddy">
<cstring>lineFilter</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineFilter">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Display WFS FeatureTypes containing this word in the title, name or abstract</string>
</property>
<property name="whatsThis">
<string>Display WFS FeatureTypes containing this word in the title, name or abstract</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="cbxFeatureCurrentViewExtent">
<property name="text">
<string>Use title for layer name</string>
<string>Only request features overlapping thencurrent view extent</string>
</property>
</widget>
</item>

4 comments on commit e4e4839

@rduivenvoorde

This comment has been minimized.

Copy link
Contributor

@rduivenvoorde rduivenvoorde replied Oct 26, 2015

Never did a comment on a commit :-)

But @mhugent this commit breaks our use case of WFS's and in my opinion does not add something to the old implementation. See for example:

http://hub.qgis.org/issues/13117

and this thread

https://lists.osgeo.org/pipermail/qgis-developer/2015-October/040038.html

can we discuss about this one?

@mhugent

This comment has been minimized.

Copy link
Contributor Author

@mhugent mhugent replied Oct 27, 2015

Did you really try a compile without that commit? The uncached mode (subsequently downloading features) was broken during multithreaded rendering. What this commit adds is a convenient way to load the features crossing the current view extent into memory (without writing the BBOX by hand). The checkbox was already there earlier an a lot of people wanted it back.

@rduivenvoorde

This comment has been minimized.

Copy link
Contributor

@rduivenvoorde rduivenvoorde replied Oct 27, 2015

Hi @mhugent , thanks for your anwer, I thought you introduced this option.

Nope, sorry. Did not do that try to compile with that commit, but Multithreading was introduced when? Because 2.8.3 is still working as we expect/want.
Maybe have a chat about this during hackfest?

@mhugent

This comment has been minimized.

Copy link
Contributor Author

@mhugent mhugent replied Oct 27, 2015

Nope, sorry. Did not do that try to compile with that commit, but Multithreading was introduced when?

Afaik in 2.4. And loading while zooming / panning also does not work for me when removing the few lines of this commit with current master. But if it works for you without this commit, I'll be happy to revert those lines.

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