• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
4 
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 // Code to create SVG for buffer examples
10 
11 #ifndef CREATE_SVG_BUFFER_HPP
12 #define CREATE_SVG_BUFFER_HPP
13 
14 #include <fstream>
15 #include <boost/core/ignore_unused.hpp>
16 #if defined(HAVE_SVG)
17 #  include <boost/geometry/io/svg/svg_mapper.hpp>
18 #endif
19 
20 template <typename Geometry1, typename Geometry2>
create_svg_buffer(std::string const & filename,Geometry1 const & original,Geometry2 const & buffer)21 void create_svg_buffer(std::string const& filename, Geometry1 const& original, Geometry2 const& buffer)
22 {
23 #if defined(HAVE_SVG)
24     typedef typename boost::geometry::point_type<Geometry1>::type point_type;
25     std::ofstream svg(filename.c_str());
26 
27     boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);
28     mapper.add(original);
29     mapper.add(buffer);
30 
31     // Draw buffer at bottom
32     mapper.map(buffer, "fill-opacity:0.6;fill:rgb(255,255,64);stroke:rgb(255,128,0);stroke-width:3");
33 
34     // Draw original on top
35     mapper.map(original, "fill-opacity:0.6;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
36 
37 #else
38     boost::ignore_unused(filename, original, buffer);
39 #endif
40 }
41 
42 // NOTE: convert manually from svg to png using Inkscape ctrl-shift-E
43 // and copy png to html/img/...
44 
45 
46 #endif // CREATE_SVG_BUFFER_HPP
47 
48