Skip to content

Commit

Permalink
More types support for QgsVectorFileWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 12, 2016
1 parent e29c7e5 commit e351d24
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 103 deletions.
7 changes: 7 additions & 0 deletions python/core/geometry/qgswkbtypes.sip
Expand Up @@ -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 );
};
17 changes: 15 additions & 2 deletions python/core/qgsvectorfilewriter.sip
Expand Up @@ -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*/
Expand Down
12 changes: 12 additions & 0 deletions src/core/geometry/qgswkbtypes.cpp
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgswkbtypes.h
Expand Up @@ -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
Expand Down

5 comments on commit e351d24

@nirvn
Copy link
Contributor

@nirvn nirvn commented on e351d24 Jan 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on e351d24 Jan 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be the default for quite some time already:

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

@nirvn
Copy link
Contributor

@nirvn nirvn commented on e351d24 Jan 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Contributor

@nirvn nirvn commented on e351d24 Jan 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member Author

@m-kuhn m-kuhn commented on e351d24 Jan 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.