本文整理汇总了C++中mapnik::feature_impl::context方法的典型用法代码示例。如果您正苦于以下问题:C++ feature_impl::context方法的具体用法?C++ feature_impl::context怎么用?C++ feature_impl::context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapnik::feature_impl
的用法示例。
在下文中一共展示了feature_impl::context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void hit_grid<T>::add_feature(mapnik::feature_impl const& feature)
{
value_type feature_id = feature.id();
// avoid adding duplicate features (e.g. in the case of both a line symbolizer and a polygon symbolizer)
typename feature_key_type::const_iterator feature_pos = f_keys_.find(feature_id);
if (feature_pos != f_keys_.end())
{
return;
}
if (ctx_->size() == 0)
{
context_type::map_type::const_iterator itr = feature.context()->begin();
context_type::map_type::const_iterator end = feature.context()->end();
for ( ;itr!=end; ++itr)
{
ctx_->add(itr->first,itr->second);
}
}
// NOTE: currently lookup keys must be strings,
// but this should be revisited
lookup_type lookup_value;
if (key_ == id_name_)
{
mapnik::util::to_string(lookup_value,feature_id);
}
else
{
if (feature.has_key(key_))
{
lookup_value = feature.get(key_).to_string();
}
else
{
MAPNIK_LOG_DEBUG(grid) << "hit_grid: Should not get here: key '" << key_ << "' not found in feature properties";
}
}
if (!lookup_value.empty())
{
// TODO - consider shortcutting f_keys if feature_id == lookup_value
// create a mapping between the pixel id and the feature key
f_keys_.emplace(feature_id,lookup_value);
// if extra fields have been supplied, push them into grid memory
if (!names_.empty())
{
// it is ~ 2x faster to copy feature attributes compared
// to building up a in-memory cache of feature_ptrs
// https://github.com/mapnik/mapnik/issues/1198
mapnik::feature_ptr feature2(mapnik::feature_factory::create(ctx_,feature_id));
feature2->set_data(feature.get_data());
features_.emplace(lookup_value,feature2);
}
}
else
{
MAPNIK_LOG_DEBUG(grid) << "hit_grid: Warning - key '" << key_ << "' was blank for " << feature;
}
}