File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
97
97
mAttributesToFetch .append ( i );
98
98
}
99
99
}
100
+
100
101
// get fid col if not yet required
101
102
if ( mFidCol == -1 && !mSource ->mFidColName .isEmpty () )
102
103
{
@@ -107,7 +108,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
107
108
++fieldCount;
108
109
}
109
110
// get geometry col
110
- if ( !( request.flags () & QgsFeatureRequest::NoGeometry ) && ! mSource ->mGeometryColName . isEmpty () )
111
+ if ( !( request.flags () & QgsFeatureRequest::NoGeometry ) && mSource ->isSpatial () )
111
112
{
112
113
if ( fieldCount != 0 )
113
114
mStatement += " ," ;
@@ -124,7 +125,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
124
125
125
126
bool filterAdded = false ;
126
127
// set spatial filter
127
- if ( request.filterType () & QgsFeatureRequest::FilterRect )
128
+ if ( request.filterType () & QgsFeatureRequest::FilterRect && isSpatial () )
128
129
{
129
130
// polygons should be CCW for SqlGeography
130
131
QString r;
@@ -162,6 +163,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
162
163
mStatement += " and (" + mSource ->mSqlWhereClause + " )" ;
163
164
}
164
165
166
+ // QgsDebugMsg( mStatement );
165
167
if ( fieldCount == 0 )
166
168
{
167
169
QgsDebugMsg ( " QgsMssqlProvider::select no fields have been requested" );
Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ class QgsMssqlFeatureSource : public QgsAbstractFeatureSource
62
62
// SQL statement used to limit the features retrieved
63
63
QString mSqlWhereClause ;
64
64
65
+ // Return True if this feature source has spatial attributes.
66
+ bool isSpatial () { return !mGeometryColName .isEmpty () || !mGeometryColType .isEmpty (); }
67
+
65
68
friend class QgsMssqlFeatureIterator ;
66
69
};
67
70
@@ -111,6 +114,9 @@ class QgsMssqlFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsM
111
114
112
115
// for parsing sql geometries
113
116
QgsMssqlGeometryParser mParser ;
117
+
118
+ // Return True of the geometry column was found when parsing the columns.
119
+ bool isSpatial () { return mGeometryCol > -1 ; }
114
120
};
115
121
116
122
#endif // QGSMSSQLFEATUREITERATOR_H
You can’t perform that action at this time.
0 commit comments