Skip to content

Commit 403f59f

Browse files
committed
Bug #10974 QGIS WFS Server provides too much precision PR #1520 UI
Add a cell in the WFS vector layer table to specify the coordinate precision by layer
1 parent 6148bba commit 403f59f

6 files changed

+109
-63
lines changed

src/app/qgsprojectproperties.cpp

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
379379
QSignalMapper *smDelete = new QSignalMapper( this );
380380
connect( smDelete, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSDeleteStateChanged( int ) ) );
381381

382-
twWFSLayers->setColumnCount( 5 );
382+
twWFSLayers->setColumnCount( 6 );
383383
twWFSLayers->horizontalHeader()->setVisible( true );
384384
twWFSLayers->setRowCount( mapLayers.size() );
385385

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

406406
smPublied->setMapping( cbp, j );
407407
connect( cbp, SIGNAL( stateChanged( int ) ), smPublied, SLOT( map() ) );
408+
409+
QSpinBox* psb = new QSpinBox();
410+
psb->setValue( QgsProject::instance()->readNumEntry( "WFSLayersPrecision", "/"+currentLayer->id(), 8 ) );
411+
twWFSLayers->setCellWidget( j, 2, psb );
408412

409413
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( currentLayer );
410414
QgsVectorDataProvider* provider = vlayer->dataProvider();
411415
if (( provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) && ( provider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) )
412416
{
413417
QCheckBox* cbu = new QCheckBox();
414418
cbu->setChecked( wfstUpdateLayerIdList.contains( currentLayer->id() ) );
415-
twWFSLayers->setCellWidget( j, 2, cbu );
419+
twWFSLayers->setCellWidget( j, 3, cbu );
416420

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

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

435439
smDelete->setMapping( cbd, j );
436440
connect( cbd, SIGNAL( stateChanged( int ) ), smDelete, SLOT( map() ) );
@@ -866,21 +870,25 @@ void QgsProjectProperties::apply()
866870
if ( cb && cb->isChecked() )
867871
{
868872
wfsLayerList << id;
869-
}
870-
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 2 ) );
871-
if ( cb && cb->isChecked() )
872-
{
873-
wfstUpdateLayerList << id;
874-
}
875-
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 3 ) );
876-
if ( cb && cb->isChecked() )
877-
{
878-
wfstInsertLayerList << id;
879-
}
880-
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 4 ) );
881-
if ( cb && cb->isChecked() )
882-
{
883-
wfstDeleteLayerList << id;
873+
874+
QSpinBox* sb = qobject_cast<QSpinBox *>( twWFSLayers->cellWidget( i, 2 ) );
875+
QgsProject::instance()->writeEntry( "WFSLayersPrecision", "/"+id, sb->value() );
876+
877+
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 3 ) );
878+
if ( cb && cb->isChecked() )
879+
{
880+
wfstUpdateLayerList << id;
881+
}
882+
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 4 ) );
883+
if ( cb && cb->isChecked() )
884+
{
885+
wfstInsertLayerList << id;
886+
}
887+
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 5 ) );
888+
if ( cb && cb->isChecked() )
889+
{
890+
wfstDeleteLayerList << id;
891+
}
884892
}
885893
}
886894
QgsProject::instance()->writeEntry( "WFSLayers", "/", wfsLayerList );

src/mapserver/qgswfsprojectparser.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,31 @@ QStringList QgsWFSProjectParser::wfsLayers() const
457457
return mProjectParser.wfsLayers();
458458
}
459459

460+
int QgsWFSProjectParser::wfsLayerPrecision( const QString& aLayerId ) const
461+
{
462+
QStringList wfsLayersId = mProjectParser.wfsLayers();
463+
if ( !wfsLayersId.contains( aLayerId ) )
464+
{
465+
return -1;
466+
}
467+
int prec = 8;
468+
QDomElement propertiesElem = mProjectParser.propertiesElem();
469+
if ( !propertiesElem.isNull() )
470+
{
471+
QDomElement wfsPrecElem = propertiesElem.firstChildElement( "WFSLayersPrecision" );
472+
if ( !wfsPrecElem.isNull() )
473+
{
474+
QDomElement wfsLayerPrecElem = wfsPrecElem.firstChildElement( aLayerId );
475+
if ( !wfsLayerPrecElem.isNull() )
476+
{
477+
QString precStr = wfsLayerPrecElem.text();
478+
prec = precStr.toInt();
479+
}
480+
}
481+
}
482+
return prec;
483+
}
484+
460485
QList<QgsMapLayer*> QgsWFSProjectParser::mapLayerFromTypeName( const QString& aTypeName, bool useCache ) const
461486
{
462487
Q_UNUSED( useCache );

src/mapserver/qgswfsprojectparser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class QgsWFSProjectParser
3434
void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const;
3535

3636
QStringList wfsLayers() const;
37+
int wfsLayerPrecision( const QString& aLayerId ) const;
3738

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

0 commit comments

Comments
 (0)