]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/io/svg.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
11 //` Shows the usage of svg_mapper
16 #include <boost/geometry.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
18 #include <boost/geometry/geometries/polygon.hpp>
22 // Specify the basic type
23 typedef boost::geometry::model::d2::point_xy
<double> point_type
;
25 // Declare some geometries and set their values
27 boost::geometry::assign_values(a
, 3, 6);
29 boost::geometry::model::polygon
<point_type
> b
;
30 boost::geometry::read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", b
);
32 boost::geometry::model::linestring
<point_type
> c
;
33 c
.push_back(point_type(3, 4));
34 c
.push_back(point_type(4, 5));
36 // Declare a stream and an SVG mapper
37 std::ofstream
svg("my_map.svg");
38 boost::geometry::svg_mapper
<point_type
> mapper(svg
, 400, 400);
40 // Add geometries such that all these geometries fit on the map
45 // Draw the geometries on the SVG map, using a specific SVG style
46 mapper
.map(a
, "fill-opacity:0.5;fill:rgb(153,204,0);stroke:rgb(153,204,0);stroke-width:2", 5);
47 mapper
.map(b
, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
48 mapper
.map(c
, "opacity:0.4;fill:none;stroke:rgb(212,0,0);stroke-width:5");
50 // Destructor of map will be called - adding </svg>
51 // Destructor of stream will be called, closing the file
63 [$img/io/svg_mapper.png]