diff --git a/plugins/input/shape/shape.cpp b/plugins/input/shape/shape.cpp index 9073cc3c3..ad1980408 100644 --- a/plugins/input/shape/shape.cpp +++ b/plugins/input/shape/shape.cpp @@ -23,10 +23,7 @@ #include #include #include - #include - - #include "shape_featureset.hpp" #include "shape_index_featureset.hpp" @@ -40,10 +37,12 @@ shape_datasource::shape_datasource(const parameters ¶ms) type_(datasource::Vector), file_length_(0), indexed_(false), - desc_(params.get("name"),"latin1") + desc_(params.get("name"),"utf-8") { try { + std::string encoding = params.get("encoding"); + if (encoding.length() > 0) desc_.set_encoding(encoding); shape_io shape(shape_name_); init(shape); for (int i=0;i(filter,shape_name_,q.property_names())); + (new shape_index_featureset(filter, + shape_name_, + q.property_names(), + desc_.get_encoding())); } else { return featureset_ptr - (new shape_featureset(filter,shape_name_,q.property_names(),file_length_)); + (new shape_featureset(filter, + shape_name_, + q.property_names(), + desc_.get_encoding(), + file_length_)); } } @@ -179,12 +185,19 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt) const if (indexed_) { return featureset_ptr - (new shape_index_featureset(filter,shape_name_,names)); + (new shape_index_featureset(filter, + shape_name_, + names, + desc_.get_encoding())); } else { return featureset_ptr - (new shape_featureset(filter,shape_name_,names,file_length_)); + (new shape_featureset(filter, + shape_name_, + names, + desc_.get_encoding(), + file_length_)); } } diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index a6e361feb..4d7a119b2 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -27,12 +27,13 @@ template shape_featureset::shape_featureset(const filterT& filter, const std::string& shape_file, const std::set& attribute_names, + std::string const& encoding, long file_length ) : filter_(filter), shape_type_(shape_io::shape_null), shape_(shape_file), query_ext_(), - tr_(new transcoder("latin1")), + tr_(new transcoder(encoding)), file_length_(file_length), count_(0) { diff --git a/plugins/input/shape/shape_featureset.hpp b/plugins/input/shape/shape_featureset.hpp index f0fb3035d..90b96bf1b 100644 --- a/plugins/input/shape/shape_featureset.hpp +++ b/plugins/input/shape/shape_featureset.hpp @@ -43,8 +43,11 @@ class shape_featureset : public Featureset mutable int total_geom_size; mutable int count_; public: - shape_featureset(const filterT& filter, const std::string& shape_file, - const std::set& attribute_names,long file_length); + shape_featureset(const filterT& filter, + const std::string& shape_file, + const std::set& attribute_names, + std::string const& encoding, + long file_length); virtual ~shape_featureset(); feature_ptr next(); private: diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 6bf487792..8742cdd24 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -28,11 +28,12 @@ template shape_index_featureset::shape_index_featureset(const filterT& filter, const std::string& shape_file, - const std::set& attribute_names) + const std::set& attribute_names, + std::string const& encoding) : filter_(filter), shape_type_(0), shape_(shape_file), - tr_(new transcoder("latin1")), + tr_(new transcoder(encoding)), count_(0) { diff --git a/plugins/input/shape/shape_index_featureset.hpp b/plugins/input/shape/shape_index_featureset.hpp index fabab4300..e0cee5d66 100644 --- a/plugins/input/shape/shape_index_featureset.hpp +++ b/plugins/input/shape/shape_index_featureset.hpp @@ -43,8 +43,10 @@ class shape_index_featureset : public Featureset mutable int count_; public: - shape_index_featureset(const filterT& filter,const std::string& shape_file, - const std::set& attribute_names); + shape_index_featureset(const filterT& filter, + const std::string& shape_file, + const std::set& attribute_names, + std::string const& encoding); virtual ~shape_index_featureset(); feature_ptr next(); private: