37 #include <QTextStream> 45 #include <ogr_srs_api.h> 46 #include <cpl_error.h> 49 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800 50 #define TO8F(x) (x).toUtf8().constData() 52 #define TO8F(x) QFile::encodeName( x ).constData() 57 const QString &theVectorFileName,
74 , mWkbType(
QGis::fromOldWkbType( geometryType ) )
75 , mSymbologyExport( symbologyExport )
76 , mSymbologyScaleDenominator( 1.0 )
78 init( theVectorFileName, theFileEncoding, fields,
QGis::fromOldWkbType( geometryType ), srs, driverName, datasourceOptions, layerOptions, newFilename );
92 init( vectorFileName, fileEncoding, fields, geometryType, srs, driverName, datasourceOptions, layerOptions, newFilename );
106 if ( driverName ==
"MapInfo MIF" )
110 else if ( driverName ==
"SpatiaLite" )
113 if ( !datasourceOptions.
contains(
"SPATIALITE=YES" ) )
115 datasourceOptions.
append(
"SPATIALITE=YES" );
118 else if ( driverName ==
"DBF file" )
121 if ( !layerOptions.
contains(
"SHPT=NULL" ) )
123 layerOptions.
append(
"SHPT=NULL" );
133 OGRSFDriverH poDriver;
154 if ( driverName ==
"ESRI Shapefile" && !vectorFileName.
endsWith(
".shp", Qt::CaseInsensitive ) )
156 vectorFileName +=
".shp";
158 else if ( driverName ==
"DBF file" && !vectorFileName.
endsWith(
".dbf", Qt::CaseInsensitive ) )
160 vectorFileName +=
".dbf";
163 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700 166 for (
int i = 0; i < fields.
count(); ++i )
168 QString name = fields[i].name().left( 10 );
171 mErrorMessage =
QObject::tr(
"trimming attribute name '%1' to ten significant characters produces duplicate column name." )
172 .
arg( fields[i].name() );
182 else if ( driverName ==
"KML" )
184 if ( !vectorFileName.
endsWith(
".kml", Qt::CaseInsensitive ) )
186 vectorFileName +=
".kml";
189 if ( fileEncoding.
compare(
"UTF-8", Qt::CaseInsensitive ) != 0 )
192 fileEncoding =
"UTF-8";
207 Q_FOREACH (
const QString& ext, allExts )
209 if ( vectorFileName.
endsWith(
'.' + ext, Qt::CaseInsensitive ) )
218 vectorFileName +=
'.' + allExts[0];
225 char **options =
nullptr;
226 if ( !datasourceOptions.
isEmpty() )
228 options =
new char *[ datasourceOptions.
size()+1 ];
229 for (
int i = 0; i < datasourceOptions.
size(); i++ )
231 options[i] = CPLStrdup( datasourceOptions[i].toLocal8Bit().data() );
233 options[ datasourceOptions.
size()] =
nullptr;
237 mDS = OGR_Dr_CreateDataSource( poDriver,
TO8F( vectorFileName ), options );
241 for (
int i = 0; i < datasourceOptions.
size(); i++ )
242 CPLFree( options[i] );
261 QgsDebugMsg(
"error finding QTextCodec for " + fileEncoding );
268 QgsDebugMsg(
"error finding QTextCodec for " + enc );
288 options =
new char *[ layerOptions.
size()+1 ];
289 for (
int i = 0; i < layerOptions.
size(); i++ )
291 options[i] = CPLStrdup( layerOptions[i].toLocal8Bit().data() );
293 options[ layerOptions.
size()] =
nullptr;
297 CPLSetConfigOption(
"SHAPE_ENCODING",
"" );
303 for (
int i = 0; i < layerOptions.
size(); i++ )
304 CPLFree( options[i] );
310 if ( !settings.
value(
"/qgis/ignoreShapeEncoding",
true ).
toBool() )
312 CPLSetConfigOption(
"SHAPE_ENCODING",
nullptr );
319 QString layerName = vectorFileName.
left( vectorFileName.
indexOf(
".shp", Qt::CaseInsensitive ) );
320 QFile prjFile( layerName +
".qpj" );
321 if ( prjFile.
open( QIODevice::WriteOnly ) )
329 QgsDebugMsg(
"Couldn't open file " + layerName +
".qpj" );
342 OGRFeatureDefnH defn = OGR_L_GetLayerDefn(
mLayer );
353 for (
int fldIdx = 0; fldIdx < fields.
count(); ++fldIdx )
355 const QgsField& attrField = fields[fldIdx];
357 OGRFieldType ogrType = OFTString;
358 int ogrWidth = attrField.
length();
359 int ogrPrecision = attrField.
precision();
360 if ( ogrPrecision > 0 )
363 switch ( attrField.
type() )
365 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 2000000 366 case QVariant::LongLong:
368 ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
372 case QVariant::LongLong:
373 ogrType = OFTInteger64;
374 ogrWidth = ogrWidth > 0 && ogrWidth <= 20 ? ogrWidth : 20;
378 case QVariant::String:
380 if ( ogrWidth <= 0 || ogrWidth > 255 )
385 ogrType = OFTInteger;
386 ogrWidth = ogrWidth > 0 && ogrWidth <= 10 ? ogrWidth : 10;
390 case QVariant::Double:
410 case QVariant::DateTime:
418 ogrType = OFTDateTime;
435 for ( i = 0; i < 10; i++ )
440 for ( j = 0; j < fields.
size() && name.compare( fields[j].name(), Qt::CaseInsensitive ) != 0; j++ )
443 if ( j == fields.
size() )
461 OGR_Fld_SetWidth( fld, ogrWidth );
464 if ( ogrPrecision >= 0 )
466 OGR_Fld_SetPrecision( fld, ogrPrecision );
474 if ( OGR_L_CreateField(
mLayer, fld,
true ) != OGRERR_NONE )
481 OGR_Fld_Destroy( fld );
484 OGR_Fld_Destroy( fld );
487 QgsDebugMsg(
QString(
"returned field index for %1: %2" ).arg( name ).arg( ogrIdx ) );
488 if ( ogrIdx < 0 || existingIdxs.
contains( ogrIdx ) )
490 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700 493 int fieldCount = OGR_FD_GetFieldCount( defn );
495 OGRFieldDefnH fdefn = OGR_FD_GetFieldDefn( defn, fieldCount - 1 );
498 const char *fieldName = OGR_Fld_GetNameRef( fdefn );
500 if ( attrField.
name().
left( strlen( fieldName ) ) == fieldName )
502 ogrIdx = fieldCount - 1;
507 ogrIdx = OGR_FD_GetFieldCount( defn ) - 1;
521 existingIdxs.
insert( ogrIdx );
535 *newFilename = vectorFileName;
551 datasetOptions.
clear();
552 layerOptions.
clear();
554 driverMetadata.
insert(
"AVCE00",
556 "Arc/Info ASCII Coverage",
566 datasetOptions.
clear();
567 layerOptions.
clear();
571 "systems default line termination conventions. " 572 "This may be overridden here." ),
581 QObject::tr(
"By default, BNA files are created in multi-line format. " 582 "For each record, the first line contains the identifiers and the " 583 "type/number of coordinates to follow. Each following line contains " 584 "a pair of coordinates." ),
589 QObject::tr(
"BNA records may contain from 2 to 4 identifiers per record. " 590 "Some software packages only support a precise number of identifiers. " 591 "You can override the default value (2) by a precise value" ),
596 <<
"NB_SOURCE_FIELDS",
601 QObject::tr(
"The BNA writer will try to recognize ellipses and circles when writing a polygon. " 602 "This will only work if the feature has previously been read from a BNA file. " 603 "As some software packages do not support ellipses/circles in BNA data file, " 604 "it may be useful to tell the writer by specifying ELLIPSES_AS_ELLIPSES=NO not " 605 "to export them as such, but keep them as polygons." ),
610 QObject::tr(
"Limit the number of coordinate pairs per line in multiline format." ),
615 QObject::tr(
"Set the number of decimal for coordinates. Default value is 10." ),
619 driverMetadata.
insert(
"BNA",
631 datasetOptions.
clear();
632 layerOptions.
clear();
635 QObject::tr(
"By default when creating new .csv files they " 636 "are created with the line termination conventions " 637 "of the local platform (CR/LF on Win32 or LF on all other systems). " 638 "This may be overridden through the use of the LINEFORMAT option." ),
647 QObject::tr(
"By default, the geometry of a feature written to a .csv file is discarded. " 648 "It is possible to export the geometry in its WKT representation by " 649 "specifying GEOMETRY=AS_WKT. It is also possible to export point geometries " 650 "into their X,Y,Z components by specifying GEOMETRY=AS_XYZ, GEOMETRY=AS_XY " 651 "or GEOMETRY=AS_YX." ),
662 QObject::tr(
"Create the associated .csvt file to describe the type of each " 663 "column of the layer and its optional width and precision." ),
677 QObject::tr(
"Write a UTF-8 Byte Order Mark (BOM) at the start of the file." ),
681 driverMetadata.
insert(
"CSV",
683 "Comma Separated Value [CSV]",
693 datasetOptions.
clear();
694 layerOptions.
clear();
697 QObject::tr(
"Override the type of shapefile created. " 698 "Can be one of NULL for a simple .dbf file with no .shp file, POINT, " 699 "ARC, POLYGON or MULTIPOINT for 2D, or POINTZ, ARCZ, POLYGONZ or " 700 "MULTIPOINTZ for 3D. Shapefiles with measure values are not supported, " 701 "nor are MULTIPATCH files." ),
720 QObject::tr(
"set the encoding value in the DBF file. " 721 "The default value is LDID/87. It is not clear " 722 "what other values may be appropriate." ),
730 QObject::tr(
"Set to YES to resize fields to their optimal size." ),
734 driverMetadata.
insert(
"ESRI",
746 datasetOptions.
clear();
747 layerOptions.
clear();
749 driverMetadata.
insert(
"DBF File",
761 datasetOptions.
clear();
762 layerOptions.
clear();
764 driverMetadata.
insert(
"FMEObjects Gateway",
766 "FMEObjects Gateway",
776 datasetOptions.
clear();
777 layerOptions.
clear();
780 QObject::tr(
"Set to YES to write a bbox property with the bounding box " 781 "of the geometries at the feature and feature collection level." ),
786 QObject::tr(
"Maximum number of figures after decimal separator to write in coordinates. " 787 "Default to 15. Truncation will occur to remove trailing zeros." ),
791 driverMetadata.
insert(
"GeoJSON",
803 datasetOptions.
clear();
804 layerOptions.
clear();
807 QObject::tr(
"whether the document must be in RSS 2.0 or Atom 1.0 format. " 808 "Default value : RSS" ),
816 QObject::tr(
"The encoding of location information. Default value : SIMPLE. " 817 "W3C_GEO only supports point geometries. " 818 "SIMPLE or W3C_GEO only support geometries in geographic WGS84 coordinates." ),
827 QObject::tr(
"If defined to YES, extension fields will be written. " 828 "If the field name not found in the base schema matches " 829 "the foo_bar pattern, foo will be considered as the namespace " 830 "of the element, and a <foo:bar> element will be written. " 831 "Otherwise, elements will be written in the <ogr:> namespace." ),
836 QObject::tr(
"If defined to NO, only <entry> or <item> elements will be written. " 837 "The user will have to provide the appropriate header and footer of the document." ),
842 QObject::tr(
"XML content that will be put between the <channel> element and the " 843 "first <item> element for a RSS document, or between the xml tag and " 844 "the first <entry> element for an Atom document. " ),
849 QObject::tr(
"Value put inside the <title> element in the header. " 850 "If not provided, a dummy value will be used as that element is compulsory." ),
855 QObject::tr(
"Value put inside the <description> element in the header. " 856 "If not provided, a dummy value will be used as that element is compulsory." ),
861 QObject::tr(
"Value put inside the <link> element in the header. " 862 "If not provided, a dummy value will be used as that element is compulsory." ),
867 QObject::tr(
"Value put inside the <updated> element in the header. " 868 "Should be formatted as a XML datetime. " 869 "If not provided, a dummy value will be used as that element is compulsory." ),
874 QObject::tr(
"Value put inside the <author><name> element in the header. " 875 "If not provided, a dummy value will be used as that element is compulsory." ),
880 QObject::tr(
"Value put inside the <id> element in the header. " 881 "If not provided, a dummy value will be used as that element is compulsory." ),
885 driverMetadata.
insert(
"GeoRSS",
897 datasetOptions.
clear();
898 layerOptions.
clear();
901 QObject::tr(
"If provided, this URI will be inserted as the schema location. " 902 "Note that the schema file isn't actually accessed by OGR, so it " 903 "is up to the user to ensure it will match the schema of the OGR " 904 "produced GML data file." ),
909 QObject::tr(
"This writes a GML application schema file to a corresponding " 910 ".xsd file (with the same basename). If INTERNAL is used the " 911 "schema is written within the GML file, but this is experimental " 912 "and almost certainly not valid XML. " 913 "OFF disables schema generation (and is implicit if XSISCHEMAURI is used)." ),
922 QObject::tr(
"This is the prefix for the application target namespace." ),
927 QObject::tr(
"Can be set to TRUE to avoid writing the prefix of the " 928 "application target namespace in the GML file." ),
933 QObject::tr(
"Defaults to 'http://ogr.maptools.org/'. " 934 "This is the application target namespace." ),
935 "http://ogr.maptools.org/" 939 QObject::tr(
"If not specified, GML2 will be used." ),
949 QObject::tr(
"only valid when FORMAT=GML3/GML3Degree/GML3.2) Default to YES. " 950 "If YES, SRS with EPSG authority will be written with the " 951 "'urn:ogc:def:crs:EPSG::' prefix. In the case, if the SRS is a " 952 "geographic SRS without explicit AXIS order, but that the same " 953 "SRS authority code imported with ImportFromEPSGA() should be " 954 "treated as lat/long, then the function will take care of coordinate " 955 "order swapping. If set to NO, SRS with EPSG authority will be " 956 "written with the 'EPSG:' prefix, even if they are in lat/long order." ),
961 QObject::tr(
"only valid when FORMAT=GML3/GML3Degree/GML3.2) Default to YES. " 962 "If set to NO, the <gml:boundedBy> element will not be written for " 968 QObject::tr(
"Default to YES. If YES, the output will be indented with spaces " 969 "for more readability, but at the expense of file size." ),
974 driverMetadata.
insert(
"GML",
976 "Geography Markup Language [GML]",
986 datasetOptions.
clear();
987 layerOptions.
clear();
989 driverMetadata.
insert(
"GMT",
991 "Generic Mapping Tools [GMT]",
1001 datasetOptions.
clear();
1002 layerOptions.
clear();
1005 QObject::tr(
"By default when writing a layer whose features are of " 1006 "type wkbLineString, the GPX driver chooses to write " 1007 "them as routes. If FORCE_GPX_TRACK=YES is specified, " 1008 "they will be written as tracks." ),
1013 QObject::tr(
"By default when writing a layer whose features are of " 1014 "type wkbMultiLineString, the GPX driver chooses to write " 1015 "them as tracks. If FORCE_GPX_ROUTE=YES is specified, " 1016 "they will be written as routes, provided that the multilines " 1017 "are composed of only one single line." ),
1022 QObject::tr(
"If GPX_USE_EXTENSIONS=YES is specified, " 1023 "extra fields will be written inside the <extensions> tag." ),
1028 QObject::tr(
"Only used if GPX_USE_EXTENSIONS=YES and GPX_EXTENSIONS_NS_URL " 1029 "is set. The namespace value used for extension tags. By default, 'ogr'." ),
1034 QObject::tr(
"Only used if GPX_USE_EXTENSIONS=YES and GPX_EXTENSIONS_NS " 1035 "is set. The namespace URI. By default, 'http://osgeo.org/gdal'." ),
1036 "http://osgeo.org/gdal" 1040 QObject::tr(
"By default files are created with the line termination " 1041 "conventions of the local platform (CR/LF on win32 or LF " 1042 "on all other systems). This may be overridden through use " 1043 "of the LINEFORMAT layer creation option which may have a value " 1044 "of CRLF (DOS format) or LF (Unix format)." ),
1052 driverMetadata.
insert(
"GPX",
1054 "GPS eXchange Format [GPX]",
1064 datasetOptions.
clear();
1065 layerOptions.
clear();
1067 driverMetadata.
insert(
"Interlis 1",
1071 "*.itf *.xml *.ili",
1079 datasetOptions.
clear();
1080 layerOptions.
clear();
1082 driverMetadata.
insert(
"Interlis 2",
1086 "*.itf *.xml *.ili",
1094 datasetOptions.
clear();
1095 layerOptions.
clear();
1098 QObject::tr(
"Allows you to specify the field to use for the KML <name> element. " ),
1103 QObject::tr(
"Allows you to specify the field to use for the KML <description> element." ),
1108 QObject::tr(
"Allows you to specify the AltitudeMode to use for KML geometries. " 1109 "This will only affect 3D geometries and must be one of the valid KML options." ),
1112 <<
"relativeToGround" 1117 driverMetadata.
insert(
"KML",
1119 "Keyhole Markup Language [KML]",
1129 datasetOptions.
clear();
1130 layerOptions.
clear();
1133 QObject::tr(
"Use this to turn on 'quick spatial index mode'. " 1134 "In this mode writing files can be about 5 times faster, " 1135 "but spatial queries can be up to 30 times slower." ),
1142 driverMetadata.
insert(
"MapInfo File",
1154 driverMetadata.
insert(
"MapInfo MIF",
1166 datasetOptions.
clear();
1167 layerOptions.
clear();
1170 QObject::tr(
"Determine whether 2D (seed_2d.dgn) or 3D (seed_3d.dgn) " 1171 "seed file should be used. This option is ignored if the SEED option is provided." ),
1181 QObject::tr(
"Indicate whether the whole seed file should be copied. " 1182 "If not, only the first three elements will be copied." ),
1187 QObject::tr(
"Indicates whether the color table should be copied from the seed file." ),
1192 QObject::tr(
"Override the master unit name from the seed file with " 1193 "the provided one or two character unit name." ),
1198 QObject::tr(
"Override the sub unit name from the seed file with the provided " 1199 "one or two character unit name." ),
1204 QObject::tr(
"Override the number of subunits per master unit. " 1205 "By default the seed file value is used." ),
1210 QObject::tr(
"Override the number of UORs (Units of Resolution) " 1211 "per sub unit. By default the seed file value is used." ),
1216 QObject::tr(
"ORIGIN=x,y,z: Override the origin of the design plane. " 1217 "By default the origin from the seed file is used." ),
1221 driverMetadata.
insert(
"DGN",
1233 datasetOptions.
clear();
1234 layerOptions.
clear();
1236 driverMetadata.
insert(
"DGN",
1248 datasetOptions.
clear();
1249 layerOptions.
clear();
1252 QObject::tr(
"Should update files be incorporated into the base data on the fly. " ),
1260 QObject::tr(
"Should multipoint soundings be split into many single point sounding features. " 1261 "Multipoint geometries are not well handled by many formats, " 1262 "so it can be convenient to split single sounding features with many points " 1263 "into many single point features." ),
1268 QObject::tr(
"Should a DEPTH attribute be added on SOUNDG features and assign the depth " 1269 "of the sounding. This should only be enabled with SPLIT_MULTIPOINT is " 1275 QObject::tr(
"Should all the low level geometry primitives be returned as special " 1276 "IsolatedNode, ConnectedNode, Edge and Face layers." ),
1281 QObject::tr(
"If enabled, numeric attributes assigned an empty string as a value will " 1282 "be preserved as a special numeric value. This option should not generally " 1283 "be needed, but may be useful when translated S-57 to S-57 losslessly." ),
1288 QObject::tr(
"Should LNAM and LNAM_REFS fields be attached to features capturing " 1289 "the feature to feature relationships in the FFPT group of the S-57 file." ),
1294 QObject::tr(
"Should additional attributes relating features to their underlying " 1295 "geometric primitives be attached. These are the values of the FSPT group, " 1296 "and are primarily needed when doing S-57 to S-57 translations." ),
1301 QObject::tr(
"Should attribute values be recoded to UTF-8 from the character encoding " 1302 "specified in the S57 DSSI record." ),
1308 driverMetadata.
insert(
"S57",
1320 datasetOptions.
clear();
1321 layerOptions.
clear();
1323 driverMetadata.
insert(
"SDTS",
1325 "Spatial Data Transfer Standard [SDTS]",
1326 QObject::tr(
"Spatial Data Transfer Standard [SDTS]" ),
1335 datasetOptions.
clear();
1336 layerOptions.
clear();
1339 QObject::tr(
"Can be used to avoid creating the geometry_columns and spatial_ref_sys " 1340 "tables in a new database. By default these metadata tables are created " 1341 "when a new database is created." ),
1356 QObject::tr(
"Controls the format used for the geometry column. Defaults to WKB." 1357 "This is generally more space and processing efficient, but harder " 1358 "to inspect or use in simple applications than WKT (Well Known Text)." ),
1366 QObject::tr(
"Controls whether layer and field names will be laundered for easier use " 1367 "in SQLite. Laundered names will be converted to lower case and some special " 1368 "characters(' - #) will be changed to underscores." ),
1385 QObject::tr(
"column_name1[,column_name2, ...] A list of (String) columns that " 1386 "must be compressed with ZLib DEFLATE algorithm. This might be beneficial " 1387 "for databases that have big string blobs. However, use with care, since " 1388 "the value of such columns will be seen as compressed binary content with " 1389 "other SQLite utilities (or previous OGR versions). With OGR, when inserting, " 1390 "modifying or queryings compressed columns, compression/decompression is " 1391 "done transparently. However, such columns cannot be (easily) queried with " 1392 "an attribute filter or WHERE clause. Note: in table definition, such columns " 1393 "have the 'VARCHAR_deflate' declaration type." ),
1397 driverMetadata.
insert(
"SQLite",
1409 datasetOptions.
clear();
1410 layerOptions.
clear();
1413 QObject::tr(
"Can be used to avoid creating the geometry_columns and spatial_ref_sys " 1414 "tables in a new database. By default these metadata tables are created " 1415 "when a new database is created." ),
1424 QObject::tr(
"Insert the content of the EPSG CSV files into the spatial_ref_sys table. " 1425 "Set to NO for regular SQLite databases." ),
1434 QObject::tr(
"Controls whether layer and field names will be laundered for easier use " 1435 "in SQLite. Laundered names will be converted to lower case and some special " 1436 "characters(' - #) will be changed to underscores." ),
1441 QObject::tr(
"If the database is of the SpatiaLite flavour, and if OGR is linked " 1442 "against libspatialite, this option can be used to control if a spatial " 1443 "index must be created." ),
1448 QObject::tr(
"If the format of the geometry BLOB is of the SpatiaLite flavour, " 1449 "this option can be used to control if the compressed format for " 1450 "geometries (LINESTRINGs, POLYGONs) must be used" ),
1455 QObject::tr(
"Used to force the SRID number of the SRS associated with the layer. " 1456 "When this option isn't specified and that a SRS is associated with the " 1457 "layer, a search is made in the spatial_ref_sys to find a match for the " 1458 "SRS, and, if there is no match, a new entry is inserted for the SRS in " 1459 "the spatial_ref_sys table. When the SRID option is specified, this " 1460 "search (and the eventual insertion of a new entry) will not be done: " 1461 "the specified SRID is used as such." ),
1466 QObject::tr(
"column_name1[,column_name2, ...] A list of (String) columns that " 1467 "must be compressed with ZLib DEFLATE algorithm. This might be beneficial " 1468 "for databases that have big string blobs. However, use with care, since " 1469 "the value of such columns will be seen as compressed binary content with " 1470 "other SQLite utilities (or previous OGR versions). With OGR, when inserting, " 1471 "modifying or queryings compressed columns, compression/decompression is " 1472 "done transparently. However, such columns cannot be (easily) queried with " 1473 "an attribute filter or WHERE clause. Note: in table definition, such columns " 1474 "have the 'VARCHAR_deflate' declaration type." ),
1478 driverMetadata.
insert(
"SpatiaLite",
1489 datasetOptions.
clear();
1490 layerOptions.
clear();
1494 QObject::tr(
"Override the header file used - in place of header.dxf." ),
1499 QObject::tr(
"Override the trailer file used - in place of trailer.dxf." ),
1504 driverMetadata.
insert(
"DXF",
1516 datasetOptions.
clear();
1517 layerOptions.
clear();
1520 QObject::tr(
"Indicates the GeoConcept export file extension. " 1521 "TXT was used by earlier releases of GeoConcept. GXT is currently used." ),
1530 QObject::tr(
"path to the GCT : the GCT file describe the GeoConcept types definitions: " 1531 "In this file, every line must start with //# followed by a keyword. " 1532 "Lines starting with // are comments." ),
1537 driverMetadata.
insert(
"Geoconcept",
1549 datasetOptions.
clear();
1550 layerOptions.
clear();
1553 QObject::tr(
"When this option is set, the new layer will be created inside the named " 1554 "FeatureDataset folder. If the folder does not already exist, it will be created." ),
1559 QObject::tr(
"Set name of geometry column in new layer. Defaults to 'SHAPE'." ),
1564 QObject::tr(
"Name of the OID column to create. Defaults to 'OBJECTID'." ),
1568 driverMetadata.
insert(
"FileGDB",
1580 datasetOptions.
clear();
1581 layerOptions.
clear();
1584 QObject::tr(
"By default, the driver will try to detect the data type of fields. If set " 1585 "to STRING, all fields will be of String type." ),
1593 driverMetadata.
insert(
"XLSX",
1595 "MS Office Open XML spreadsheet",
1605 datasetOptions.
clear();
1606 layerOptions.
clear();
1609 QObject::tr(
"By default, the driver will try to detect the data type of fields. If set " 1610 "to STRING, all fields will be of String type." ),
1618 driverMetadata.
insert(
"ODS",
1620 "Open Document Spreadsheet",
1638 for ( ; it != sDriverMetadata.
constEnd(); ++it )
1640 if ( it.
key().startsWith( driverName ) || it.
value().longName.startsWith( driverName ) )
1642 driverMetadata = it.
value();
1654 OGRwkbGeometryType ogrType =
static_cast<OGRwkbGeometryType
>( type );
1676 OGRFeatureH poFeature = createFeature( feature );
1690 for ( ; symbolIt != symbols.
constEnd(); ++symbolIt )
1692 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1693 for (
int i = 0; i < nSymbolLayers; ++i )
1697 if ( it == mSymbolLayerTable.constEnd() )
1705 currentStyle = ( *symbolIt )->symbolLayer( i )->ogrFeatureStyle( mmsf, musf );
1709 if ( symbolIt != symbols.
constBegin() || i != 0 )
1711 styleString.
append(
';' );
1713 styleString.
append( currentStyle );
1717 OGR_F_SetStyleString( poFeature, currentStyle.toLocal8Bit().data() );
1718 if ( !writeFeature(
mLayer, poFeature ) )
1730 if ( !writeFeature(
mLayer, poFeature ) )
1736 OGR_F_Destroy( poFeature );
1740 OGRFeatureH QgsVectorFileWriter::createFeature(
QgsFeature& feature )
1745 OGRFeatureH poFeature = OGR_F_Create( OGR_L_GetLayerDefn(
mLayer ) );
1751 OGRErr err = OGR_F_SetFID( poFeature, static_cast<long>( fid ) );
1752 if ( err != OGRERR_NONE )
1755 .arg( feature.
id() )
1756 .arg( err ).
arg( CPLGetLastErrorMsg() )
1762 for (
int fldIdx = 0; fldIdx <
mFields.
count(); ++fldIdx )
1776 switch ( attrValue.
type() )
1778 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 1780 case QVariant::UInt:
1781 OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.
toInt() );
1783 case QVariant::LongLong:
1784 case QVariant::ULongLong:
1785 OGR_F_SetFieldInteger64( poFeature, ogrField, attrValue.
toLongLong() );
1787 case QVariant::String:
1792 OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.
toInt() );
1794 case QVariant::String:
1795 case QVariant::LongLong:
1796 case QVariant::UInt:
1797 case QVariant::ULongLong:
1801 case QVariant::Double:
1802 OGR_F_SetFieldDouble( poFeature, ogrField, attrValue.
toDouble() );
1804 case QVariant::Date:
1805 OGR_F_SetFieldDateTime( poFeature, ogrField,
1811 case QVariant::DateTime:
1818 OGR_F_SetFieldDateTime( poFeature, ogrField,
1828 case QVariant::Time:
1835 OGR_F_SetFieldDateTime( poFeature, ogrField,
1843 case QVariant::Invalid:
1873 OGRGeometryH mGeom2 =
nullptr;
1910 OGR_F_Destroy( poFeature );
1914 OGRErr err = OGR_G_ImportFromWkb( mGeom2, const_cast<unsigned char *>( geom->
asWkb() ), static_cast< int >( geom->
wkbSize() ) );
1915 if ( err != OGRERR_NONE )
1921 OGR_F_Destroy( poFeature );
1926 OGR_F_SetGeometryDirectly( poFeature, mGeom2 );
1930 OGRErr err = OGR_G_ImportFromWkb(
mGeom, const_cast<unsigned char *>( geom->
asWkb() ), static_cast< int >( geom->
wkbSize() ) );
1931 if ( err != OGRERR_NONE )
1937 OGR_F_Destroy( poFeature );
1942 OGR_F_SetGeometry( poFeature,
mGeom );
1953 bool QgsVectorFileWriter::writeFeature( OGRLayerH layer, OGRFeatureH feature )
1955 if ( OGR_L_CreateFeature( layer, feature ) != OGRERR_NONE )
1960 OGR_F_Destroy( feature );
1970 OGR_G_DestroyGeometry(
mGeom );
1975 OGR_DS_Destroy(
mDS );
1980 OSRDestroySpatialReference(
mOgrRef );
1994 bool skipAttributeCreation,
1997 double symbologyScale,
2004 if ( destCRS && layer )
2010 errorMessage, datasourceOptions, layerOptions, skipAttributeCreation, newFilename, symbologyExport, symbologyScale, filterExtent, overrideGeometryType, forceMulti, includeZ );
2024 bool skipAttributeCreation,
2027 double symbologyScale,
2038 bool shallTransform =
false;
2043 outputCRS = &( ct->
destCRS() );
2044 shallTransform =
true;
2049 outputCRS = &layer->
crs();
2069 QString srcFileName = theURIParts[0];
2074 *errorMessage =
QObject::tr(
"Cannot overwrite a OGR layer in place" );
2101 for (
int i = 0; i < fields.
size(); i++ )
2103 if ( fields.
at( i ).
type() == QVariant::LongLong )
2109 fields[i].setType( QVariant::Int );
2136 errorMessage->
clear();
2143 writer->addRendererAttributes( layer, allAttr );
2173 int n = 0, errors = 0;
2182 writer->startRender( layer );
2185 bool transactionsEnabled =
true;
2187 if ( OGRERR_NONE != OGR_L_StartTransaction( writer->
mLayer ) )
2189 QgsDebugMsg(
"Error when trying to enable transactions on OGRLayer." );
2190 transactionsEnabled =
false;
2196 if ( shallTransform )
2209 QString msg =
QObject::tr(
"Failed to transform a point while drawing a feature with ID '%1'. Writing stopped. (Exception: %2)" )
2213 *errorMessage = msg;
2222 if ( allAttr.
size() < 1 && skipAttributeCreation )
2230 if ( err !=
NoError && errorMessage )
2232 if ( errorMessage->
isEmpty() )
2234 *errorMessage =
QObject::tr(
"Feature write errors:" );
2240 if ( errors > 1000 )
2244 *errorMessage +=
QObject::tr(
"Stopping after %1 errors" ).
arg( errors );
2254 if ( transactionsEnabled )
2256 if ( OGRERR_NONE != OGR_L_CommitTransaction( writer->
mLayer ) )
2258 QgsDebugMsg(
"Error while committing transaction on OGRLayer." );
2262 writer->stopRender( layer );
2265 if ( errors > 0 && errorMessage && n > 0 )
2267 *errorMessage +=
QObject::tr(
"\nOnly %1 of %2 features written." ).
arg( n - errors ).
arg( n );
2280 const char *suffixes[] = {
".shp",
".shx",
".dbf",
".prj",
".qix",
".qpj" };
2281 for ( std::size_t i = 0; i <
sizeof( suffixes ) /
sizeof( *suffixes ); i++ )
2292 QgsDebugMsg(
QString(
"Removing file %1 failed: %2" ).arg( file, f.errorString() ) );
2311 int const drvCount = OGRGetDriverCount();
2313 for (
int i = 0; i < drvCount; ++i )
2315 OGRSFDriverH drv = OGRGetDriver( i );
2318 QString drvName = OGR_Dr_GetName( drv );
2319 if ( OGR_Dr_TestCapability( drv,
"CreateDataSource" ) != 0 )
2325 resultMap.
insert( filterString, drvName );
2338 int const drvCount = OGRGetDriverCount();
2341 for (
int i = 0; i < drvCount; ++i )
2343 OGRSFDriverH drv = OGRGetDriver( i );
2346 QString drvName = OGR_Dr_GetName( drv );
2347 if ( OGR_Dr_TestCapability( drv,
"CreateDataSource" ) != 0 )
2350 if ( drvName ==
"MapInfo File" )
2352 writableDrivers <<
"MapInfo MIF";
2354 else if ( drvName ==
"SQLite" )
2361 QString option =
"SPATIALITE=YES";
2362 char **options =
new char *[2];
2364 options[1] =
nullptr;
2365 OGRSFDriverH poDriver;
2370 OGRDataSourceH ds = OGR_Dr_CreateDataSource( poDriver,
TO8F(
QString(
"/vsimem/spatialitetest.sqlite" ) ), options );
2373 writableDrivers <<
"SpatiaLite";
2374 OGR_Dr_DeleteDataSource( poDriver,
TO8F(
QString(
"/vsimem/spatialitetest.sqlite" ) ) );
2375 OGR_DS_Destroy( ds );
2378 CPLFree( options[0] );
2381 else if ( drvName ==
"ESRI Shapefile" )
2383 writableDrivers <<
"DBF file";
2385 writableDrivers << drvName;
2390 Q_FOREACH (
const QString& drvName, writableDrivers )
2398 resultMap.
insert( trLongName, drvName );
2410 for ( ; it != driverFormatMap.
constEnd(); ++it )
2412 if ( !filterString.
isEmpty() )
2413 filterString +=
";;";
2415 filterString += it.
key();
2417 return filterString;
2429 return trLongName +
" [OGR] (" + glob.
toLower() +
' ' + glob.
toUpper() +
')';
2434 if ( codecName ==
"System" )
2442 c.
toInt( &isNumber );
2453 longName =
"Arc/Info ASCII Coverage";
2454 trLongName =
QObject::tr(
"Arc/Info ASCII Coverage" );
2460 longName =
"Atlas BNA";
2467 longName =
"Comma Separated Value [CSV]";
2468 trLongName =
QObject::tr(
"Comma Separated Value [CSV]" );
2474 longName =
"ESRI Shapefile";
2479 else if ( driverName.
startsWith(
"DBF file" ) )
2481 longName =
"DBF File";
2486 else if ( driverName.
startsWith(
"FMEObjects Gateway" ) )
2488 longName =
"FMEObjects Gateway";
2493 else if ( driverName.
startsWith(
"GeoJSON" ) )
2495 longName =
"GeoJSON";
2502 longName =
"GeoPackage";
2507 else if ( driverName.
startsWith(
"GeoRSS" ) )
2509 longName =
"GeoRSS";
2516 longName =
"Geography Markup Language [GML]";
2517 trLongName =
QObject::tr(
"Geography Markup Language [GML]" );
2523 longName =
"Generic Mapping Tools [GMT]";
2524 trLongName =
QObject::tr(
"Generic Mapping Tools [GMT]" );
2530 longName =
"GPS eXchange Format [GPX]";
2531 trLongName =
QObject::tr(
"GPS eXchange Format [GPX]" );
2535 else if ( driverName.
startsWith(
"Interlis 1" ) )
2537 longName =
"INTERLIS 1";
2539 glob =
"*.itf *.xml *.ili";
2542 else if ( driverName.
startsWith(
"Interlis 2" ) )
2544 longName =
"INTERLIS 2";
2546 glob =
"*.itf *.xml *.ili";
2551 longName =
"Keyhole Markup Language [KML]";
2552 trLongName =
QObject::tr(
"Keyhole Markup Language [KML]" );
2556 else if ( driverName.
startsWith(
"MapInfo File" ) )
2558 longName =
"Mapinfo TAB";
2564 else if ( driverName.
startsWith(
"MapInfo MIF" ) )
2566 longName =
"Mapinfo MIF";
2573 longName =
"Microstation DGN";
2580 longName =
"S-57 Base file";
2587 longName =
"Spatial Data Transfer Standard [SDTS]";
2588 trLongName =
QObject::tr(
"Spatial Data Transfer Standard [SDTS]" );
2592 else if ( driverName.
startsWith(
"SQLite" ) )
2594 longName =
"SQLite";
2600 else if ( driverName.
startsWith(
"SpatiaLite" ) )
2602 longName =
"SpatiaLite";
2609 longName =
"AutoCAD DXF";
2614 else if ( driverName.
startsWith(
"Geoconcept" ) )
2616 longName =
"Geoconcept";
2618 glob =
"*.gxt *.txt";
2621 else if ( driverName.
startsWith(
"FileGDB" ) )
2623 longName =
"ESRI FileGDB";
2630 longName =
"MS Office Open XML spreadsheet [XLSX]";
2631 trLongName =
QObject::tr(
"MS Office Open XML spreadsheet [XLSX]" );
2637 longName =
"Open Document Spreadsheet";
2638 trLongName =
QObject::tr(
"Open Document Spreadsheet [ODS]" );
2670 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1700 2671 mSymbolLayerTable.clear();
2672 OGRStyleTableH ogrStyleTable = OGR_STBL_Create();
2673 OGRStyleMgrH styleManager = OGR_SM_Create( ogrStyleTable );
2676 int nTotalLevels = 0;
2679 for ( ; symbolIt != symbolList.
end(); ++symbolIt )
2684 int nLevels = ( *symbolIt )->symbolLayerCount();
2685 for (
int i = 0; i < nLevels; ++i )
2687 mSymbolLayerTable.insert(( *symbolIt )->symbolLayer( i ),
QString::number( nTotalLevels ) );
2688 OGR_SM_AddStyle( styleManager,
QString::number( nTotalLevels ).toLocal8Bit(),
2689 ( *symbolIt )->symbolLayer( i )->ogrFeatureStyle( mmsf, musf ).
toLocal8Bit() );
2693 OGR_DS_SetStyleTableDirectly( ds, ogrStyleTable );
2721 startRender( layer );
2743 *errorMessage = msg;
2751 if ( !featureSymbol )
2757 if ( it == features.
end() )
2761 it.
value().append( fet );
2767 for (
int i = 0; i < symbols.
count(); i++ )
2773 if ( level < 0 || level >= 1000 )
2776 while ( level >= levels.
count() )
2778 levels[level].
append( item );
2783 int nTotalFeatures = 0;
2786 for (
int l = 0; l < levels.
count(); l++ )
2789 for (
int i = 0; i < level.
count(); i++ )
2793 if ( levelIt == features.
end() )
2802 int llayer = item.
layer();
2805 for ( ; featureIt != featureList.
end(); ++featureIt )
2808 OGRFeatureH ogrFeature = createFeature( *featureIt );
2815 QString styleString = levelIt.
key()->symbolLayer( llayer )->ogrFeatureStyle( mmsf, musf );
2819 if ( !writeFeature(
mLayer, ogrFeature ) )
2824 OGR_F_Destroy( ogrFeature );
2829 stopRender( layer );
2831 if ( nErrors > 0 && errorMessage )
2833 *errorMessage +=
QObject::tr(
"\nOnly %1 of %2 features written." ).
arg( nTotalFeatures - nErrors ).
arg( nTotalFeatures );
2850 return 1000 / scaleDenominator;
2867 return scaleDenominator / 1000;
2915 for (
int i = 0; i < rendererAttributes.
size(); ++i )
qlonglong toLongLong(bool *ok) const
Wrapper for iterator of features from vector data provider or vector layer.
static WriterError writeAsVectorFormat(QgsVectorLayer *layer, const QString &fileName, const QString &fileEncoding, const QgsCoordinateReferenceSystem *destCRS, const QString &driverName="ESRI Shapefile", bool onlySelected=false, QString *errorMessage=nullptr, const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), bool skipAttributeCreation=false, QString *newFilename=nullptr, SymbologyExport symbologyExport=NoSymbology, double symbologyScale=1.0, const QgsRectangle *filterExtent=nullptr, QgsWKBTypes::Type overrideGeometryType=QgsWKBTypes::Unknown, bool forceMulti=false, bool includeZ=false)
Write contents of vector layer to an (OGR supported) vector formt.
QString toString(Qt::DateFormat format) const
QByteArray fromUnicode(const QString &str) const
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
A rectangle specified with double values.
static QMap< QString, QString > supportedFiltersAndFormats()
Returns map with format filter string as key and OGR format key as value.
QString cap(int nth) const
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
QString & append(QChar ch)
iterator insert(const Key &key, const T &value)
OutputUnit
The unit of the output.
int size() const
Return number of items.
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
static OGRwkbGeometryType ogrTypeFromWkbType(QgsWKBTypes::Type type)
Get the ogr geometry type from an internal QGIS wkb type enum.
bool contains(const Key &key) const
const Key key(const T &value) const
WriterError mError
Contains error value if construction was not successful.
static bool deleteShapeFile(const QString &theFileName)
Delete a shapefile (and its accompanying shx / dbf / prf)
void push_back(const T &value)
QVariant maximumValue(int index)
Returns the maximum value for an attribute column or an invalid variant in case of error...
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
static QString fileFilterString()
Returns filter string that can be used for dialogs.
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QDateTime toDateTime() const
SymbologyExport mSymbologyExport
double mSymbologyScaleDenominator
Scale for symbology export (e.g.
static void warning(const QString &msg)
Goes to qWarning.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
static Type multiType(Type type)
Returns the multi type for a WKB type.
const_iterator constBegin() const
void setRendererScale(double scale)
const T & at(int i) const
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
static QGis::WkbType fromNewWkbType(QgsWKBTypes::Type type)
Converts from new (post 2.10) WKB type (OGC) to old WKB type.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
static void registerOgrDrivers()
Register OGR drivers ensuring this only happens once.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
bool addFeature(QgsFeature &feature, QgsFeatureRendererV2 *renderer=nullptr, QGis::UnitType outputUnit=QGis::Meters)
Add feature to the currently opened data source.
WkbType
Used for symbology operations.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
int precision() const
Gets the precision of the field.
The QGis class provides global constants for use throughout the application.
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
QString join(const QString &separator) const
A convenience class for writing vector files to disk.
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString & remove(int position, int n)
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
QVariant minimumValue(int index)
Returns the minimum value for an attribute column or an invalid variant in case of error...
int wkbSize() const
Returns the size of the WKB in asWkb().
int count() const
Return number of items.
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsVectorFileWriter(const QString &vectorFileName, const QString &fileEncoding, const QgsFields &fields, QGis::WkbType geometryType, const QgsCoordinateReferenceSystem *srs, const QString &driverName="ESRI Shapefile", const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QString *newFilename=nullptr, SymbologyExport symbologyExport=NoSymbology)
Create a new vector file writer.
QTextCodec * codecForLocale()
QString name() const
Gets the name of the field.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
QgsFields fields() const
Returns the list of fields of this layer.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
int renderingPass() const
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type)
Converts from old (pre 2.10) WKB type (OGR) to new WKB type.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
The output shall be in millimeters.
QString number(int n, int base)
int count(const T &value) const
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
void append(const T &value)
QString fromUtf8(const char *str, int size)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
int toInt(bool *ok) const
#define FID_TO_NUMBER(fid)
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
int toInt(bool *ok, int base) const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Get the data source specification.
const_iterator constEnd() const
QGis::UnitType mapUnits() const
Returns the units for the projection used by the CRS.
const char * constData() const
QgsWKBTypes::Type mWkbType
Geometry type which is being used.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
The output shall be in map unitx.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
~QgsVectorFileWriter()
Close opened shapefile for writing.
QList< int > QgsAttributeList
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
bool usingSymbolLevels() const
Encapsulate a field in an attribute table or data source.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QMap< int, int > mAttrIdxToOgrIdx
Map attribute indizes to OGR field indexes.
OGRSpatialReferenceH mOgrRef
const T value(const Key &key) const
QgsFeatureId id() const
Get the feature ID for this feature.
QByteArray toLocal8Bit() const
iterator find(const Key &key)
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsGeometry * geometry()
Get the geometry object associated with this feature.
static QMap< QString, QString > ogrDriverList()
Returns driver list that can be used for dialogs.
bool contains(const T &value) const
const char * typeToName(Type typ)
QString errorMessage()
Retrieves error message.
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
const Key key(const T &value) const
static Type dropM(Type type)
Drops the m dimension (if present) for a WKB type and returns the new type.
QVariant value(const QString &key, const QVariant &defaultValue) const
static QString convertCodecNameForEncodingOption(const QString &codecName)
Converts codec name to string passed to ENCODING layer creation option of OGR Shapefile.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
WriterError hasError()
Checks whether there were any errors in constructor.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Set feature IDs that should be fetched.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Returns list of symbols used for rendering the feature.
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
void setSymbologyScaleDenominator(double d)
QStringList entryList(QFlags< QDir::Filter > filters, QFlags< QDir::SortFlag > sort) const
QTextCodec * codecForName(const QByteArray &name)
const char * typeName() const
Class for storing a coordinate reference system (CRS)
QString toWkt() const
Returns a WKT representation of this CRS.
int length() const
Gets the length of the field.
UnitType
Map units that qgis supports.
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
QString left(int n) const
QString completeBaseName() const
QString canonicalPath() const
static Type flatType(Type type)
Returns the flat type for a WKB type.
double toDouble(bool *ok) const
iterator insert(const Key &key, const T &value)
Custom exception class for Coordinate Reference System related exceptions.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QString providerType() const
Return the provider type for this layer.
const_iterator constEnd() const
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
const_iterator constBegin() const
static Type to25D(Type type)
Will convert the 25D version of the flat type if supported or Unknown if not supported.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
SymbologyExport symbologyExport() const
OGRGeometryH createEmptyGeometry(QgsWKBTypes::Type wkbType)
Represents a vector layer which manages a vector based data sets.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int compare(const QString &other) const
bool exactMatch(const QString &str) const
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
static QString filterForDriver(const QString &driverName)
Creates a filter for an OGR driver key.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
static Type singleType(Type type)
Returns the single type for a WKB type.
const T value(const Key &key) const
static bool driverMetadata(const QString &driverName, MetaData &driverMetadata)