This commit is contained in:
Dane Springmeyer 2015-10-07 14:06:49 -07:00
parent ca7132b425
commit 1890d12534
5 changed files with 20 additions and 5 deletions

View file

@ -36,12 +36,15 @@ namespace mapnik {
struct attribute struct attribute
{ {
std::string name_; std::string name_;
bool is_id_;
explicit attribute(std::string const& name) explicit attribute(std::string const& name)
: name_(name) {} : name_(name),
is_id_(name == "__id__") {}
template <typename V ,typename F> template <typename V ,typename F>
V const& value(F const& f) const V const& value(F const& f) const
{ {
if (is_id_) return f.id();
return f.get(name_); return f.get(name_);
} }

View file

@ -62,7 +62,7 @@ struct expression_attributes
void operator() (attribute const& attr) const void operator() (attribute const& attr) const
{ {
names_.emplace(attr.name()); if (attr.name() != "__id__") names_.emplace(attr.name());
} }
template <typename Tag> template <typename Tag>

View file

@ -77,6 +77,10 @@ struct evaluate
value_type operator() (global_attribute const& attr) const value_type operator() (global_attribute const& attr) const
{ {
if (attr.name == "@id")
{
return feature_.id();
}
auto itr = vars_.find(attr.name); auto itr = vars_.find(attr.name);
if (itr != vars_.end()) if (itr != vars_.end())
{ {

View file

@ -67,8 +67,16 @@ namespace path_processor_detail
void operator() (attribute const& attr) const void operator() (attribute const& attr) const
{ {
// convert mapnik::value to std::string // convert mapnik::value to std::string
value const& val = feature_.get(attr.name()); std::string const& name = attr.name();
filename_ += val.to_string(); if (name == "__id__")
{
std::clog << "TODO\n";
}
else
{
value const& val = feature_.get(name);
filename_ += val.to_string();
}
} }
std::string & filename_; std::string & filename_;

View file

@ -177,7 +177,7 @@ struct grid_renderer : renderer_base<mapnik::image_rgba8>
} }
if (val < 0) if (val < 0)
{ {
throw std::runtime_error("grid renderer: feature id is negative."); val = std::abs(val);
} }
val *= 100; val *= 100;