Skip to content
Permalink
Browse files

More types support for QgsVectorFileWriter

  • Loading branch information
m-kuhn committed Jan 12, 2016
1 parent e29c7e5 commit e351d24a7d5cc205b41834d26b673a5204a69bd8
@@ -183,4 +183,11 @@ class QgsWKBTypes
* @see addM()
*/
static Type dropM( Type type );

/**
* Will convert the 25D version of the flat type if supported or Unknown if not supported.
* @param type The type to convert
* @return the 25D version of the type or Unknown
*/
static Type to25D( Type type );
};
@@ -194,8 +194,21 @@ class QgsVectorFileWriter
const QString& driverName = "ESRI Shapefile",
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList(),
QString *newFilename = 0,
QgsVectorFileWriter::SymbologyExport symbologyExport = QgsVectorFileWriter::NoSymbology
QString *newFilename = nullptr,
SymbologyExport symbologyExport = NoSymbology
);

/** Create a new vector file writer */
QgsVectorFileWriter( const QString& vectorFileName,
const QString& fileEncoding,
const QgsFields& fields,
QgsWKBTypes::Type geometryType,
const QgsCoordinateReferenceSystem* srs,
const QString& driverName = "ESRI Shapefile",
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList(),
QString *newFilename = nullptr,
SymbologyExport symbologyExport = NoSymbology
);

/** Returns map with format filter string as key and OGR format key as value*/
@@ -236,6 +236,18 @@ QgsWKBTypes::Type QgsWKBTypes::dropM( QgsWKBTypes::Type type )
return returnType;
}

QgsWKBTypes::Type QgsWKBTypes::to25D( QgsWKBTypes::Type type )
{
QgsWKBTypes::Type flat = flatType( type );

if ( flat >= Point && flat <= MultiPolygon )
return static_cast< QgsWKBTypes::Type >( flat + 0x80000000 );
else if ( type == QgsWKBTypes::NoGeometry )
return QgsWKBTypes::NoGeometry;
else
return Unknown;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
@@ -217,6 +217,12 @@ class CORE_EXPORT QgsWKBTypes
*/
static Type dropM( Type type );

/**
* Will convert the 25D version of the flat type if supported or Unknown if not supported.
* @param type The type to convert
* @return the 25D version of the type or Unknown
*/
static Type to25D( Type type );
private:

struct wkbEntry

5 comments on commit e351d24

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 22, 2016

@m-kuhn, could this possibly have caused the following regression: http://hub.qgis.org/issues/14158 ?

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 22, 2016

Seems to be the default for quite some time already:

https://github.com/qgis/QGIS/blame/master/src/core/qgsvectorfilewriter.cpp#L686

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 22, 2016

@m-kuhn , sorry if this I wrongly flagged this as causing regression. I'm very confident I was doing KML -> shapefile save as under QGIS 2.12 without having to play with a SHPT option.

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 23, 2016

@m-kuhn , I looked at QGIS 2.12; on that version, there are no layer options for ESRP Shapefile in the Save As dialogue:
2016-01-22

It's slightly odd as it appears the options were added in this commit ( f78af8b ) which dates back to QGIS 2.8, yet those layer options are absent from 2.12.

Beyond that, there is still a need to fix Save As -> ESRP Shapefile so that, by default, the SHPT layer option is not set, to allow for .shp to be saved as it used to be the case prior to now. I've looked at the code a bit, but it's one of the many parts of QGIS that isn't familiar to me. If I add a "" value, and sets that as default, I get an error saying that SHPT doesn't recognize "" as a valid value.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 23, 2016

Is it possible that the key specified in the insert does not match with the ogr driver name? f78af8b#diff-2572d1079b3ce82d94d0d5fef972b795R648

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