27 return QStringLiteral(
"integer" );
29 case QVariant::LongLong:
30 return QStringLiteral(
"long" );
32 case QVariant::Double:
33 return QStringLiteral(
"double" );
35 case QVariant::String:
36 return QStringLiteral(
"string" );
39 return QStringLiteral(
"date" );
42 return QStringLiteral(
"time" );
44 case QVariant::DateTime:
45 return QStringLiteral(
"datetime" );
50 return QStringLiteral(
"string" );
56 if ( geomType.isNull() )
57 geomType = QStringLiteral(
"none" );
62 parts << QStringLiteral(
"crs=" ) + crs.
authid();
64 for (
const auto &field : fields )
66 const QString lengthPrecision = QStringLiteral(
"(%1,%2)" ).arg( field.length() ).arg( field.precision() );
67 parts << QStringLiteral(
"field=%1:%2%3" ).arg( QString( QUrl::toPercentEncoding( field.name() ) ),
memoryLayerFieldType( field.type() ), lengthPrecision );
70 QString uri = geomType +
'?' + parts.join(
'&' );
72 return new QgsVectorLayer( uri, name, QStringLiteral(
"memory" ) );
Container of fields for a vector layer.
const QgsCoordinateReferenceSystem & crs
QString memoryLayerFieldType(QVariant::Type type)
Type
The WKB type describes the number of dimensions a geometry has.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
This class represents a coordinate reference system (CRS).
QString authid() const
Returns the authority identifier for the CRS.
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
static QgsVectorLayer * createMemoryLayer(const QString &name, const QgsFields &fields, QgsWkbTypes::Type geometryType=QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Creates a new memory layer using the specified parameters.
Represents a vector layer which manages a vector based data sets.