From 39a1038eb8dae05b1c2f8570976f7194bc2f8efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Mon, 26 Jul 2010 06:23:43 +0000 Subject: [PATCH] Added missing files: include/mapnik/svg/svg_generator.hpp and include/mapnik/svg/svg_generator_path_grammar.hpp. --- include/mapnik/svg/svg_generator.hpp | 53 +++++++++++ .../mapnik/svg/svg_generator_path_grammar.hpp | 93 +++++++++++++++++++ src/svg/svg_generator.cpp | 50 ++++++++++ 3 files changed, 196 insertions(+) create mode 100644 include/mapnik/svg/svg_generator.hpp create mode 100644 include/mapnik/svg/svg_generator_path_grammar.hpp create mode 100644 src/svg/svg_generator.cpp diff --git a/include/mapnik/svg/svg_generator.hpp b/include/mapnik/svg/svg_generator.hpp new file mode 100644 index 000000000..456eb9830 --- /dev/null +++ b/include/mapnik/svg/svg_generator.hpp @@ -0,0 +1,53 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2010 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_SVG_GENERATOR_HPP +#define MAPNIK_SVG_GENERATOR_HPP + +// mapnik +#include + +// boost +#include + +namespace mapnik { //namespace svg { + + template + class svg_generator : private boost::noncopyable + { + typedef svg::svg_generator_path_grammar path_grammar; + + public: + explicit svg_generator(OutputIterator& output_iterator); + ~svg_generator(); + + void generate_root(); + void generate_rect(); + void generate_path(); + + private: + OutputIterator& output_iterator_; + path_grammar path_grammar_; + } +}} + +#endif // MAPNIK_SVG_GENERATOR_HPP diff --git a/include/mapnik/svg/svg_generator_path_grammar.hpp b/include/mapnik/svg/svg_generator_path_grammar.hpp new file mode 100644 index 000000000..556c1f7e4 --- /dev/null +++ b/include/mapnik/svg/svg_generator_path_grammar.hpp @@ -0,0 +1,93 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2010 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef SVG_GENERATOR_PATH_GRAMMAR_HPP +#define SVG_GENERATOR_PATH_GRAMMAR_HPP + +// mapnik +#include +#include + +// boost +#include +#include + +BOOST_FUSION_ADAPT_CLASS( + mapnik::vertex_vector2::vertex_type, + (unsigned, unsigned, obj.get<2>(), /**/) + (mapnik::vertex_vector2::value_type, mapnik::vertex_vector2::value_type, obj.get<0>(), /**/) + (mapnik::vertex_vector2::value_type, mapnik::vertex_vector2::value_type, obj.get<1>(), /**/) +) + +namespace boost { namespace spirit { namespace traits { + + template <> + struct is_container + : mpl::true_ + {}; + + template <> + struct container_iterator + { + typedef mapnik::geometry2d::iterator type; + }; + + template <> + struct begin_container + { + static mapnik::geometry2d::iterator + call(mapnik::geometry2d const& g) + { + return g.begin(); + } + }; + + template <> + struct end_container + { + static mapnik::geometry2d::iterator + call(mapnik::geometry2d const& g) + { + return g.end(); + } + }; +}}} + +namespace mapnik { namespace svg { + + using namespace boost::spirit; + + template + struct svg_generator_path_grammar + : karma::grammar + { + explicit svg_generator_path_grammar() + : svg_generator_path_grammar::base_type(svg_path) + { + svg_path = *(karma::int_ << karma::lit(' ') << karma::double_ << karma::lit(' ') << karma::double_ << karma::eol); + } + + karma::rule svg_path; + }; +}} + +#endif // SVG_GENERATOR_PATH_GRAMMAR_HPP diff --git a/src/svg/svg_generator.cpp b/src/svg/svg_generator.cpp new file mode 100644 index 000000000..8a641799a --- /dev/null +++ b/src/svg/svg_generator.cpp @@ -0,0 +1,50 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2010 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include +#include + +// boost +#include + +namespace mapnik { //namespace svg { + + using namespace boost::spirit; + + template + svg_generator::svg_generator(OutputIterator& output_iterator) : + output_iterator_(output_iterator) + {} + + template + void svg_generator::generate_root() {} + + template + void svg_generator::generate_rect() {} + + template + void svg_generator::generate_path(geometry2d const & geom) + { + karma::generate(output_iterator_, path_grammar_, geom); + } +}}