upgrade shape.input to new feature impl
This commit is contained in:
parent
62fcb51e2f
commit
0dc71c9eda
6 changed files with 24 additions and 17 deletions
|
@ -121,7 +121,7 @@ const field_descriptor& dbf_file::descriptor(int col) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature const& f) const throw()
|
void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f) const throw()
|
||||||
{
|
{
|
||||||
using namespace boost::spirit;
|
using namespace boost::spirit;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature cons
|
||||||
// FIXME - avoid constructing std::string on stack
|
// FIXME - avoid constructing std::string on stack
|
||||||
std::string str(record_+fields_[col].offset_,fields_[col].length_);
|
std::string str(record_+fields_[col].offset_,fields_[col].length_);
|
||||||
boost::trim(str);
|
boost::trim(str);
|
||||||
f[name] = tr.transcode(str.c_str());
|
f.put(name,tr.transcode(str.c_str()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'N':
|
case 'N':
|
||||||
|
@ -148,7 +148,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature cons
|
||||||
|
|
||||||
if (record_[fields_[col].offset_] == '*')
|
if (record_[fields_[col].offset_] == '*')
|
||||||
{
|
{
|
||||||
boost::put(f,name,0);
|
f.put(name,0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( fields_[col].dec_>0 )
|
if ( fields_[col].dec_>0 )
|
||||||
|
@ -157,7 +157,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature cons
|
||||||
const char *itr = record_+fields_[col].offset_;
|
const char *itr = record_+fields_[col].offset_;
|
||||||
const char *end = itr + fields_[col].length_;
|
const char *end = itr + fields_[col].length_;
|
||||||
qi::phrase_parse(itr,end,double_,ascii::space,val);
|
qi::phrase_parse(itr,end,double_,ascii::space,val);
|
||||||
boost::put(f,name,val);
|
f.put(name,val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -165,7 +165,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature cons
|
||||||
const char *itr = record_+fields_[col].offset_;
|
const char *itr = record_+fields_[col].offset_;
|
||||||
const char *end = itr + fields_[col].length_;
|
const char *end = itr + fields_[col].length_;
|
||||||
qi::phrase_parse(itr,end,int_,ascii::space,val);
|
qi::phrase_parse(itr,end,int_,ascii::space,val);
|
||||||
boost::put(f,name,val);
|
f.put(name,val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
field_descriptor const& descriptor(int col) const;
|
field_descriptor const& descriptor(int col) const;
|
||||||
void move_to(int index);
|
void move_to(int index);
|
||||||
std::string string_value(int col) const;
|
std::string string_value(int col) const;
|
||||||
void add_attribute(int col, transcoder const& tr, Feature const& f) const throw();
|
void add_attribute(int col, transcoder const& tr, Feature & f) const throw();
|
||||||
private:
|
private:
|
||||||
void read_header();
|
void read_header();
|
||||||
int read_short();
|
int read_short();
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
using mapnik::geometry_type;
|
using mapnik::geometry_type;
|
||||||
using mapnik::feature_factory;
|
using mapnik::feature_factory;
|
||||||
|
using mapnik::context_ptr;
|
||||||
|
|
||||||
template <typename filterT>
|
template <typename filterT>
|
||||||
shape_featureset<filterT>::shape_featureset(const filterT& filter,
|
shape_featureset<filterT>::shape_featureset(const filterT& filter,
|
||||||
|
@ -43,7 +44,6 @@ shape_featureset<filterT>::shape_featureset(const filterT& filter,
|
||||||
long file_length,
|
long file_length,
|
||||||
int row_limit)
|
int row_limit)
|
||||||
: filter_(filter),
|
: filter_(filter),
|
||||||
//shape_type_(shape_io::shape_null),
|
|
||||||
shape_(shape_name, false),
|
shape_(shape_name, false),
|
||||||
query_ext_(),
|
query_ext_(),
|
||||||
tr_(new transcoder(encoding)),
|
tr_(new transcoder(encoding)),
|
||||||
|
@ -51,10 +51,12 @@ shape_featureset<filterT>::shape_featureset(const filterT& filter,
|
||||||
count_(0),
|
count_(0),
|
||||||
row_limit_(row_limit)
|
row_limit_(row_limit)
|
||||||
{
|
{
|
||||||
|
ctx_ = boost::make_shared<mapnik::context>();
|
||||||
shape_.shp().skip(100);
|
shape_.shp().skip(100);
|
||||||
|
|
||||||
//attributes
|
//attributes
|
||||||
typename std::set<std::string>::const_iterator pos = attribute_names.begin();
|
typename std::set<std::string>::const_iterator pos = attribute_names.begin();
|
||||||
|
|
||||||
while (pos != attribute_names.end())
|
while (pos != attribute_names.end())
|
||||||
{
|
{
|
||||||
bool found_name = false;
|
bool found_name = false;
|
||||||
|
@ -62,6 +64,7 @@ shape_featureset<filterT>::shape_featureset(const filterT& filter,
|
||||||
{
|
{
|
||||||
if (shape_.dbf().descriptor(i).name_ == *pos)
|
if (shape_.dbf().descriptor(i).name_ == *pos)
|
||||||
{
|
{
|
||||||
|
ctx_->push(*pos);
|
||||||
attr_ids_.push_back(i);
|
attr_ids_.push_back(i);
|
||||||
found_name = true;
|
found_name = true;
|
||||||
break;
|
break;
|
||||||
|
@ -115,7 +118,7 @@ feature_ptr shape_featureset<filterT>::next()
|
||||||
if (pos < std::streampos(file_length_ * 2))
|
if (pos < std::streampos(file_length_ * 2))
|
||||||
{
|
{
|
||||||
int type = shape_.type();
|
int type = shape_.type();
|
||||||
feature_ptr feature(feature_factory::create(shape_.id_));
|
feature_ptr feature(feature_factory::create(ctx_, shape_.id_));
|
||||||
|
|
||||||
if (type == shape_io::shape_point)
|
if (type == shape_io::shape_point)
|
||||||
{
|
{
|
||||||
|
@ -266,7 +269,7 @@ feature_ptr shape_featureset<filterT>::next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FIXME
|
||||||
feature->set_id(shape_.id_);
|
feature->set_id(shape_.id_);
|
||||||
if (attr_ids_.size())
|
if (attr_ids_.size())
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,12 +36,13 @@ using mapnik::Featureset;
|
||||||
using mapnik::box2d;
|
using mapnik::box2d;
|
||||||
using mapnik::feature_ptr;
|
using mapnik::feature_ptr;
|
||||||
using mapnik::transcoder;
|
using mapnik::transcoder;
|
||||||
|
using mapnik::context_ptr;
|
||||||
|
|
||||||
template <typename filterT>
|
template <typename filterT>
|
||||||
class shape_featureset : public Featureset
|
class shape_featureset : public Featureset
|
||||||
{
|
{
|
||||||
filterT filter_;
|
filterT filter_;
|
||||||
//int shape_type_;
|
context_ptr ctx_;
|
||||||
shape_io shape_;
|
shape_io shape_;
|
||||||
box2d<double> query_ext_;
|
box2d<double> query_ext_;
|
||||||
boost::scoped_ptr<transcoder> tr_;
|
boost::scoped_ptr<transcoder> tr_;
|
||||||
|
|
|
@ -49,6 +49,7 @@ shape_index_featureset<filterT>::shape_index_featureset(const filterT& filter,
|
||||||
count_(0),
|
count_(0),
|
||||||
row_limit_(row_limit)
|
row_limit_(row_limit)
|
||||||
{
|
{
|
||||||
|
ctx_ = boost::make_shared<mapnik::context>();
|
||||||
shape_.shp().skip(100);
|
shape_.shp().skip(100);
|
||||||
|
|
||||||
boost::shared_ptr<shape_file> index = shape_.index();
|
boost::shared_ptr<shape_file> index = shape_.index();
|
||||||
|
@ -79,6 +80,7 @@ shape_index_featureset<filterT>::shape_index_featureset(const filterT& filter,
|
||||||
{
|
{
|
||||||
if (shape_.dbf().descriptor(i).name_ == *pos)
|
if (shape_.dbf().descriptor(i).name_ == *pos)
|
||||||
{
|
{
|
||||||
|
ctx_->push(*pos);
|
||||||
attr_ids_.insert(i);
|
attr_ids_.insert(i);
|
||||||
found_name = true;
|
found_name = true;
|
||||||
break;
|
break;
|
||||||
|
@ -119,7 +121,7 @@ feature_ptr shape_index_featureset<filterT>::next()
|
||||||
shape_.move_to(pos);
|
shape_.move_to(pos);
|
||||||
|
|
||||||
int type = shape_.type();
|
int type = shape_.type();
|
||||||
feature_ptr feature(feature_factory::create(shape_.id_));
|
feature_ptr feature(feature_factory::create(ctx_,shape_.id_));
|
||||||
if (type == shape_io::shape_point)
|
if (type == shape_io::shape_point)
|
||||||
{
|
{
|
||||||
double x = shape_.shp().read_double();
|
double x = shape_.shp().read_double();
|
||||||
|
@ -210,7 +212,7 @@ feature_ptr shape_index_featureset<filterT>::next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FIXME
|
||||||
feature->set_id(shape_.id_);
|
feature->set_id(shape_.id_);
|
||||||
if (attr_ids_.size())
|
if (attr_ids_.size())
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
using mapnik::Featureset;
|
using mapnik::Featureset;
|
||||||
using mapnik::box2d;
|
using mapnik::box2d;
|
||||||
using mapnik::feature_ptr;
|
using mapnik::feature_ptr;
|
||||||
|
using mapnik::context_ptr;
|
||||||
|
|
||||||
template <typename filterT>
|
template <typename filterT>
|
||||||
class shape_index_featureset : public Featureset
|
class shape_index_featureset : public Featureset
|
||||||
|
@ -55,7 +56,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
filterT filter_;
|
filterT filter_;
|
||||||
//int shape_type_;
|
context_ptr ctx_;
|
||||||
shape_io & shape_;
|
shape_io & shape_;
|
||||||
boost::scoped_ptr<transcoder> tr_;
|
boost::scoped_ptr<transcoder> tr_;
|
||||||
std::vector<int> ids_;
|
std::vector<int> ids_;
|
||||||
|
|
Loading…
Reference in a new issue