Skip to content
Permalink
Browse files

Added the ability to create memory layer with 25d geometry

  • Loading branch information
alisovenko committed Dec 26, 2016
1 parent d2f41ac commit 6bc9a4a93f80df2215b3675702c10a1007941ca6
Showing with 32 additions and 45 deletions.
  1. +16 −35 src/gui/qgsnewmemorylayerdialog.cpp
  2. +9 −10 src/gui/qgsnewvectorlayerdialog.cpp
  3. +7 −0 src/ui/qgsnewmemorylayerdialogbase.ui
@@ -40,33 +40,9 @@ QgsVectorLayer *QgsNewMemoryLayerDialog::runAndCreateLayer( QWidget *parent )

QgsWkbTypes::Type geometrytype = dialog.selectedType();

QString geomType;
switch ( geometrytype )
{
case QgsWkbTypes::Point:
geomType = QStringLiteral( "point" );
break;
case QgsWkbTypes::LineString:
geomType = QStringLiteral( "linestring" );
break;
case QgsWkbTypes::Polygon:
geomType = QStringLiteral( "polygon" );
break;
case QgsWkbTypes::MultiPoint:
geomType = QStringLiteral( "multipoint" );
break;
case QgsWkbTypes::MultiLineString:
geomType = QStringLiteral( "multilinestring" );
break;
case QgsWkbTypes::MultiPolygon:
geomType = QStringLiteral( "multipolygon" );
break;
case QgsWkbTypes::NoGeometry:
geomType = QStringLiteral( "none" );
break;
default:
geomType = QStringLiteral( "point" );
}
QString geomType = QgsWkbTypes::displayString(geometrytype);
if ( geomType.isNull())
geomType = "none";

QString layerProperties = QStringLiteral( "%1?" ).arg( geomType );
if ( QgsWkbTypes::NoGeometry != geometrytype )
@@ -103,35 +79,40 @@ QgsNewMemoryLayerDialog::~QgsNewMemoryLayerDialog()

QgsWkbTypes::Type QgsNewMemoryLayerDialog::selectedType() const
{
QgsWkbTypes::Type wkbType = QgsWkbTypes::Unknown;
if ( !buttonGroupGeometry->isChecked() )
{
return QgsWkbTypes::NoGeometry;
wkbType = QgsWkbTypes::NoGeometry;
}
else if ( mPointRadioButton->isChecked() )
{
return QgsWkbTypes::Point;
wkbType = QgsWkbTypes::Point;
}
else if ( mLineRadioButton->isChecked() )
{
return QgsWkbTypes::LineString;
wkbType = QgsWkbTypes::LineString;
}
else if ( mPolygonRadioButton->isChecked() )
{
return QgsWkbTypes::Polygon;
wkbType = QgsWkbTypes::Polygon;
}
else if ( mMultiPointRadioButton->isChecked() )
{
return QgsWkbTypes::MultiPoint;
wkbType = QgsWkbTypes::MultiPoint;
}
else if ( mMultiLineRadioButton->isChecked() )
{
return QgsWkbTypes::MultiLineString;
wkbType = QgsWkbTypes::MultiLineString;
}
else if ( mMultiPolygonRadioButton->isChecked() )
{
return QgsWkbTypes::MultiPolygon;
wkbType = QgsWkbTypes::MultiPolygon;
}
return QgsWkbTypes::Unknown;

if (mGeometryWithZCheckBox->isChecked() && wkbType != QgsWkbTypes::Unknown && wkbType != QgsWkbTypes::NoGeometry)
wkbType = QgsWkbTypes::to25D(wkbType);

return wkbType;
}

QgsCoordinateReferenceSystem QgsNewMemoryLayerDialog::crs() const
@@ -145,25 +145,24 @@ void QgsNewVectorLayerDialog::on_mTypeBox_currentIndexChanged( int index )

QgsWkbTypes::Type QgsNewVectorLayerDialog::selectedType() const
{
QgsWkbTypes::Type wkbType = QgsWkbTypes::Unknown;
if ( mPointRadioButton->isChecked() )
{
if (mGeometryWithZCheckBox->isChecked())
return QgsWkbTypes::Point25D;
return QgsWkbTypes::Point;
wkbType = QgsWkbTypes::Point;
}
else if ( mLineRadioButton->isChecked() )
{
if (mGeometryWithZCheckBox->isChecked())
return QgsWkbTypes::LineString25D;
return QgsWkbTypes::LineString;
wkbType = QgsWkbTypes::LineString;
}
else if ( mPolygonRadioButton->isChecked() )
{
if (mGeometryWithZCheckBox->isChecked())
return QgsWkbTypes::Polygon25D;
return QgsWkbTypes::Polygon;
wkbType = QgsWkbTypes::Polygon;
}
return QgsWkbTypes::Unknown;

if (mGeometryWithZCheckBox->isChecked() && wkbType != QgsWkbTypes::Unknown)
wkbType = QgsWkbTypes::to25D(wkbType);

return wkbType;
}

int QgsNewVectorLayerDialog::selectedCrsId() const
@@ -78,6 +78,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="mGeometryWithZCheckBox">
<property name="text">
<string>Geometries with Z coordinate</string>
</property>
</widget>
</item>
<item>
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="focusPolicy">

0 comments on commit 6bc9a4a

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