@@ -159,21 +159,28 @@ void QgsWFSProvider::copyFeature( QgsFeature* f, QgsFeature& feature, bool fetch
159
159
160
160
// copy the geometry
161
161
QgsGeometry* geometry = f->geometry ();
162
- if ( geometry )
162
+ if ( geometry && fetchGeometry )
163
163
{
164
164
unsigned char *geom = geometry->asWkb ();
165
165
int geomSize = geometry->wkbSize ();
166
166
unsigned char * copiedGeom = new unsigned char [geomSize];
167
167
memcpy ( copiedGeom, geom, geomSize );
168
168
feature.setGeometryAndOwnership ( copiedGeom, geomSize );
169
169
}
170
+ else
171
+ {
172
+ feature.setGeometry ( 0 );
173
+ }
170
174
171
175
// and the attributes
172
176
const QgsAttributes& attributes = f->attributes ();
173
177
feature.setAttributes ( attributes );
178
+
179
+ int i = 0 ;
174
180
for ( QgsAttributeList::const_iterator it = fetchAttributes.begin (); it != fetchAttributes.end (); ++it )
175
181
{
176
- feature.setAttribute ( *it, attributes[*it] );
182
+ feature.setAttribute ( i, attributes[*it] );
183
+ ++i;
177
184
}
178
185
179
186
// id and valid
@@ -351,96 +358,6 @@ QgsFeatureIterator QgsWFSProvider::getFeatures( const QgsFeatureRequest& request
351
358
return QgsFeatureIterator ( new QgsWFSFeatureIterator ( this , request ) );
352
359
}
353
360
354
- void QgsWFSProvider::select ( QgsAttributeList fetchAttributes,
355
- QgsRectangle rect,
356
- bool fetchGeometry,
357
- bool useIntersect )
358
- {
359
-
360
- if ( geometryType () == QGis::WKBNoGeometry )
361
- {
362
- fetchGeometry = false ;
363
- }
364
-
365
- mUseIntersect = useIntersect;
366
- mAttributesToFetch = fetchAttributes;
367
- mFetchGeom = fetchGeometry;
368
-
369
- if ( rect.isEmpty () )
370
- { // select all features
371
- mSpatialFilter = mExtent ;
372
- mSelectedFeatures = mFeatures .keys ();
373
- }
374
- else
375
- { // select features intersecting caller's extent
376
- QString dsURI = dataSourceUri ();
377
- // first time through, initialize GetRenderedOnly args
378
- // ctor cannot initialize because layer object not available then
379
- if ( ! mInitGro )
380
- { // did user check "Cache Features" in WFS layer source selection?
381
- if ( dsURI.contains ( " BBOX" ) )
382
- { // no: initialize incremental getFeature
383
- if ( initGetRenderedOnly ( rect ) )
384
- {
385
- mGetRenderedOnly = true ;
386
- }
387
- else
388
- { // initialization failed;
389
- QgsDebugMsg ( QString ( " GetRenderedOnly initialization failed; incorrect operation may occur\n %1" )
390
- .arg ( dataSourceUri () ) );
391
- QMessageBox ( QMessageBox::Warning, " Non-Cached layer initialization failed!" ,
392
- QString ( " Incorrect operation may occur:\n %1" ).arg ( dataSourceUri () ) );
393
- }
394
- }
395
- mInitGro = true ;
396
- }
397
-
398
- if ( mGetRenderedOnly )
399
- { // "Cache Features" was not selected for this layer
400
- // has rendered extent expanded beyond last-retrieved WFS extent?
401
- // NB: "intersect" instead of "contains" tolerates rounding errors;
402
- // avoids unnecessary second fetch on zoom-in/zoom-out sequences
403
- QgsRectangle olap ( rect );
404
- olap = olap.intersect ( &mGetExtent );
405
- if ( doubleNear ( rect.width (), olap.width () ) && doubleNear ( rect.height (), olap.height () ) )
406
- { // difference between canvas and layer extents is within rounding error: do not re-fetch
407
- QgsDebugMsg ( QString ( " Layer %1 GetRenderedOnly: no fetch required" ).arg ( mLayer ->name () ) );
408
- }
409
- else
410
- { // combined old and new extents might speed up local panning & zooming
411
- mGetExtent .combineExtentWith ( &rect );
412
- // but see if the combination is useless or too big
413
- double pArea = mGetExtent .width () * mGetExtent .height ();
414
- double cArea = rect.width () * rect.height ();
415
- if ( olap.isEmpty () || pArea > ( cArea * 4.0 ) )
416
- { // new canvas extent does not overlap or combining old and new extents would
417
- // fetch > 4 times the area to be rendered; get only what will be rendered
418
- mGetExtent = rect;
419
- }
420
- QgsDebugMsg ( QString ( " Layer %1 GetRenderedOnly: fetching extent %2" )
421
- .arg ( mLayer ->name (), mGetExtent .asWktCoordinates () ) );
422
- dsURI = dsURI.replace ( QRegExp ( " BBOX=[^&]*" ),
423
- QString ( " BBOX=%1,%2,%3,%4" )
424
- .arg ( mGetExtent .xMinimum (), 0 , ' f' )
425
- .arg ( mGetExtent .yMinimum (), 0 , ' f' )
426
- .arg ( mGetExtent .xMaximum (), 0 , ' f' )
427
- .arg ( mGetExtent .yMaximum (), 0 , ' f' ) );
428
- // TODO: BBOX may not be combined with FILTER. WFS spec v. 1.1.0, sec. 14.7.3 ff.
429
- // if a FILTER is present, the BBOX must be merged into it, capabilities permitting.
430
- // Else one criterion must be abandoned and the user warned. [WBC 111221]
431
- setDataSourceUri ( dsURI );
432
- reloadData ();
433
- mLayer ->updateExtents ();
434
- }
435
- }
436
-
437
- mSpatialFilter = rect;
438
- mSelectedFeatures = mSpatialIndex ->intersects ( mSpatialFilter );
439
- }
440
-
441
- mFeatureIterator = mSelectedFeatures .begin ();
442
- }
443
-
444
361
int QgsWFSProvider::getFeature ( const QString& uri )
445
362
{
446
363
if ( mRequestEncoding == QgsWFSProvider::GET )
0 commit comments