Skip to content

Commit cb088a2

Browse files
committed
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) (followup 9a6235d)
1 parent dcec6bb commit cb088a2

File tree

1 file changed

+108
-27
lines changed

1 file changed

+108
-27
lines changed

src/core/qgsvectorfilewriter.cpp

Lines changed: 108 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
764764
<< QStringLiteral( "AS_XYZ" )
765765
<< QStringLiteral( "AS_XY" )
766766
<< QStringLiteral( "AS_YX" ),
767-
QStringLiteral( "AS_XY" ), // Default value
767+
QStringLiteral( "" ), // Default value
768768
true // Allow None
769769
) );
770770

@@ -807,9 +807,21 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
807807
QObject::tr( "Override the type of shapefile created. "
808808
"Can be one of NULL for a simple .dbf file with no .shp file, POINT, "
809809
"ARC, POLYGON or MULTIPOINT for 2D, or POINTZ, ARCZ, POLYGONZ or "
810-
"MULTIPOINTZ for 3D. Shapefiles with measure values are not supported, "
811-
"nor are MULTIPATCH files." ),
812-
QStringList()
810+
"MULTIPOINTZ for 3D;" ) +
811+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,1,0)
812+
QObject::tr( " Shapefiles with measure values are not supported,"
813+
" nor are MULTIPATCH files." ) +
814+
#endif
815+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,0)
816+
QObject::tr( " POINTM, ARCM, POLYGONM or MULTIPOINTM for measured geometries"
817+
" and POINTZM, ARCZM, POLYGONZM or MULTIPOINTZM for 3D measured"
818+
" geometries." ) +
819+
#endif
820+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
821+
QObject::tr( " MULTIPATCH files are supported since GDAL 2.2." ) +
822+
#endif
823+
""
824+
, QStringList()
813825
<< QStringLiteral( "NULL" )
814826
<< QStringLiteral( "POINT" )
815827
<< QStringLiteral( "ARC" )
@@ -818,7 +830,21 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
818830
<< QStringLiteral( "POINTZ" )
819831
<< QStringLiteral( "ARCZ" )
820832
<< QStringLiteral( "POLYGONZ" )
821-
<< QStringLiteral( "MULTIPOINTZ" ),
833+
<< QStringLiteral( "MULTIPOINTZ" )
834+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,0)
835+
<< QStringLiteral( "POINTM" )
836+
<< QStringLiteral( "ARCM" )
837+
<< QStringLiteral( "POLYGONM" )
838+
<< QStringLiteral( "MULTIPOINTM" )
839+
<< QStringLiteral( "POINTZM" )
840+
<< QStringLiteral( "ARCZM" )
841+
<< QStringLiteral( "POLYGONZM" )
842+
<< QStringLiteral( "MULTIPOINTZM" )
843+
#endif
844+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
845+
<< QStringLiteral( "MULTIPATCH" )
846+
#endif
847+
<< QStringLiteral( "" ),
822848
QString(), // Default value
823849
true // Allow None
824850
) );
@@ -940,7 +966,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
940966
"the foo_bar pattern, foo will be considered as the namespace "
941967
"of the element, and a <foo:bar> element will be written. "
942968
"Otherwise, elements will be written in the <ogr:> namespace." ),
943-
true // Default value
969+
false // Default value
944970
) );
945971

946972
datasetOptions.insert( QStringLiteral( "WRITE_HEADER_AND_FOOTER" ), new BoolOption(
@@ -1116,7 +1142,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
11161142

11171143
layerOptions.insert( QStringLiteral( "GEOMETRY_NAME" ), new StringOption(
11181144
QObject::tr( "Name for the geometry column" ),
1119-
QStringLiteral( "geometry" ) // Default value
1145+
QStringLiteral( "geom" ) // Default value
11201146
) );
11211147

11221148
layerOptions.insert( "SPATIAL_INDEX", new BoolOption(
@@ -1175,7 +1201,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
11751201
datasetOptions.insert( QStringLiteral( "GPX_USE_EXTENSIONS" ), new BoolOption(
11761202
QObject::tr( "If GPX_USE_EXTENSIONS=YES is specified, "
11771203
"extra fields will be written inside the <extensions> tag." ),
1178-
true // Default value
1204+
false // Default value
11791205
) );
11801206

11811207
datasetOptions.insert( QStringLiteral( "GPX_EXTENSIONS_NS" ), new StringOption(
@@ -1266,8 +1292,16 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
12661292
<< QStringLiteral( "clampToGround" )
12671293
<< QStringLiteral( "relativeToGround" )
12681294
<< QStringLiteral( "absolute" ),
1269-
QStringLiteral( "clampToGround" ) // Default value
1295+
QStringLiteral( "relativeToGround" ) // Default value
1296+
) );
1297+
1298+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
1299+
datasetOptions.insert( QStringLiteral( "DOCUMENT_ID" ), new StringOption(
1300+
QObject::tr( "The DOCUMENT_ID datasource creation option can be used to specified "
1301+
"the id of the root <Document> node. The default value is root_doc." ),
1302+
QStringLiteral( "root_doc" ) // Default value
12701303
) );
1304+
#endif
12711305

12721306
driverMetadata.insert( QStringLiteral( "KML" ),
12731307
MetaData(
@@ -1285,15 +1319,34 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
12851319
datasetOptions.clear();
12861320
layerOptions.clear();
12871321

1288-
layerOptions.insert( QStringLiteral( "SPATIAL_INDEX_MODE" ), new SetOption(
1289-
QObject::tr( "Use this to turn on 'quick spatial index mode'. "
1290-
"In this mode writing files can be about 5 times faster, "
1291-
"but spatial queries can be up to 30 times slower." ),
1292-
QStringList()
1293-
<< QStringLiteral( "QUICK" ),
1294-
QLatin1String( "" ), // Default value
1295-
true // Allow None
1322+
datasetOptions.insert( QStringLiteral( "SPATIAL_INDEX_MODE" ), new SetOption(
1323+
QObject::tr( "Use this to turn on 'quick spatial index mode'. "
1324+
"In this mode writing files can be about 5 times faster, "
1325+
"but spatial queries can be up to 30 times slower." ),
1326+
QStringList()
1327+
<< QStringLiteral( "QUICK" )
1328+
<< QStringLiteral( "OPTIMIZED" ),
1329+
QLatin1String( "QUICK" ), // Default value
1330+
true // Allow None
1331+
) );
1332+
1333+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,2)
1334+
datasetOptions.insert( QStringLiteral( "BLOCK_SIZE" ), new IntOption(
1335+
QObject::tr( "(multiples of 512): Block size for .map files. Defaults "
1336+
"to 512. MapInfo 15.2 and above creates .tab files with a "
1337+
"blocksize of 16384 bytes. Any MapInfo version should be "
1338+
"able to handle block sizes from 512 to 32256." ),
1339+
512
1340+
) );
1341+
#endif
1342+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
1343+
layerOptions.insert( QStringLiteral( "BOUNDS" ), new StringOption(
1344+
QObject::tr( "xmin,ymin,xmax,ymax: Define custom layer bounds to increase the "
1345+
"accuracy of the coordinates. Note: the geometry of written "
1346+
"features must be within the defined box." ),
1347+
QLatin1String( "" ) // Default value
12961348
) );
1349+
#endif
12971350

12981351
driverMetadata.insert( QStringLiteral( "MapInfo File" ),
12991352
MetaData(
@@ -1415,7 +1468,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
14151468
datasetOptions.insert( QStringLiteral( "RETURN_PRIMITIVES" ), new BoolOption(
14161469
QObject::tr( "Should all the low level geometry primitives be returned as special "
14171470
"IsolatedNode, ConnectedNode, Edge and Face layers." ),
1418-
true // Default value
1471+
false // Default value
14191472
) );
14201473

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

14411494
datasetOptions.insert( QStringLiteral( "RECODE_BY_DSSI" ), new BoolOption(
@@ -1632,17 +1685,15 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
16321685
datasetOptions.clear();
16331686
layerOptions.clear();
16341687

1635-
#if 0
16361688
datasetOptions.insert( "HEADER", new StringOption(
16371689
QObject::tr( "Override the header file used - in place of header.dxf." ),
1638-
"" // Default value
1690+
QLatin1String( "" ) // Default value
16391691
) );
16401692

16411693
datasetOptions.insert( "TRAILER", new StringOption(
16421694
QObject::tr( "Override the trailer file used - in place of trailer.dxf." ),
1643-
"" // Default value
1695+
QLatin1String( "" ) // Default value
16441696
) );
1645-
#endif
16461697

16471698
driverMetadata.insert( QStringLiteral( "DXF" ),
16481699
MetaData(
@@ -1668,14 +1719,20 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
16681719
QStringLiteral( "GXT" ) // Default value
16691720
) );
16701721

1671-
#if 0
16721722
datasetOptions.insert( "CONFIG", new StringOption(
16731723
QObject::tr( "path to the GCT : the GCT file describe the GeoConcept types definitions: "
16741724
"In this file, every line must start with //# followed by a keyword. "
16751725
"Lines starting with // are comments." ),
1676-
"" // Default value
1726+
QLatin1String( "" ) // Default value
1727+
) );
1728+
1729+
datasetOptions.insert( "FEATURETYPE", new StringOption(
1730+
QObject::tr( "defines the feature to be created. The TYPE corresponds to one of the Name "
1731+
"found in the GCT file for a type section. The SUBTYPE corresponds to one of "
1732+
"the Name found in the GCT file for a sub-type section within the previous "
1733+
"type section." ),
1734+
QLatin1String( "" ) // Default value
16771735
) );
1678-
#endif
16791736

16801737
driverMetadata.insert( QStringLiteral( "Geoconcept" ),
16811738
MetaData(
@@ -1703,7 +1760,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
17031760
QStringLiteral( "SHAPE" ) // Default value
17041761
) );
17051762

1706-
layerOptions.insert( QStringLiteral( "OID_NAME" ), new StringOption(
1763+
layerOptions.insert( QStringLiteral( "FID" ), new StringOption(
17071764
QObject::tr( "Name of the OID column to create. Defaults to 'OBJECTID'." ),
17081765
QStringLiteral( "OBJECTID" ) // Default value
17091766
) );
@@ -1734,6 +1791,18 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
17341791
false // Allow None
17351792
) );
17361793

1794+
layerOptions.insert( QStringLiteral( "OGR_XLSX_HEADERS" ), new SetOption(
1795+
QObject::tr( "By default, the driver will read the first lines of each sheet to detect "
1796+
"if the first line might be the name of columns. If set to FORCE, the "
1797+
"driver will consider the first default" ),
1798+
QStringList()
1799+
<< QStringLiteral( "FORCE" )
1800+
<< QStringLiteral( "DISABLE" )
1801+
<< QStringLiteral( "AUTO" ),
1802+
QStringLiteral( "AUTO" ), // Default value
1803+
false // Allow None
1804+
) );
1805+
17371806
driverMetadata.insert( QStringLiteral( "XLSX" ),
17381807
MetaData(
17391808
QStringLiteral( "MS Office Open XML spreadsheet" ),
@@ -1760,6 +1829,18 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
17601829
false // Allow None
17611830
) );
17621831

1832+
layerOptions.insert( QStringLiteral( "OGR_ODS_HEADERS" ), new SetOption(
1833+
QObject::tr( "By default, the driver will read the first lines of each sheet to detect "
1834+
"if the first line might be the name of columns. If set to FORCE, the "
1835+
"driver will consider the first default" ),
1836+
QStringList()
1837+
<< QStringLiteral( "FORCE" )
1838+
<< QStringLiteral( "DISABLE" )
1839+
<< QStringLiteral( "AUTO" ),
1840+
QStringLiteral( "AUTO" ), // Default value
1841+
false // Allow None
1842+
) );
1843+
17631844
driverMetadata.insert( QStringLiteral( "ODS" ),
17641845
MetaData(
17651846
QStringLiteral( "Open Document Spreadsheet" ),

0 commit comments

Comments
 (0)