Skip to content

Commit d444536

Browse files
committed
[spatialite provider] Fix ZM support
1 parent 2ec1a0f commit d444536

5 files changed

+633
-454
lines changed

src/app/qgsnewspatialitelayerdialog.cpp

+23-4
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() &&
@@ -366,11 +384,12 @@ bool QgsNewSpatialiteLayerDialog::apply()
366384

367385
QgsDebugMsg( sql ); // OK
368386

369-
QString sqlAddGeom = QStringLiteral( "select AddGeometryColumn(%1,%2,%3,%4,2)" )
387+
QString sqlAddGeom = QStringLiteral( "select AddGeometryColumn(%1,%2,%3,%4,%5)" )
370388
.arg( quotedValue( leLayerName->text() ),
371389
quotedValue( leGeometryColumn->text() ) )
372390
.arg( mCrsId.split( ':' ).value( 1, QStringLiteral( "0" ) ).toInt() )
373-
.arg( quotedValue( selectedType() ) );
391+
.arg( quotedValue( selectedType() ) )
392+
.arg( quotedValue( selectedZM() ) );
374393
QgsDebugMsg( sqlAddGeom ); // OK
375394

376395
QString sqlCreateIndex = QStringLiteral( "select CreateSpatialIndex(%1,%2)" )

src/app/qgsnewspatialitelayerdialog.h

+2
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)