Skip to content
Permalink
Browse files
[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 20bc41d2a139d80c9795c34c754068a9d14588ae
Showing with 50 additions and 31 deletions.
  1. +10 −4 src/app/qgisapp.cpp
  2. +20 −4 src/providers/wfs/qgswfsprovider.cpp
  3. +13 −14 src/providers/wfs/qgswfssourceselect.cpp
  4. +7 −9 src/ui/qgswfssourceselectbase.ui
@@ -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" );

@@ -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;
}

@@ -61,6 +61,7 @@ QgsWFSProvider::QgsWFSProvider( const QString& uri )
}

reloadData();

if ( mValid )
{
getLayerCapabilities();
@@ -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();
@@ -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() ) );
@@ -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
@@ -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()
@@ -419,5 +419,4 @@ void QgsWFSSourceSelect::showEvent( QShowEvent* event )
}
}
}
mBboxCheckBox->hide();
}
@@ -112,7 +112,7 @@
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
<number>5</number>
</property>
<column>
<property name="text">
@@ -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>
@@ -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>

0 comments on commit 20bc41d

Please sign in to comment.