26using namespace Qt::StringLiterals;
32 case QMetaType::Type::Int:
35 case QMetaType::Type::LongLong:
38 case QMetaType::Type::Double:
41 case QMetaType::Type::QString:
44 case QMetaType::Type::QDate:
47 case QMetaType::Type::QTime:
50 case QMetaType::Type::QDateTime:
53 case QMetaType::Type::QByteArray:
56 case QMetaType::Type::Bool:
59 case QMetaType::Type::QVariantMap:
62 case QMetaType::Type::User:
63 if ( typeString.compare(
"geometry"_L1, Qt::CaseInsensitive ) == 0 )
78 if ( geomType.isNull() )
84 if ( !crs.
authid().isEmpty() )
85 parts << u
"crs=%1"_s.arg( crs.
authid() );
93 for (
const QgsField &field : fields )
95 const QString lengthPrecision = u
"(%1,%2)"_s.arg( field.length() ).arg( field.precision() );
96 parts << u
"field=%1:%2%3%4"_s.arg( QString( QUrl::toPercentEncoding( field.name() ) ),
97 memoryLayerFieldType( field.type() == QMetaType::Type::QVariantList || field.type() == QMetaType::Type::QStringList ? field.subType() : field.type(), field.typeName() ),
99 field.type() == QMetaType::Type::QVariantList || field.type() == QMetaType::Type::QStringList ? u
"[]"_s : QString() );
102 const QString uri = geomType +
'?' + parts.join(
'&' );
WkbType
The WKB type describes the number of dimensions a geometry has.
@ Preferred
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString toWkt(Qgis::CrsWktVariant variant=Qgis::CrsWktVariant::Wkt1Gdal, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Contains information about the context in which a coordinate transform is executed.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
static QgsVectorLayer * createMemoryLayer(const QString &name, const QgsFields &fields, Qgis::WkbType geometryType=Qgis::WkbType::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), bool loadDefaultStyle=true) SIP_FACTORY
Creates a new memory layer using the specified parameters.
Represents a vector layer which manages a vector based dataset.
static Q_INVOKABLE QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
QString memoryLayerFieldType(QMetaType::Type type, const QString &typeString)
Setting options for loading vector layers.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
bool loadDefaultStyle
Set to true if the default layer style should be loaded.