mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
svg_renderer: group layers in inkscape capatible way - refs #1917
This commit is contained in:
parent
4c4a63aa9c
commit
fd428cf11b
@ -31,6 +31,7 @@
|
||||
#include <mapnik/svg/output/svg_output_grammars.hpp>
|
||||
#include <mapnik/svg/output/svg_output_attributes.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
|
||||
namespace mapnik { namespace svg {
|
||||
@ -57,6 +58,9 @@ namespace mapnik { namespace svg {
|
||||
void generate_opening_root(root_output_attributes const& root_attributes);
|
||||
void generate_closing_root();
|
||||
void generate_rect(rect_output_attributes const& rect_attributes);
|
||||
void generate_opening_group(mapnik::value_integer val);
|
||||
void generate_opening_group(std::string const& val);
|
||||
void generate_closing_group();
|
||||
template <typename PathType>
|
||||
void generate_path(PathType const& path, path_output_attributes const& path_attributes)
|
||||
{
|
||||
|
||||
@ -172,7 +172,8 @@ struct svg_root_attributes_grammar : karma::grammar<OutputIterator, mapnik::svg:
|
||||
lit("width=") << confix('"', '"')[int_ << lit("px")]
|
||||
<< lit(" height=") << confix('"', '"')[int_ << lit("px")]
|
||||
<< " version=" << confix('"', '"')[double_]
|
||||
<< " xmlns=" << confix('"', '"')[string];
|
||||
<< " xmlns=" << confix('"', '"')[string]
|
||||
<< lit(" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"");
|
||||
}
|
||||
|
||||
karma::rule<OutputIterator, mapnik::svg::root_output_attributes()> svg_root_attributes;
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
// mapnik
|
||||
#include <mapnik/svg/output/svg_generator.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
@ -65,5 +66,39 @@ namespace mapnik { namespace svg {
|
||||
karma::generate(output_iterator_, lit("<rect ") << attributes_grammar << lit("/>\n"), rect_attributes);
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
void svg_generator<OutputIterator>::generate_opening_group(mapnik::value_integer val)
|
||||
{
|
||||
std::string string_val;
|
||||
mapnik::util::to_string(string_val,val);
|
||||
karma::generate(output_iterator_, lit("<g id=\"")
|
||||
<< lit(string_val)
|
||||
<< lit("\"")
|
||||
<< lit(" inkscape:groupmode=\"layer\"")
|
||||
<< lit(" inkscape:label=\"")
|
||||
<< lit(string_val)
|
||||
<< lit("\"")
|
||||
<< lit("\n"));
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
void svg_generator<OutputIterator>::generate_opening_group(std::string const& val)
|
||||
{
|
||||
karma::generate(output_iterator_, lit("<g id=\"")
|
||||
<< lit(val)
|
||||
<< lit("\"")
|
||||
<< lit(" inkscape:groupmode=\"layer\"")
|
||||
<< lit(" inkscape:label=\"")
|
||||
<< lit(val)
|
||||
<< lit("\"")
|
||||
<< lit(">\n"));
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
void svg_generator<OutputIterator>::generate_closing_group()
|
||||
{
|
||||
karma::generate(output_iterator_, lit("</g>\n"));
|
||||
}
|
||||
|
||||
template class svg_generator<std::ostream_iterator<char> >;
|
||||
}}
|
||||
|
||||
@ -104,12 +104,14 @@ void svg_renderer<T>::end_map_processing(Map const& map)
|
||||
template <typename T>
|
||||
void svg_renderer<T>::start_layer_processing(layer const& lay, box2d<double> const& query_extent)
|
||||
{
|
||||
generator_.generate_opening_group(lay.name());
|
||||
MAPNIK_LOG_DEBUG(svg_renderer) << "svg_renderer: Start layer processing=" << lay.name();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void svg_renderer<T>::end_layer_processing(layer const& lay)
|
||||
{
|
||||
generator_.generate_closing_group();
|
||||
MAPNIK_LOG_DEBUG(svg_renderer) << "svg_renderer: End layer processing=" << lay.name();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user