Use overlap optimization in load_map_string too
This commit is contained in:
parent
def0fd1f31
commit
0a2be27ba9
1 changed files with 54 additions and 0 deletions
|
@ -149,6 +149,58 @@ private:
|
|||
std::string xml_base_path_;
|
||||
};
|
||||
|
||||
void map_allow_overlap_optimization(Map &map)
|
||||
{
|
||||
// Due manual rule optimization for marker symbolizers. If all styles
|
||||
// use only marker symbolizers and all rules of the styles have explictly
|
||||
// define allow_overlap=true, then set ignore_placement=true. This has
|
||||
// both performance benefits and allows the rendering to run in constant space
|
||||
// as the collision quadtree is not used.
|
||||
// Note that the code can be generalized to include texts and points.
|
||||
bool ignore_placement = true;
|
||||
for (auto style_it = map.begin_styles(); style_it != map.end_styles(); style_it++)
|
||||
{
|
||||
for (auto & rule : style_it->second.get_rules_nonconst())
|
||||
{
|
||||
for (auto & sym : rule)
|
||||
{
|
||||
if (sym.is<markers_symbolizer>())
|
||||
{
|
||||
markers_symbolizer & marker = sym.get<markers_symbolizer>();
|
||||
auto prop_it = marker.properties.find(keys::allow_overlap);
|
||||
if (prop_it != marker.properties.end())
|
||||
{
|
||||
if (prop_it->second == true)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// In all other cases (non-marker symbolizer, allow_overlap not explictly true) do not set ignore_placement
|
||||
ignore_placement = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ignore_placement)
|
||||
{
|
||||
for (auto style_it = map.begin_styles(); style_it != map.end_styles(); style_it++)
|
||||
{
|
||||
for (auto & rule : style_it->second.get_rules_nonconst())
|
||||
{
|
||||
for (auto & sym : rule)
|
||||
{
|
||||
if (sym.is<markers_symbolizer>())
|
||||
{
|
||||
markers_symbolizer & marker = sym.get<markers_symbolizer>();
|
||||
marker.properties[keys::ignore_placement] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MAPNIK_LOG_DEBUG(load_map) << "setting ignore_placement=true due to all rules having allow_overlap=true";
|
||||
}
|
||||
}
|
||||
|
||||
void load_map(Map & map, std::string const& filename, bool strict, std::string base_path)
|
||||
{
|
||||
|
@ -157,6 +209,7 @@ void load_map(Map & map, std::string const& filename, bool strict, std::string b
|
|||
read_xml(filename, tree.root());
|
||||
map_parser parser(map, strict, filename);
|
||||
parser.parse_map(map, tree.root(), base_path);
|
||||
map_allow_overlap_optimization(map);
|
||||
}
|
||||
|
||||
void load_map_string(Map & map, std::string const& str, bool strict, std::string base_path)
|
||||
|
@ -172,6 +225,7 @@ void load_map_string(Map & map, std::string const& str, bool strict, std::string
|
|||
}
|
||||
map_parser parser(map, strict, base_path);
|
||||
parser.parse_map(map, tree.root(), base_path);
|
||||
map_allow_overlap_optimization(map);
|
||||
}
|
||||
|
||||
void map_parser::parse_map(Map & map, xml_node const& node, std::string const& base_path)
|
||||
|
|
Loading…
Reference in a new issue