Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit 9e17c55

Browse files
authored
Merge pull request #40 from umr-dbs/ogr-source-caching-fix
Fix OGR source util caching on empty collection
2 parents e71a5a4 + 6b5d27d commit 9e17c55

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/util/ogr_source_util.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ void OGRSourceUtil::readAnyCollection(const QueryRectangle &rect,
115115
// a call suggested by OGR Tutorial as "just in case" (to start reading from first feature)
116116
layer->ResetReading();
117117

118-
// no need to process any further if result is empty
119-
if (layer->GetFeatureCount() < 1) {
120-
return;
121-
}
122-
123118
//start reading the FeatureCollection
124119
OGRFeatureDefn *attributeDefn = layer->GetLayerDefn();
125120
createAttributeArrays(attributeDefn, collection->feature_attributes);
126121
initTimeReading(attributeDefn, layer, rect);
127122

123+
// no need to process any further if result is empty
124+
if (layer->GetFeatureCount() <= 0) {
125+
return;
126+
}
127+
128128
//createFromWkt allocates a geometry and writes its pointer into a local pointer, therefore the third parameter is a OGRGeometry **.
129129
//afterwards it is moved into a unique_ptr
130130
OGRGeometry *default_geometry_raw = nullptr;
@@ -351,7 +351,7 @@ OGRSourceUtil::readRingToPolygonCollection(const OGRLinearRing *ring, std::uniqu
351351
collection->finishRing();
352352
}
353353

354-
// create the AttributeArrays for the FeatureCollection based on Attribute Fields in OGRLayer.
354+
// create the AttributeArrays for the FeatureCollection based on Attribute Fields in OGRLayer.
355355
// only if the user asked for the attribute in the query parameters.
356356
// create a string vector with the attribute names for writing the attributes for each feature easier
357357
void OGRSourceUtil::createAttributeArrays(OGRFeatureDefn *attributeDefn, AttributeArrays &attributeArrays) {
@@ -389,7 +389,7 @@ void OGRSourceUtil::createAttributeArrays(OGRFeatureDefn *attributeDefn, Attribu
389389

390390

391391
// write attribute values for the given attribute definition using the attributeNames
392-
// returns false if an error occurred and ErrorHandling is set to skip so that
392+
// returns false if an error occurred and ErrorHandling is set to skip so that
393393
// the last written feature has to be removed again in the calling function
394394
bool OGRSourceUtil::readAttributesIntoCollection(AttributeArrays &attributeArrays, OGRFeatureDefn *attributeDefn,
395395
OGRFeature *feature, int featureIndex) {

0 commit comments

Comments
 (0)