From ff66cc13261e910ce9510063894e931e57db903d Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Fri, 10 Feb 2012 10:52:06 +0000 Subject: [PATCH] + check if index is valid in to_string() + output feature id --- include/mapnik/feature.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 557fdea3b..81a9b7da4 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -254,12 +254,16 @@ public: std::string to_string() const { std::stringstream ss; - ss << "Feature (" << std::endl; + ss << "Feature ( id=" << id_ << std::endl; context_type::map_type::const_iterator itr = ctx_->mapping_.begin(); context_type::map_type::const_iterator end = ctx_->mapping_.end(); for ( ;itr!=end; ++itr) { - ss << " " << itr->first << ":" << data_[itr->second] << std::endl; + std::size_t index = itr->second; + if (index < data_.size()) + { + ss << " " << itr->first << ":" << data_[itr->second] << std::endl; + } } ss << ")" << std::endl; return ss.str();