svg_renderer: use precision of 4, accept map request/scale_factor, and fix output of multipart geometries

This commit is contained in:
Dane Springmeyer 2013-06-20 21:27:42 -07:00
parent b1a50d1000
commit e3c5ae9cf4
3 changed files with 20 additions and 7 deletions

View file

@ -36,6 +36,7 @@
#include <mapnik/ctrans.hpp> // for CoordTransform #include <mapnik/ctrans.hpp> // for CoordTransform
#include <mapnik/image_compositing.hpp> // for composite_mode_e #include <mapnik/image_compositing.hpp> // for composite_mode_e
#include <mapnik/pixel_position.hpp> #include <mapnik/pixel_position.hpp>
#include <mapnik/request.hpp>
// boost // boost
#include <boost/variant/static_visitor.hpp> #include <boost/variant/static_visitor.hpp>
@ -70,7 +71,8 @@ class MAPNIK_DECL svg_renderer : public feature_style_processor<svg_renderer<Out
{ {
public: public:
typedef svg_renderer<OutputIterator> processor_impl_type; typedef svg_renderer<OutputIterator> processor_impl_type;
svg_renderer(Map const& m, OutputIterator& output_iterator, unsigned offset_x=0, unsigned offset_y=0); svg_renderer(Map const& m, OutputIterator& output_iterator, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
svg_renderer(Map const& m, request const& req, OutputIterator& output_iterator, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
~svg_renderer(); ~svg_renderer();
void start_map_processing(Map const& map); void start_map_processing(Map const& map);

View file

@ -126,7 +126,7 @@ namespace mapnik { namespace util {
{ {
typedef boost::spirit::karma::real_policies<T> base_type; typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; } static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6u ;} static unsigned precision(T n) { return 4u ;}
}; };
} }
@ -161,14 +161,14 @@ namespace mapnik { namespace util {
; ;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< svg_path << lit('\"') << lit("d=\"") << svg_path << lit("\"")
; ;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
<< svg_path << lit('\"') << lit("d=\"") << svg_path << lit("\"")
; ;
svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit("d=\"") << lit('M') svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M')
| &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ]) | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ])
<< lit(' ') << coordinate << lit(' ') << coordinate) % lit(' ') << lit(' ') << coordinate << lit(' ') << coordinate) % lit(' ')
; ;

View file

@ -30,9 +30,10 @@
namespace mapnik namespace mapnik
{ {
template <typename T> template <typename T>
svg_renderer<T>::svg_renderer(Map const& m, T & output_iterator, unsigned offset_x, unsigned offset_y) : svg_renderer<T>::svg_renderer(Map const& m, T & output_iterator, double scale_factor, unsigned offset_x, unsigned offset_y) :
feature_style_processor<svg_renderer>(m), feature_style_processor<svg_renderer>(m, scale_factor),
output_iterator_(output_iterator), output_iterator_(output_iterator),
width_(m.width()), width_(m.width()),
height_(m.height()), height_(m.height()),
@ -40,6 +41,16 @@ svg_renderer<T>::svg_renderer(Map const& m, T & output_iterator, unsigned offset
generator_(output_iterator) generator_(output_iterator)
{} {}
template <typename T>
svg_renderer<T>::svg_renderer(Map const& m, request const& req, T & output_iterator, double scale_factor, unsigned offset_x, unsigned offset_y) :
feature_style_processor<svg_renderer>(m, scale_factor),
output_iterator_(output_iterator),
width_(req.width()),
height_(req.height()),
t_(req.width(),req.height(),req.extent(),offset_x,offset_y),
generator_(output_iterator)
{}
template <typename T> template <typename T>
svg_renderer<T>::~svg_renderer() {} svg_renderer<T>::~svg_renderer() {}