Added missing files: include/mapnik/svg/svg_generator.hpp and include/mapnik/svg/svg_generator_path_grammar.hpp.
This commit is contained in:
parent
853d55b7d6
commit
39a1038eb8
3 changed files with 196 additions and 0 deletions
53
include/mapnik/svg/svg_generator.hpp
Normal file
53
include/mapnik/svg/svg_generator.hpp
Normal file
|
@ -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 <mapnik/svg/svg_generator_path_grammar.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
namespace mapnik { //namespace svg {
|
||||
|
||||
template <typename OutputIterator>
|
||||
class svg_generator : private boost::noncopyable
|
||||
{
|
||||
typedef svg::svg_generator_path_grammar<OutputIterator> 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
|
93
include/mapnik/svg/svg_generator_path_grammar.hpp
Normal file
93
include/mapnik/svg/svg_generator_path_grammar.hpp
Normal file
|
@ -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 <mapnik/vertex.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/fusion/include/adapt_class.hpp>
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
|
||||
BOOST_FUSION_ADAPT_CLASS(
|
||||
mapnik::vertex_vector2<mapnik::vertex2d>::vertex_type,
|
||||
(unsigned, unsigned, obj.get<2>(), /**/)
|
||||
(mapnik::vertex_vector2<mapnik::vertex2d>::value_type, mapnik::vertex_vector2<mapnik::vertex2d>::value_type, obj.get<0>(), /**/)
|
||||
(mapnik::vertex_vector2<mapnik::vertex2d>::value_type, mapnik::vertex_vector2<mapnik::vertex2d>::value_type, obj.get<1>(), /**/)
|
||||
)
|
||||
|
||||
namespace boost { namespace spirit { namespace traits {
|
||||
|
||||
template <>
|
||||
struct is_container<mapnik::geometry2d const>
|
||||
: mpl::true_
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct container_iterator<mapnik::geometry2d const>
|
||||
{
|
||||
typedef mapnik::geometry2d::iterator type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct begin_container<mapnik::geometry2d const>
|
||||
{
|
||||
static mapnik::geometry2d::iterator
|
||||
call(mapnik::geometry2d const& g)
|
||||
{
|
||||
return g.begin();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct end_container<mapnik::geometry2d const>
|
||||
{
|
||||
static mapnik::geometry2d::iterator
|
||||
call(mapnik::geometry2d const& g)
|
||||
{
|
||||
return g.end();
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace mapnik { namespace svg {
|
||||
|
||||
using namespace boost::spirit;
|
||||
|
||||
template <typename OutputIterator>
|
||||
struct svg_generator_path_grammar
|
||||
: karma::grammar<OutputIterator, mapnik::geometry2d()>
|
||||
{
|
||||
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<OutputIterator, mapnik::geometry2d()> svg_path;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif // SVG_GENERATOR_PATH_GRAMMAR_HPP
|
50
src/svg/svg_generator.cpp
Normal file
50
src/svg/svg_generator.cpp
Normal file
|
@ -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 <mapnik/svg/svg_generator.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
|
||||
namespace mapnik { //namespace svg {
|
||||
|
||||
using namespace boost::spirit;
|
||||
|
||||
template <typename OutputIterator>
|
||||
svg_generator<OutputIterator>::svg_generator(OutputIterator& output_iterator) :
|
||||
output_iterator_(output_iterator)
|
||||
{}
|
||||
|
||||
template <typename OutputIterator>
|
||||
void svg_generator<OutputIterator>::generate_root() {}
|
||||
|
||||
template <typename OutputIterator>
|
||||
void svg_generator<OutputIterator>::generate_rect() {}
|
||||
|
||||
template <typename OutputIterator>
|
||||
void svg_generator<OutputIterator>::generate_path(geometry2d const & geom)
|
||||
{
|
||||
karma::generate(output_iterator_, path_grammar_, geom);
|
||||
}
|
||||
}}
|
Loading…
Reference in a new issue