diff --git a/src/mbtiles_vector_featureset.cpp b/src/mbtiles_vector_featureset.cpp index 0e03069..3475398 100644 --- a/src/mbtiles_vector_featureset.cpp +++ b/src/mbtiles_vector_featureset.cpp @@ -53,23 +53,30 @@ bool mbtiles_vector_featureset::valid() const return vector_tile_.get() != nullptr; } +mapnik::feature_ptr mbtiles_vector_featureset::next_feature() +{ + mapnik::feature_ptr f = mapnik::feature_ptr(); + if (valid()) { + f = vector_tile_->next(); + } + return f; +} + mapnik::feature_ptr mbtiles_vector_featureset::next() { // If current tile is processed completely, go forward to the next tile. // else step forward to the next feature - mapnik::feature_ptr f = mapnik::feature_ptr(); - if (!valid()) - { - return f; - } - f = vector_tile_->next(); - if (f) - { + mapnik::feature_ptr f = next_feature(); + if (f) { return f; } while (next_tile() && open_tile() && valid()) { - return vector_tile_->next(); + f = next_feature(); + if (f) + { + return f; + } } return mapnik::feature_ptr(); } diff --git a/src/mbtiles_vector_featureset.hpp b/src/mbtiles_vector_featureset.hpp index 1ebef31..9a9b484 100644 --- a/src/mbtiles_vector_featureset.hpp +++ b/src/mbtiles_vector_featureset.hpp @@ -43,6 +43,7 @@ class mbtiles_vector_featureset : public mapnik::Featureset virtual ~mbtiles_vector_featureset(); mapnik::feature_ptr next(); private: + mapnik::feature_ptr next_feature(); bool valid() const; std::shared_ptr database_; mapnik::context_ptr context_;