give users a hint on what to do when they hit 'Invalid index file'

This commit is contained in:
Dane Springmeyer 2016-01-26 12:19:34 -08:00
parent 5d40745236
commit 753a0ad216

View file

@ -69,7 +69,7 @@ bool spatial_index<Value, Filter, InputStream>::check_header(InputStream& in)
template <typename Value, typename Filter, typename InputStream>
box2d<double> spatial_index<Value, Filter, InputStream>::bounding_box(InputStream& in)
{
if (!check_header(in)) throw std::runtime_error("Invalid index file");
if (!check_header(in)) throw std::runtime_error("Invalid index file (regenerate with shapeindex)");
in.seekg(16 + 4, std::ios::beg);
box2d<double> box;
read_envelope(in, box);
@ -80,7 +80,7 @@ box2d<double> spatial_index<Value, Filter, InputStream>::bounding_box(InputStrea
template <typename Value, typename Filter, typename InputStream>
void spatial_index<Value, Filter, InputStream>::query(Filter const& filter, InputStream& in, std::vector<Value>& results)
{
if (!check_header(in)) throw std::runtime_error("Invalid index file");
if (!check_header(in)) throw std::runtime_error("Invalid index file (regenerate with shapeindex)");
in.seekg(16, std::ios::beg);
query_node(filter, in, results);
}
@ -115,7 +115,7 @@ void spatial_index<Value, Filter, InputStream>::query_node(Filter const& filter,
template <typename Value, typename Filter, typename InputStream>
void spatial_index<Value, Filter, InputStream>::query_first_n(Filter const& filter, InputStream& in, std::vector<Value>& results, std::size_t count)
{
if (!check_header(in)) throw std::runtime_error("Invalid index file");
if (!check_header(in)) throw std::runtime_error("Invalid index file (regenerate with shapeindex)");
in.seekg(16, std::ios::beg);
query_first_n_impl(filter, in, results, count);
}