/usr/include/boost/geometry/io/svg
Edit: /usr/include/boost/geometry/io/svg/svg_mapper.hpp (14180B)
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2009-2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2015, 2016.
// Modifications copyright (c) 2015-2016, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_IO_SVG_MAPPER_HPP
#define BOOST_GEOMETRY_IO_SVG_MAPPER_HPP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// Helper geometries (all points are transformed to svg-points)
#include
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template
struct svg_map
{
BOOST_MPL_ASSERT_MSG
(
false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
, (Geometry)
);
};
template
struct svg_map
{
template
static inline void apply(std::ostream& stream,
std::string const& style, double size,
Point const& point, TransformStrategy const& strategy)
{
SvgPoint ipoint;
geometry::transform(point, ipoint, strategy);
stream << geometry::svg(ipoint, style, size) << std::endl;
}
};
template
struct svg_map_box_seg
{
template
static inline void apply(std::ostream& stream,
std::string const& style, double size,
BoxSeg1 const& box_seg, TransformStrategy const& strategy)
{
BoxSeg2 ibox_seg;
// Fix bug in gcc compiler warning for possible uninitialization
#if defined(BOOST_GCC)
geometry::assign_zero(ibox_seg);
#endif
geometry::transform(box_seg, ibox_seg, strategy);
stream << geometry::svg(ibox_seg, style, size) << std::endl;
}
};
template
struct svg_map
: svg_map_box_seg, SvgPoint>
{};
template
struct svg_map
: svg_map_box_seg, SvgPoint>
{};
template
struct svg_map_range
{
template
static inline void apply(std::ostream& stream,
std::string const& style, double size,
Range1 const& range, TransformStrategy const& strategy)
{
Range2 irange;
geometry::transform(range, irange, strategy);
stream << geometry::svg(irange, style, size) << std::endl;
}
};
template
struct svg_map
: svg_map_range, SvgPoint>
{};
template
struct svg_map
: svg_map_range, SvgPoint>
{};
template
struct svg_map
{
template
static inline void apply(std::ostream& stream,
std::string const& style, double size,
Polygon const& polygon, TransformStrategy const& strategy)
{
model::polygon ipoly;
geometry::transform(polygon, ipoly, strategy);
stream << geometry::svg(ipoly, style, size) << std::endl;
}
};
template
struct svg_map
{
typedef typename single_tag_of
<
typename geometry::tag::type
>::type stag;
template
static inline void apply(std::ostream& stream,
std::string const& style, double size,
Multi const& multi, TransformStrategy const& strategy)
{
for (typename boost::range_iterator::type it
= boost::begin(multi);
it != boost::end(multi);
++it)
{
svg_map
<
stag,
typename boost::range_value::type,
SvgPoint
>::apply(stream, style, size, *it, strategy);
}
}
};
template
struct devarianted_svg_map
{
template
static inline void apply(std::ostream& stream,
std::string const& style,
double size,
Geometry const& geometry,
TransformStrategy const& strategy)
{
svg_map
<
typename tag_cast
<
typename tag::type,
multi_tag
>::type,
typename boost::remove_const::type,
SvgPoint
>::apply(stream, style, size, geometry, strategy);
}
};
template
struct devarianted_svg_map >
{
template
struct visitor: static_visitor
{
std::ostream& m_os;
std::string const& m_style;
double m_size;
TransformStrategy const& m_strategy;
visitor(std::ostream& os,
std::string const& style,
double size,
TransformStrategy const& strategy)
: m_os(os)
, m_style(style)
, m_size(size)
, m_strategy(strategy)
{}
template
inline void operator()(Geometry const& geometry) const
{
devarianted_svg_map::apply(m_os, m_style, m_size, geometry, m_strategy);
}
};
template
static inline void apply(std::ostream& stream,
std::string const& style,
double size,
variant const& geometry,
TransformStrategy const& strategy)
{
boost::apply_visitor(visitor(stream, style, size, strategy), geometry);
}
};
} // namespace dispatch
#endif
template
inline void svg_map(std::ostream& stream,
std::string const& style, double size,
Geometry const& geometry, TransformStrategy const& strategy)
{
dispatch::devarianted_svg_map::apply(stream,
style, size, geometry, strategy);
}
/*!
\brief Helper class to create SVG maps
\tparam Point Point type, for input geometries.
\tparam SameScale Boolean flag indicating if horizontal and vertical scale should
be the same. The default value is true
\tparam SvgCoordinateType Coordinate type of SVG points. SVG is capable to
use floating point coordinates. Therefore the default value is double
\ingroup svg
\qbk{[include reference/io/svg.qbk]}
*/
template
<
typename Point,
bool SameScale = true,
typename SvgCoordinateType = double
>
class svg_mapper : boost::noncopyable
{
typedef model::point svg_point_type;
typedef typename geometry::select_most_precise
<
typename coordinate_type::type,
double
>::type calculation_type;
typedef strategy::transform::map_transformer
<
calculation_type,
geometry::dimension::type::value,
geometry::dimension::type::value,
true,
SameScale
> transformer_type;
model::box m_bounding_box;
boost::scoped_ptr m_matrix;
std::ostream& m_stream;
SvgCoordinateType m_width, m_height;
std::string m_width_height; // for