Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE]: choice to keep WFS layers in cache or load the data on redraw
  • Loading branch information
mhugent committed Dec 13, 2011
1 parent cafdd63 commit 20bc41d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 31 deletions.
14 changes: 10 additions & 4 deletions src/app/qgisapp.cpp
Expand Up @@ -2427,10 +2427,16 @@ void QgisApp::addWmsLayer()

void QgisApp::addWfsLayer()
{
if ( !mMapCanvas )
{
return;
}

if ( mMapCanvas && mMapCanvas->isDrawing() )
{
return;
}

// Fudge for now
QgsDebugMsg( "about to addWfsLayer" );

Expand All @@ -2444,12 +2450,12 @@ void QgisApp::addWfsLayer()
connect( wfss , SIGNAL( addWfsLayer( QString, QString ) ),
this , SLOT( addWfsLayer( QString, QString ) ) );

if ( mapCanvas() )
{
wfss->setProperty( "MapExtent", mapCanvas()->extent().toString() ); //hack to reenable wfs with extent setting
}
wfss->setProperty( "MapExtent", mMapCanvas->extent().toString() ); //hack to reenable wfs with extent setting

bool bkRenderFlag = mMapCanvas->renderFlag();
mMapCanvas->setRenderFlag( false );
wfss->exec();
mMapCanvas->setRenderFlag( bkRenderFlag );
delete wfss;
}

Expand Down
24 changes: 20 additions & 4 deletions src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -61,6 +61,7 @@ QgsWFSProvider::QgsWFSProvider( const QString& uri )
}

reloadData();

if ( mValid )
{
getLayerCapabilities();
Expand Down Expand Up @@ -230,15 +231,30 @@ void QgsWFSProvider::select( QgsAttributeList fetchAttributes,
mAttributesToFetch = fetchAttributes;
mFetchGeom = fetchGeometry;

if ( rect.isEmpty() )
QString dsURI = dataSourceUri();
if ( dsURI.contains( "BBOX" ) )
{
mSpatialFilter = mExtent;
QUrl url( dsURI );
url.removeQueryItem( "BBOX" );
url.addQueryItem( "BBOX", QString::number( rect.xMinimum() ) + "," + QString::number( rect.yMinimum() ) + ","
+ QString::number( rect.xMaximum() ) + "," + QString::number( rect.yMaximum() ) );
setDataSourceUri( url.toString() );
reloadData();
mSelectedFeatures = mFeatures.keys();
mSpatialFilter = rect;
}
else
{
mSpatialFilter = rect;
mSelectedFeatures = mSpatialIndex->intersects( mSpatialFilter );
if ( rect.isEmpty() )
{
mSpatialFilter = mExtent;
mSelectedFeatures = mFeatures.keys();
}
else
{
mSpatialFilter = rect;
mSelectedFeatures = mSpatialIndex->intersects( mSpatialFilter );
}
}

mFeatureIterator = mSelectedFeatures.begin();
Expand Down
27 changes: 13 additions & 14 deletions src/providers/wfs/qgswfssourceselect.cpp
Expand Up @@ -42,16 +42,16 @@ QgsWFSSourceSelect::QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl, bool emb
{
setupUi( this );

btnAdd = buttonBox->button( QDialogButtonBox::Ok );
btnAdd = buttonBox->button( QDialogButtonBox::Apply );
btnAdd->setEnabled( false );

if ( embeddedMode )
{
buttonBox->button( QDialogButtonBox::Ok )->hide();
buttonBox->button( QDialogButtonBox::Cancel )->hide();
buttonBox->button( QDialogButtonBox::Apply )->hide();
buttonBox->button( QDialogButtonBox::Close )->hide();
}

connect( buttonBox, SIGNAL( accepted() ), this, SLOT( addLayer() ) );
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( addLayer() ) );
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
connect( btnNew, SIGNAL( clicked() ), this, SLOT( addEntryToServerList() ) );
connect( btnEdit, SIGNAL( clicked() ), this, SLOT( modifyEntryOfServerList() ) );
Expand Down Expand Up @@ -178,6 +178,7 @@ void QgsWFSSourceSelect::capabilitiesReplyFinished()
newItem->setText( 0, featureType.title );
newItem->setText( 1, featureType.name );
newItem->setText( 2, featureType.abstract );
newItem->setCheckState( 3, Qt::Checked );
treeWidget->addTopLevelItem( newItem );

// insert the available CRS into mAvailableCRS
Expand Down Expand Up @@ -260,27 +261,26 @@ void QgsWFSSourceSelect::addLayer()
return;
}

QgsRectangle bBox;
QgsRectangle currentRectangle;
if ( mBboxCheckBox->isChecked() )
{
currentRectangle = mExtent;
}


QList<QTreeWidgetItem*> selectedItems = treeWidget->selectedItems();
QList<QTreeWidgetItem*>::const_iterator sIt = selectedItems.constBegin();
for ( ; sIt != selectedItems.constEnd(); ++sIt )
{
QString typeName = ( *sIt )->text( 1 );
QString crs = labelCoordRefSys->text();
QString filter = ( *sIt )->text( 3 );
QString filter = ( *sIt )->text( 4 );

QgsRectangle currentRectangle;
if (( *sIt )->checkState( 3 ) == Qt::Unchecked )
{
currentRectangle = mExtent;
}

//add a wfs layer to the map
QgsWFSConnection conn( cmbConnections->currentText() );
QString uri = conn.uriGetFeature( typeName, crs, filter, currentRectangle );
emit addWfsLayer( uri, typeName );
}
accept();
}

void QgsWFSSourceSelect::changeCRS()
Expand Down Expand Up @@ -419,5 +419,4 @@ void QgsWFSSourceSelect::showEvent( QShowEvent* event )
}
}
}
mBboxCheckBox->hide();
}
16 changes: 7 additions & 9 deletions src/ui/qgswfssourceselectbase.ui
Expand Up @@ -112,7 +112,7 @@
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
<number>5</number>
</property>
<column>
<property name="text">
Expand All @@ -129,6 +129,11 @@
<string>Abstract</string>
</property>
</column>
<column>
<property name="text">
<string>cacheFeatures</string>
</property>
</column>
<column>
<property name="text">
<string>Filter</string>
Expand Down Expand Up @@ -185,19 +190,12 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="mBboxCheckBox">
<property name="text">
<string>Only request features overlapping the current view extent</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
Expand Down

0 comments on commit 20bc41d

Please sign in to comment.