Skip to content

Commit 601e373

Browse files
committedJul 24, 2017
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)
1 parent ab6dd74 commit 601e373

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
@@ -825,7 +825,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
825825
<< "AS_XYZ"
826826
<< "AS_XY"
827827
<< "AS_YX",
828-
"AS_XY", // Default value
828+
"", // Default value
829829
true // Allow None
830830
) );
831831

@@ -868,9 +868,21 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
868868
QObject::tr( "Override the type of shapefile created. "
869869
"Can be one of NULL for a simple .dbf file with no .shp file, POINT, "
870870
"ARC, POLYGON or MULTIPOINT for 2D, or POINTZ, ARCZ, POLYGONZ or "
871-
"MULTIPOINTZ for 3D. Shapefiles with measure values are not supported, "
872-
"nor are MULTIPATCH files." ),
873-
QStringList()
871+
"MULTIPOINTZ for 3D;" ) +
872+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,1,0)
873+
QObject::tr( " Shapefiles with measure values are not supported,"
874+
" nor are MULTIPATCH files." ) +
875+
#endif
876+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,0)
877+
QObject::tr( " POINTM, ARCM, POLYGONM or MULTIPOINTM for measured geometries"
878+
" and POINTZM, ARCZM, POLYGONZM or MULTIPOINTZM for 3D measured"
879+
" geometries." ) +
880+
#endif
881+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
882+
QObject::tr( " MULTIPATCH files are supported since GDAL 2.2." ) +
883+
#endif
884+
""
885+
, QStringList()
874886
<< "NULL"
875887
<< "POINT"
876888
<< "ARC"
@@ -879,7 +891,21 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
879891
<< "POINTZ"
880892
<< "ARCZ"
881893
<< "POLYGONZ"
882-
<< "MULTIPOINTZ",
894+
<< "MULTIPOINTZ"
895+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,0)
896+
<< "POINTM"
897+
<< "ARCM"
898+
<< "POLYGONM"
899+
<< "MULTIPOINTM"
900+
<< "POINTZM"
901+
<< "ARCZM"
902+
<< "POLYGONZM"
903+
<< "MULTIPOINTZM"
904+
#endif
905+
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
906+
<< "MULTIPATCH"
907+
#endif
908+
<< "",
883909
QString(), // Default value
884910
true // Allow None
885911
) );
@@ -1001,7 +1027,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
10011027
"the foo_bar pattern, foo will be considered as the namespace "
10021028
"of the element, and a <foo:bar> element will be written. "
10031029
"Otherwise, elements will be written in the <ogr:> namespace." ),
1004-
true // Default value
1030+
false // Default value
10051031
) );
10061032

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

11781204
layerOptions.insert( "GEOMETRY_NAME", new StringOption(
11791205
QObject::tr( "Name for the geometry column" ),
1180-
"geometry" // Default value
1206+
"geom" // Default value
11811207
) );
11821208

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

12441270
datasetOptions.insert( "GPX_EXTENSIONS_NS", new StringOption(
@@ -1329,8 +1355,16 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
13291355
<< "clampToGround"
13301356
<< "relativeToGround"
13311357
<< "absolute",
1332-
"clampToGround" // Default value
1358+
"relativeToGround" // Default value
1359+
) );
1360+
1361+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
1362+
datasetOptions.insert( "DOCUMENT_ID", new StringOption(
1363+
QObject::tr( "The DOCUMENT_ID datasource creation option can be used to specified "
1364+
"the id of the root <Document> node. The default value is root_doc." ),
1365+
"root_doc" // Default value
13331366
) );
1367+
#endif
13341368

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

1351-
layerOptions.insert( "SPATIAL_INDEX_MODE", new SetOption(
1352-
QObject::tr( "Use this to turn on 'quick spatial index mode'. "
1353-
"In this mode writing files can be about 5 times faster, "
1354-
"but spatial queries can be up to 30 times slower." ),
1355-
QStringList()
1356-
<< "QUICK",
1357-
"", // Default value
1358-
true // Allow None
1385+
datasetOptions.insert( "SPATIAL_INDEX_MODE", new SetOption(
1386+
QObject::tr( "Use this to turn on 'quick spatial index mode'. "
1387+
"In this mode writing files can be about 5 times faster, "
1388+
"but spatial queries can be up to 30 times slower." ),
1389+
QStringList()
1390+
<< "QUICK"
1391+
<< "OPTIMIZED",
1392+
"QUICK", // Default value
1393+
true // Allow None
1394+
) );
1395+
1396+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,2)
1397+
datasetOptions.insert( "BLOCK_SIZE", new IntOption(
1398+
QObject::tr( "(multiples of 512): Block size for .map files. Defaults "
1399+
"to 512. MapInfo 15.2 and above creates .tab files with a "
1400+
"blocksize of 16384 bytes. Any MapInfo version should be "
1401+
"able to handle block sizes from 512 to 32256." ),
1402+
512
1403+
) );
1404+
#endif
1405+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
1406+
layerOptions.insert( "BOUNDS", new StringOption(
1407+
QObject::tr( "xmin,ymin,xmax,ymax: Define custom layer bounds to increase the "
1408+
"accuracy of the coordinates. Note: the geometry of written "
1409+
"features must be within the defined box." ),
1410+
"" // Default value
13591411
) );
1412+
#endif
13601413

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

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

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

1698-
#if 0
16991751
datasetOptions.insert( "HEADER", new StringOption(
17001752
QObject::tr( "Override the header file used - in place of header.dxf." ),
1701-
"" // Default value
1753+
QLatin1String( "" ) // Default value
17021754
) );
17031755

17041756
datasetOptions.insert( "TRAILER", new StringOption(
17051757
QObject::tr( "Override the trailer file used - in place of trailer.dxf." ),
1706-
"" // Default value
1758+
QLatin1String( "" ) // Default value
17071759
) );
1708-
#endif
17091760

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

1734-
#if 0
17351785
datasetOptions.insert( "CONFIG", new StringOption(
17361786
QObject::tr( "path to the GCT : the GCT file describe the GeoConcept types definitions: "
17371787
"In this file, every line must start with //# followed by a keyword. "
17381788
"Lines starting with // are comments." ),
1739-
"" // Default value
1789+
QLatin1String( "" ) // Default value
1790+
) );
1791+
1792+
datasetOptions.insert( "FEATURETYPE", new StringOption(
1793+
QObject::tr( "defines the feature to be created. The TYPE corresponds to one of the Name "
1794+
"found in the GCT file for a type section. The SUBTYPE corresponds to one of "
1795+
"the Name found in the GCT file for a sub-type section within the previous "
1796+
"type section." ),
1797+
QLatin1String( "" ) // Default value
17401798
) );
1741-
#endif
17421799

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

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

1857+
layerOptions.insert( "OGR_XLSX_HEADERS", new SetOption(
1858+
QObject::tr( "By default, the driver will read the first lines of each sheet to detect "
1859+
"if the first line might be the name of columns. If set to FORCE, the "
1860+
"driver will consider the first default" ),
1861+
QStringList()
1862+
<< "FORCE"
1863+
<< "DISABLE"
1864+
<< "AUTO",
1865+
"AUTO", // Default value
1866+
false // Allow None
1867+
) );
1868+
18001869
driverMetadata.insert( "XLSX",
18011870
MetaData(
18021871
"MS Office Open XML spreadsheet",
@@ -1823,6 +1892,18 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
18231892
false // Allow None
18241893
) );
18251894

1895+
layerOptions.insert( "OGR_ODS_HEADERS", new SetOption(
1896+
QObject::tr( "By default, the driver will read the first lines of each sheet to detect "
1897+
"if the first line might be the name of columns. If set to FORCE, the "
1898+
"driver will consider the first default" ),
1899+
QStringList()
1900+
<< "FORCE"
1901+
<< "DISABLE"
1902+
<< "AUTO",
1903+
"AUTO", // Default value
1904+
false // Allow None
1905+
) );
1906+
18261907
driverMetadata.insert( "ODS",
18271908
MetaData(
18281909
"Open Document Spreadsheet",

0 commit comments

Comments
 (0)
Please sign in to comment.