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 case QVariant::LongLong:
367 ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
371 case QVariant::String:
373 if ( ogrWidth <= 0 || ogrWidth > 255 )
378 ogrType = OFTInteger;
379 ogrWidth = ogrWidth > 0 && ogrWidth <= 10 ? ogrWidth : 10;
383 case QVariant::Double:
403 case QVariant::DateTime:
411 ogrType = OFTDateTime;
428 for ( i = 0; i < 10; i++ )
433 for ( j = 0; j < fields.
size() && name.compare( fields[j].name(), Qt::CaseInsensitive ) != 0; j++ )
436 if ( j == fields.
size() )
454 OGR_Fld_SetWidth( fld, ogrWidth );
457 if ( ogrPrecision >= 0 )
459 OGR_Fld_SetPrecision( fld, ogrPrecision );
467 if ( OGR_L_CreateField(
mLayer, fld,
true ) != OGRERR_NONE )
474 OGR_Fld_Destroy( fld );
477 OGR_Fld_Destroy( fld );
480 QgsDebugMsg(
QString(
"returned field index for %1: %2" ).arg( name ).arg( ogrIdx ) );
481 if ( ogrIdx < 0 || existingIdxs.
contains( ogrIdx ) )
483 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700 486 int fieldCount = OGR_FD_GetFieldCount( defn );
488 OGRFieldDefnH fdefn = OGR_FD_GetFieldDefn( defn, fieldCount - 1 );
491 const char *fieldName = OGR_Fld_GetNameRef( fdefn );
493 if ( attrField.
name().
left( strlen( fieldName ) ) == fieldName )
495 ogrIdx = fieldCount - 1;
500 ogrIdx = OGR_FD_GetFieldCount( defn ) - 1;
514 existingIdxs.
insert( ogrIdx );
528 *newFilename = vectorFileName;
544 datasetOptions.
clear();
545 layerOptions.
clear();
547 driverMetadata.
insert(
"AVCE00",
549 "Arc/Info ASCII Coverage",
559 datasetOptions.
clear();
560 layerOptions.
clear();
564 "systems default line termination conventions. " 565 "This may be overridden here." ),
574 QObject::tr(
"By default, BNA files are created in multi-line format. " 575 "For each record, the first line contains the identifiers and the " 576 "type/number of coordinates to follow. Each following line contains " 577 "a pair of coordinates." ),
582 QObject::tr(
"BNA records may contain from 2 to 4 identifiers per record. " 583 "Some software packages only support a precise number of identifiers. " 584 "You can override the default value (2) by a precise value" ),
589 <<
"NB_SOURCE_FIELDS",
594 QObject::tr(
"The BNA writer will try to recognize ellipses and circles when writing a polygon. " 595 "This will only work if the feature has previously been read from a BNA file. " 596 "As some software packages do not support ellipses/circles in BNA data file, " 597 "it may be useful to tell the writer by specifying ELLIPSES_AS_ELLIPSES=NO not " 598 "to export them as such, but keep them as polygons." ),
603 QObject::tr(
"Limit the number of coordinate pairs per line in multiline format." ),
608 QObject::tr(
"Set the number of decimal for coordinates. Default value is 10." ),
612 driverMetadata.
insert(
"BNA",
624 datasetOptions.
clear();
625 layerOptions.
clear();
628 QObject::tr(
"By default when creating new .csv files they " 629 "are created with the line termination conventions " 630 "of the local platform (CR/LF on Win32 or LF on all other systems). " 631 "This may be overridden through the use of the LINEFORMAT option." ),
640 QObject::tr(
"By default, the geometry of a feature written to a .csv file is discarded. " 641 "It is possible to export the geometry in its WKT representation by " 642 "specifying GEOMETRY=AS_WKT. It is also possible to export point geometries " 643 "into their X,Y,Z components by specifying GEOMETRY=AS_XYZ, GEOMETRY=AS_XY " 644 "or GEOMETRY=AS_YX." ),
655 QObject::tr(
"Create the associated .csvt file to describe the type of each " 656 "column of the layer and its optional width and precision." ),
670 QObject::tr(
"Write a UTF-8 Byte Order Mark (BOM) at the start of the file." ),
674 driverMetadata.
insert(
"CSV",
676 "Comma Separated Value [CSV]",
686 datasetOptions.
clear();
687 layerOptions.
clear();
690 QObject::tr(
"Override the type of shapefile created. " 691 "Can be one of NULL for a simple .dbf file with no .shp file, POINT, " 692 "ARC, POLYGON or MULTIPOINT for 2D, or POINTZ, ARCZ, POLYGONZ or " 693 "MULTIPOINTZ for 3D. Shapefiles with measure values are not supported, " 694 "nor are MULTIPATCH files." ),
713 QObject::tr(
"set the encoding value in the DBF file. " 714 "The default value is LDID/87. It is not clear " 715 "what other values may be appropriate." ),
723 QObject::tr(
"Set to YES to resize fields to their optimal size." ),
727 driverMetadata.
insert(
"ESRI",
739 datasetOptions.
clear();
740 layerOptions.
clear();
742 driverMetadata.
insert(
"DBF File",
754 datasetOptions.
clear();
755 layerOptions.
clear();
757 driverMetadata.
insert(
"FMEObjects Gateway",
759 "FMEObjects Gateway",
769 datasetOptions.
clear();
770 layerOptions.
clear();
773 QObject::tr(
"Set to YES to write a bbox property with the bounding box " 774 "of the geometries at the feature and feature collection level." ),
779 QObject::tr(
"Maximum number of figures after decimal separator to write in coordinates. " 780 "Default to 15. Truncation will occur to remove trailing zeros." ),
784 driverMetadata.
insert(
"GeoJSON",
796 datasetOptions.
clear();
797 layerOptions.
clear();
800 QObject::tr(
"whether the document must be in RSS 2.0 or Atom 1.0 format. " 801 "Default value : RSS" ),
809 QObject::tr(
"The encoding of location information. Default value : SIMPLE. " 810 "W3C_GEO only supports point geometries. " 811 "SIMPLE or W3C_GEO only support geometries in geographic WGS84 coordinates." ),
820 QObject::tr(
"If defined to YES, extension fields will be written. " 821 "If the field name not found in the base schema matches " 822 "the foo_bar pattern, foo will be considered as the namespace " 823 "of the element, and a <foo:bar> element will be written. " 824 "Otherwise, elements will be written in the <ogr:> namespace." ),
829 QObject::tr(
"If defined to NO, only <entry> or <item> elements will be written. " 830 "The user will have to provide the appropriate header and footer of the document." ),
835 QObject::tr(
"XML content that will be put between the <channel> element and the " 836 "first <item> element for a RSS document, or between the xml tag and " 837 "the first <entry> element for an Atom document. " ),
842 QObject::tr(
"Value put inside the <title> element in the header. " 843 "If not provided, a dummy value will be used as that element is compulsory." ),
848 QObject::tr(
"Value put inside the <description> element in the header. " 849 "If not provided, a dummy value will be used as that element is compulsory." ),
854 QObject::tr(
"Value put inside the <link> element in the header. " 855 "If not provided, a dummy value will be used as that element is compulsory." ),
860 QObject::tr(
"Value put inside the <updated> element in the header. " 861 "Should be formatted as a XML datetime. " 862 "If not provided, a dummy value will be used as that element is compulsory." ),
867 QObject::tr(
"Value put inside the <author><name> element in the header. " 868 "If not provided, a dummy value will be used as that element is compulsory." ),
873 QObject::tr(
"Value put inside the <id> element in the header. " 874 "If not provided, a dummy value will be used as that element is compulsory." ),
878 driverMetadata.
insert(
"GeoRSS",
890 datasetOptions.
clear();
891 layerOptions.
clear();
894 QObject::tr(
"If provided, this URI will be inserted as the schema location. " 895 "Note that the schema file isn't actually accessed by OGR, so it " 896 "is up to the user to ensure it will match the schema of the OGR " 897 "produced GML data file." ),
902 QObject::tr(
"This writes a GML application schema file to a corresponding " 903 ".xsd file (with the same basename). If INTERNAL is used the " 904 "schema is written within the GML file, but this is experimental " 905 "and almost certainly not valid XML. " 906 "OFF disables schema generation (and is implicit if XSISCHEMAURI is used)." ),
915 QObject::tr(
"This is the prefix for the application target namespace." ),
920 QObject::tr(
"Can be set to TRUE to avoid writing the prefix of the " 921 "application target namespace in the GML file." ),
926 QObject::tr(
"Defaults to 'http://ogr.maptools.org/'. " 927 "This is the application target namespace." ),
928 "http://ogr.maptools.org/" 932 QObject::tr(
"If not specified, GML2 will be used." ),
942 QObject::tr(
"only valid when FORMAT=GML3/GML3Degree/GML3.2) Default to YES. " 943 "If YES, SRS with EPSG authority will be written with the " 944 "'urn:ogc:def:crs:EPSG::' prefix. In the case, if the SRS is a " 945 "geographic SRS without explicit AXIS order, but that the same " 946 "SRS authority code imported with ImportFromEPSGA() should be " 947 "treated as lat/long, then the function will take care of coordinate " 948 "order swapping. If set to NO, SRS with EPSG authority will be " 949 "written with the 'EPSG:' prefix, even if they are in lat/long order." ),
954 QObject::tr(
"only valid when FORMAT=GML3/GML3Degree/GML3.2) Default to YES. " 955 "If set to NO, the <gml:boundedBy> element will not be written for " 961 QObject::tr(
"Default to YES. If YES, the output will be indented with spaces " 962 "for more readability, but at the expense of file size." ),
967 driverMetadata.
insert(
"GML",
969 "Geography Markup Language [GML]",
979 datasetOptions.
clear();
980 layerOptions.
clear();
982 driverMetadata.
insert(
"GMT",
984 "Generic Mapping Tools [GMT]",
994 datasetOptions.
clear();
995 layerOptions.
clear();
998 QObject::tr(
"By default when writing a layer whose features are of " 999 "type wkbLineString, the GPX driver chooses to write " 1000 "them as routes. If FORCE_GPX_TRACK=YES is specified, " 1001 "they will be written as tracks." ),
1006 QObject::tr(
"By default when writing a layer whose features are of " 1007 "type wkbMultiLineString, the GPX driver chooses to write " 1008 "them as tracks. If FORCE_GPX_ROUTE=YES is specified, " 1009 "they will be written as routes, provided that the multilines " 1010 "are composed of only one single line." ),
1015 QObject::tr(
"If GPX_USE_EXTENSIONS=YES is specified, " 1016 "extra fields will be written inside the <extensions> tag." ),
1021 QObject::tr(
"Only used if GPX_USE_EXTENSIONS=YES and GPX_EXTENSIONS_NS_URL " 1022 "is set. The namespace value used for extension tags. By default, 'ogr'." ),
1027 QObject::tr(
"Only used if GPX_USE_EXTENSIONS=YES and GPX_EXTENSIONS_NS " 1028 "is set. The namespace URI. By default, 'http://osgeo.org/gdal'." ),
1029 "http://osgeo.org/gdal" 1033 QObject::tr(
"By default files are created with the line termination " 1034 "conventions of the local platform (CR/LF on win32 or LF " 1035 "on all other systems). This may be overridden through use " 1036 "of the LINEFORMAT layer creation option which may have a value " 1037 "of CRLF (DOS format) or LF (Unix format)." ),
1045 driverMetadata.
insert(
"GPX",
1047 "GPS eXchange Format [GPX]",
1057 datasetOptions.
clear();
1058 layerOptions.
clear();
1060 driverMetadata.
insert(
"Interlis 1",
1064 "*.itf *.xml *.ili",
1072 datasetOptions.
clear();
1073 layerOptions.
clear();
1075 driverMetadata.
insert(
"Interlis 2",
1079 "*.itf *.xml *.ili",
1087 datasetOptions.
clear();
1088 layerOptions.
clear();
1091 QObject::tr(
"Allows you to specify the field to use for the KML <name> element. " ),
1096 QObject::tr(
"Allows you to specify the field to use for the KML <description> element." ),
1101 QObject::tr(
"Allows you to specify the AltitudeMode to use for KML geometries. " 1102 "This will only affect 3D geometries and must be one of the valid KML options." ),
1105 <<
"relativeToGround" 1110 driverMetadata.
insert(
"KML",
1112 "Keyhole Markup Language [KML]",
1122 datasetOptions.
clear();
1123 layerOptions.
clear();
1126 QObject::tr(
"Use this to turn on 'quick spatial index mode'. " 1127 "In this mode writing files can be about 5 times faster, " 1128 "but spatial queries can be up to 30 times slower." ),
1135 driverMetadata.
insert(
"MapInfo File",
1147 driverMetadata.
insert(
"MapInfo MIF",
1159 datasetOptions.
clear();
1160 layerOptions.
clear();
1163 QObject::tr(
"Determine whether 2D (seed_2d.dgn) or 3D (seed_3d.dgn) " 1164 "seed file should be used. This option is ignored if the SEED option is provided." ),
1174 QObject::tr(
"Indicate whether the whole seed file should be copied. " 1175 "If not, only the first three elements will be copied." ),
1180 QObject::tr(
"Indicates whether the color table should be copied from the seed file." ),
1185 QObject::tr(
"Override the master unit name from the seed file with " 1186 "the provided one or two character unit name." ),
1191 QObject::tr(
"Override the sub unit name from the seed file with the provided " 1192 "one or two character unit name." ),
1197 QObject::tr(
"Override the number of subunits per master unit. " 1198 "By default the seed file value is used." ),
1203 QObject::tr(
"Override the number of UORs (Units of Resolution) " 1204 "per sub unit. By default the seed file value is used." ),
1209 QObject::tr(
"ORIGIN=x,y,z: Override the origin of the design plane. " 1210 "By default the origin from the seed file is used." ),
1214 driverMetadata.
insert(
"DGN",
1226 datasetOptions.
clear();
1227 layerOptions.
clear();
1229 driverMetadata.
insert(
"DGN",
1241 datasetOptions.
clear();
1242 layerOptions.
clear();
1245 QObject::tr(
"Should update files be incorporated into the base data on the fly. " ),
1253 QObject::tr(
"Should multipoint soundings be split into many single point sounding features. " 1254 "Multipoint geometries are not well handled by many formats, " 1255 "so it can be convenient to split single sounding features with many points " 1256 "into many single point features." ),
1261 QObject::tr(
"Should a DEPTH attribute be added on SOUNDG features and assign the depth " 1262 "of the sounding. This should only be enabled with SPLIT_MULTIPOINT is " 1268 QObject::tr(
"Should all the low level geometry primitives be returned as special " 1269 "IsolatedNode, ConnectedNode, Edge and Face layers." ),
1274 QObject::tr(
"If enabled, numeric attributes assigned an empty string as a value will " 1275 "be preserved as a special numeric value. This option should not generally " 1276 "be needed, but may be useful when translated S-57 to S-57 losslessly." ),
1281 QObject::tr(
"Should LNAM and LNAM_REFS fields be attached to features capturing " 1282 "the feature to feature relationships in the FFPT group of the S-57 file." ),
1287 QObject::tr(
"Should additional attributes relating features to their underlying " 1288 "geometric primitives be attached. These are the values of the FSPT group, " 1289 "and are primarily needed when doing S-57 to S-57 translations." ),
1294 QObject::tr(
"Should attribute values be recoded to UTF-8 from the character encoding " 1295 "specified in the S57 DSSI record." ),
1301 driverMetadata.
insert(
"S57",
1313 datasetOptions.
clear();
1314 layerOptions.
clear();
1316 driverMetadata.
insert(
"SDTS",
1318 "Spatial Data Transfer Standard [SDTS]",
1319 QObject::tr(
"Spatial Data Transfer Standard [SDTS]" ),
1328 datasetOptions.
clear();
1329 layerOptions.
clear();
1332 QObject::tr(
"Can be used to avoid creating the geometry_columns and spatial_ref_sys " 1333 "tables in a new database. By default these metadata tables are created " 1334 "when a new database is created." ),
1349 QObject::tr(
"Controls the format used for the geometry column. Defaults to WKB." 1350 "This is generally more space and processing efficient, but harder " 1351 "to inspect or use in simple applications than WKT (Well Known Text)." ),
1359 QObject::tr(
"Controls whether layer and field names will be laundered for easier use " 1360 "in SQLite. Laundered names will be converted to lower case and some special " 1361 "characters(' - #) will be changed to underscores." ),
1378 QObject::tr(
"column_name1[,column_name2, ...] A list of (String) columns that " 1379 "must be compressed with ZLib DEFLATE algorithm. This might be beneficial " 1380 "for databases that have big string blobs. However, use with care, since " 1381 "the value of such columns will be seen as compressed binary content with " 1382 "other SQLite utilities (or previous OGR versions). With OGR, when inserting, " 1383 "modifying or queryings compressed columns, compression/decompression is " 1384 "done transparently. However, such columns cannot be (easily) queried with " 1385 "an attribute filter or WHERE clause. Note: in table definition, such columns " 1386 "have the 'VARCHAR_deflate' declaration type." ),
1390 driverMetadata.
insert(
"SQLite",
1402 datasetOptions.
clear();
1403 layerOptions.
clear();
1406 QObject::tr(
"Can be used to avoid creating the geometry_columns and spatial_ref_sys " 1407 "tables in a new database. By default these metadata tables are created " 1408 "when a new database is created." ),
1417 QObject::tr(
"Insert the content of the EPSG CSV files into the spatial_ref_sys table. " 1418 "Set to NO for regular SQLite databases." ),
1427 QObject::tr(
"Controls whether layer and field names will be laundered for easier use " 1428 "in SQLite. Laundered names will be converted to lower case and some special " 1429 "characters(' - #) will be changed to underscores." ),
1434 QObject::tr(
"If the database is of the SpatiaLite flavour, and if OGR is linked " 1435 "against libspatialite, this option can be used to control if a spatial " 1436 "index must be created." ),
1441 QObject::tr(
"If the format of the geometry BLOB is of the SpatiaLite flavour, " 1442 "this option can be used to control if the compressed format for " 1443 "geometries (LINESTRINGs, POLYGONs) must be used" ),
1448 QObject::tr(
"Used to force the SRID number of the SRS associated with the layer. " 1449 "When this option isn't specified and that a SRS is associated with the " 1450 "layer, a search is made in the spatial_ref_sys to find a match for the " 1451 "SRS, and, if there is no match, a new entry is inserted for the SRS in " 1452 "the spatial_ref_sys table. When the SRID option is specified, this " 1453 "search (and the eventual insertion of a new entry) will not be done: " 1454 "the specified SRID is used as such." ),
1459 QObject::tr(
"column_name1[,column_name2, ...] A list of (String) columns that " 1460 "must be compressed with ZLib DEFLATE algorithm. This might be beneficial " 1461 "for databases that have big string blobs. However, use with care, since " 1462 "the value of such columns will be seen as compressed binary content with " 1463 "other SQLite utilities (or previous OGR versions). With OGR, when inserting, " 1464 "modifying or queryings compressed columns, compression/decompression is " 1465 "done transparently. However, such columns cannot be (easily) queried with " 1466 "an attribute filter or WHERE clause. Note: in table definition, such columns " 1467 "have the 'VARCHAR_deflate' declaration type." ),
1471 driverMetadata.
insert(
"SpatiaLite",
1482 datasetOptions.
clear();
1483 layerOptions.
clear();
1487 QObject::tr(
"Override the header file used - in place of header.dxf." ),
1492 QObject::tr(
"Override the trailer file used - in place of trailer.dxf." ),
1497 driverMetadata.
insert(
"DXF",
1509 datasetOptions.
clear();
1510 layerOptions.
clear();
1513 QObject::tr(
"Indicates the GeoConcept export file extension. " 1514 "TXT was used by earlier releases of GeoConcept. GXT is currently used." ),
1523 QObject::tr(
"path to the GCT : the GCT file describe the GeoConcept types definitions: " 1524 "In this file, every line must start with //# followed by a keyword. " 1525 "Lines starting with // are comments." ),
1530 driverMetadata.
insert(
"Geoconcept",
1542 datasetOptions.
clear();
1543 layerOptions.
clear();
1546 QObject::tr(
"When this option is set, the new layer will be created inside the named " 1547 "FeatureDataset folder. If the folder does not already exist, it will be created." ),
1552 QObject::tr(
"Set name of geometry column in new layer. Defaults to 'SHAPE'." ),
1557 QObject::tr(
"Name of the OID column to create. Defaults to 'OBJECTID'." ),
1561 driverMetadata.
insert(
"FileGDB",
1573 datasetOptions.
clear();
1574 layerOptions.
clear();
1577 QObject::tr(
"By default, the driver will try to detect the data type of fields. If set " 1578 "to STRING, all fields will be of String type." ),
1586 driverMetadata.
insert(
"XLSX",
1588 "MS Office Open XML spreadsheet",
1598 datasetOptions.
clear();
1599 layerOptions.
clear();
1602 QObject::tr(
"By default, the driver will try to detect the data type of fields. If set " 1603 "to STRING, all fields will be of String type." ),
1611 driverMetadata.
insert(
"ODS",
1613 "Open Document Spreadsheet",
1631 for ( ; it != sDriverMetadata.
constEnd(); ++it )
1633 if ( it.
key().startsWith( driverName ) || it.
value().longName.startsWith( driverName ) )
1635 driverMetadata = it.
value();
1647 OGRwkbGeometryType ogrType =
static_cast<OGRwkbGeometryType
>( type );
1669 OGRFeatureH poFeature = createFeature( feature );
1683 for ( ; symbolIt != symbols.
constEnd(); ++symbolIt )
1685 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1686 for (
int i = 0; i < nSymbolLayers; ++i )
1690 if ( it == mSymbolLayerTable.constEnd() )
1698 currentStyle = ( *symbolIt )->symbolLayer( i )->ogrFeatureStyle( mmsf, musf );
1702 if ( symbolIt != symbols.
constBegin() || i != 0 )
1704 styleString.
append(
';' );
1706 styleString.
append( currentStyle );
1710 OGR_F_SetStyleString( poFeature, currentStyle.toLocal8Bit().data() );
1711 if ( !writeFeature(
mLayer, poFeature ) )
1723 if ( !writeFeature(
mLayer, poFeature ) )
1729 OGR_F_Destroy( poFeature );
1733 OGRFeatureH QgsVectorFileWriter::createFeature(
QgsFeature& feature )
1738 OGRFeatureH poFeature = OGR_F_Create( OGR_L_GetLayerDefn(
mLayer ) );
1744 OGRErr err = OGR_F_SetFID( poFeature, static_cast<long>( fid ) );
1745 if ( err != OGRERR_NONE )
1748 .arg( feature.
id() )
1749 .arg( err ).
arg( CPLGetLastErrorMsg() )
1755 for (
int fldIdx = 0; fldIdx <
mFields.
count(); ++fldIdx )
1769 switch ( attrValue.
type() )
1771 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000 1773 case QVariant::UInt:
1774 OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.
toInt() );
1776 case QVariant::LongLong:
1777 case QVariant::ULongLong:
1778 OGR_F_SetFieldInteger64( poFeature, ogrField, attrValue.
toLongLong() );
1780 case QVariant::String:
1785 OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.
toInt() );
1787 case QVariant::String:
1788 case QVariant::LongLong:
1789 case QVariant::UInt:
1790 case QVariant::ULongLong:
1794 case QVariant::Double:
1795 OGR_F_SetFieldDouble( poFeature, ogrField, attrValue.
toDouble() );
1797 case QVariant::Date:
1798 OGR_F_SetFieldDateTime( poFeature, ogrField,
1804 case QVariant::DateTime:
1811 OGR_F_SetFieldDateTime( poFeature, ogrField,
1821 case QVariant::Time:
1828 OGR_F_SetFieldDateTime( poFeature, ogrField,
1836 case QVariant::Invalid:
1866 OGRGeometryH mGeom2 =
nullptr;
1903 OGR_F_Destroy( poFeature );
1907 OGRErr err = OGR_G_ImportFromWkb( mGeom2, const_cast<unsigned char *>( geom->
asWkb() ), static_cast< int >( geom->
wkbSize() ) );
1908 if ( err != OGRERR_NONE )
1914 OGR_F_Destroy( poFeature );
1919 OGR_F_SetGeometryDirectly( poFeature, mGeom2 );
1923 OGRErr err = OGR_G_ImportFromWkb(
mGeom, const_cast<unsigned char *>( geom->
asWkb() ), static_cast< int >( geom->
wkbSize() ) );
1924 if ( err != OGRERR_NONE )
1930 OGR_F_Destroy( poFeature );
1935 OGR_F_SetGeometry( poFeature,
mGeom );
1946 bool QgsVectorFileWriter::writeFeature( OGRLayerH layer, OGRFeatureH feature )
1948 if ( OGR_L_CreateFeature( layer, feature ) != OGRERR_NONE )
1953 OGR_F_Destroy( feature );
1963 OGR_G_DestroyGeometry(
mGeom );
1968 OGR_DS_Destroy(
mDS );
1973 OSRDestroySpatialReference(
mOgrRef );
1987 bool skipAttributeCreation,
1990 double symbologyScale,
1997 if ( destCRS && layer )
2003 errorMessage, datasourceOptions, layerOptions, skipAttributeCreation, newFilename, symbologyExport, symbologyScale, filterExtent, overrideGeometryType, forceMulti, includeZ );
2017 bool skipAttributeCreation,
2020 double symbologyScale,
2031 bool shallTransform =
false;
2036 outputCRS = &( ct->
destCRS() );
2037 shallTransform =
true;
2042 outputCRS = &layer->
crs();
2062 QString srcFileName = theURIParts[0];
2067 *errorMessage =
QObject::tr(
"Cannot overwrite a OGR layer in place" );
2094 for (
int i = 0; i < fields.
size(); i++ )
2096 if ( fields.
at( i ).
type() == QVariant::LongLong )
2102 fields[i].setType( QVariant::Int );
2129 errorMessage->
clear();
2136 writer->addRendererAttributes( layer, allAttr );
2166 int n = 0, errors = 0;
2175 writer->startRender( layer );
2178 bool transactionsEnabled =
true;
2180 if ( OGRERR_NONE != OGR_L_StartTransaction( writer->
mLayer ) )
2182 QgsDebugMsg(
"Error when trying to enable transactions on OGRLayer." );
2183 transactionsEnabled =
false;
2189 if ( shallTransform )
2202 QString msg =
QObject::tr(
"Failed to transform a point while drawing a feature with ID '%1'. Writing stopped. (Exception: %2)" )
2206 *errorMessage = msg;
2215 if ( allAttr.
size() < 1 && skipAttributeCreation )
2223 if ( err !=
NoError && errorMessage )
2225 if ( errorMessage->
isEmpty() )
2227 *errorMessage =
QObject::tr(
"Feature write errors:" );
2233 if ( errors > 1000 )
2237 *errorMessage +=
QObject::tr(
"Stopping after %1 errors" ).
arg( errors );
2247 if ( transactionsEnabled )
2249 if ( OGRERR_NONE != OGR_L_CommitTransaction( writer->
mLayer ) )
2251 QgsDebugMsg(
"Error while committing transaction on OGRLayer." );
2255 writer->stopRender( layer );
2258 if ( errors > 0 && errorMessage && n > 0 )
2260 *errorMessage +=
QObject::tr(
"\nOnly %1 of %2 features written." ).
arg( n - errors ).
arg( n );
2273 const char *suffixes[] = {
".shp",
".shx",
".dbf",
".prj",
".qix",
".qpj" };
2274 for ( std::size_t i = 0; i <
sizeof( suffixes ) /
sizeof( *suffixes ); i++ )
2285 QgsDebugMsg(
QString(
"Removing file %1 failed: %2" ).arg( file, f.errorString() ) );
2304 int const drvCount = OGRGetDriverCount();
2306 for (
int i = 0; i < drvCount; ++i )
2308 OGRSFDriverH drv = OGRGetDriver( i );
2311 QString drvName = OGR_Dr_GetName( drv );
2312 if ( OGR_Dr_TestCapability( drv,
"CreateDataSource" ) != 0 )
2318 resultMap.
insert( filterString, drvName );
2331 int const drvCount = OGRGetDriverCount();
2334 for (
int i = 0; i < drvCount; ++i )
2336 OGRSFDriverH drv = OGRGetDriver( i );
2339 QString drvName = OGR_Dr_GetName( drv );
2340 if ( OGR_Dr_TestCapability( drv,
"CreateDataSource" ) != 0 )
2343 if ( drvName ==
"MapInfo File" )
2345 writableDrivers <<
"MapInfo MIF";
2347 else if ( drvName ==
"SQLite" )
2354 QString option =
"SPATIALITE=YES";
2355 char **options =
new char *[2];
2357 options[1] =
nullptr;
2358 OGRSFDriverH poDriver;
2363 OGRDataSourceH ds = OGR_Dr_CreateDataSource( poDriver,
TO8F(
QString(
"/vsimem/spatialitetest.sqlite" ) ), options );
2366 writableDrivers <<
"SpatiaLite";
2367 OGR_Dr_DeleteDataSource( poDriver,
TO8F(
QString(
"/vsimem/spatialitetest.sqlite" ) ) );
2368 OGR_DS_Destroy( ds );
2371 CPLFree( options[0] );
2374 else if ( drvName ==
"ESRI Shapefile" )
2376 writableDrivers <<
"DBF file";
2378 writableDrivers << drvName;
2383 Q_FOREACH (
const QString& drvName, writableDrivers )
2391 resultMap.
insert( trLongName, drvName );
2403 for ( ; it != driverFormatMap.
constEnd(); ++it )
2405 if ( !filterString.
isEmpty() )
2406 filterString +=
";;";
2408 filterString += it.
key();
2410 return filterString;
2422 return trLongName +
" [OGR] (" + glob.
toLower() +
' ' + glob.
toUpper() +
')';
2427 if ( codecName ==
"System" )
2435 c.
toInt( &isNumber );
2446 longName =
"Arc/Info ASCII Coverage";
2447 trLongName =
QObject::tr(
"Arc/Info ASCII Coverage" );
2453 longName =
"Atlas BNA";
2460 longName =
"Comma Separated Value [CSV]";
2461 trLongName =
QObject::tr(
"Comma Separated Value [CSV]" );
2467 longName =
"ESRI Shapefile";
2472 else if ( driverName.
startsWith(
"DBF file" ) )
2474 longName =
"DBF File";
2479 else if ( driverName.
startsWith(
"FMEObjects Gateway" ) )
2481 longName =
"FMEObjects Gateway";
2486 else if ( driverName.
startsWith(
"GeoJSON" ) )
2488 longName =
"GeoJSON";
2495 longName =
"GeoPackage";
2500 else if ( driverName.
startsWith(
"GeoRSS" ) )
2502 longName =
"GeoRSS";
2509 longName =
"Geography Markup Language [GML]";
2510 trLongName =
QObject::tr(
"Geography Markup Language [GML]" );
2516 longName =
"Generic Mapping Tools [GMT]";
2517 trLongName =
QObject::tr(
"Generic Mapping Tools [GMT]" );
2523 longName =
"GPS eXchange Format [GPX]";
2524 trLongName =
QObject::tr(
"GPS eXchange Format [GPX]" );
2528 else if ( driverName.
startsWith(
"Interlis 1" ) )
2530 longName =
"INTERLIS 1";
2532 glob =
"*.itf *.xml *.ili";
2535 else if ( driverName.
startsWith(
"Interlis 2" ) )
2537 longName =
"INTERLIS 2";
2539 glob =
"*.itf *.xml *.ili";
2544 longName =
"Keyhole Markup Language [KML]";
2545 trLongName =
QObject::tr(
"Keyhole Markup Language [KML]" );
2549 else if ( driverName.
startsWith(
"MapInfo File" ) )
2551 longName =
"Mapinfo TAB";
2557 else if ( driverName.
startsWith(
"MapInfo MIF" ) )
2559 longName =
"Mapinfo MIF";
2566 longName =
"Microstation DGN";
2573 longName =
"S-57 Base file";
2580 longName =
"Spatial Data Transfer Standard [SDTS]";
2581 trLongName =
QObject::tr(
"Spatial Data Transfer Standard [SDTS]" );
2585 else if ( driverName.
startsWith(
"SQLite" ) )
2587 longName =
"SQLite";
2593 else if ( driverName.
startsWith(
"SpatiaLite" ) )
2595 longName =
"SpatiaLite";
2602 longName =
"AutoCAD DXF";
2607 else if ( driverName.
startsWith(
"Geoconcept" ) )
2609 longName =
"Geoconcept";
2611 glob =
"*.gxt *.txt";
2614 else if ( driverName.
startsWith(
"FileGDB" ) )
2616 longName =
"ESRI FileGDB";
2623 longName =
"MS Office Open XML spreadsheet [XLSX]";
2624 trLongName =
QObject::tr(
"MS Office Open XML spreadsheet [XLSX]" );
2630 longName =
"Open Document Spreadsheet";
2631 trLongName =
QObject::tr(
"Open Document Spreadsheet [ODS]" );
2663 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1700 2664 mSymbolLayerTable.clear();
2665 OGRStyleTableH ogrStyleTable = OGR_STBL_Create();
2666 OGRStyleMgrH styleManager = OGR_SM_Create( ogrStyleTable );
2669 int nTotalLevels = 0;
2672 for ( ; symbolIt != symbolList.
end(); ++symbolIt )
2677 int nLevels = ( *symbolIt )->symbolLayerCount();
2678 for (
int i = 0; i < nLevels; ++i )
2680 mSymbolLayerTable.insert(( *symbolIt )->symbolLayer( i ),
QString::number( nTotalLevels ) );
2681 OGR_SM_AddStyle( styleManager,
QString::number( nTotalLevels ).toLocal8Bit(),
2682 ( *symbolIt )->symbolLayer( i )->ogrFeatureStyle( mmsf, musf ).
toLocal8Bit() );
2686 OGR_DS_SetStyleTableDirectly( ds, ogrStyleTable );
2714 startRender( layer );
2736 *errorMessage = msg;
2744 if ( !featureSymbol )
2750 if ( it == features.
end() )
2754 it.
value().append( fet );
2760 for (
int i = 0; i < symbols.
count(); i++ )
2766 if ( level < 0 || level >= 1000 )
2769 while ( level >= levels.
count() )
2771 levels[level].
append( item );
2776 int nTotalFeatures = 0;
2779 for (
int l = 0; l < levels.
count(); l++ )
2782 for (
int i = 0; i < level.
count(); i++ )
2786 if ( levelIt == features.
end() )
2795 int llayer = item.
layer();
2798 for ( ; featureIt != featureList.
end(); ++featureIt )
2801 OGRFeatureH ogrFeature = createFeature( *featureIt );
2808 QString styleString = levelIt.
key()->symbolLayer( llayer )->ogrFeatureStyle( mmsf, musf );
2812 if ( !writeFeature(
mLayer, ogrFeature ) )
2817 OGR_F_Destroy( ogrFeature );
2822 stopRender( layer );
2824 if ( nErrors > 0 && errorMessage )
2826 *errorMessage +=
QObject::tr(
"\nOnly %1 of %2 features written." ).
arg( nTotalFeatures - nErrors ).
arg( nTotalFeatures );
2843 return 1000 / scaleDenominator;
2860 return scaleDenominator / 1000;
2908 for (
int i = 0; i < rendererAttributes.
size(); ++i )
QgsFeatureId id() const
Get the feature ID for this feature.
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
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
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.
SymbologyExport symbologyExport() const
QString cap(int nth) const
QString & append(QChar ch)
QgsAttributeList attributeList() const
Returns list of attribute indexes.
iterator insert(const Key &key, const T &value)
OutputUnit
The unit of the output.
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 maximum value for an attribute column or invalid variant in case of error.
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.
QgsFields fields() const
Returns the list of fields of this layer.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
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
QString toWkt() const
Returns a WKT representation of this CRS.
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.
int precision() const
Gets the precision of the field.
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.
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 minimum value for an attribute column or invalid variant in case of error.
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()
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
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.
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
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
#define FID_TO_NUMBER(fid)
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
QString name() const
Gets the name of the field.
int toInt(bool *ok, int base) const
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
const_iterator constEnd() const
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.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Get the data source specification.
QList< int > QgsAttributeList
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
int count() const
Return number of items.
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
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)
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
QMap< int, int > mAttrIdxToOgrIdx
Map attribute indizes to OGR field indexes.
OGRSpatialReferenceH mOgrRef
const T value(const Key &key) const
QByteArray toLocal8Bit() const
iterator find(const Key &key)
int renderingPass() const
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 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.
QString providerType() const
Return the provider type for this layer.
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.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int wkbSize() const
Returns the size of the WKB in asWkb().
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.
void setSymbologyScaleDenominator(double d)
QStringList entryList(QFlags< QDir::Filter > filters, QFlags< QDir::SortFlag > sort) const
QTextCodec * codecForName(const QByteArray &name)
bool usingSymbolLevels() const
const char * typeName() const
Class for storing a coordinate reference system (CRS)
int length() const
Gets the length of the field.
int size() const
Return number of items.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
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
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
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)
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
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.
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.
OGRGeometryH createEmptyGeometry(QgsWKBTypes::Type wkbType)
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
int compare(const QString &other) const
bool exactMatch(const QString &str) const
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
static QString filterForDriver(const QString &driverName)
Creates a filter for an OGR driver key.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
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)
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
QGis::UnitType mapUnits() const
Returns the units for the projection used by the CRS.