From b43ee6dd0494b31965946fa5a21149202a7c12a8 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 18 Feb 2016 11:44:39 +0100 Subject: [PATCH] beef up `has_index` method to check if *.index file is valid (has expected header) (ref #3300) --- plugins/input/shape/shape_io.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp index c2fd3a564..1828ebd54 100644 --- a/plugins/input/shape/shape_io.hpp +++ b/plugins/input/shape/shape_io.hpp @@ -23,16 +23,16 @@ #ifndef SHAPE_IO_HPP #define SHAPE_IO_HPP +// stl +#include +#include // mapnik #include #include - +#include // boost #include - -// stl -#include - +// #include "dbfile.hpp" #include "shapefile.hpp" @@ -72,7 +72,13 @@ public: inline bool has_index() const { - return (index_ && index_->is_open()); + if (index_ && index_->is_open()) + { + bool status = mapnik::util::check_spatial_index(index_->file()); + index_->seek(0);// rewind + return status; + } + return false; } inline int id() const { return id_;}