diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp
index 636b0ffed14..2c00db54cd6 100644
--- a/src/app/qgsmaptooladdfeature.cpp
+++ b/src/app/qgsmaptooladdfeature.cpp
@@ -146,7 +146,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}
else if ( layerWKBType == QgsWkbTypes::Point25D )
{
- g = QgsGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), 0.0 ) );
+ g = QgsGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), getDefaultZValue() ) );
}
else if ( layerWKBType == QgsWkbTypes::MultiPoint )
{
@@ -155,7 +155,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
else if ( layerWKBType == QgsWkbTypes::MultiPoint25D )
{
QgsMultiPointV2* mp = new QgsMultiPointV2();
- mp->addGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), 0.0 ) );
+ mp->addGeometry( new QgsPointV2( QgsWkbTypes::PointZ, savePoint.x(), savePoint.y(), getDefaultZValue() ) );
g = QgsGeometry( mp );
}
else
diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp
index b2013838e28..82a223b44f4 100644
--- a/src/app/qgsoptions.cpp
+++ b/src/app/qgsoptions.cpp
@@ -854,6 +854,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mLineGhostCheckBox->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/line_ghost" ), false ).toBool() );
+ mDefaultZValueSpinBox->setValue(
+ mSettings->value( QStringLiteral( "/qgis/digitizing/default_z_value" ), Qgis::DEFAULT_Z_COORDINATE ).toDouble()
+ );
+
//default snap mode
mSnappingEnabledDefault->setChecked( mSettings->value( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), false ).toBool() );
mDefaultSnapModeComboBox->addItem( tr( "Vertex" ), QgsSnappingConfig::Vertex );
@@ -1362,6 +1366,8 @@ void QgsOptions::saveOptions()
settings.setValue( QStringLiteral( "/qgis/digitizing/line_ghost" ), mLineGhostCheckBox->isChecked() );
+ mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), mDefaultZValueSpinBox->value() );
+
//default snap mode
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snap_enabled" ), mSnappingEnabledDefault->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/default_snap_type" ), mDefaultSnapModeComboBox->currentData().toInt() );
diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp
index 3693e257868..a17d82798b2 100644
--- a/src/core/qgis.cpp
+++ b/src/core/qgis.cpp
@@ -87,6 +87,7 @@ double Qgis::DEFAULT_HIGHLIGHT_MIN_WIDTH_MM = 1.0;
double Qgis::SCALE_PRECISION = 0.9999999999;
+double Qgis::DEFAULT_Z_COORDINATE = 0.0;
double qgsPermissiveToDouble( QString string, bool &ok )
{
diff --git a/src/core/qgis.h b/src/core/qgis.h
index 1dd9cabe755..7150efb3507 100644
--- a/src/core/qgis.h
+++ b/src/core/qgis.h
@@ -113,6 +113,11 @@ class CORE_EXPORT Qgis
* @note added in 2.15*/
static double SCALE_PRECISION;
+ /**
+ *
+ * @note added in 3.0 */
+ static double DEFAULT_Z_COORDINATE;
+
private:
// String representation of unit types (set in qgis.cpp)
static const char *qgisUnitTypes[];
diff --git a/src/gui/qgsmaptoolcapture.cpp b/src/gui/qgsmaptoolcapture.cpp
index 8e50aaba928..a0056fce59c 100644
--- a/src/gui/qgsmaptoolcapture.cpp
+++ b/src/gui/qgsmaptoolcapture.cpp
@@ -46,6 +46,7 @@ QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas* canvas, QgsAdvancedDigitizin
#ifdef Q_OS_WIN
, mSkipNextContextMenuEvent( 0 )
#endif
+ , mDefaultZValue(Qgis::DEFAULT_Z_COORDINATE)
{
mCaptureMode = mode;
@@ -84,6 +85,8 @@ void QgsMapToolCapture::activate()
mTempRubberBand->show();
QgsMapToolAdvancedDigitizing::activate();
+
+ mDefaultZValue = QSettings().value( QStringLiteral( "/qgis/digitizing/default_z_value" ), Qgis::DEFAULT_Z_COORDINATE ).toDouble();
}
void QgsMapToolCapture::deactivate()
@@ -332,7 +335,7 @@ int QgsMapToolCapture::nextPoint( const QgsPointV2& mapPoint, QgsPointV2& layerP
QgsPoint mapP( mapPoint.x(), mapPoint.y() );
layerPoint = QgsPointV2( toLayerCoordinates( vlayer, mapP ) ); //transform snapped point back to layer crs
if ( QgsWkbTypes::hasZ( vlayer->wkbType() ) )
- layerPoint.addZValue( 0.0 );
+ layerPoint.addZValue( getDefaultZValue() );
if ( QgsWkbTypes::hasM( vlayer->wkbType() ) )
layerPoint.addMValue( 0.0 );
}
diff --git a/src/gui/qgsmaptoolcapture.h b/src/gui/qgsmaptoolcapture.h
index 07617bdf771..692accb19b6 100644
--- a/src/gui/qgsmaptoolcapture.h
+++ b/src/gui/qgsmaptoolcapture.h
@@ -82,6 +82,11 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
*/
void deleteTempRubberBand();
+ /**
+ * Return defalut Z value
+ */
+ double getDefaultZValue() {return mDefaultZValue;};
+
private slots:
void validationFinished();
void currentLayerChanged( QgsMapLayer *layer );
@@ -212,6 +217,7 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
QgsVertexMarker* mSnappingMarker;
+ double mDefaultZValue;
#ifdef Q_OS_WIN
int mSkipNextContextMenuEvent;
#endif
diff --git a/src/gui/qgsnewvectorlayerdialog.cpp b/src/gui/qgsnewvectorlayerdialog.cpp
index 18e6b38ff1d..4d36477a293 100644
--- a/src/gui/qgsnewvectorlayerdialog.cpp
+++ b/src/gui/qgsnewvectorlayerdialog.cpp
@@ -147,14 +147,20 @@ QgsWkbTypes::Type QgsNewVectorLayerDialog::selectedType() const
{
if ( mPointRadioButton->isChecked() )
{
+ if (mGeometryWithZCheckBox->isChecked())
+ return QgsWkbTypes::Point25D;
return QgsWkbTypes::Point;
}
else if ( mLineRadioButton->isChecked() )
{
+ if (mGeometryWithZCheckBox->isChecked())
+ return QgsWkbTypes::LineString25D;
return QgsWkbTypes::LineString;
}
else if ( mPolygonRadioButton->isChecked() )
{
+ if (mGeometryWithZCheckBox->isChecked())
+ return QgsWkbTypes::Polygon25D;
return QgsWkbTypes::Polygon;
}
return QgsWkbTypes::Unknown;
diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp
index f2881621d82..4ea8d5d5da9 100644
--- a/src/providers/ogr/qgsogrprovider.cpp
+++ b/src/providers/ogr/qgsogrprovider.cpp
@@ -2671,21 +2671,39 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
case QgsWkbTypes::Point:
OGRvectortype = wkbPoint;
break;
+ case QgsWkbTypes::Point25D:
+ OGRvectortype = wkbPoint25D;
+ break;
case QgsWkbTypes::LineString:
OGRvectortype = wkbLineString;
break;
+ case QgsWkbTypes::LineString25D:
+ OGRvectortype = wkbLineString25D;
+ break;
case QgsWkbTypes::Polygon:
OGRvectortype = wkbPolygon;
break;
+ case QgsWkbTypes::Polygon25D:
+ OGRvectortype = wkbPolygon25D;
+ break;
case QgsWkbTypes::MultiPoint:
OGRvectortype = wkbMultiPoint;
break;
+ case QgsWkbTypes::MultiPoint25D:
+ OGRvectortype = wkbMultiPoint25D;
+ break;
case QgsWkbTypes::MultiLineString:
OGRvectortype = wkbMultiLineString;
break;
+ case QgsWkbTypes::MultiLineString25D:
+ OGRvectortype = wkbMultiLineString25D;
+ break;
case QgsWkbTypes::MultiPolygon:
OGRvectortype = wkbMultiPolygon;
break;
+ case QgsWkbTypes::MultiPolygon25D:
+ OGRvectortype = wkbMultiPolygon25D;
+ break;
default:
{
QgsMessageLog::logMessage( QObject::tr( "Unknown vector type of %1" ).arg(( int )( vectortype ) ), QObject::tr( "OGR" ) );
diff --git a/src/ui/qgsnewvectorlayerdialogbase.ui b/src/ui/qgsnewvectorlayerdialogbase.ui
index bdd97ea584f..07f57d2ed4f 100644
--- a/src/ui/qgsnewvectorlayerdialogbase.ui
+++ b/src/ui/qgsnewvectorlayerdialogbase.ui
@@ -6,7 +6,7 @@
0
0
- 444
+ 471
578
@@ -69,22 +69,29 @@
Type
-
- -
-
-
- Point
-
-
-
- -
+
+
-
Line
- -
+
-
+
+
+ Point
+
+
+
+ -
+
+
+ Geometries with Z coordinate
+
+
+
+ -
Polygon
diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui
index 57803a11d80..25b234ae952 100644
--- a/src/ui/qgsoptionsbase.ui
+++ b/src/ui/qgsoptionsbase.ui
@@ -1023,7 +1023,7 @@
0
0
- 607
+ 839
850
@@ -1813,7 +1813,7 @@
0
- -299
+ 0
839
982
@@ -3755,8 +3755,8 @@
0
0
- 586
- 701
+ 839
+ 734
@@ -3769,16 +3769,6 @@
Feature creation
-
-
-
-
-
- 0
- 0
-
-
-
-
-
@@ -3819,6 +3809,39 @@
+ -
+
+
+ Default Z value
+
+
+
+ -
+
+
+ 3
+
+
+ -999999.998999999952503
+
+
+ 1000000.000000000000000
+
+
+ 1.000000000000000
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+