Skip to content
Permalink
Browse files

Merge pull request #5827 from nirvn/spatialite_zm

[spatialite provider] Fix ZM support
  • Loading branch information
nirvn committed Dec 11, 2017
2 parents 2ec1a0f + 1da0f8e commit 3d1d82e7d2e1a83a3016db51139d330119e71f5f
@@ -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" ) ) );
@@ -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() &&
@@ -320,7 +338,8 @@ bool QgsNewSpatialiteLayerDialog::createDb()
settings.setValue( QStringLiteral( "SpatiaLite/connections/selected" ), fi.fileName() + tr( "@" ) + fi.canonicalFilePath() );
settings.setValue( key, fi.canonicalFilePath() );

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

pbnFindSRID->setEnabled( true );
@@ -366,11 +385,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)" )
@@ -426,6 +446,9 @@ bool QgsNewSpatialiteLayerDialog::apply()
leGeometryColumn->text() ), leLayerName->text(), QStringLiteral( "spatialite" ) );
if ( layer->isValid() )
{
// Reload connections to refresh browser panel
QgisApp::instance()->reloadConnections();

// register this layer with the central layers registry
QList<QgsMapLayer *> myList;
myList << layer;
@@ -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();

0 comments on commit 3d1d82e

Please sign in to comment.
You can’t perform that action at this time.