-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change WFS provider for new vector api
- Loading branch information
Showing
9 changed files
with
220 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "qgswfsfeatureiterator.h" | ||
#include "qgsspatialindex.h" | ||
#include "qgswfsprovider.h" | ||
|
||
QgsWFSFeatureIterator::QgsWFSFeatureIterator( QgsWFSProvider* provider, const QgsFeatureRequest& request ): | ||
QgsAbstractFeatureIterator( request ), mProvider( provider ) | ||
{ | ||
//select ids | ||
//get iterator | ||
if ( !mProvider ) | ||
{ | ||
return; | ||
} | ||
|
||
switch ( request.filterType() ) | ||
{ | ||
case QgsFeatureRequest::FilterRect: | ||
if ( mProvider->mSpatialIndex ) | ||
{ | ||
mSelectedFeatures = mProvider->mSpatialIndex->intersects( request.filterRect() ); | ||
} | ||
break; | ||
case QgsFeatureRequest::FilterFid: | ||
mSelectedFeatures.push_back( request.filterFid() ); | ||
break; | ||
case QgsFeatureRequest::FilterNone: | ||
mSelectedFeatures = mProvider->mFeatures.keys(); | ||
default: //QgsFeatureRequest::FilterNone | ||
mSelectedFeatures = mProvider->mFeatures.keys(); | ||
} | ||
|
||
mFeatureIterator = mSelectedFeatures.constBegin(); | ||
} | ||
|
||
QgsWFSFeatureIterator::~QgsWFSFeatureIterator() | ||
{ | ||
|
||
} | ||
|
||
bool QgsWFSFeatureIterator::nextFeature( QgsFeature& f ) | ||
{ | ||
if ( !mProvider ) | ||
{ | ||
return false; | ||
} | ||
|
||
if ( mFeatureIterator == mSelectedFeatures.constEnd() ) | ||
{ | ||
return false; | ||
} | ||
|
||
QMap<QgsFeatureId, QgsFeature* >::iterator it = mProvider->mFeatures.find( *mFeatureIterator ); | ||
if ( it == mProvider->mFeatures.end() ) | ||
{ | ||
return false; | ||
} | ||
QgsFeature* fet = it.value(); | ||
mProvider->copyFeature( fet, f, !( mRequest.flags() & QgsFeatureRequest::NoGeometry ), mRequest.subsetOfAttributes() ); | ||
++mFeatureIterator; | ||
return true; | ||
} | ||
|
||
bool QgsWFSFeatureIterator::rewind() | ||
{ | ||
return false; | ||
} | ||
|
||
bool QgsWFSFeatureIterator::close() | ||
{ | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef QGSWFSFEATUREITERATOR_H | ||
#define QGSWFSFEATUREITERATOR_H | ||
|
||
#include "qgsfeatureiterator.h" | ||
|
||
class QgsWFSProvider; | ||
|
||
class QgsWFSFeatureIterator: public QgsAbstractFeatureIterator | ||
{ | ||
public: | ||
QgsWFSFeatureIterator( QgsWFSProvider* provider, const QgsFeatureRequest& request ); | ||
~QgsWFSFeatureIterator(); | ||
|
||
bool nextFeature( QgsFeature& f ); | ||
bool rewind(); | ||
bool close(); | ||
|
||
private: | ||
QgsWFSProvider* mProvider; | ||
QList<QgsFeatureId> mSelectedFeatures; | ||
QList<QgsFeatureId>::const_iterator mFeatureIterator; | ||
}; | ||
|
||
#endif // QGSWFSFEATUREITERATOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.