Skip to content

Commit

Permalink
[spatialite provider] Fix ZM support
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Dec 11, 2017
1 parent 2ec1a0f commit d444536
Show file tree
Hide file tree
Showing 5 changed files with 633 additions and 454 deletions.
27 changes: 23 additions & 4 deletions src/app/qgsnewspatialitelayerdialog.cpp
Expand Up @@ -56,10 +56,10 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
restoreGeometry( settings.value( QStringLiteral( "Windows/NewSpatiaLiteLayer/geometry" ) ).toByteArray() );

mGeometryTypeBox->addItem( tr( "Point" ), QStringLiteral( "POINT" ) );
mGeometryTypeBox->addItem( tr( "Line" ), QStringLiteral( "LINE" ) );
mGeometryTypeBox->addItem( tr( "Line" ), QStringLiteral( "LINESTRING" ) );
mGeometryTypeBox->addItem( tr( "Polygon" ), QStringLiteral( "POLYGON" ) );
mGeometryTypeBox->addItem( tr( "MultiPoint" ), QStringLiteral( "MULTIPOINT" ) );
mGeometryTypeBox->addItem( tr( "MultiLine" ), QStringLiteral( "MULTILINE" ) );
mGeometryTypeBox->addItem( tr( "MultiLine" ), QStringLiteral( "MULTILINESTRING" ) );
mGeometryTypeBox->addItem( tr( "MultiPolygon" ), QStringLiteral( "MULTIPOLYGON" ) );

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

QString QgsNewSpatialiteLayerDialog::selectedZM() const
{
if ( mGeometryWithZCheckBox->isChecked() && !mGeometryWithMCheckBox->isChecked() )
{
return QStringLiteral( "XYZ" );
}
else if ( !mGeometryWithZCheckBox->isChecked() && mGeometryWithMCheckBox->isChecked() )
{
return QStringLiteral( "XYM" );
}
else if ( mGeometryWithZCheckBox->isChecked() && mGeometryWithMCheckBox->isChecked() )
{
return QStringLiteral( "XYZM" );
}

return QStringLiteral( "XY" );
}

void QgsNewSpatialiteLayerDialog::checkOk()
{
bool created = !leLayerName->text().isEmpty() &&
Expand Down Expand Up @@ -366,11 +384,12 @@ bool QgsNewSpatialiteLayerDialog::apply()

QgsDebugMsg( sql ); // OK

QString sqlAddGeom = QStringLiteral( "select AddGeometryColumn(%1,%2,%3,%4,2)" )
QString sqlAddGeom = QStringLiteral( "select AddGeometryColumn(%1,%2,%3,%4,%5)" )
.arg( quotedValue( leLayerName->text() ),
quotedValue( leGeometryColumn->text() ) )
.arg( mCrsId.split( ':' ).value( 1, QStringLiteral( "0" ) ).toInt() )
.arg( quotedValue( selectedType() ) );
.arg( quotedValue( selectedType() ) )
.arg( quotedValue( selectedZM() ) );
QgsDebugMsg( sqlAddGeom ); // OK

QString sqlCreateIndex = QStringLiteral( "select CreateSpatialIndex(%1,%2)" )
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsnewspatialitelayerdialog.h
Expand Up @@ -55,6 +55,8 @@ class APP_EXPORT QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNew
private:
//! Returns the selected geometry type
QString selectedType() const;
//! Returns the selected Z dimension and/or M measurement
QString selectedZM() const;

//! Create a new database
bool createDb();
Expand Down

0 comments on commit d444536

Please sign in to comment.