Skip to content

Commit

Permalink
Add checkbox to only load wfs features intersecting the current canva…
Browse files Browse the repository at this point in the history
…s extent. Funded by Sourcepole QGIS Enterprise
  • Loading branch information
mhugent committed Apr 2, 2015
1 parent c3321e5 commit e4e4839
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 83 deletions.
5 changes: 5 additions & 0 deletions src/providers/wfs/qgswfsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
4 changes: 3 additions & 1 deletion src/providers/wfs/qgswfssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
171 changes: 89 additions & 82 deletions src/ui/qgswfssourceselectbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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>
Expand Down

4 comments on commit e4e4839

@rduivenvoorde
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.