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" );
47 case QVariant::ByteArray:
48 return QStringLiteral(
"binary" );
51 return QStringLiteral(
"boolean" );
56 return QStringLiteral(
"string" );
62 if ( geomType.isNull() )
63 geomType = QStringLiteral(
"none" );
68 parts << QStringLiteral(
"crs=" ) + crs.
authid();
70 for (
const auto &field : fields )
72 const QString lengthPrecision = QStringLiteral(
"(%1,%2)" ).arg( field.length() ).arg( field.precision() );
73 parts << QStringLiteral(
"field=%1:%2%3" ).arg( QString( QUrl::toPercentEncoding( field.name() ) ),
memoryLayerFieldType( field.type() ), lengthPrecision );
76 QString uri = geomType +
'?' + parts.join(
'&' );
78 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.
This class represents a coordinate reference system (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.
QString authid() const
Returns the authority identifier for the CRS.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.