Skip to content

Commit

Permalink
Bug #10974 QGIS WFS Server provides too much precision PR #1520 UI
Browse files Browse the repository at this point in the history
Add a cell in the WFS vector layer table to specify the coordinate precision by layer
  • Loading branch information
rldhont committed Aug 22, 2014
1 parent 6148bba commit 403f59f
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 63 deletions.
46 changes: 27 additions & 19 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -379,7 +379,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
QSignalMapper *smDelete = new QSignalMapper( this );
connect( smDelete, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSDeleteStateChanged( int ) ) );

twWFSLayers->setColumnCount( 5 );
twWFSLayers->setColumnCount( 6 );
twWFSLayers->horizontalHeader()->setVisible( true );
twWFSLayers->setRowCount( mapLayers.size() );

Expand All @@ -405,14 +405,18 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa

smPublied->setMapping( cbp, j );
connect( cbp, SIGNAL( stateChanged( int ) ), smPublied, SLOT( map() ) );

QSpinBox* psb = new QSpinBox();
psb->setValue( QgsProject::instance()->readNumEntry( "WFSLayersPrecision", "/"+currentLayer->id(), 8 ) );
twWFSLayers->setCellWidget( j, 2, psb );

QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( currentLayer );
QgsVectorDataProvider* provider = vlayer->dataProvider();
if (( provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) && ( provider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) )
{
QCheckBox* cbu = new QCheckBox();
cbu->setChecked( wfstUpdateLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 2, cbu );
twWFSLayers->setCellWidget( j, 3, cbu );

smUpdate->setMapping( cbu, j );
connect( cbu, SIGNAL( stateChanged( int ) ), smUpdate, SLOT( map() ) );
Expand All @@ -421,7 +425,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
{
QCheckBox* cbi = new QCheckBox();
cbi->setChecked( wfstInsertLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 3, cbi );
twWFSLayers->setCellWidget( j, 4, cbi );

smInsert->setMapping( cbi, j );
connect( cbi, SIGNAL( stateChanged( int ) ), smInsert, SLOT( map() ) );
Expand All @@ -430,7 +434,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
{
QCheckBox* cbd = new QCheckBox();
cbd->setChecked( wfstDeleteLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 4, cbd );
twWFSLayers->setCellWidget( j, 5, cbd );

smDelete->setMapping( cbd, j );
connect( cbd, SIGNAL( stateChanged( int ) ), smDelete, SLOT( map() ) );
Expand Down Expand Up @@ -866,21 +870,25 @@ void QgsProjectProperties::apply()
if ( cb && cb->isChecked() )
{
wfsLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 2 ) );
if ( cb && cb->isChecked() )
{
wfstUpdateLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 3 ) );
if ( cb && cb->isChecked() )
{
wfstInsertLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 4 ) );
if ( cb && cb->isChecked() )
{
wfstDeleteLayerList << id;

QSpinBox* sb = qobject_cast<QSpinBox *>( twWFSLayers->cellWidget( i, 2 ) );
QgsProject::instance()->writeEntry( "WFSLayersPrecision", "/"+id, sb->value() );

cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 3 ) );
if ( cb && cb->isChecked() )
{
wfstUpdateLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 4 ) );
if ( cb && cb->isChecked() )
{
wfstInsertLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 5 ) );
if ( cb && cb->isChecked() )
{
wfstDeleteLayerList << id;
}
}
}
QgsProject::instance()->writeEntry( "WFSLayers", "/", wfsLayerList );
Expand Down
25 changes: 25 additions & 0 deletions src/mapserver/qgswfsprojectparser.cpp
Expand Up @@ -457,6 +457,31 @@ QStringList QgsWFSProjectParser::wfsLayers() const
return mProjectParser.wfsLayers();
}

int QgsWFSProjectParser::wfsLayerPrecision( const QString& aLayerId ) const
{
QStringList wfsLayersId = mProjectParser.wfsLayers();
if ( !wfsLayersId.contains( aLayerId ) )
{
return -1;
}
int prec = 8;
QDomElement propertiesElem = mProjectParser.propertiesElem();
if ( !propertiesElem.isNull() )
{
QDomElement wfsPrecElem = propertiesElem.firstChildElement( "WFSLayersPrecision" );
if ( !wfsPrecElem.isNull() )
{
QDomElement wfsLayerPrecElem = wfsPrecElem.firstChildElement( aLayerId );
if ( !wfsLayerPrecElem.isNull() )
{
QString precStr = wfsLayerPrecElem.text();
prec = precStr.toInt();
}
}
}
return prec;
}

QList<QgsMapLayer*> QgsWFSProjectParser::mapLayerFromTypeName( const QString& aTypeName, bool useCache ) const
{
Q_UNUSED( useCache );
Expand Down
1 change: 1 addition & 0 deletions src/mapserver/qgswfsprojectparser.h
Expand Up @@ -34,6 +34,7 @@ class QgsWFSProjectParser
void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const;

QStringList wfsLayers() const;
int wfsLayerPrecision( const QString& aLayerId ) const;

QList<QgsMapLayer*> mapLayerFromTypeName( const QString& aTypeName, bool useCache = true ) const;

Expand Down

0 comments on commit 403f59f

Please sign in to comment.