Skip to content
Permalink
Browse files

allow geometryless memory layers

  • Loading branch information
SebDieBln committed Jan 8, 2016
1 parent acf7493 commit 397795839cbbe217b04751076296bf38c96529d5
@@ -38,7 +38,6 @@ QgsVectorLayer *QgsNewMemoryLayerDialog::runAndCreateLayer( QWidget *parent )
}

QGis::WkbType geometrytype = dialog.selectedType();
QString crsId = dialog.crs().authid();

QString geomType;
switch ( geometrytype )
@@ -61,11 +60,18 @@ QgsVectorLayer *QgsNewMemoryLayerDialog::runAndCreateLayer( QWidget *parent )
case QGis::WKBMultiPolygon:
geomType = "multipolygon";
break;
case QGis::WKBNoGeometry:
geomType = "none";
break;
default:
geomType = "point";
}

QString layerProperties = QString( "%1?crs=%2&memoryid=%3" ).arg( geomType, crsId, QUuid::createUuid().toString() );
QString layerProperties = QString( "%1?" ).arg( geomType );
if ( QGis::WKBNoGeometry != geometrytype )
layerProperties.append( QString( "crs=%1&" ).arg( dialog.crs().authid() ) );
layerProperties.append( QString( "memoryid=%1" ).arg( QUuid::createUuid().toString() ) );

QString name = dialog.layerName().isEmpty() ? tr( "New scratch layer" ) : dialog.layerName();
QgsVectorLayer* newLayer = new QgsVectorLayer( layerProperties, name, QString( "memory" ) );
return newLayer;
@@ -97,7 +103,11 @@ QgsNewMemoryLayerDialog::~QgsNewMemoryLayerDialog()

QGis::WkbType QgsNewMemoryLayerDialog::selectedType() const
{
if ( mPointRadioButton->isChecked() )
if ( !buttonGroupGeometry->isChecked() )
{
return QGis::WKBNoGeometry;
}
else if ( mPointRadioButton->isChecked() )
{
return QGis::WKBPoint;
}
@@ -60,6 +60,8 @@ QgsMemoryProvider::QgsMemoryProvider( const QString& uri )
mWkbType = QGis::WKBMultiLineString;
else if ( geometry == "multipolygon" )
mWkbType = QGis::WKBMultiPolygon;
else if ( geometry == "none" )
mWkbType = QGis::WKBNoGeometry;
else
mWkbType = QGis::WKBUnknown;

@@ -201,6 +203,9 @@ QString QgsMemoryProvider::dataSourceUri( bool expandAuthConfig ) const
case QGis::WKBMultiPolygon :
geometry = "MultiPolygon";
break;
case QGis::WKBNoGeometry :
geometry = "None";
break;
default:
geometry = "";
break;
@@ -24,50 +24,64 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="buttonGroup1">
<widget class="QGroupBox" name="buttonGroupGeometry">
<property name="title">
<string>Type</string>
<string>Geometry type and CRS</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="mPointRadioButton">
<property name="text">
<string>Point</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="mLineRadioButton">
<property name="text">
<string>Line</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="mPolygonRadioButton">
<property name="text">
<string>Polygon</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="mMultiPointRadioButton">
<property name="text">
<string>Multipoint</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="mMultiLineRadioButton">
<property name="text">
<string>Multiline</string>
</property>
</widget>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QRadioButton" name="mMultiPointRadioButton">
<property name="text">
<string>Multipoint</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="mMultiPolygonRadioButton">
<property name="text">
<string>Multipolygon</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="mPolygonRadioButton">
<property name="text">
<string>Polygon</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="mPointRadioButton">
<property name="text">
<string>Point</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="mLineRadioButton">
<property name="text">
<string>Line</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="mMultiLineRadioButton">
<property name="text">
<string>Multiline</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="mMultiPolygonRadioButton">
<property name="text">
<string>Multipolygon</string>
<item>
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
@@ -88,13 +102,6 @@
</item>
</layout>
</item>
<item>
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
@@ -144,14 +151,14 @@
</customwidgets>
<tabstops>
<tabstop>mNameLineEdit</tabstop>
<tabstop>buttonGroupGeometry</tabstop>
<tabstop>mPointRadioButton</tabstop>
<tabstop>mLineRadioButton</tabstop>
<tabstop>mPolygonRadioButton</tabstop>
<tabstop>mMultiPointRadioButton</tabstop>
<tabstop>mMultiLineRadioButton</tabstop>
<tabstop>mMultiPolygonRadioButton</tabstop>
<tabstop>mCrsSelector</tabstop>
<tabstop>mButtonBox</tabstop>
</tabstops>
<resources/>
<connections>

0 comments on commit 3977958

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