@@ -35,17 +35,6 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect
35
35
return filterRect.isNull () || ( f.hasGeometry () && f.geometry ().intersects ( filterRect ) );
36
36
}
37
37
38
- // When fetching from server, fetch all attributes and geometry by default so that we can cache them
39
- QStringList fetchAttribNames;
40
- QList<int > fetchAttribIdx;
41
- fetchAttribIdx.reserve ( mFields .size () );
42
- fetchAttribNames.reserve ( mFields .size () );
43
- for ( int idx = 0 , n = mFields .size (); idx < n; ++idx )
44
- {
45
- fetchAttribNames.append ( mFields .at ( idx ).name () );
46
- fetchAttribIdx.append ( idx );
47
- }
48
-
49
38
// Fetch 100 features at the time
50
39
int startId = ( id / 100 ) * 100 ;
51
40
int stopId = std::min ( startId + 100 , mObjectIds .length () );
@@ -77,7 +66,7 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect
77
66
78
67
const QVariantMap queryData = QgsArcGisRestUtils::getObjects (
79
68
mDataSource .param ( QStringLiteral ( " url" ) ), authcfg, objectIds, mDataSource .param ( QStringLiteral ( " crs" ) ), true ,
80
- fetchAttribNames , QgsWkbTypes::hasM ( mGeometryType ), QgsWkbTypes::hasZ ( mGeometryType ),
69
+ QStringList () , QgsWkbTypes::hasM ( mGeometryType ), QgsWkbTypes::hasZ ( mGeometryType ),
81
70
filterRect, errorTitle, errorMessage, headers, feedback );
82
71
83
72
if ( queryData.isEmpty () )
@@ -102,36 +91,33 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect
102
91
int featureId = startId + i;
103
92
104
93
// Set attributes
105
- if ( !fetchAttribIdx.isEmpty () )
94
+ const QVariantMap attributesData = featureData[QStringLiteral ( " attributes" )].toMap ();
95
+ feature.setFields ( mFields );
96
+ QgsAttributes attributes ( mFields .size () );
97
+ for ( int idx = 0 ; idx < mFields .size (); ++idx )
106
98
{
107
- const QVariantMap attributesData = featureData[QStringLiteral ( " attributes" )].toMap ();
108
- feature.setFields ( mFields );
109
- QgsAttributes attributes ( mFields .size () );
110
- for ( int idx : qgis::as_const ( fetchAttribIdx ) )
99
+ QVariant attribute = attributesData[mFields .at ( idx ).name ()];
100
+ if ( attribute.isNull () )
101
+ {
102
+ // ensure that null values are mapped correctly for PyQGIS
103
+ attribute = QVariant ( QVariant::Int );
104
+ }
105
+
106
+ // date/datetime fields must be converted
107
+ if ( mFields .at ( idx ).type () == QVariant::DateTime || mFields .at ( idx ).type () == QVariant::Date )
108
+ attribute = QgsArcGisRestUtils::parseDateTime ( attribute );
109
+
110
+ if ( !mFields .at ( idx ).convertCompatible ( attribute ) )
111
+ {
112
+ QgsDebugMsg ( QStringLiteral ( " Invalid value %1 for field %2 of type %3" ).arg ( attributesData[mFields .at ( idx ).name ()].toString (), mFields .at ( idx ).name (), mFields .at ( idx ).typeName () ) );
113
+ }
114
+ attributes[idx] = attribute;
115
+ if ( mFields .at ( idx ).name () == mObjectIdFieldName )
111
116
{
112
- QVariant attribute = attributesData[mFields .at ( idx ).name ()];
113
- if ( attribute.isNull () )
114
- {
115
- // ensure that null values are mapped correctly for PyQGIS
116
- attribute = QVariant ( QVariant::Int );
117
- }
118
-
119
- // date/datetime fields must be converted
120
- if ( mFields .at ( idx ).type () == QVariant::DateTime || mFields .at ( idx ).type () == QVariant::Date )
121
- attribute = QgsArcGisRestUtils::parseDateTime ( attribute );
122
-
123
- if ( !mFields .at ( idx ).convertCompatible ( attribute ) )
124
- {
125
- QgsDebugMsg ( QStringLiteral ( " Invalid value %1 for field %2 of type %3" ).arg ( attributesData[mFields .at ( idx ).name ()].toString (), mFields .at ( idx ).name (), mFields .at ( idx ).typeName () ) );
126
- }
127
- attributes[idx] = attribute;
128
- if ( mFields .at ( idx ).name () == mObjectIdFieldName )
129
- {
130
- featureId = startId + objectIds.indexOf ( attributesData[mFields .at ( idx ).name ()].toInt () );
131
- }
117
+ featureId = startId + objectIds.indexOf ( attributesData[mFields .at ( idx ).name ()].toInt () );
132
118
}
133
- feature.setAttributes ( attributes );
134
119
}
120
+ feature.setAttributes ( attributes );
135
121
136
122
// Set FID
137
123
feature.setId ( featureId );
0 commit comments