Skip to content

Commit 3d1d82e

Browse files
authored
Merge pull request #5827 from nirvn/spatialite_zm
[spatialite provider] Fix ZM support
2 parents 2ec1a0f + 1da0f8e commit 3d1d82e

6 files changed

+692
-456
lines changed

src/app/qgsnewspatialitelayerdialog.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
5656
restoreGeometry( settings.value( QStringLiteral( "Windows/NewSpatiaLiteLayer/geometry" ) ).toByteArray() );
5757

5858
mGeometryTypeBox->addItem( tr( "Point" ), QStringLiteral( "POINT" ) );
59-
mGeometryTypeBox->addItem( tr( "Line" ), QStringLiteral( "LINE" ) );
59+
mGeometryTypeBox->addItem( tr( "Line" ), QStringLiteral( "LINESTRING" ) );
6060
mGeometryTypeBox->addItem( tr( "Polygon" ), QStringLiteral( "POLYGON" ) );
6161
mGeometryTypeBox->addItem( tr( "MultiPoint" ), QStringLiteral( "MULTIPOINT" ) );
62-
mGeometryTypeBox->addItem( tr( "MultiLine" ), QStringLiteral( "MULTILINE" ) );
62+
mGeometryTypeBox->addItem( tr( "MultiLine" ), QStringLiteral( "MULTILINESTRING" ) );
6363
mGeometryTypeBox->addItem( tr( "MultiPolygon" ), QStringLiteral( "MULTIPOLYGON" ) );
6464

6565
mAddAttributeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionNewAttribute.svg" ) ) );
@@ -147,6 +147,24 @@ QString QgsNewSpatialiteLayerDialog::selectedType() const
147147
return mGeometryTypeBox->currentData( Qt::UserRole ).toString();
148148
}
149149

150+
QString QgsNewSpatialiteLayerDialog::selectedZM() const
151+
{
152+
if ( mGeometryWithZCheckBox->isChecked() && !mGeometryWithMCheckBox->isChecked() )
153+
{
154+
return QStringLiteral( "XYZ" );
155+
}
156+
else if ( !mGeometryWithZCheckBox->isChecked() && mGeometryWithMCheckBox->isChecked() )
157+
{
158+
return QStringLiteral( "XYM" );
159+
}
160+
else if ( mGeometryWithZCheckBox->isChecked() && mGeometryWithMCheckBox->isChecked() )
161+
{
162+
return QStringLiteral( "XYZM" );
163+
}
164+
165+
return QStringLiteral( "XY" );
166+
}
167+
150168
void QgsNewSpatialiteLayerDialog::checkOk()
151169
{
152170
bool created = !leLayerName->text().isEmpty() &&
@@ -320,7 +338,8 @@ bool QgsNewSpatialiteLayerDialog::createDb()
320338
settings.setValue( QStringLiteral( "SpatiaLite/connections/selected" ), fi.fileName() + tr( "@" ) + fi.canonicalFilePath() );
321339
settings.setValue( key, fi.canonicalFilePath() );
322340

323-
QMessageBox::information( nullptr, tr( "SpatiaLite Database" ), tr( "Registered new database!" ) );
341+
// Reload connections to refresh browser panel
342+
QgisApp::instance()->reloadConnections();
324343
}
325344

326345
pbnFindSRID->setEnabled( true );
@@ -366,11 +385,12 @@ bool QgsNewSpatialiteLayerDialog::apply()
366385

367386
QgsDebugMsg( sql ); // OK
368387

369-
QString sqlAddGeom = QStringLiteral( "select AddGeometryColumn(%1,%2,%3,%4,2)" )
388+
QString sqlAddGeom = QStringLiteral( "select AddGeometryColumn(%1,%2,%3,%4,%5)" )
370389
.arg( quotedValue( leLayerName->text() ),
371390
quotedValue( leGeometryColumn->text() ) )
372391
.arg( mCrsId.split( ':' ).value( 1, QStringLiteral( "0" ) ).toInt() )
373-
.arg( quotedValue( selectedType() ) );
392+
.arg( quotedValue( selectedType() ) )
393+
.arg( quotedValue( selectedZM() ) );
374394
QgsDebugMsg( sqlAddGeom ); // OK
375395

376396
QString sqlCreateIndex = QStringLiteral( "select CreateSpatialIndex(%1,%2)" )
@@ -426,6 +446,9 @@ bool QgsNewSpatialiteLayerDialog::apply()
426446
leGeometryColumn->text() ), leLayerName->text(), QStringLiteral( "spatialite" ) );
427447
if ( layer->isValid() )
428448
{
449+
// Reload connections to refresh browser panel
450+
QgisApp::instance()->reloadConnections();
451+
429452
// register this layer with the central layers registry
430453
QList<QgsMapLayer *> myList;
431454
myList << layer;

src/app/qgsnewspatialitelayerdialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class APP_EXPORT QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNew
5555
private:
5656
//! Returns the selected geometry type
5757
QString selectedType() const;
58+
//! Returns the selected Z dimension and/or M measurement
59+
QString selectedZM() const;
5860

5961
//! Create a new database
6062
bool createDb();

0 commit comments

Comments
 (0)