Skip to content
Permalink
Browse files

vector layer save as: adjust our to OGR's defaults

* GPX_USE_EXTENSIONS default is false not true (fixes #16811)
* CSV GEOMETRY is none not AS_XY (fixes #16819)

(backported from commit cb088a2)
  • Loading branch information
jef-n committed Jul 24, 2017
1 parent ab6dd74 commit 601e37351b22159f25a27e5c62714a6aa67eb2be
Showing with 108 additions and 27 deletions.
  1. +108 −27 src/core/qgsvectorfilewriter.cpp
@@ -825,7 +825,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
<< "AS_XYZ"
<< "AS_XY"
<< "AS_YX",
"AS_XY", // Default value
"", // Default value
true // Allow None
) );

@@ -868,9 +868,21 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
QObject::tr( "Override the type of shapefile created. "
"Can be one of NULL for a simple .dbf file with no .shp file, POINT, "
"ARC, POLYGON or MULTIPOINT for 2D, or POINTZ, ARCZ, POLYGONZ or "
"MULTIPOINTZ for 3D. Shapefiles with measure values are not supported, "
"nor are MULTIPATCH files." ),
QStringList()
"MULTIPOINTZ for 3D;" ) +
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,1,0)
QObject::tr( " Shapefiles with measure values are not supported,"
" nor are MULTIPATCH files." ) +
#endif
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,0)
QObject::tr( " POINTM, ARCM, POLYGONM or MULTIPOINTM for measured geometries"
" and POINTZM, ARCZM, POLYGONZM or MULTIPOINTZM for 3D measured"
" geometries." ) +
#endif
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
QObject::tr( " MULTIPATCH files are supported since GDAL 2.2." ) +
#endif
""
, QStringList()
<< "NULL"
<< "POINT"
<< "ARC"
@@ -879,7 +891,21 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
<< "POINTZ"
<< "ARCZ"
<< "POLYGONZ"
<< "MULTIPOINTZ",
<< "MULTIPOINTZ"
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,0)
<< "POINTM"
<< "ARCM"
<< "POLYGONM"
<< "MULTIPOINTM"
<< "POINTZM"
<< "ARCZM"
<< "POLYGONZM"
<< "MULTIPOINTZM"
#endif
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
<< "MULTIPATCH"
#endif
<< "",
QString(), // Default value
true // Allow None
) );
@@ -1001,7 +1027,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
"the foo_bar pattern, foo will be considered as the namespace "
"of the element, and a <foo:bar> element will be written. "
"Otherwise, elements will be written in the <ogr:> namespace." ),
true // Default value
false // Default value
) );

datasetOptions.insert( "WRITE_HEADER_AND_FOOTER", new BoolOption(
@@ -1177,7 +1203,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()

layerOptions.insert( "GEOMETRY_NAME", new StringOption(
QObject::tr( "Name for the geometry column" ),
"geometry" // Default value
"geom" // Default value
) );

#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
@@ -1238,7 +1264,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
datasetOptions.insert( "GPX_USE_EXTENSIONS", new BoolOption(
QObject::tr( "If GPX_USE_EXTENSIONS=YES is specified, "
"extra fields will be written inside the <extensions> tag." ),
true // Default value
false // Default value
) );

datasetOptions.insert( "GPX_EXTENSIONS_NS", new StringOption(
@@ -1329,8 +1355,16 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
<< "clampToGround"
<< "relativeToGround"
<< "absolute",
"clampToGround" // Default value
"relativeToGround" // Default value
) );

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
datasetOptions.insert( "DOCUMENT_ID", new StringOption(
QObject::tr( "The DOCUMENT_ID datasource creation option can be used to specified "
"the id of the root <Document> node. The default value is root_doc." ),
"root_doc" // Default value
) );
#endif

driverMetadata.insert( "KML",
MetaData(
@@ -1348,15 +1382,34 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
datasetOptions.clear();
layerOptions.clear();

layerOptions.insert( "SPATIAL_INDEX_MODE", new SetOption(
QObject::tr( "Use this to turn on 'quick spatial index mode'. "
"In this mode writing files can be about 5 times faster, "
"but spatial queries can be up to 30 times slower." ),
QStringList()
<< "QUICK",
"", // Default value
true // Allow None
datasetOptions.insert( "SPATIAL_INDEX_MODE", new SetOption(
QObject::tr( "Use this to turn on 'quick spatial index mode'. "
"In this mode writing files can be about 5 times faster, "
"but spatial queries can be up to 30 times slower." ),
QStringList()
<< "QUICK"
<< "OPTIMIZED",
"QUICK", // Default value
true // Allow None
) );

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,2)
datasetOptions.insert( "BLOCK_SIZE", new IntOption(
QObject::tr( "(multiples of 512): Block size for .map files. Defaults "
"to 512. MapInfo 15.2 and above creates .tab files with a "
"blocksize of 16384 bytes. Any MapInfo version should be "
"able to handle block sizes from 512 to 32256." ),
512
) );
#endif
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
layerOptions.insert( "BOUNDS", new StringOption(
QObject::tr( "xmin,ymin,xmax,ymax: Define custom layer bounds to increase the "
"accuracy of the coordinates. Note: the geometry of written "
"features must be within the defined box." ),
"" // Default value
) );
#endif

driverMetadata.insert( "MapInfo File",
MetaData(
@@ -1478,7 +1531,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
datasetOptions.insert( "RETURN_PRIMITIVES", new BoolOption(
QObject::tr( "Should all the low level geometry primitives be returned as special "
"IsolatedNode, ConnectedNode, Edge and Face layers." ),
true // Default value
false // Default value
) );

datasetOptions.insert( "PRESERVE_EMPTY_NUMBERS", new BoolOption(
@@ -1498,7 +1551,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
QObject::tr( "Should additional attributes relating features to their underlying "
"geometric primitives be attached. These are the values of the FSPT group, "
"and are primarily needed when doing S-57 to S-57 translations." ),
true // Default value
false // Default value
) );

datasetOptions.insert( "RECODE_BY_DSSI", new BoolOption(
@@ -1695,17 +1748,15 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
datasetOptions.clear();
layerOptions.clear();

#if 0
datasetOptions.insert( "HEADER", new StringOption(
QObject::tr( "Override the header file used - in place of header.dxf." ),
"" // Default value
QLatin1String( "" ) // Default value
) );

datasetOptions.insert( "TRAILER", new StringOption(
QObject::tr( "Override the trailer file used - in place of trailer.dxf." ),
"" // Default value
QLatin1String( "" ) // Default value
) );
#endif

driverMetadata.insert( "DXF",
MetaData(
@@ -1731,14 +1782,20 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
"GXT" // Default value
) );

#if 0
datasetOptions.insert( "CONFIG", new StringOption(
QObject::tr( "path to the GCT : the GCT file describe the GeoConcept types definitions: "
"In this file, every line must start with //# followed by a keyword. "
"Lines starting with // are comments." ),
"" // Default value
QLatin1String( "" ) // Default value
) );

datasetOptions.insert( "FEATURETYPE", new StringOption(
QObject::tr( "defines the feature to be created. The TYPE corresponds to one of the Name "
"found in the GCT file for a type section. The SUBTYPE corresponds to one of "
"the Name found in the GCT file for a sub-type section within the previous "
"type section." ),
QLatin1String( "" ) // Default value
) );
#endif

driverMetadata.insert( "Geoconcept",
MetaData(
@@ -1766,7 +1823,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
"SHAPE" // Default value
) );

layerOptions.insert( "OID_NAME", new StringOption(
layerOptions.insert( "FID", new StringOption(
QObject::tr( "Name of the OID column to create. Defaults to 'OBJECTID'." ),
"OBJECTID" // Default value
) );
@@ -1797,6 +1854,18 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
false // Allow None
) );

layerOptions.insert( "OGR_XLSX_HEADERS", new SetOption(
QObject::tr( "By default, the driver will read the first lines of each sheet to detect "
"if the first line might be the name of columns. If set to FORCE, the "
"driver will consider the first default" ),
QStringList()
<< "FORCE"
<< "DISABLE"
<< "AUTO",
"AUTO", // Default value
false // Allow None
) );

driverMetadata.insert( "XLSX",
MetaData(
"MS Office Open XML spreadsheet",
@@ -1823,6 +1892,18 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
false // Allow None
) );

layerOptions.insert( "OGR_ODS_HEADERS", new SetOption(
QObject::tr( "By default, the driver will read the first lines of each sheet to detect "
"if the first line might be the name of columns. If set to FORCE, the "
"driver will consider the first default" ),
QStringList()
<< "FORCE"
<< "DISABLE"
<< "AUTO",
"AUTO", // Default value
false // Allow None
) );

driverMetadata.insert( "ODS",
MetaData(
"Open Document Spreadsheet",

0 comments on commit 601e373

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