Compare commits
1 commit
master
...
feature-id
Author | SHA1 | Date | |
---|---|---|---|
|
1890d12534 |
5 changed files with 20 additions and 5 deletions
|
@ -36,12 +36,15 @@ namespace mapnik {
|
|||
struct attribute
|
||||
{
|
||||
std::string name_;
|
||||
bool is_id_;
|
||||
explicit attribute(std::string const& name)
|
||||
: name_(name) {}
|
||||
: name_(name),
|
||||
is_id_(name == "__id__") {}
|
||||
|
||||
template <typename V ,typename F>
|
||||
V const& value(F const& f) const
|
||||
{
|
||||
if (is_id_) return f.id();
|
||||
return f.get(name_);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ struct expression_attributes
|
|||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
names_.emplace(attr.name());
|
||||
if (attr.name() != "__id__") names_.emplace(attr.name());
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
|
|
|
@ -77,6 +77,10 @@ struct evaluate
|
|||
|
||||
value_type operator() (global_attribute const& attr) const
|
||||
{
|
||||
if (attr.name == "@id")
|
||||
{
|
||||
return feature_.id();
|
||||
}
|
||||
auto itr = vars_.find(attr.name);
|
||||
if (itr != vars_.end())
|
||||
{
|
||||
|
|
|
@ -67,8 +67,16 @@ namespace path_processor_detail
|
|||
void operator() (attribute const& attr) const
|
||||
{
|
||||
// convert mapnik::value to std::string
|
||||
value const& val = feature_.get(attr.name());
|
||||
filename_ += val.to_string();
|
||||
std::string const& name = attr.name();
|
||||
if (name == "__id__")
|
||||
{
|
||||
std::clog << "TODO\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
value const& val = feature_.get(name);
|
||||
filename_ += val.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
std::string & filename_;
|
||||
|
|
|
@ -177,7 +177,7 @@ struct grid_renderer : renderer_base<mapnik::image_rgba8>
|
|||
}
|
||||
if (val < 0)
|
||||
{
|
||||
throw std::runtime_error("grid renderer: feature id is negative.");
|
||||
val = std::abs(val);
|
||||
}
|
||||
|
||||
val *= 100;
|
||||
|
|
Loading…
Reference in a new issue