whitespace fixes - closes #911

This commit is contained in:
Dane Springmeyer 2012-02-01 17:53:35 -08:00
parent 1cafc03a46
commit 17d13cff67
242 changed files with 5431 additions and 5431 deletions

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -45,20 +45,20 @@
// apps using mapnik do not
// need agg headers
namespace agg {
struct trans_affine;
struct trans_affine;
}
namespace mapnik {
class marker;
struct rasterizer;
template <typename T>
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T> >,
private boost::noncopyable
{
public:
// create with default, empty placement detector
agg_renderer(Map const& m, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
@ -101,7 +101,7 @@ public:
proj_transform const& prj_trans);
void process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans);
proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/,
Feature const& /*feature*/,
proj_transform const& /*prj_trans*/)

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -33,13 +33,13 @@ public:
arrow();
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
box2d<double> extent() const;
box2d<double> extent() const;
private:
unsigned pos_;
double x_[7];
double y_[7];
unsigned cmd_[9];
};
};
}
#endif // MAPNIK_ARROW_HPP

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -35,13 +35,13 @@ struct attribute
std::string name_;
explicit attribute(std::string const& name)
: name_(name) {}
template <typename V ,typename F>
V const& value(F const& f) const
{
return f.get(name_);
return f.get(name_);
}
std::string const& name() const { return name_;}
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -39,41 +39,41 @@ struct expression_attributes : boost::static_visitor<void>
{
explicit expression_attributes(std::set<std::string> & names)
: names_(names) {}
void operator() (value_type const& x) const
void operator() (value_type const& x) const
{
boost::ignore_unused_variable_warning(x);
}
void operator() (attribute const& attr) const
{
names_.insert(attr.name());
}
template <typename Tag>
template <typename Tag>
void operator() (binary_node<Tag> const& x) const
{
boost::apply_visitor(expression_attributes(names_),x.left);
boost::apply_visitor(expression_attributes(names_),x.right);
}
template <typename Tag>
void operator() (unary_node<Tag> const& x) const
{
boost::apply_visitor(expression_attributes(names_),x.expr);
boost::apply_visitor(expression_attributes(names_),x.expr);
}
void operator() (regex_match_node const& x) const
{
boost::apply_visitor(expression_attributes(names_),x.expr);
}
void operator() (regex_replace_node const& x) const
{
boost::apply_visitor(expression_attributes(names_),x.expr);
}
private:
std::set<std::string>& names_;
};
@ -82,10 +82,10 @@ struct symbolizer_attributes : public boost::static_visitor<>
{
symbolizer_attributes(std::set<std::string>& names)
: names_(names) {}
template <typename T>
void operator () (T const&) const {}
void operator () (text_symbolizer const& sym)
{
std::set<expression_ptr>::const_iterator it;
@ -97,9 +97,9 @@ struct symbolizer_attributes : public boost::static_visitor<>
}
collect_metawriter(sym);
}
void operator () (point_symbolizer const& sym)
{
{
path_expression_ptr const& filename_expr = sym.get_filename();
if (filename_expr)
{
@ -115,7 +115,7 @@ struct symbolizer_attributes : public boost::static_visitor<>
}
void operator () (line_pattern_symbolizer const& sym)
{
{
path_expression_ptr const& filename_expr = sym.get_filename();
if (filename_expr)
{
@ -130,7 +130,7 @@ struct symbolizer_attributes : public boost::static_visitor<>
}
void operator () (polygon_pattern_symbolizer const& sym)
{
{
path_expression_ptr const& filename_expr = sym.get_filename();
if (filename_expr)
{
@ -138,7 +138,7 @@ struct symbolizer_attributes : public boost::static_visitor<>
}
collect_metawriter(sym);
}
void operator () (shield_symbolizer const& sym)
{
std::set<expression_ptr>::const_iterator it;
@ -148,7 +148,7 @@ struct symbolizer_attributes : public boost::static_visitor<>
{
if (*it) boost::apply_visitor(f_attr, **it);
}
path_expression_ptr const& filename_expr = sym.get_filename();
if (filename_expr)
{
@ -173,7 +173,7 @@ struct symbolizer_attributes : public boost::static_visitor<>
collect_metawriter(sym);
}
// TODO - support remaining syms
private:
std::set<std::string>& names_;
void collect_metawriter(symbolizer_base const& sym)
@ -189,10 +189,10 @@ class attribute_collector : public boost::noncopyable
private:
std::set<std::string>& names_;
public:
attribute_collector(std::set<std::string>& names)
: names_(names) {}
template <typename RuleType>
void operator() (RuleType const& r)
{
@ -203,21 +203,21 @@ public:
{
boost::apply_visitor(s_attr,*symIter++);
}
expression_ptr const& expr = r.get_filter();
expression_attributes f_attr(names_);
boost::apply_visitor(f_attr,*expr);
}
}
};
struct directive_collector : public boost::static_visitor<>
{
directive_collector(double * filter_factor)
: filter_factor_(filter_factor) {}
template <typename T>
void operator () (T const&) const {}
void operator () (raster_symbolizer const& sym)
{
*filter_factor_ = sym.calculate_filter_factor();

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -34,7 +34,7 @@ enum eAttributeType {
String =4,
Boolean =5,
Geometry=6,
Object=7
Object=7
};
class attribute_descriptor
@ -49,7 +49,7 @@ public:
primary_key_(primary_key),
size_(size),
precision_(precision) {}
attribute_descriptor(attribute_descriptor const& other)
: name_(other.name_),
type_(other.type_),
@ -60,7 +60,7 @@ public:
attribute_descriptor& operator=(attribute_descriptor const& other)
{
if (this == &other)
return *this;
return *this;
name_=other.name_;
type_=other.type_;
primary_key_=other.primary_key_;
@ -87,8 +87,8 @@ public:
int get_size() const
{
return size_;
}
}
int get_precision() const
{
return precision_;
@ -101,7 +101,7 @@ private:
int size_;
int precision_;
};
template <typename charT,typename traits>
inline std::basic_ostream<charT,traits>&
operator << (std::basic_ostream<charT,traits>& out,

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -34,15 +34,15 @@
#include <iomanip>
namespace mapnik {
/*!
* A spatial envelope (i.e. bounding box) which also defines some basic operators.
*/
template <typename T> class MAPNIK_DECL box2d
template <typename T> class MAPNIK_DECL box2d
: boost::equality_comparable<box2d<T> ,
boost::addable<box2d<T>,
boost::dividable2<box2d<T>, T,
boost::multipliable2<box2d<T>, T > > > >
boost::addable<box2d<T>,
boost::dividable2<box2d<T>, T,
boost::multipliable2<box2d<T>, T > > > >
{
public:
typedef box2d<T> box2d_type;
@ -82,14 +82,14 @@ public:
void clip(const box2d_type &other);
bool from_string(const std::string& s);
bool valid() const;
// define some operators
// define some operators
box2d_type& operator+=(box2d_type const& other);
box2d_type& operator*=(T);
box2d_type& operator/=(T);
T operator[](int index) const;
};
template <class charT,class traits,class T>
inline std::basic_ostream<charT,traits>&
operator << (std::basic_ostream<charT,traits>& out,
@ -98,8 +98,8 @@ operator << (std::basic_ostream<charT,traits>& out,
std::basic_ostringstream<charT,traits> s;
s.copyfmt(out);
s.width(0);
s <<"box2d(" << std::setprecision(16)
<< e.minx() << "," << e.miny() <<","
s <<"box2d(" << std::setprecision(16)
<< e.minx() << "," << e.miny() <<","
<< e.maxx() << "," << e.maxy() <<")";
out << s.str();
return out;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -28,15 +28,15 @@
#include <mapnik/symbolizer.hpp>
#include <mapnik/filter_factory.hpp>
namespace mapnik
namespace mapnik
{
struct MAPNIK_DECL building_symbolizer : public symbolizer_base
{
building_symbolizer();
building_symbolizer(color const& fill, expression_ptr height);
building_symbolizer(color const& fill, expression_ptr height);
color const& get_fill() const;
void set_fill(color const& fill);
void set_fill(color const& fill);
expression_ptr height() const;
void set_height(expression_ptr height);
void set_opacity(double opacity);
@ -46,7 +46,7 @@ private:
color fill_;
expression_ptr height_;
double opacity_;
};
};
}

View file

@ -47,7 +47,7 @@
// apps using mapnik do not
// need agg headers
namespace agg {
struct trans_affine;
struct trans_affine;
}
namespace mapnik {
@ -112,8 +112,8 @@ public:
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/,
Feature const& /*feature*/,
proj_transform const& /*prj_trans*/)
Feature const& /*feature*/,
proj_transform const& /*prj_trans*/)
{
// cairo renderer doesn't support processing of multiple symbolizers.
return false;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -35,8 +35,8 @@
#include <sstream>
namespace mapnik {
class MAPNIK_DECL color
class MAPNIK_DECL color
: boost::equality_comparable<color>
{
private:
@ -44,7 +44,7 @@ private:
boost::uint8_t green_;
boost::uint8_t blue_;
boost::uint8_t alpha_;
public:
color()
: red_(0xff),
@ -52,38 +52,38 @@ public:
blue_(0xff),
alpha_(0xff)
{}
color(unsigned red, unsigned green, unsigned blue, unsigned alpha = 0xff)
: red_(red),
green_(green),
blue_(blue),
alpha_(alpha)
{}
color( std::string const& css_string);
color(const color& rhs)
: red_(rhs.red_),
green_(rhs.green_),
blue_(rhs.blue_),
alpha_(rhs.alpha_)
alpha_(rhs.alpha_)
{}
color& operator=(const color& rhs)
{
if (this==&rhs) return *this;
red_=rhs.red_;
green_=rhs.green_;
blue_=rhs.blue_;
alpha_=rhs.alpha_;
return *this;
}
{
if (this==&rhs) return *this;
red_=rhs.red_;
green_=rhs.green_;
blue_=rhs.blue_;
alpha_=rhs.alpha_;
return *this;
}
inline unsigned red() const
{
return red_;
}
inline unsigned green() const
{
return green_;
@ -95,8 +95,8 @@ public:
inline unsigned alpha() const
{
return alpha_;
}
}
inline void set_red(unsigned red)
{
red_ = red;
@ -105,7 +105,7 @@ public:
{
green_ = green;
}
inline void set_blue(unsigned blue)
{
blue_ = blue;
@ -123,19 +123,19 @@ public:
return (alpha_ << 24) | (blue_ << 16) | (green_ << 8) | (red_) ;
#endif
}
inline bool operator==(color const& rhs) const
{
return (red_== rhs.red()) &&
(green_ == rhs.green()) &&
(blue_ == rhs.blue()) &&
(alpha_ == rhs.alpha());
}
std::string to_string() const;
std::string to_string() const;
std::string to_hex_string() const;
};
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -36,17 +36,17 @@
#if BOOST_VERSION >= 104500
#include <mapnik/css_color_grammar.hpp>
namespace mapnik {
namespace mapnik {
class MAPNIK_DECL color_factory : boost::noncopyable
{
public:
static void init_from_string(color & c, std::string const& css_color)
{
{
typedef std::string::const_iterator iterator_type;
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
css_color_grammar g;
iterator_type first = css_color.begin();
iterator_type last = css_color.end();
@ -56,15 +56,15 @@ public:
g,
boost::spirit::ascii::space,
c);
if (!result)
if (!result)
{
throw config_error(std::string("Failed to parse color value: ") +
"Expected a CSS color, but got '" + css_color + "'");
}
}
}
static color from_string(std::string const& css_color)
{
{
color c;
init_from_string(c,css_color);
return c;
@ -75,16 +75,16 @@ public:
#else
#include <mapnik/css_color_grammar_deprecated.hpp>
namespace mapnik {
namespace mapnik {
class MAPNIK_DECL color_factory : boost::noncopyable
{
public:
static void init_from_string(color & c, std::string const& css_color)
{
{
typedef std::string::const_iterator iterator_type;
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
css_color_grammar g;
iterator_type first = css_color.begin();
@ -96,7 +96,7 @@ public:
g,
boost::spirit::ascii::space,
css_);
if (!result)
if (!result)
{
throw config_error(std::string("Failed to parse color value: ") +
"Expected a CSS color, but got '" + css_color + "'");
@ -105,10 +105,10 @@ public:
c.set_green(css_.g);
c.set_blue(css_.b);
c.set_alpha(css_.a);
}
}
static color from_string(std::string const& css_color)
{
{
color c;
init_from_string(c,css_color);
return c;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -41,7 +41,7 @@ public:
virtual const char * what() const throw()
{
return what_.c_str();
return what_.c_str();
}
void append_context(const std::string & ctx) const

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -30,21 +30,21 @@
#include <iomanip>
#include <sstream>
namespace mapnik {
namespace mapnik {
template <typename T,int dim>
struct coord {
typedef T type;
};
template <typename T>
struct coord<T,2>
struct coord<T,2>
: boost::addable<coord<T,2>,
boost::addable2<coord<T,2>,T,
boost::subtractable<coord<T,2>,
boost::subtractable2<coord<T,2>,T,
boost::dividable2<coord<T,2>, T,
boost::multipliable2<coord<T,2>, T > > > > > >
{
typedef T type;
T x;
@ -82,28 +82,28 @@ public:
y+=rhs.y;
return *this;
}
coord<T,2>& operator+=(T rhs)
{
x+=rhs;
y+=rhs;
return *this;
}
coord<T,2>& operator-=(coord<T,2> const& rhs)
{
x-=rhs.x;
y-=rhs.y;
return *this;
}
coord<T,2>& operator-=(T rhs)
{
x-=rhs;
y-=rhs;
return *this;
}
coord<T,2>& operator*=(T t)
{
x*=t;
@ -119,7 +119,7 @@ public:
};
template <typename T>
struct coord<T,3>
struct coord<T,3>
{
typedef T type;
T x;
@ -153,12 +153,12 @@ public:
typedef coord<double,2> coord2d;
typedef coord<int,2> coord2i;
template <typename charT,typename traits,typename T ,int dim>
inline std::basic_ostream<charT,traits>&
operator << (std::basic_ostream<charT,traits>& out,
const coord<T,dim>& c);
template <typename charT,typename traits,typename T>
inline std::basic_ostream<charT,traits>&
operator << (std::basic_ostream<charT,traits>& out,
@ -167,7 +167,7 @@ operator << (std::basic_ostream<charT,traits>& out,
std::basic_ostringstream<charT,traits> s;
s.copyfmt(out);
s.width(0);
s << "coord2(" << std::setprecision(16)
s << "coord2(" << std::setprecision(16)
<< c.x << "," << c.y<< ")";
out << s.str();
return out;
@ -181,11 +181,11 @@ operator << (std::basic_ostream<charT,traits>& out,
std::basic_ostringstream<charT,traits> s;
s.copyfmt(out);
s.width(0);
s << "coord3(" << std::setprecision(16)
s << "coord3(" << std::setprecision(16)
<< c.x << "," << c.y<< "," << c.z<<")";
out << s.str();
return out;
}
}
}
#endif // MAPNIK_COORD_HPP

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -31,57 +31,57 @@
namespace mapnik {
template <typename T>
class coord_array
{
class coord_array
{
typedef T coord_type;
coord_type* pt_;
const unsigned size_;
public:
public:
coord_array(unsigned size=0)
: pt_(static_cast<coord_type*>(size==0?0: ::operator new (sizeof(coord_type)*size))),
size_(size) {}
coord_array(const coord_array& rhs)
: pt_(static_cast<coord_type*>(rhs.size_==0?0: ::operator new (sizeof(coord_type)*rhs.size_))),
size_(rhs.size_) {
memcpy(pt_,rhs.pt_,sizeof(coord_type)*rhs.size_);
}
~coord_array()
~coord_array()
{
::operator delete (pt_);
}
unsigned size() const
unsigned size() const
{
return size_;
}
void set(unsigned index,double x,double y)
{
assert(index<size_);
pt_[index].x=x;
pt_[index].y=y;
}
const coord_type& at(unsigned index) const
const coord_type& at(unsigned index) const
{
assert(index<size_);
return pt_[index];
}
const coord_type& operator[] (unsigned index) const
{
assert (index<size_);
return pt_[index];
}
coord_type& operator[] (unsigned index)
{
assert (index<size_);
return pt_[index];
}
private:
coord_array& operator=(const coord_array&);
};

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -31,7 +31,7 @@
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_action.hpp>
// phoenix
// phoenix
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
@ -234,7 +234,7 @@ struct percent_conv_impl
{
typedef unsigned type;
};
unsigned operator() (double val) const
{
return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5));
@ -248,7 +248,7 @@ struct alpha_conv_impl
{
typedef unsigned type;
};
unsigned operator() (double val) const
{
return clip_int<0,255>(int((255.0 * val) + 0.5));
@ -260,8 +260,8 @@ inline double hue_to_rgb( double m1, double m2, double h)
{
if (h < 0.0) h = h + 1.0;
else if (h > 1) h = h - 1.0;
if (h * 6 < 1.0)
if (h * 6 < 1.0)
return m1 + (m2 - m1) * h * 6.0;
if (h * 2 < 1.0)
return m2;
@ -277,7 +277,7 @@ struct hsl_conv_impl
{
typedef void type;
};
template <typename T0,typename T1, typename T2, typename T3>
void operator() (T0 & c, T1 h, T2 s, T3 l) const
{
@ -286,17 +286,17 @@ struct hsl_conv_impl
h /= 360.0;
s /= 100.0;
l /= 100.0;
if (l <= 0.5)
m2 = l * (s + 1.0);
else
m2 = l + s - l*s;
m2 = l + s - l*s;
m1 = l * 2 - m2;
double r = hue_to_rgb(m1, m2, h + 1.0/3.0);
double g = hue_to_rgb(m1, m2, h);
double b = hue_to_rgb(m1, m2, h - 1.0/3.0);
c.set_red(clip_int<0,255>(int((255.0 * r) + 0.5)));
c.set_green(clip_int<0,255>(int((255.0 * g) + 0.5)));
c.set_blue(clip_int<0,255>(int((255.0 * b) + 0.5)));
@ -307,10 +307,10 @@ struct hsl_conv_impl
template <typename Iterator>
struct css_color_grammar : qi::grammar<Iterator, color(), ascii_space_type>
{
css_color_grammar()
: css_color_grammar::base_type(css_color)
{
using qi::lit;
using qi::_val;
@ -319,58 +319,58 @@ struct css_color_grammar : qi::grammar<Iterator, color(), ascii_space_type>
using qi::_a;
using qi::_b;
using qi::_c;
using ascii::no_case;
using ascii::no_case;
using phoenix::at_c;
css_color %= rgba_color
| rgba_percent_color
| rgba_percent_color
| hsl_percent_color
| hex_color
| hex_color_small
| hex_color
| hex_color_small
| no_case[named];
hex_color = lit('#')
hex_color = lit('#')
>> hex2 [ at_c<0>(_val) = _1 ]
>> hex2 [ at_c<1>(_val) = _1 ]
>> hex2 [ at_c<2>(_val) = _1 ]
>>-hex2 [ at_c<3>(_val) = _1 ]
;
hex_color_small = lit('#')
>> hex1 [ at_c<0>(_val) = _1 | _1 << 4 ]
>> hex1 [ at_c<1>(_val) = _1 | _1 << 4 ]
>> hex1 [ at_c<2>(_val) = _1 | _1 << 4 ]
>>-hex1 [ at_c<3>(_val) = _1 | _1 << 4 ]
;
rgba_color = lit("rgb") >> -lit('a')
>> lit('(')
>> dec3 [at_c<0>(_val) = _1] >> ','
>> dec3 [at_c<1>(_val) = _1] >> ','
>> dec3 [at_c<2>(_val) = _1]
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
>> lit('(')
>> dec3 [at_c<0>(_val) = _1] >> ','
>> dec3 [at_c<1>(_val) = _1] >> ','
>> dec3 [at_c<2>(_val) = _1]
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
;
rgba_percent_color = lit("rgb") >> -lit('a')
>> lit('(')
>> double_ [at_c<0>(_val) = percent_converter(_1)] >> '%' >> ','
>> double_ [at_c<1>(_val) = percent_converter(_1)] >> '%' >> ','
>> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%'
>> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%'
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
;
hsl_percent_color = lit("hsl") >> -lit('a')
>> lit('(')
>> double_ [ _a = _1] >> ',' // hue 0..360
>> lit('(')
>> double_ [ _a = _1] >> ',' // hue 0..360
>> double_ [ _b = _1] >> '%' >> ',' // saturation 0..100%
>> double_ [ _c = _1] >> '%' // lightness 0..100%
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) // opacity 0...1
>> lit (')') [ hsl_converter(_val,_a,_b,_c)]
;
}
qi::uint_parser< unsigned, 16, 2, 2 > hex2 ;
qi::uint_parser< unsigned, 16, 1, 1 > hex1 ;
qi::uint_parser< unsigned, 10, 1, 3 > dec3 ;
@ -382,8 +382,8 @@ struct css_color_grammar : qi::grammar<Iterator, color(), ascii_space_type>
qi::rule<Iterator, color(), ascii_space_type> css_color;
named_colors_ named;
phoenix::function<percent_conv_impl> percent_converter;
phoenix::function<alpha_conv_impl> alpha_converter;
phoenix::function<hsl_conv_impl> hsl_converter;
phoenix::function<alpha_conv_impl> alpha_converter;
phoenix::function<hsl_conv_impl> hsl_converter;
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -31,7 +31,7 @@
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_action.hpp>
// phoenix
// phoenix
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
@ -40,7 +40,7 @@
// fusion
#include <boost/fusion/include/adapt_struct.hpp>
// not in boost 1.41
// not in boost 1.41
//#include <boost/fusion/include/adapt_class.hpp>
// stl
@ -59,11 +59,11 @@ namespace mapnik
// temp workaround . TODO: adapt mapnik::color
struct css
{
css ()
css ()
: r(255),g(255),b(255),a(255) {}
css(unsigned r_,unsigned g_, unsigned b_,unsigned a_ = 0xff)
: r(r_),g(g_),b(b_),a(a_) {}
unsigned r;
unsigned g;
unsigned b;
@ -262,7 +262,7 @@ struct percent_conv_impl
{
typedef unsigned type;
};
unsigned operator() (double val) const
{
return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5));
@ -276,7 +276,7 @@ struct alpha_conv_impl
{
typedef unsigned type;
};
unsigned operator() (double val) const
{
return clip_int<0,255>(int((255.0 * val) + 0.5));
@ -289,8 +289,8 @@ inline double hue_to_rgb( double m1, double m2, double h)
{
if (h < 0.0) h = h + 1.0;
else if (h > 1) h = h - 1.0;
if (h * 6 < 1.0)
if (h * 6 < 1.0)
return m1 + (m2 - m1) * h * 6.0;
if (h * 2 < 1.0)
return m2;
@ -306,7 +306,7 @@ struct hsl_conv_impl
{
typedef void type;
};
template <typename T0,typename T1, typename T2, typename T3>
void operator() (T0 & c, T1 h, T2 s, T3 l) const
{
@ -315,17 +315,17 @@ struct hsl_conv_impl
h /= 360.0;
s /= 100.0;
l /= 100.0;
if (l <= 0.5)
m2 = l * (s + 1.0);
else
m2 = l + s - l*s;
m2 = l + s - l*s;
m1 = l * 2 - m2;
double r = hue_to_rgb(m1, m2, h + 1.0/3.0);
double g = hue_to_rgb(m1, m2, h);
double b = hue_to_rgb(m1, m2, h - 1.0/3.0);
c.r = clip_int<0,255>(int((255.0 * r) + 0.5));
c.g = clip_int<0,255>(int((255.0 * g) + 0.5));
c.b = clip_int<0,255>(int((255.0 * b) + 0.5));
@ -336,10 +336,10 @@ struct hsl_conv_impl
template <typename Iterator>
struct css_color_grammar : qi::grammar<Iterator, css(), ascii_space_type>
{
css_color_grammar()
: css_color_grammar::base_type(css_color)
{
using qi::lit;
using qi::_val;
@ -348,58 +348,58 @@ struct css_color_grammar : qi::grammar<Iterator, css(), ascii_space_type>
using qi::_a;
using qi::_b;
using qi::_c;
using ascii::no_case;
using ascii::no_case;
using phoenix::at_c;
css_color %= rgba_color
| rgba_percent_color
| hsl_percent_color
| hex_color
| hex_color_small
| hsl_percent_color
| hex_color
| hex_color_small
| no_case[named];
hex_color %= lit('#')
>> hex2
>> hex2
>> hex2
>> -hex2
hex_color %= lit('#')
>> hex2
>> hex2
>> hex2
>> -hex2
;
hex_color_small = lit('#')
>> hex1 [ at_c<0>(_val) = _1 | _1 << 4 ]
>> hex1 [ at_c<1>(_val) = _1 | _1 << 4 ]
>> hex1 [ at_c<2>(_val) = _1 | _1 << 4 ]
>> -hex1[ at_c<3>(_val) = _1 | _1 << 4 ]
;
rgba_color = lit("rgb") >> -lit('a')
>> lit('(')
>> dec3 [at_c<0>(_val) = _1] >> ','
>> dec3 [at_c<1>(_val) = _1] >> ','
>> dec3 [at_c<2>(_val) = _1]
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
>> lit('(')
>> dec3 [at_c<0>(_val) = _1] >> ','
>> dec3 [at_c<1>(_val) = _1] >> ','
>> dec3 [at_c<2>(_val) = _1]
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
;
rgba_percent_color = lit("rgb") >> -lit('a')
>> lit('(')
>> double_ [at_c<0>(_val) = percent_converter(_1)] >> '%' >> ','
>> double_ [at_c<1>(_val) = percent_converter(_1)] >> '%' >> ','
>> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%'
>> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%'
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)])
>> lit(')')
;
hsl_percent_color = lit("hsl") >> -lit('a')
>> lit('(')
>> double_ [ _a = _1] >> ',' // hue 0..360
>> lit('(')
>> double_ [ _a = _1] >> ',' // hue 0..360
>> double_ [ _b = _1] >> '%' >> ',' // saturation 0..100%
>> double_ [ _c = _1] >> '%' // lightness 0..100%
>> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) // opacity 0...1
>> lit (')') [ hsl_converter(_val,_a,_b,_c)]
;
}
qi::uint_parser< unsigned, 16, 2, 2 > hex2 ;
qi::uint_parser< unsigned, 16, 1, 1 > hex1 ;
qi::uint_parser< unsigned, 10, 1, 3 > dec3 ;
@ -411,7 +411,7 @@ struct css_color_grammar : qi::grammar<Iterator, css(), ascii_space_type>
qi::rule<Iterator, css(), ascii_space_type> css_color;
named_colors_ named;
phoenix::function<percent_conv_impl> percent_converter;
phoenix::function<alpha_conv_impl> alpha_converter;
phoenix::function<alpha_conv_impl> alpha_converter;
phoenix::function<hsl_conv_impl> hsl_converter;
};

View file

@ -165,31 +165,31 @@ struct MAPNIK_DECL coord_transform_parallel
typedef typename Geometry::value_type value_type;
coord_transform_parallel(Transform const& t,
Geometry const& geom,
proj_transform const& prj_trans )
: t_(t),
geom_(geom),
prj_trans_(prj_trans),
offset_(0.0),
threshold_(10),
m_status(initial) {}
Geometry const& geom,
proj_transform const& prj_trans )
: t_(t),
geom_(geom),
prj_trans_(prj_trans),
offset_(0.0),
threshold_(10),
m_status(initial) {}
enum status
{
initial,
{
initial,
start,
first,
first,
process,
last_vertex,
angle_joint,
end
end
};
double get_offset() const
{
return offset_;
}
void set_offset(double offset)
{
offset_ = offset;
@ -199,7 +199,7 @@ struct MAPNIK_DECL coord_transform_parallel
{
return threshold_;
}
void set_threshold(unsigned int t)
{
threshold_ = t;
@ -208,7 +208,7 @@ struct MAPNIK_DECL coord_transform_parallel
unsigned vertex(double * x , double * y)
{
double z=0;
if (offset_==0.0)
{
unsigned command = geom_.vertex(x,y);
@ -239,10 +239,10 @@ struct MAPNIK_DECL coord_transform_parallel
angle_a = atan2((m_pre_y-m_cur_y),(m_pre_x-m_cur_x));
dx_pre = cos(angle_a + pi_by_2);
dy_pre = sin(angle_a + pi_by_2);
#ifdef MAPNIK_DEBUG
std::clog << "offsetting line by: " << offset_ << "\n";
std::clog << "initial dx=" << (dx_pre * offset_) << " dy=" << (dy_pre * offset_) << "\n";
#endif
#ifdef MAPNIK_DEBUG
std::clog << "offsetting line by: " << offset_ << "\n";
std::clog << "initial dx=" << (dx_pre * offset_) << " dy=" << (dy_pre * offset_) << "\n";
#endif
*x = m_pre_x + (dx_pre * offset_);
*y = m_pre_y + (dy_pre * offset_);
m_status = process;
@ -250,23 +250,23 @@ struct MAPNIK_DECL coord_transform_parallel
case process:
switch(m_cur_cmd)
{
case SEG_LINETO:
m_next_cmd = geom_.vertex(&m_next_x, &m_next_y);
prj_trans_.backward(m_next_x,m_next_y,z);
t_.forward(&m_next_x,&m_next_y);
switch(m_next_cmd)
{
case SEG_LINETO:
m_next_cmd = geom_.vertex(&m_next_x, &m_next_y);
prj_trans_.backward(m_next_x,m_next_y,z);
t_.forward(&m_next_x,&m_next_y);
switch(m_next_cmd)
{
case SEG_LINETO:
m_status = angle_joint;
break;
default:
m_status = last_vertex;
break;
}
m_status = angle_joint;
break;
case SEG_END:
m_status = end;
return SEG_END;
default:
m_status = last_vertex;
break;
}
break;
case SEG_END:
m_status = end;
return SEG_END;
}
break;
case last_vertex:
@ -289,8 +289,8 @@ struct MAPNIK_DECL coord_transform_parallel
}
else // skip sharp spikes
{
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_DEBUG
dx_curr = cos(angle_a + pi_by_2);
dy_curr = sin(angle_a + pi_by_2);
sin_curve = dx_curr*dy_pre-dy_curr*dx_pre;
@ -298,35 +298,35 @@ struct MAPNIK_DECL coord_transform_parallel
std::clog << "angle b: " << angle_b << "\n";
std::clog << "h: " << h << "\n";
std::clog << "sin_curve: " << sin_curve << "\n";
#endif
#endif
m_status = process;
break;
}
// alternate sharp spike fix, but suboptimal...
/*
sin_curve = dx_curr*dy_pre-dy_curr*dx_pre;
cos_curve = -dx_pre*dx_curr-dy_pre*dy_curr;
#ifdef MAPNIK_DEBUG
std::clog << "sin_curve value: " << sin_curve << "\n";
#endif
if(sin_curve > -0.3 && sin_curve < 0.3) {
angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x));
h = tan((angle_b - angle_a)/2.0);
*x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_);
*y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_);
} else {
if (angle_b - angle_a > 0)
h = -1.0*(1.0+cos_curve)/sin_curve;
else
h = (1.0+cos_curve)/sin_curve;
*x = m_cur_x + (dx_curr + base_shift*dy_curr)*offset_;
*y = m_cur_y + (dy_curr - base_shift*dx_curr)*offset_;
}
sin_curve = dx_curr*dy_pre-dy_curr*dx_pre;
cos_curve = -dx_pre*dx_curr-dy_pre*dy_curr;
#ifdef MAPNIK_DEBUG
std::clog << "sin_curve value: " << sin_curve << "\n";
#endif
if(sin_curve > -0.3 && sin_curve < 0.3) {
angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x));
h = tan((angle_b - angle_a)/2.0);
*x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_);
*y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_);
} else {
if (angle_b - angle_a > 0)
h = -1.0*(1.0+cos_curve)/sin_curve;
else
h = (1.0+cos_curve)/sin_curve;
*x = m_cur_x + (dx_curr + base_shift*dy_curr)*offset_;
*y = m_cur_y + (dy_curr - base_shift*dx_curr)*offset_;
}
*/
m_pre_x = *x;
m_pre_x = *y;
m_cur_x = m_next_x;
@ -337,7 +337,7 @@ struct MAPNIK_DECL coord_transform_parallel
m_status = process;
return m_pre_cmd;
}
}
}
}
}
@ -346,7 +346,7 @@ struct MAPNIK_DECL coord_transform_parallel
geom_.rewind(pos);
m_status = initial;
}
private:
Transform const& t_;
Geometry const& geom_;
@ -390,7 +390,7 @@ public:
CoordTransform(int width, int height, const box2d<double>& extent,
double offset_x = 0, double offset_y = 0)
: width_(width), height_(height), extent_(extent),
offset_x_(offset_x), offset_y_(offset_y)
offset_x_(offset_x), offset_y_(offset_y)
{
sx_ = static_cast<double>(width_) / extent_.width();
sy_ = static_cast<double>(height_) / extent_.height();

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -42,15 +42,15 @@
namespace mapnik {
typedef MAPNIK_DECL boost::shared_ptr<Feature> feature_ptr;
struct MAPNIK_DECL Featureset : private boost::noncopyable
{
virtual feature_ptr next()=0;
virtual ~Featureset() {};
};
typedef MAPNIK_DECL boost::shared_ptr<Featureset> featureset_ptr;
class MAPNIK_DECL datasource_exception : public std::exception
{
private:
@ -65,7 +65,7 @@ public:
return message_.c_str();
}
};
class MAPNIK_DECL datasource : private boost::noncopyable
{
public:
@ -83,9 +83,9 @@ public:
datasource (parameters const& params)
: params_(params),
is_bound_(false)
is_bound_(false)
{}
/*!
* @brief Get the configuration parameters of the data source.
*
@ -97,18 +97,18 @@ public:
{
return params_;
}
/*!
* @brief Get the type of the datasource
* @return The type of the datasource (Vector or Raster)
*/
virtual datasource_t type() const=0;
/*!
* @brief Connect to the datasource
*/
virtual void bind() const {};
virtual featureset_ptr features(const query& q) const=0;
virtual featureset_ptr features_at_point(coord2d const& pt) const=0;
virtual box2d<double> envelope() const=0;
@ -119,12 +119,12 @@ protected:
parameters params_;
mutable bool is_bound_;
};
typedef std::string datasource_name();
typedef datasource* create_ds(const parameters& params, bool bind);
typedef void destroy_ds(datasource *ds);
class datasource_deleter
{
public:
@ -135,8 +135,8 @@ public:
};
typedef boost::shared_ptr<datasource> datasource_ptr;
#define DATASOURCE_PLUGIN(classname) \
extern "C" MAPNIK_EXP std::string datasource_name() \
{ \

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -37,7 +37,7 @@
#include <map>
namespace mapnik {
class MAPNIK_DECL datasource_cache :
class MAPNIK_DECL datasource_cache :
public singleton <datasource_cache,CreateStatic>,
private boost::noncopyable
{
@ -53,7 +53,7 @@ private:
static std::vector<std::string> plugin_directories_;
public:
static std::vector<std::string> plugin_names();
static std::string plugin_directories();
static std::string plugin_directories();
static void register_datasources(const std::string& path);
static boost::shared_ptr<datasource> create(parameters const& params, bool bind=true);
};

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -28,16 +28,16 @@
namespace mapnik
{
struct ellipsoid;
// great-circle distance
// great-circle distance
class great_circle_distance
{
public:
double operator() (coord2d const& pt0, coord2d const& pt1) const;
};
// vincenty distance
// vincenty distance
/*
class vincenty_distance : boost::noncopyble
{

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -26,7 +26,7 @@
namespace mapnik {
struct ellipsoid
{
double a; // semi mayor axis
double a; // semi mayor axis
double b; // semi minor axis
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -47,7 +47,7 @@ public:
virtual const char * what() const throw()
{
return what_.c_str();
return what_.c_str();
}
protected:
@ -63,14 +63,14 @@ protected:
* are provided to help with instanciation.
*
* @par Limitations:
* - The enum must start at zero.
* - The enum must be consecutive.
* - The enum must start at zero.
* - The enum must be consecutive.
* - The enum must be terminated with a special token consisting of the enum's
* name plus "_MAX".
* - The corresponding char pointer array must be terminated with an empty string.
* - The names must only consist of characters and digits (<i>a-z, A-Z, 0-9</i>),
* underscores (<i>_</i>) and dashes (<i>-</i>).
*
*
*
* @warning At the moment the verify() method is called during static initialization.
* It quits the application with exit code 1 if any error is detected. The other solution
@ -103,7 +103,7 @@ protected:
* @endcode
* And here is how to use the resulting type Fruit
* @code
*
*
* int
* main(int argc, char * argv[]) {
* fruit f(APPLE);
@ -116,11 +116,11 @@ protected:
* cerr << "Hmmm ... yummy " << f << endl;
* break;
* }
*
*
* f = CHERRY;
*
* fruit_enum native_enum = f;
*
*
* f.from_string("passion_fruit");
*
* for (unsigned i = 0; i < fruit::MAX; ++i) {
@ -139,9 +139,9 @@ class MAPNIK_DECL enumeration {
public:
typedef ENUM native_type;
enumeration() {};
enumeration( ENUM v ) : value_(v) {}
enumeration( const enumeration & other ) : value_(other.value_) {}
enumeration( ENUM v ) : value_(v) {}
enumeration( const enumeration & other ) : value_(other.value_) {}
/** Assignment operator for native enum values. */
void operator=(ENUM v)
{
@ -160,7 +160,7 @@ public:
return value_;
}
enum Max
enum Max
{
MAX = THE_MAX
};
@ -168,7 +168,7 @@ public:
{
return THE_MAX;
}
/** Converts @p str to an enum.
/** Converts @p str to an enum.
* @throw illegal_enum_value @p str is not a legal identifier.
* */
void from_string(const std::string & str)
@ -181,7 +181,7 @@ public:
return;
}
}
throw illegal_enum_value(std::string("Illegal enumeration value '") +
throw illegal_enum_value(std::string("Illegal enumeration value '") +
str + "' for enum " + our_name_);
}
@ -210,7 +210,7 @@ public:
is.unget();
break;
}
}
}
try
{
@ -231,11 +231,11 @@ public:
}
/** Prints the string identifier to the output stream @p os. */
std::ostream & print(std::ostream & os = std::cerr) const
std::ostream & print(std::ostream & os = std::cerr) const
{
return os << our_strings_[value_];
}
/** Static helper function to iterate over valid identifiers. */
static const char * get_string(unsigned i)
{
@ -252,14 +252,14 @@ public:
if (our_strings_[i] == 0 )
{
std::cerr << "### FATAL: Not enough strings for enum "
<< our_name_ << " defined in file '" << filename
<< our_name_ << " defined in file '" << filename
<< "' at line " << line_no << std::endl;
//std::exit(1);
}
}
if ( std::string("") != our_strings_[THE_MAX])
{
std::cerr << "### FATAL: The string array for enum " << our_name_
std::cerr << "### FATAL: The string array for enum " << our_name_
<< " defined in file '" << filename << "' at line " << line_no
<< " has too many items or is not terminated with an "
<< "empty string." << std::endl;
@ -285,10 +285,10 @@ private:
ENUM value_;
static const char ** our_strings_ ;
static std::string our_name_ ;
static bool our_verified_flag_;
static bool our_verified_flag_;
};
/** ostream operator for enumeration
/** ostream operator for enumeration
* @relates mapnik::enumeration
*/
template <class ENUM, int THE_MAX>
@ -299,7 +299,7 @@ operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
return os;
}
/** istream operator for enumeration
/** istream operator for enumeration
* @relates mapnik::enumeration
*/
template <class ENUM, int THE_MAX>
@ -315,7 +315,7 @@ operator>>(std::istream & is, mapnik::enumeration<ENUM, THE_MAX> & e)
/** Helper macro. Creates a typedef.
* @relates mapnik::enumeration
*/
#define DEFINE_ENUM( name, e) \
#define DEFINE_ENUM( name, e) \
typedef enumeration<e, e ## _MAX> name
/** Helper macro. Runs the verify() method during static initialization.

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -36,47 +36,47 @@ struct evaluate : boost::static_visitor<T1>
{
typedef T0 feature_type;
typedef T1 value_type;
explicit evaluate(feature_type const& f)
: feature_(f) {}
value_type operator() (value_type x) const
{
return x;
}
value_type operator() (attribute const& attr) const
{
return attr.value<value_type,feature_type>(feature_);
}
value_type operator() (binary_node<tags::logical_and> const & x) const
{
return (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.left).to_bool())
&& (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.right).to_bool());
}
value_type operator() (binary_node<tags::logical_or> const & x) const
{
return (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.left).to_bool())
return (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.left).to_bool())
|| (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.right).to_bool());
}
template <typename Tag>
template <typename Tag>
value_type operator() (binary_node<Tag> const& x) const
{
typename make_op<Tag>::type operation;
return operation(boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.left),
return operation(boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.left),
boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.right));
}
template <typename Tag>
value_type operator() (unary_node<Tag> const& x) const
{
return ! (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.expr).to_bool());
return ! (boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.expr).to_bool());
}
value_type operator() (regex_match_node const& x) const
{
value_type v = boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.expr);
@ -84,10 +84,10 @@ struct evaluate : boost::static_visitor<T1>
return boost::u32regex_match(v.to_unicode(),x.pattern);
#else
return boost::regex_match(v.to_string(),x.pattern);
#endif
#endif
}
value_type operator() (regex_replace_node const& x) const
{
value_type v = boost::apply_visitor(evaluate<feature_type,value_type>(feature_),x.expr);
@ -97,9 +97,9 @@ struct evaluate : boost::static_visitor<T1>
std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format);
mapnik::transcoder tr_("utf8");
return tr_.transcode(repl.c_str());
#endif
#endif
}
feature_type const& feature_;
};

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -63,15 +63,15 @@ struct unicode_impl
{
typedef UnicodeString type;
};
explicit unicode_impl(mapnik::transcoder const& tr)
: tr_(tr) {}
UnicodeString operator()(std::string const& str) const
{
return tr_.transcode(str.c_str());
}
mapnik::transcoder const& tr_;
};
@ -82,10 +82,10 @@ struct regex_match_impl
{
typedef expr_node type;
};
explicit regex_match_impl(mapnik::transcoder const& tr)
: tr_(tr) {}
template <typename T0,typename T1>
expr_node operator() (T0 & node, T1 const& pattern) const
{
@ -95,7 +95,7 @@ struct regex_match_impl
return regex_match_node(node,pattern);
#endif
}
mapnik::transcoder const& tr_;
};
@ -106,10 +106,10 @@ struct regex_replace_impl
{
typedef expr_node type;
};
explicit regex_replace_impl(mapnik::transcoder const& tr)
: tr_(tr) {}
template <typename T0,typename T1,typename T2>
expr_node operator() (T0 & node, T1 const& pattern, T2 const& format) const
{
@ -119,15 +119,15 @@ struct regex_replace_impl
return regex_replace_node(node,pattern,format);
#endif
}
mapnik::transcoder const& tr_;
};
template <typename Iterator>
struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
{
{
typedef qi::rule<Iterator, expr_node(), space_type> rule_type;
explicit expression_grammar(mapnik::transcoder const& tr)
: expression_grammar::base_type(expr),
unicode_(unicode_impl(tr)),
@ -151,22 +151,22 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
using qi::hex;
using qi::omit;
using standard_wide::char_;
expr = logical_expr.alias();
logical_expr = not_expr [_val = _1]
logical_expr = not_expr [_val = _1]
>>
*( ( ( lit("and") | lit("&&")) >> not_expr [_val && _1] )
| (( lit("or") | lit("||")) >> not_expr [_val || _1])
)
;
not_expr =
not_expr =
cond_expr [_val = _1 ]
| ((lit("not") | lit('!')) >> cond_expr [ _val = !_1 ])
;
cond_expr = equality_expr [_val = _1] | additive_expr [_val = _1]
cond_expr = equality_expr [_val = _1] | additive_expr [_val = _1]
;
equality_expr =
@ -175,24 +175,24 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
| (( lit("!=") | lit("<>") | lit("neq") ) >> relational_expr [_val != _1])
)
;
regex_match_expr = lit(".match")
>> lit('(')
>> ustring [_val = _1]
>> lit('(')
>> ustring [_val = _1]
>> lit(')')
;
regex_replace_expr =
regex_replace_expr =
lit(".replace")
>> lit('(')
>> lit('(')
>> ustring [_a = _1]
>> lit(',')
>> lit(',')
>> ustring [_b = _1]
>> lit(')') [_val = regex_replace_(_r1,_a,_b)]
;
relational_expr = additive_expr[_val = _1]
>>
relational_expr = additive_expr[_val = _1]
>>
*( ( (lit("<=") | lit("le") ) >> additive_expr [ _val <= _1 ])
| ( (lit('<') | lit("lt") ) >> additive_expr [ _val < _1 ])
| ( (lit(">=") | lit("ge") ) >> additive_expr [ _val >= _1 ])
@ -204,7 +204,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
| '-' >> multiplicative_expr[_val -= _1]
)
;
multiplicative_expr = primary_expr [_val = _1]
>> *( '*' >> primary_expr [_val *= _1]
| '/' >> primary_expr [_val /= _1]
@ -213,8 +213,8 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
| regex_replace_expr(_val) [_val = _1]
)
;
primary_expr = strict_double [_val = _1]
| int_ [_val = _1]
| lit("true") [_val = true]
@ -224,26 +224,26 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
| attr [_val = construct<mapnik::attribute>( _1 ) ]
| '(' >> expr [_val = _1 ] >> ')'
;
unesc_char.add("\\a", '\a')("\\b", '\b')("\\f", '\f')("\\n", '\n')
("\\r", '\r')("\\t", '\t')("\\v", '\v')("\\\\", '\\')
("\\\'", '\'')("\\\"", '\"')
;
ustring %= omit[quote_char[_a = _1]]
>> *(unesc_char | "\\x" >> hex | (char_ - lit(_a)))
>> lit(_a);
quote_char %= char_('\'') | char_('"');
#if BOOST_VERSION > 104200
attr %= '[' >> no_skip[+~char_(']')] >> ']';
#else
attr %= '[' >> lexeme[+(char_ - ']')] >> ']';
#endif
}
qi::real_parser<double, qi::strict_real_policies<double> > strict_double;
boost::phoenix::function<unicode_impl> unicode_;
boost::phoenix::function<regex_match_impl> regex_match_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -39,7 +39,7 @@
namespace mapnik
{
namespace tags {
namespace tags {
struct plus
{
static const char* str()
@ -163,14 +163,14 @@ struct regex_replace_node;
typedef mapnik::value value_type;
typedef boost::variant <
typedef boost::variant <
value_type,
attribute,
boost::recursive_wrapper<binary_node<tags::plus> >,
boost::recursive_wrapper<binary_node<tags::plus> >,
boost::recursive_wrapper<binary_node<tags::minus> >,
boost::recursive_wrapper<binary_node<tags::mult> >,
boost::recursive_wrapper<binary_node<tags::mult> >,
boost::recursive_wrapper<binary_node<tags::div> >,
boost::recursive_wrapper<binary_node<tags::mod> >,
boost::recursive_wrapper<binary_node<tags::mod> >,
boost::recursive_wrapper<binary_node<tags::less> >,
boost::recursive_wrapper<binary_node<tags::less_equal> >,
boost::recursive_wrapper<binary_node<tags::greater> >,
@ -210,7 +210,7 @@ struct unary_node
{
return Tag::str();
}
expr_node expr;
};
@ -220,7 +220,7 @@ struct binary_node
binary_node(expr_node const& a, expr_node const& b)
: left(a),
right(b) {}
static const char* type()
{
return Tag::str();
@ -234,7 +234,7 @@ struct regex_match_node
regex_match_node (expr_node const& a, UnicodeString const& ustr)
: expr(a),
pattern(boost::make_u32regex(ustr)) {}
expr_node expr;
boost::u32regex pattern;
};
@ -246,7 +246,7 @@ struct regex_replace_node
: expr(a),
pattern(boost::make_u32regex(ustr)),
format(f) {}
expr_node expr;
boost::u32regex pattern;
UnicodeString format;
@ -257,7 +257,7 @@ struct regex_match_node
regex_match_node (expr_node const& a, std::string const& str)
: expr(a),
pattern(str) {}
expr_node expr;
boost::regex pattern;
};
@ -269,7 +269,7 @@ struct regex_replace_node
: expr(a),
pattern(str),
format(f) {}
expr_node expr;
boost::regex pattern;
std::string format;
@ -289,50 +289,50 @@ struct function_call
// ops
inline expr_node & operator += ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::plus>(left,right);
}
inline expr_node & operator -= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::minus>(left,right);
inline expr_node & operator += ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::plus>(left,right);
}
inline expr_node & operator *= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::mult>(left,right);
inline expr_node & operator -= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::minus>(left,right);
}
inline expr_node & operator /= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::div>(left,right);
inline expr_node & operator *= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::mult>(left,right);
}
inline expr_node & operator %= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::mod>(left,right);
inline expr_node & operator /= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::div>(left,right);
}
inline expr_node & operator %= ( expr_node &left ,const expr_node &right)
{
return left = binary_node<tags::mod>(left,right);
}
inline expr_node & operator < ( expr_node &left, expr_node const& right)
{
return left = binary_node<tags::less>(left,right);
}
}
inline expr_node & operator <= ( expr_node &left, expr_node const& right)
{
return left = binary_node<tags::less_equal>(left,right);
}
}
inline expr_node & operator > ( expr_node &left, expr_node const& right)
{
return left = binary_node<tags::greater>(left,right);
}
}
inline expr_node & operator >= ( expr_node &left, expr_node const& right)
{
return left = binary_node<tags::greater_equal>(left,right);
}
}
inline expr_node & operator == ( expr_node &left, expr_node const& right)
{

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -46,16 +46,16 @@
namespace mapnik {
typedef boost::shared_ptr<raster> raster_ptr;
typedef boost::shared_ptr<raster> raster_ptr;
class feature_impl;
template <typename T>
class context : private boost::noncopyable,
template <typename T>
class context : private boost::noncopyable,
public boost::associative_property_map<T>
{
friend class feature_impl;
friend class feature_impl;
public:
typedef T map_type;
typedef typename boost::associative_property_map<map_type> base_type;
@ -65,21 +65,21 @@ public:
typedef typename map_type::difference_type difference_type;
typedef typename map_type::iterator iterator;
typedef typename map_type::const_iterator const_iterator;
context()
: base_type(mapping_) {}
size_type push(key_type const& name)
{
size_type index = mapping_.size();
mapping_.insert(std::make_pair(name, index));
return index;
}
size_type size() const { return mapping_.size(); }
const_iterator begin() const { return mapping_.begin();}
const_iterator end() const { return mapping_.end();}
private:
map_type mapping_;
};
@ -92,37 +92,37 @@ class feature_impl : private boost::noncopyable
friend class feature_kv_iterator;
public:
typedef mapnik::value value_type;
typedef mapnik::value value_type;
typedef std::vector<value_type> cont_type;
typedef feature_kv_iterator iterator;
feature_impl(context_ptr const& ctx, int id)
feature_impl(context_ptr const& ctx, int id)
: id_(id),
ctx_(ctx),
data_(ctx_->mapping_.size())
{}
inline int id() const { return id_;}
inline void set_id(int id) { id_ = id;}
template <typename T>
void put(context_type::key_type const& key, T const& val)
{
put(key,value(val));
}
}
template <typename T>
void put_new(context_type::key_type const& key, T const& val)
{
put_new(key,value(val));
}
}
void put(context_type::key_type const& key, value const& val)
{
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
data_[itr->second] = val;
@ -131,11 +131,11 @@ public:
throw std::out_of_range("Key doesn't exist");
}
void put_new(context_type::key_type const& key, value const& val)
{
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
data_[itr->second] = val;
@ -146,25 +146,25 @@ public:
if (index == data_.size())
data_.push_back(val);
}
}
}
bool has_key(context_type::key_type const& key) const
{
return (ctx_->mapping_.find(key) != ctx_->mapping_.end());
}
value_type const& get(context_type::key_type const& key) const
{
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
return data_[itr->second];
}
throw std::out_of_range("Key doesn't exist");
}
value_type const& get(std::size_t index) const
{
if (index < data_.size())
@ -176,7 +176,7 @@ public:
{
return data_.size();
}
context_ptr context()
{
return ctx_;
@ -186,32 +186,32 @@ public:
{
return geom_cont_;
}
boost::ptr_vector<geometry_type> & paths()
boost::ptr_vector<geometry_type> & paths()
{
return geom_cont_;
}
void add_geometry(geometry_type * geom)
{
geom_cont_.push_back(geom);
}
unsigned num_geometries() const
{
return geom_cont_.size();
}
geometry_type const& get_geometry(unsigned index) const
{
return geom_cont_[index];
}
geometry_type& get_geometry(unsigned index)
{
return geom_cont_[index];
}
box2d<double> envelope() const
{
box2d<double> result;
@ -229,13 +229,13 @@ public:
}
}
return result;
}
}
const raster_ptr& get_raster() const
{
return raster_;
}
void set_raster(raster_ptr const& raster)
{
raster_ = raster;
@ -250,9 +250,9 @@ public:
{
return feature_kv_iterator(*this);
}
std::string to_string() const
{
{
std::stringstream ss;
ss << "Feature (" << std::endl;
context_type::map_type::const_iterator itr = ctx_->mapping_.begin();
@ -273,7 +273,7 @@ private:
cont_type data_;
};
inline std::ostream& operator<< (std::ostream & out,feature_impl const& f)
{
out << f.to_string();

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -40,7 +40,7 @@ struct feature_factory
//return boost::allocate_shared<Feature>(boost::fast_pool_allocator<Feature>(),fid);
return boost::make_shared<Feature>(ctx,fid);
}
};
};
}
#endif // MAPNIK_FEATURE_FACTORY_HPP

View file

@ -30,7 +30,7 @@
//#include <mapnik/feature.hpp>
#include <mapnik/value.hpp>
namespace mapnik {
namespace mapnik {
class feature_impl;
@ -41,20 +41,20 @@ class feature_kv_iterator :
{
public:
typedef boost::tuple<std::string,value> value_type;
feature_kv_iterator (feature_impl const& f, bool begin = false);
private:
friend class boost::iterator_core_access;
friend class boost::iterator_core_access;
void increment();
bool equal( feature_kv_iterator const& other) const;
value_type const& dereference() const;
feature_impl const& f_;
std::map<std::string,std::size_t>::const_iterator itr_;
mutable value_type kv_;
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -40,9 +40,9 @@ namespace mapnik
class Map;
class layer;
class projection;
template <typename Processor>
class feature_style_processor
class feature_style_processor
{
struct symbol_dispatch;
public:

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -26,7 +26,7 @@
namespace mapnik
{
class fill
class fill
{
};

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -37,7 +37,7 @@ typedef boost::shared_ptr<expr_node> expression_ptr;
MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt, std::string const& encoding);
MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt);
}
#endif // MAPNIK_FILTER_FACTORY_HPP

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -27,16 +27,16 @@
#include <mapnik/datasource.hpp>
namespace mapnik {
template <typename T>
class filter_featureset : public Featureset
template <typename T>
class filter_featureset : public Featureset
{
typedef T filter_type;
public:
filter_featureset(featureset_ptr fs, filter_type const& filter)
: fs_(fs), filter_(filter) {}
feature_ptr next()
{
feature_ptr feature = fs_->next();
@ -46,7 +46,7 @@ public:
}
return feature;
}
private:
featureset_ptr fs_;
filter_type filter_;

View file

@ -183,7 +183,7 @@ public:
(*face)->set_pixel_sizes(size);
}
}
void set_character_sizes(float size)
{
for (std::vector<face_ptr>::iterator face = faces_.begin(); face != faces_.end(); ++face)
@ -202,25 +202,25 @@ class stroker : boost::noncopyable
public:
explicit stroker(FT_Stroker s)
: s_(s) {}
void init(double radius)
{
FT_Stroker_Set(s_, (FT_Fixed) (radius * (1<<6)),
FT_STROKER_LINECAP_ROUND,
FT_STROKER_LINEJOIN_ROUND,
0);
FT_Stroker_Set(s_, (FT_Fixed) (radius * (1<<6)),
FT_STROKER_LINECAP_ROUND,
FT_STROKER_LINEJOIN_ROUND,
0);
}
FT_Stroker const& get() const
{
return s_;
}
~stroker()
{
#ifdef MAPNIK_DEBUG
std::clog << "~stroker: destroy stroker:" << s_ << std::endl;
#endif
#endif
FT_Stroker_Done(s_);
}
private:

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -35,8 +35,8 @@ namespace mapnik
class MAPNIK_DECL font_set
{
public:
font_set();
font_set(std::string const& name);
font_set();
font_set(std::string const& name);
font_set(font_set const& rhs);
font_set& operator=(font_set const& rhs);
unsigned size() const;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -25,7 +25,7 @@
#include <cmath>
namespace mapnik
namespace mapnik
{
struct MAPNIK_DECL gamma
{

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -54,7 +54,7 @@ bool clip_test(T p,T q,double& tmin,double& tmax)
} else if (q<0.0) result=false;
return result;
}
template <typename T,typename Image>
bool clip_line(T& x0,T& y0,T& x1,T& y1,box2d<T> const& box)
{
@ -87,26 +87,26 @@ bool clip_line(T& x0,T& y0,T& x1,T& y1,box2d<T> const& box)
}
return false;
}
template <typename Iter>
template <typename Iter>
inline bool point_inside_path(double x,double y,Iter start,Iter end)
{
bool inside=false;
double x0=boost::get<0>(*start);
double y0=boost::get<1>(*start);
double x1,y1;
while (++start!=end)
while (++start!=end)
{
if ( boost::get<2>(*start) == SEG_MOVETO)
{
x0 = boost::get<0>(*start);
y0 = boost::get<1>(*start);
continue;
}
}
x1=boost::get<0>(*start);
y1=boost::get<1>(*start);
if ((((y1 <= y) && (y < y0)) ||
((y0 <= y) && (y < y1))) &&
( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
@ -124,7 +124,7 @@ inline bool point_in_circle(double x,double y,double cx,double cy,double r)
double d2 = dx * dx + dy * dy;
return (d2 <= r * r);
}
template <typename T>
inline T sqr(T x)
{
@ -137,23 +137,23 @@ inline double distance2(double x0,double y0,double x1,double y1)
double dy = y1 - y0;
return sqr(dx) + sqr(dy);
}
inline double distance(double x0,double y0, double x1,double y1)
{
return std::sqrt(distance2(x0,y0,x1,y1));
}
inline double point_to_segment_distance(double x, double y,
double ax, double ay,
inline double point_to_segment_distance(double x, double y,
double ax, double ay,
double bx, double by)
{
double len2 = distance2(ax,ay,bx,by);
if (len2 < 1e-14)
if (len2 < 1e-14)
{
return distance(x,y,ax,ay);
}
double r = ((x - ax)*(bx - ax) + (y - ay)*(by -ay))/len2;
if ( r < 0 )
{
@ -166,24 +166,24 @@ inline double point_to_segment_distance(double x, double y,
double s = ((ay - y)*(bx - ax) - (ax - x)*(by - ay))/len2;
return std::fabs(s) * std::sqrt(len2);
}
template <typename Iter>
template <typename Iter>
inline bool point_on_path(double x,double y,Iter start,Iter end, double tol)
{
double x0=boost::get<0>(*start);
double y0=boost::get<1>(*start);
double x1,y1;
while (++start != end)
while (++start != end)
{
if ( boost::get<2>(*start) == SEG_MOVETO)
{
x0 = boost::get<0>(*start);
y0 = boost::get<1>(*start);
continue;
}
}
x1=boost::get<0>(*start);
y1=boost::get<1>(*start);
double distance = point_to_segment_distance(x,y,x0,y0,x1,y1);
if (distance < tol)
return true;
@ -192,7 +192,7 @@ inline bool point_on_path(double x,double y,Iter start,Iter end, double tol)
}
return false;
}
// filters
struct filter_in_box
{

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -53,32 +53,32 @@ private:
eGeomType type_;
mutable unsigned itr_;
public:
geometry()
: type_(Unknown),
itr_(0)
{}
explicit geometry(eGeomType type)
: type_(type),
itr_(0)
{}
eGeomType type() const
eGeomType type() const
{
return type_;
}
void set_type(eGeomType type)
{
type_ = type;
}
container_type const& data() const
{
return cont_;
}
box2d<double> envelope() const
{
box2d<double> result;
@ -134,7 +134,7 @@ public:
}
// if the path segment crosses the bisector
else if ((y0 <= *y && y1 >= *y) ||
(y0 >= *y && y1 <= *y))
(y0 >= *y && y1 <= *y))
{
// then calculate the intersection
double xi = x0;
@ -170,7 +170,7 @@ public:
}
/* center of gravity centroid
- best visually but does not work with multipolygons
- best visually but does not work with multipolygons
*/
void label_position(double *x, double *y) const
{
@ -179,14 +179,14 @@ public:
middle_point(x,y);
return;
}
unsigned size = cont_.size();
if (size < 3)
if (size < 3)
{
cont_.get_vertex(0,x,y);
return;
}
double ai;
double atmp = 0;
double xtmp = 0;
@ -197,9 +197,9 @@ public:
double y1 =0;
double ox =0;
double oy =0;
unsigned i;
// Use first point as origin to improve numerical accuracy
cont_.get_vertex(0,&ox,&oy);
@ -207,7 +207,7 @@ public:
{
cont_.get_vertex(i,&x0,&y0);
cont_.get_vertex(i+1,&x1,&y1);
x0 -= ox; y0 -= oy;
x1 -= ox; y1 -= oy;
@ -215,7 +215,7 @@ public:
atmp += ai;
xtmp += (x1 + x0) * ai;
ytmp += (y1 + y0) * ai;
}
}
if (atmp != 0)
{
*x = (xtmp/(3*atmp)) + ox;
@ -223,7 +223,7 @@ public:
return;
}
*x=x0;
*y=y0;
*y=y0;
}
/* center of bounding box centroid */
@ -232,7 +232,7 @@ public:
box2d<double> box = envelope();
*x = box.center().x;
*y = box.center().y;
*y = box.center().y;
}
/* summarized distance centroid */
@ -253,7 +253,7 @@ public:
double y0 = 0.0;
double x1 = 0.0;
double y1 = 0.0;
unsigned size = cont_.size();
unsigned size = cont_.size();
for (i = 0; i < size-1; i++)
{
cont_.get_vertex(i,&x0,&y0);
@ -266,7 +266,7 @@ public:
*x = cx / tl;
*y = cy / tl;
}
void middle_point(double *x, double *y) const
{
// calculate mid point on path
@ -274,18 +274,18 @@ public:
double y0=0;
double x1=0;
double y1=0;
unsigned size = cont_.size();
if (size == 1)
{
cont_.get_vertex(0,x,y);
cont_.get_vertex(0,x,y);
}
else if (size == 2)
{
cont_.get_vertex(0,&x0,&y0);
cont_.get_vertex(1,&x1,&y1);
*x = 0.5 * (x1 + x0);
*y = 0.5 * (y1 + y0);
*y = 0.5 * (y1 + y0);
}
else
{
@ -305,7 +305,7 @@ public:
cont_.get_vertex(pos-1,&x0,&y0);
cont_.get_vertex(pos,&x1,&y1);
double dx = x1 - x0;
double dy = y1 - y0;
double dy = y1 - y0;
double seg_len = std::sqrt(dx * dx + dy * dy);
if (( dist + seg_len) >= midlen)
{
@ -316,10 +316,10 @@ public:
}
dist += seg_len;
}
}
}
}
void push_vertex(coord_type x, coord_type y, CommandType c)
void push_vertex(coord_type x, coord_type y, CommandType c)
{
cont_.push_back(x,y,c);
}
@ -328,34 +328,34 @@ public:
{
push_vertex(x,y,SEG_LINETO);
}
void move_to(coord_type x,coord_type y)
{
push_vertex(x,y,SEG_MOVETO);
}
unsigned num_points() const
{
return cont_.size();
}
unsigned vertex(double* x, double* y) const
{
return cont_.get_vertex(itr_++,x,y);
}
}
unsigned get_vertex(unsigned pos, double* x, double* y) const
{
return cont_.get_vertex(pos, x, y);
}
}
void rewind(unsigned ) const
{
itr_=0;
}
bool hit_test(coord_type x, coord_type y, double tol) const
{
{
if (cont_.size() == 1) {
// Handle points
double x0, y0;
@ -367,7 +367,7 @@ public:
double y0=0;
rewind(0);
vertex(&x0, &y0);
unsigned command;
double x1,y1;
while (SEG_END != (command=vertex(&x1, &y1)))
@ -377,7 +377,7 @@ public:
x0 = x1;
y0 = y1;
continue;
}
}
if ((((y1 <= y) && (y < y0)) ||
((y0 <= y) && (y < y1))) &&
( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
@ -388,15 +388,15 @@ public:
return inside;
}
return false;
}
void set_capacity(size_t size)
}
void set_capacity(size_t size)
{
cont_.set_capacity(size);
}
};
typedef geometry<double,vertex_vector> geometry_type;
typedef geometry<double,vertex_vector> geometry_type;
typedef boost::shared_ptr<geometry_type> geometry_ptr;
typedef boost::ptr_vector<geometry_type> geometry_container;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -32,7 +32,7 @@
namespace mapnik
{
#ifdef BOOST_BIG_ENDIAN
#define MAPNIK_BIG_ENDIAN
#endif
@ -72,38 +72,38 @@ typedef boost::uint8_t byte;
((byte*) &def_temp)[3]=(M)[0]; \
(V)=def_temp; } while(0)
// read int16_t NDR (little endian)
inline void read_int16_ndr(const char* data, boost::int16_t & val)
{
#ifndef MAPNIK_BIG_ENDIAN
std::memcpy(&val,data,2);
#else
val = (data[0]&0xff) |
val = (data[0]&0xff) |
((data[1]&0xff)<<8);
#endif
}
// read int32_t NDR (little endian)
inline void read_int32_ndr(const char* data, boost::int32_t & val)
{
#ifndef MAPNIK_BIG_ENDIAN
std::memcpy(&val,data,4);
#else
val = (data[0]&0xff) |
((data[1]&0xff)<<8) |
((data[2]&0xff)<<16) |
val = (data[0]&0xff) |
((data[1]&0xff)<<8) |
((data[2]&0xff)<<16) |
((data[3]&0xff)<<24);
#endif
}
// read double NDR (little endian)
inline void read_double_ndr(const char* data, double & val)
{
#ifndef MAPNIK_BIG_ENDIAN
std::memcpy(&val,&data[0],8);
#else
boost::int64_t bits = ((boost::int64_t)data[0] & 0xff) |
boost::int64_t bits = ((boost::int64_t)data[0] & 0xff) |
((boost::int64_t)data[1] & 0xff) << 8 |
((boost::int64_t)data[2] & 0xff) << 16 |
((boost::int64_t)data[3] & 0xff) << 24 |
@ -113,8 +113,8 @@ inline void read_double_ndr(const char* data, double & val)
((boost::int64_t)data[7] & 0xff) << 56 ;
std::memcpy(&val,&bits,8);
#endif
}
}
// read int16_t XDR (big endian)
inline void read_int16_xdr(const char* data, boost::int16_t & val)
{
@ -124,7 +124,7 @@ inline void read_int16_xdr(const char* data, boost::int16_t & val)
std::memcpy(&val,data,2);
#endif
}
// read int32_t XDR (big endian)
inline void read_int32_xdr(const char* data, boost::int32_t & val)
{
@ -134,12 +134,12 @@ inline void read_int32_xdr(const char* data, boost::int32_t & val)
std::memcpy(&val,data,4);
#endif
}
// read double XDR (big endian)
inline void read_double_xdr(const char* data, double & val)
{
#ifndef MAPNIK_BIG_ENDIAN
boost::int64_t bits = ((boost::int64_t)data[7] & 0xff) |
boost::int64_t bits = ((boost::int64_t)data[7] & 0xff) |
((boost::int64_t)data[6] & 0xff) << 8 |
((boost::int64_t)data[5] & 0xff) << 16 |
((boost::int64_t)data[4] & 0xff) << 24 |
@ -163,7 +163,7 @@ inline int rint( double val)
inline double round (double val)
{
return floor(val);
}
}
#define _USE_MATH_DEFINES
#ifndef M_PI

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -32,13 +32,13 @@
// stl
#include <vector>
namespace mapnik
{
typedef std::pair<double, mapnik::color> stop_pair;
typedef std::vector<stop_pair > stop_array;
enum gradient_enum
{
NO_GRADIENT,
@ -60,7 +60,7 @@ enum gradient_unit_enum
DEFINE_ENUM( gradient_unit_e, gradient_unit_enum );
class MAPNIK_DECL gradient
{
{
gradient_e gradient_type_;
stop_array stops_;
// control points for the gradient, x1/y1 is the start point, x2/y2 the stop point.
@ -92,7 +92,7 @@ public:
void add_stop(double offset, color const& c);
bool has_stop() const;
stop_array const& get_stop_array() const;
void set_control_points(double x1, double y1, double x2, double y2, double r=0);

View file

@ -164,7 +164,7 @@ public:
}
boost::optional<color> const& get_background() const;
void set_background(const color& c);
void set_grayscale_to_alpha();
@ -172,12 +172,12 @@ public:
void set_color_to_alpha(color const& c);
void set_alpha(float opacity);
inline const image_data_32& data() const
{
return data_;
}
inline image_data_32& data()
{
return data_;
@ -435,7 +435,7 @@ public:
unsigned r0 = rgba0 & 0xff ;
unsigned g0 = (rgba0 >> 8 ) & 0xff;
unsigned b0 = (rgba0 >> 16) & 0xff;
unsigned atmp = a1 + a0 - ((a1 * a0 + 255) >> 8);
if (atmp)
{
@ -444,7 +444,7 @@ public:
b0 = byte((b1 * a1 + (b0 * a0) - ((b0 * a0 * a1 + 255) >> 8)) / atmp);
}
a0 = byte(atmp);
row_to[x] = (a0 << 24)| (b0 << 16) | (g0 << 8) | (r0) ;
#endif
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -130,7 +130,7 @@ class hextree : private boost::noncopyable
{
return 255 * std::pow(b/255, g);
}
public:
explicit hextree(unsigned max_colors=256, const double &g=2.0)
: max_colors_(max_colors),
@ -233,7 +233,7 @@ public:
int dist, newdist;
// find closest match based on mean of r,g,b,a
std::vector<rgba>::const_iterator pit =
std::vector<rgba>::const_iterator pit =
std::lower_bound(sorted_pal_.begin(), sorted_pal_.end(), c, rgba::mean_sort_cmp());
ind = pit-sorted_pal_.begin();
if (ind == sorted_pal_.size())
@ -337,11 +337,11 @@ private:
printf("%d: (+%d/%d/%.5f) (%d %d %d %d)\n",
id, (int)r->count, (int)r->pixel_count, r->reduce_cost,
(int)round(gamma(r->reds / r->count, gamma_)),
(int)round(gamma(r->greens / r->count, gamma_)),
(int)round(gamma(r->greens / r->count, gamma_)),
(int)round(gamma(r->blues / r->count, gamma_)),
(int)(r->alphas / r->count));
else
printf("%d: (%d/%d/%.5f) (%d %d %d %d)\n", id,
printf("%d: (%d/%d/%.5f) (%d %d %d %d)\n", id,
(int)r->count, (int)r->pixel_count, r->reduce_cost,
(int)round(gamma(r->reds / r->pixel_count, gamma_)),
(int)round(gamma(r->greens / r->pixel_count, gamma_)),
@ -387,7 +387,7 @@ private:
double mean_g = r->greens / r->pixel_count;
double mean_b = r->blues / r->pixel_count;
double mean_a = r->alphas / r->pixel_count;
for (unsigned idx=0; idx < 16; ++idx)
for (unsigned idx=0; idx < 16; ++idx)
{
if (r->children_[idx] != 0)
{
@ -406,7 +406,7 @@ private:
}
}
}
// starting from root_, unfold nodes with biggest penalty
// until all available colors are assigned to processed nodes
void assign_node_colors()
@ -438,7 +438,7 @@ private:
{
colors_--;
cur_node->count = 0;
for (unsigned idx=0; idx < 16; ++idx)
for (unsigned idx=0; idx < 16; ++idx)
{
if (cur_node->children_[idx] != 0)
{

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -32,9 +32,9 @@ class hit_test_filter
public:
hit_test_filter(double x, double y, double tol)
: x_(x),
y_(y),
y_(y),
tol_(tol) {}
bool pass(Feature const& feature)
{
for (unsigned i=0;i<feature.num_geometries();++i)
@ -45,7 +45,7 @@ public:
}
return false;
}
private:
double x_;
double y_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -33,7 +33,7 @@
namespace mapnik
{
// Compositing modes
// Compositing modes
// http://www.w3.org/TR/2009/WD-SVGCompositing-20090430/
enum composite_mode_e
@ -79,13 +79,13 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode)
typedef agg::renderer_base<pixfmt_type> renderer_type;
typedef agg::comp_op_adaptor_rgba<color, order> blender_type;
typedef agg::renderer_base<pixfmt_type> renderer_type;
agg::rendering_buffer source(im.getBytes(),im.width(),im.height(),im.width() * 4);
agg::rendering_buffer mask(im2.getBytes(),im2.width(),im2.height(),im2.width() * 4);
agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixf(source);
agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixf_mask(mask);
switch(mode)
{
case clear :
@ -132,7 +132,7 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode)
break;
case multiply:
pixf.comp_op(agg::comp_op_multiply);
break;
break;
case screen:
pixf.comp_op(agg::comp_op_screen);
break;
@ -141,7 +141,7 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode)
break;
case darken:
pixf.comp_op(agg::comp_op_darken);
break;
break;
case lighten:
pixf.comp_op(agg::comp_op_lighten);
break;
@ -174,7 +174,7 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode)
break;
default:
break;
}
renderer_type ren(pixf);
agg::renderer_base<pixfmt_type> rb(pixf);

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -30,13 +30,13 @@
#include <cassert>
#include <cstring>
namespace mapnik
namespace mapnik
{
template <class T> class ImageData
{
public:
typedef T pixel_type;
ImageData(unsigned width,unsigned height)
: width_(width),
height_(height),
@ -44,11 +44,11 @@ public:
{
if (pData_) std::memset(pData_,0,sizeof(T)*width_*height_);
}
ImageData(const ImageData<T>& rhs)
:width_(rhs.width_),
height_(rhs.height_),
pData_((rhs.width_!=0 && rhs.height_!=0)?
pData_((rhs.width_!=0 && rhs.height_!=0)?
static_cast<T*>(::operator new(sizeof(T)*rhs.width_*rhs.height_)) :0)
{
if (pData_) std::memcpy(pData_,rhs.pData_,sizeof(T)*rhs.width_* rhs.height_);
@ -75,14 +75,14 @@ public:
{
for (unsigned y = 0; y < height_; ++y)
{
T * row = getRow(y);
T * row = getRow(y);
for (unsigned x = 0; x < width_; ++x)
{
row[x] = t;
}
}
}
inline const T* getData() const
{
return pData_;
@ -97,22 +97,22 @@ public:
{
return (unsigned char*)pData_;
}
inline unsigned char* getBytes()
{
return (unsigned char*)pData_;
}
inline const T* getRow(unsigned row) const
{
return pData_+row*width_;
}
inline T* getRow(unsigned row)
{
return pData_+row*width_;
}
inline void setRow(unsigned row,const T* buf,unsigned size)
{
assert(row<height_);
@ -128,7 +128,7 @@ public:
{
::operator delete(pData_),pData_=0;
}
private:
const unsigned width_;
const unsigned height_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -31,14 +31,14 @@
#include <stdexcept>
#include <string>
namespace mapnik
namespace mapnik
{
class image_reader_exception : public std::exception
{
private:
std::string message_;
public:
image_reader_exception(const std::string& message)
image_reader_exception(const std::string& message)
: message_(message) {}
~image_reader_exception() throw() {}
@ -60,7 +60,7 @@ struct MAPNIK_DECL image_reader
bool register_image_reader(const std::string& type,image_reader* (*)(const std::string&));
MAPNIK_DECL image_reader* get_image_reader(const std::string& file,const std::string& type);
MAPNIK_DECL image_reader* get_image_reader(const std::string& file);
}
#endif // MAPNIK_IMAGE_READER_HPP

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -37,13 +37,13 @@
namespace mapnik {
class Map;
class Map;
class ImageWriterException : public std::exception
{
private:
std::string message_;
public:
ImageWriterException(const std::string& message)
ImageWriterException(const std::string& message)
: message_(message) {}
~ImageWriterException() throw() {}
@ -70,7 +70,7 @@ MAPNIK_DECL void save_to_file(T const& image,
std::string const& filename,
std::string const& type,
rgba_palette const& palette);
// guess type from file extension
template <typename T>
MAPNIK_DECL void save_to_file(T const& image,
@ -80,7 +80,7 @@ template <typename T>
MAPNIK_DECL void save_to_file(T const& image,
std::string const& filename,
rgba_palette const& palette);
template <typename T>
MAPNIK_DECL std::string save_to_string(T const& image,
std::string const& type);
@ -133,7 +133,7 @@ inline bool is_ps (std::string const& filename)
{
return boost::algorithm::iends_with(filename,std::string(".ps"));
}
inline boost::optional<std::string> type_from_filename(std::string const& filename)
{
@ -176,7 +176,7 @@ void add_border(T & image)
}
for (unsigned y = 0; y < image.height();++y)
{
image(0,y) = 0xff00ffff; //yellow
image(0,y) = 0xff00ffff; //yellow
image(image.width()-1,y) = 0xffff0000; // blue
}
}
@ -214,7 +214,7 @@ void scale_image_bilinear_old (Image& target,const Image& source, double x_off_f
template <typename Image>
void scale_image_bilinear8 (Image& target,const Image& source, double x_off_f=0, double y_off_f=0);
/////////// save_to_file ////////////////////////////////////////////////
/////////// save_to_file ////////////////////////////////////////////////
inline MAPNIK_DECL void save_to_file(image_32 const& image,
std::string const& file)
@ -252,7 +252,7 @@ inline MAPNIK_DECL std::string save_to_string(image_32 const& image,
{
return save_to_string<image_data_32>(image.data(), type, palette);
}
///////////////////////////////////////////////////////////////////////////
#ifdef _MSC_VER
@ -265,14 +265,14 @@ template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
rgba_palette const&);
template MAPNIK_DECL void save_to_file<image_data_32>(image_data_32 const&,
std::string const&);
std::string const&);
template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
std::string const&,
std::string const&,
rgba_palette const&);
template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
std::string const&,
std::string const&);
@ -282,18 +282,18 @@ template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<i
rgba_palette const&);
template MAPNIK_DECL void save_to_file<image_view<image_data_32> > (image_view<image_data_32> const&,
std::string const&);
std::string const&);
template MAPNIK_DECL std::string save_to_string<image_data_32>(image_data_32 const&,
std::string const&,
rgba_palette const&);
template MAPNIK_DECL std::string save_to_string<image_view<image_data_32> > (image_view<image_data_32> const&,
std::string const&);
template MAPNIK_DECL std::string save_to_string<image_view<image_data_32> > (image_view<image_data_32> const&,
std::string const&,
std::string const&);
template MAPNIK_DECL std::string save_to_string<image_view<image_data_32> > (image_view<image_data_32> const&,
std::string const&,
rgba_palette const&);
#endif

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -24,35 +24,35 @@
#define MAPNIK_IMAGE_VIEW_HPP
namespace mapnik {
template <typename T>
class image_view
template <typename T>
class image_view
{
public:
typedef typename T::pixel_type pixel_type;
image_view(unsigned x, unsigned y, unsigned width, unsigned height, T const& data)
: x_(x),
y_(y),
width_(width),
height_(height),
data_(data)
data_(data)
{
if (x_ >= data_.width()) x_=data_.width()-1;
if (y_ >= data_.height()) x_=data_.height()-1;
if (x_ + width_ > data_.width()) width_= data_.width() - x_;
if (y_ + height_ > data_.height()) height_= data_.height() - y_;
}
~image_view() {}
image_view(image_view<T> const& rhs)
: x_(rhs.x_),
y_(rhs.y_),
width_(rhs.width_),
height_(rhs.height_),
data_(rhs.data_) {}
image_view<T> & operator=(image_view<T> const& rhs)
{
if (&rhs==this) return *this;
@ -62,7 +62,7 @@ public:
height_ = rhs.height_;
data_ = rhs.data_;
}
inline unsigned x() const
{
return x_;
@ -72,7 +72,7 @@ public:
{
return y_;
}
inline unsigned width() const
{
return width_;
@ -81,7 +81,7 @@ public:
{
return height_;
}
inline const pixel_type* getRow(unsigned row) const
{
return data_.getRow(row + y_) + x_;
@ -94,7 +94,7 @@ public:
{
return data_;
}
private:
unsigned x_;
unsigned y_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -38,14 +38,14 @@ extern "C"
namespace mapnik {
#define BUFFER_SIZE 4096
typedef struct
typedef struct
{
struct jpeg_destination_mgr pub;
std::ostream * out;
JOCTET * buffer;
} dest_mgr;
inline void init_destination( j_compress_ptr cinfo)
{
dest_mgr * dest = reinterpret_cast<dest_mgr*>(cinfo->dest);
@ -64,30 +64,30 @@ inline boolean empty_output_buffer (j_compress_ptr cinfo)
dest->pub.free_in_buffer = BUFFER_SIZE;
return true;
}
inline void term_destination( j_compress_ptr cinfo)
{
dest_mgr * dest = reinterpret_cast<dest_mgr*>(cinfo->dest);
size_t size = BUFFER_SIZE - dest->pub.free_in_buffer;
if (size > 0)
if (size > 0)
{
dest->out->write((char*)dest->buffer, size);
}
dest->out->flush();
}
template <typename T1, typename T2>
void save_as_jpeg(T1 & file,int quality, T2 const& image)
{
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
int width=image.width();
int height=image.height();
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
cinfo.dest = (struct jpeg_destination_mgr *)(*cinfo.mem->alloc_small)
((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof(dest_mgr));
dest_mgr * dest = (dest_mgr*) cinfo.dest;
@ -95,18 +95,18 @@ void save_as_jpeg(T1 & file,int quality, T2 const& image)
dest->pub.empty_output_buffer = empty_output_buffer;
dest->pub.term_destination = term_destination;
dest->out = &file;
//jpeg_stdio_dest(&cinfo, fp);
cinfo.image_width = width;
cinfo.image_height = height;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality,1);
jpeg_start_compress(&cinfo, 1);
JSAMPROW row_pointer[1];
JSAMPLE* row=reinterpret_cast<JSAMPLE*>( ::operator new (sizeof(JSAMPLE) * width*3));
while (cinfo.next_scanline < cinfo.image_height)
while (cinfo.next_scanline < cinfo.image_height)
{
const unsigned* imageRow=image.getRow(cinfo.next_scanline);
int index=0;
@ -126,10 +126,10 @@ void save_as_jpeg(T1 & file,int quality, T2 const& image)
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
::operator delete(row);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
}
}
}
#endif

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -32,8 +32,8 @@
namespace mapnik
{
//this needs to be tree structure
//as a proof of a concept _only_ we use sequential scan
//this needs to be tree structure
//as a proof of a concept _only_ we use sequential scan
struct label_collision_detector
{
@ -56,7 +56,7 @@ struct label_collision_detector
{
labels_.clear();
}
private:
label_placements labels_;
@ -71,12 +71,12 @@ public:
explicit label_collision_detector2(box2d<double> const& extent)
: tree_(extent) {}
bool has_placement(box2d<double> const& box)
{
tree_t::query_iterator itr = tree_.query_in_box(box);
tree_t::query_iterator end = tree_.query_end();
for ( ;itr != end; ++itr)
{
if (itr->intersects(box))
@ -84,33 +84,33 @@ public:
return false;
}
}
tree_.insert(box,box);
return true;
}
void clear()
{
tree_.clear();
}
}
};
// quad_tree based label collision detector with seperate check/insert
class label_collision_detector3 : boost::noncopyable
{
typedef quad_tree< box2d<double> > tree_t;
tree_t tree_;
public:
explicit label_collision_detector3(box2d<double> const& extent)
: tree_(extent) {}
bool has_placement(box2d<double> const& box)
{
tree_t::query_iterator itr = tree_.query_in_box(box);
tree_t::query_iterator end = tree_.query_end();
for ( ;itr != end; ++itr)
{
if (itr->intersects(box))
@ -118,7 +118,7 @@ public:
return false;
}
}
return true;
}
@ -126,14 +126,14 @@ public:
{
tree_.insert(box, box);
}
void clear()
{
tree_.clear();
}
};
//quad tree based label collission detector so labels dont appear within a given distance
class label_collision_detector4 : boost::noncopyable
{
@ -142,26 +142,26 @@ public:
{
label(box2d<double> const& b) : box(b) {}
label(box2d<double> const& b, UnicodeString const& t) : box(b), text(t) {}
box2d<double> box;
UnicodeString text;
};
private:
private:
typedef quad_tree< label > tree_t;
tree_t tree_;
public:
typedef tree_t::query_iterator query_iterator;
explicit label_collision_detector4(box2d<double> const& extent)
: tree_(extent) {}
bool has_placement(box2d<double> const& box)
{
tree_t::query_iterator itr = tree_.query_in_box(box);
tree_t::query_iterator end = tree_.query_end();
for ( ;itr != end; ++itr)
{
if (itr->box.intersects(box))
@ -169,16 +169,16 @@ public:
return false;
}
}
return true;
}
}
bool has_placement(box2d<double> const& box, UnicodeString const& text, double distance)
{
box2d<double> bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance);
tree_t::query_iterator itr = tree_.query_in_box(bigger_box);
tree_t::query_iterator end = tree_.query_end();
for ( ;itr != end; ++itr)
{
if (itr->box.intersects(box) || (text == itr->text && itr->box.intersects(bigger_box)))
@ -186,16 +186,16 @@ public:
return false;
}
}
return true;
}
}
bool has_point_placement(box2d<double> const& box, double distance)
{
box2d<double> bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance);
tree_t::query_iterator itr = tree_.query_in_box(bigger_box);
tree_t::query_iterator end = tree_.query_end();
for ( ;itr != end; ++itr)
{
if (itr->box.intersects(bigger_box))
@ -203,32 +203,32 @@ public:
return false;
}
}
return true;
}
}
void insert(box2d<double> const& box)
{
tree_.insert(label(box), box);
}
void insert(box2d<double> const& box, UnicodeString const& text)
{
tree_.insert(label(box, text), box);
}
void clear()
{
tree_.clear();
}
box2d<double> const& extent() const
{
return tree_.extent();
}
query_iterator begin() { return tree_.query_in_box(extent()); }
query_iterator end() { return tree_.query_end(); }
query_iterator begin() { return tree_.query_in_box(extent()); }
query_iterator end() { return tree_.query_end(); }
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -35,9 +35,9 @@ namespace mapnik
/*!
* @brief A Mapnik map layer.
*
* Create a layer with a named string and, optionally, an srs string either
* with a Proj.4 epsg code ('+init=epsg:<code>') or with a Proj.4 literal
* ('+proj=<literal>'). If no srs is specified it will default to
* Create a layer with a named string and, optionally, an srs string either
* with a Proj.4 epsg code ('+init=epsg:<code>') or with a Proj.4 literal
* ('+proj=<literal>'). If no srs is specified it will default to
* '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
*/
class MAPNIK_DECL layer
@ -47,7 +47,7 @@ public:
layer(layer const& l);
layer& operator=(layer const& l);
bool operator==(layer const& other) const;
/*!
* @brief Set the name of the layer.
*/
@ -56,77 +56,77 @@ public:
/*!
* @return the name of the layer.
*/
const std::string& name() const;
/*!
* @brief Set the SRS of the layer.
*/
void set_srs(std::string const& srs);
/*!
* @return the SRS of the layer.
*/
std::string const& srs() const;
/*!
* @brief Add a new style to this layer.
*
* @param stylename The name of the style to add.
*/
void add_style(std::string const& stylename);
/*!
* @return the styles list attached to this layer.
*/
std::vector<std::string> const& styles() const;
/*!
* @return the styles list attached to this layer
* (const version).
*/
std::vector<std::string>& styles();
/*!
* @param maxZoom The minimum zoom level to set
*/
void setMinZoom(double minZoom);
/*!
* @param maxZoom The maximum zoom level to set
*/
void setMaxZoom(double maxZoom);
/*!
* @return the minimum zoom level of the layer.
*/
double getMinZoom() const;
/*!
* @return the maximum zoom level of the layer.
*/
double getMaxZoom() const;
/*!
* @brief Set whether this layer is active and will be rendered.
*/
void setActive(bool active);
/*!
* @return whether this layer is active and will be rendered.
*/
bool isActive() const;
/*!
* @brief Set whether this layer is queryable.
*/
void setQueryable(bool queryable);
/*!
* @return whether this layer is queryable or not.
*/
bool isQueryable() const;
/*!
* @brief Get the visability for a specific scale.
*
@ -140,27 +140,27 @@ public:
* scale < maxzoom + 1e-6
*/
bool isVisible(double scale) const;
/*!
* @param clear_cache Set whether this layer's labels are cached.
*/
void set_clear_label_cache(bool clear_cache);
/*!
* @return whether this layer's labels are cached.
*/
bool clear_label_cache() const;
bool clear_label_cache() const;
/*!
* @param clear_cache Set whether this layer's features should be cached if used by multiple styles.
*/
void set_cache_features(bool cache_features);
/*!
* @return whether this layer's features will be cached if used by multiple styles
*/
bool cache_features() const;
bool cache_features() const;
/*!
* @param group_by Set the field rendering of this layer is grouped by.
*/
@ -177,24 +177,24 @@ public:
* @param ds The datasource to attach.
*/
void set_datasource(datasource_ptr const& ds);
/*!
* @return the datasource attached to this layer.
*/
datasource_ptr datasource() const;
/*!
* @return the geographic envelope/bounding box of the data in the layer.
*/
box2d<double> envelope() const;
~layer();
private:
void swap(const layer& other);
std::string name_;
std::string srs_;
double minZoom_;
double maxZoom_;
bool active_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -29,7 +29,7 @@
// stl
#include <string>
namespace mapnik
namespace mapnik
{
void read_xml2( std::string const & filename, boost::property_tree::ptree & pt);
void read_xml2_string( std::string const & str, boost::property_tree::ptree & pt, std::string const & base_path="");

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -27,14 +27,14 @@
#include <mapnik/symbolizer.hpp>
//#include <boost/shared_ptr.hpp>
namespace mapnik
{
namespace mapnik
{
struct MAPNIK_DECL line_pattern_symbolizer :
public symbolizer_with_image, public symbolizer_base
{
line_pattern_symbolizer(path_expression_ptr file);
line_pattern_symbolizer(line_pattern_symbolizer const& rhs);
};
};
}
#endif // MAPNIK_LINE_PATTERN_SYMBOLIZER_HPP

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -28,7 +28,7 @@
#include <mapnik/symbolizer.hpp>
#include <mapnik/enumeration.hpp>
namespace mapnik
namespace mapnik
{
enum line_rasterizer_enum {
@ -43,19 +43,19 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base
{
explicit line_symbolizer()
: symbolizer_base(),
stroke_(),
rasterizer_p_(RASTERIZER_FULL) {}
stroke_(),
rasterizer_p_(RASTERIZER_FULL) {}
line_symbolizer(stroke const& stroke)
: symbolizer_base(),
stroke_(stroke),
rasterizer_p_(RASTERIZER_FULL) {}
stroke_(stroke),
rasterizer_p_(RASTERIZER_FULL) {}
line_symbolizer(color const& pen,float width=1.0)
: symbolizer_base(),
stroke_(pen,width),
rasterizer_p_(RASTERIZER_FULL) {}
stroke_(pen,width),
rasterizer_p_(RASTERIZER_FULL) {}
stroke const& get_stroke() const
{
return stroke_;
@ -65,12 +65,12 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base
{
stroke_ = stk;
}
void set_rasterizer(line_rasterizer_e rasterizer_p)
{
rasterizer_p_ = rasterizer_p;
}
line_rasterizer_e get_rasterizer() const
{
return rasterizer_p_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -37,16 +37,16 @@
namespace mapnik
{
class MAPNIK_DECL Map
{
{
public:
enum aspect_fix_mode
enum aspect_fix_mode
{
// grow the width or height of the specified geo bbox to fill the map size. default behaviour.
GROW_BBOX,
// grow the width or height of the map to accomodate the specified geo bbox.
GROW_CANVAS,
// shrink the width or height of the specified geo bbox to fill the map size.
// shrink the width or height of the specified geo bbox to fill the map size.
SHRINK_BBOX,
// shrink the width or height of the map to accomodate the specified geo bbox.
SHRINK_CANVAS,
@ -56,12 +56,12 @@ public:
ADJUST_BBOX_HEIGHT,
// adjust the width of the map, leave height and geo bbox unchanged
ADJUST_CANVAS_WIDTH,
//adjust the height of the map, leave width and geo bbox unchanged
//adjust the height of the map, leave width and geo bbox unchanged
ADJUST_CANVAS_HEIGHT,
//
//
aspect_fix_mode_MAX
};
private:
static const unsigned MIN_MAPSIZE=16;
static const unsigned MAX_MAPSIZE=MIN_MAPSIZE<<10;
@ -81,7 +81,7 @@ private:
std::string base_path_;
parameters extra_attr_;
parameters extra_params_;
public:
typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator;
@ -89,7 +89,7 @@ public:
typedef std::map<std::string,font_set>::const_iterator const_fontset_iterator;
typedef std::map<std::string,font_set>::iterator fontset_iterator;
typedef std::map<std::string,metawriter_ptr>::const_iterator const_metawriter_iterator;
/*! \brief Default constructor.
*
* Creates a map with these parameters:
@ -115,20 +115,20 @@ public:
/*! \brief Assignment operator
*
* TODO: to be documented
*
*
*/
Map& operator=(const Map& rhs);
/*! \brief Get all styles
* @return Const reference to styles
*/
std::map<std::string,feature_type_style> const& styles() const;
/*! \brief Get all styles
std::map<std::string,feature_type_style> const& styles() const;
/*! \brief Get all styles
* @return Non-constant reference to styles
*/
std::map<std::string,feature_type_style> & styles();
/*! \brief Get first iterator in styles.
* @return Constant style iterator.
*/
@ -201,7 +201,7 @@ public:
* @return Constant metawriter iterator.
*/
const_metawriter_iterator end_metawriters() const;
/*! \brief Insert a fontset into the map.
* @param name The name of the fontset.
* @param style The fontset to insert.
@ -209,7 +209,7 @@ public:
* @return false If failure.
*/
bool insert_fontset(std::string const& name, font_set const& fontset);
/*! \brief Find a fontset.
* @param name The name of the fontset.
* @return The fontset if found. If not found return the default map fontset.
@ -246,7 +246,7 @@ public:
* @return Non-constant layer.
*/
layer& getLayer(size_t index);
/*! \brief Remove a layer.
* @param index layer number.
*/
@ -300,31 +300,31 @@ public:
* @param c Background color.
*/
void set_background(const color& c);
/*! \brief Get the map background color
/*! \brief Get the map background color
* @return Background color as boost::optional
* object
*/
boost::optional<color> const& background() const;
/*! \brief Set the map background image filename.
* @param c Background image filename.
*/
void set_background_image(std::string const& image_filename);
/*! \brief Get the map background image
* @return Background image path as std::string
* object
*/
boost::optional<std::string> const& background_image() const;
/*! \brief Set buffer size
/*! \brief Set buffer size
* @param buffer_size Buffer size in pixels.
*/
void set_buffer_size(int buffer_size);
/*! \brief Get the map buffer size
/*! \brief Get the map buffer size
* @return Buffer size as int
*/
int buffer_size() const;
@ -333,9 +333,9 @@ public:
* @param box The bounding box for the maximum extent.
*/
void set_maximum_extent(box2d<double>const& box);
/*! \brief Get the map maximum extent as box2d<double>
*/
*/
boost::optional<box2d<double> > const& maximum_extent() const;
/*! \brief Get the map base path where paths should be relative to.
@ -352,7 +352,7 @@ public:
*/
void zoom(double factor);
/*! \brief Zoom the map to a bounding box.
/*! \brief Zoom the map to a bounding box.
*
* Aspect is handled automatic if not fitting to width/height.
* @param box The bounding box where to zoom.
@ -376,16 +376,16 @@ public:
* @return The current buffered bounding box.
*/
box2d<double> get_buffered_extent() const;
/*!
* @return The Map Scale.
*/
double scale() const;
double scale_denominator() const;
CoordTransform view_transform() const;
/*!
* @brief Query a Map layer (by layer index) for features
*
@ -416,7 +416,7 @@ public:
* @brief Resolve names to object references for metawriters.
*/
void init_metawriters();
~Map();
inline void set_aspect_fix_mode(aspect_fix_mode afm) { aspectFixMode_ = afm; }
@ -473,7 +473,7 @@ public:
private:
void fixAspectRatio();
};
DEFINE_ENUM(aspect_fix_mode_e,Map::aspect_fix_mode);
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -44,7 +44,7 @@
#include <cassert>
#include <cstring>
namespace mapnik
namespace mapnik
{
typedef agg::pod_bvector<mapnik::svg::path_attributes> attr_storage;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -137,7 +137,7 @@ template <typename Locator, typename Detector> bool markers_placement<Locator, D
double *x, double *y, double *angle, bool add_to_detector)
{
if (done_) return false;
unsigned cmd;
double spacing_left;
if (marker_nr_++ == 0)
@ -197,7 +197,7 @@ template <typename Locator, typename Detector> bool markers_placement<Locator, D
} else if (d - spacing_left < size_.width()/2)
{
//Segment is long enough, but we are to close to the end
//Note: This function moves backwards. This could lead to an infinite
// loop when another function adds a positive offset. Therefore we
// only move backwards when there is no offset

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -49,7 +49,7 @@ enum marker_type_enum {
DEFINE_ENUM( marker_type_e, marker_type_enum );
struct MAPNIK_DECL markers_symbolizer :
struct MAPNIK_DECL markers_symbolizer :
public symbolizer_with_image, public symbolizer_base
{
public:

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -31,7 +31,7 @@
#include <vector>
namespace mapnik {
class MAPNIK_DECL memory_datasource : public datasource
{
friend class memory_featureset;
@ -50,8 +50,8 @@ public:
private:
std::vector<feature_ptr> features_;
mapnik::layer_descriptor desc_;
};
};
}
#endif // MAPNIK_MEMORY_DATASOURCE_HPP

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -30,7 +30,7 @@
#include <boost/utility.hpp>
namespace mapnik {
class memory_featureset : public Featureset, private boost::noncopyable
{
public:
@ -47,7 +47,7 @@ public:
{}
virtual ~memory_featureset() {}
feature_ptr next()
{
while (pos_ != end_)
@ -64,14 +64,14 @@ public:
}
++pos_;
}
return feature_ptr();
}
private:
box2d<double> bbox_;
std::vector<feature_ptr>::const_iterator pos_;
std::vector<feature_ptr>::const_iterator end_;
std::vector<feature_ptr>::const_iterator end_;
};
}

View file

@ -49,7 +49,7 @@ class metawriter_property_map
public:
typedef std::map<std::string, UnicodeString> property_map;
typedef property_map::const_iterator const_iterator;
metawriter_property_map() {}
UnicodeString const& operator[](std::string const& key) const;
UnicodeString& operator[](std::string const& key) {return m_[key];}
@ -61,7 +61,7 @@ public:
{
return m_.end();
}
UnicodeString const& get(std::string const& key) const
{
return (*this)[key];
@ -89,9 +89,9 @@ class metawriter
public:
typedef coord_transform2<CoordTransform,geometry_type> path_type;
metawriter(metawriter_properties dflt_properties) :
dflt_properties_(dflt_properties),
width_(0),
height_(0) {}
dflt_properties_(dflt_properties),
width_(0),
height_(0) {}
virtual ~metawriter() {};
/** Output a rectangular area.
* \param box Area (in pixel coordinates)
@ -123,11 +123,11 @@ public:
* \param properties metawriter_property_map object with userdefined values.
* Useful for setting filename etc.
*/
virtual void start(metawriter_property_map const& properties)
virtual void start(metawriter_property_map const& properties)
{
boost::ignore_unused_variable_warning(properties);
};
/** Stop processing.
* Write file footer, close database connection, ...
*/

View file

@ -40,13 +40,13 @@ namespace mapnik {
metawriter_ptr metawriter_create(const boost::property_tree::ptree &pt);
/**
* Writes properties into the given property tree representing the
* Writes properties into the given property tree representing the
* metawriter argument, and which can be used to reconstruct it.
*/
void metawriter_save(
const metawriter_ptr &m,
boost::property_tree::ptree &pt,
bool explicit_defaults);
const metawriter_ptr &m,
boost::property_tree::ptree &pt,
bool explicit_defaults);
}

View file

@ -37,13 +37,13 @@ namespace mapnik {
/**
* Keeps metadata information in-memory, where it can be retrieved by whatever's
* calling Mapnik and custom output provided.
* calling Mapnik and custom output provided.
*
* Stored data is all in image coordinates in the current implementation.
*
* This is most useful when Mapnik is being called from Python, and the result
* of the metawriter can be queried and injected into the (meta)tile or whatever
* in a very flexible way. E.g: for a GUI app the metawriter can be used to
* in a very flexible way. E.g: for a GUI app the metawriter can be used to
* create hit areas, for a web app it could be used to create an HTML image map.
*
* Because this is kept in-memory, applying this metawriter to features which are
@ -51,66 +51,66 @@ namespace mapnik {
* many attributes are also kept.
*/
class MAPNIK_DECL metawriter_inmem
: public metawriter, private boost::noncopyable {
: public metawriter, private boost::noncopyable {
public:
/**
* Construct an in-memory writer which keeps properties specified by the
* dflt_properties argument. For example: if dflt_properties contains "name",
* then the name attribute of rendered features referencing this metawriter
* will be kept in memory.
*/
/**
* Construct an in-memory writer which keeps properties specified by the
* dflt_properties argument. For example: if dflt_properties contains "name",
* then the name attribute of rendered features referencing this metawriter
* will be kept in memory.
*/
metawriter_inmem(metawriter_properties dflt_properties);
~metawriter_inmem();
virtual void add_box(box2d<double> const& box, Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_text(text_placement_info const& p,
face_manager_freetype &font_manager,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_polygon(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_line(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void start(metawriter_property_map const& properties);
/**
* An instance of a rendered feature. The box represents the image
* coordinates of a bounding box around the feature. The properties
* are the intersection of the features' properties and the "kept"
* properties of the metawriter.
*/
struct MAPNIK_DECL meta_instance {
box2d<double> box;
std::map<std::string, value> properties;
};
virtual void add_box(box2d<double> const& box, Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_text(text_placement_info const& p,
face_manager_freetype &font_manager,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_polygon(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_line(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
typedef std::list<meta_instance> meta_instance_list;
virtual void start(metawriter_property_map const& properties);
// const-only access to the instances.
const meta_instance_list &instances() const;
/**
* An instance of a rendered feature. The box represents the image
* coordinates of a bounding box around the feature. The properties
* are the intersection of the features' properties and the "kept"
* properties of the metawriter.
*/
struct MAPNIK_DECL meta_instance {
box2d<double> box;
std::map<std::string, value> properties;
};
typedef std::list<meta_instance> meta_instance_list;
// const-only access to the instances.
const meta_instance_list &instances() const;
// utility iterators for use in the python bindings.
meta_instance_list::const_iterator inst_begin() const;
meta_instance_list::const_iterator inst_end() const;
// utility iterators for use in the python bindings.
meta_instance_list::const_iterator inst_begin() const;
meta_instance_list::const_iterator inst_end() const;
private:
std::list<meta_instance> instances_;
std::list<meta_instance> instances_;
void add_vertices(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
void add_vertices(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
};
/** Shared pointer to metawriter_inmem object. */
typedef boost::shared_ptr<metawriter_inmem> metawriter_inmem_ptr;

View file

@ -51,9 +51,9 @@ public:
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_polygon(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
virtual void add_line(path_type & path,
Feature const& feature,
CoordTransform const& t,
@ -74,9 +74,9 @@ public:
virtual void set_map_srs(projection const& proj);
protected:
enum {
HEADER_NOT_WRITTEN = -1,
STOPPED = -2,
STARTED = 0
HEADER_NOT_WRITTEN = -1,
STOPPED = -2,
STARTED = 0
};
/** Features written. */
int count_;
@ -129,10 +129,10 @@ public:
virtual void start(metawriter_property_map const& properties);
virtual void stop();
/** Set filename template.
*
* This template is processed with values from Map's metawriter properties to
* create the actual filename during start() call.
*/
*
* This template is processed with values from Map's metawriter properties to
* create the actual filename during start() call.
*/
void set_filename(path_expression_ptr fn);
/** Get filename template. */
path_expression_ptr get_filename() const;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -45,16 +45,16 @@ struct RGBPolicy
inline static unsigned index_from_level(unsigned level, rgb const& c)
{
unsigned shift = 7 - level;
return (((c.r >> shift) & 1) << 2)
| (((c.g >> shift) & 1) << 1)
return (((c.r >> shift) & 1) << 2)
| (((c.g >> shift) & 1) << 1)
| ((c.b >> shift) & 1);
}
};
template <typename T, typename InsertPolicy = RGBPolicy >
class octree : private boost::noncopyable
{
struct node
{
struct node
{
node ()
: reds(0),
@ -182,7 +182,7 @@ public:
node * cur_node = root_;
while (cur_node)
{
if (cur_node->children_count == 0)
if (cur_node->children_count == 0)
return cur_node->index + offset_;
unsigned idx = InsertPolicy::index_from_level(level,c);
cur_node = cur_node->children_[idx];
@ -202,7 +202,7 @@ public:
palette.reserve(colors_);
create_palette(palette, root_);
}
void computeCost(node *r)
{
r->reduce_cost = 0;
@ -220,7 +220,7 @@ public:
dr = r->children_[idx]->reds / r->children_[idx]->count_cum - mean_r;
dg = r->children_[idx]->greens / r->children_[idx]->count_cum - mean_g;
db = r->children_[idx]->blues / r->children_[idx]->count_cum - mean_b;
r->reduce_cost += r->children_[idx]->reduce_cost;
r->reduce_cost += (dr*dr + dg*dg + db*db) * r->children_[idx]->count_cum;
}
@ -230,7 +230,7 @@ public:
{
computeCost(root_);
reducible_[0].push_back(root_);
// sort reducible by reduce_cost
for (unsigned i=0;i<InsertPolicy::MAX_LEVELS;++i)
{
@ -275,15 +275,15 @@ public:
delete cur_node->children_[idx], cur_node->children_[idx]=0;
}
}
reducible_[red_idx].erase(pos);
if (num_children > 0 )
if (num_children > 0 )
{
colors_ -= (num_children - 1);
}
}
}
void create_palette(std::vector<rgb> & palette, node * itr) const
{
if (itr->count != 0)
@ -296,12 +296,12 @@ public:
}
for (unsigned i=0; i < 8 ;++i)
{
if (itr->children_[i] != 0)
if (itr->children_[i] != 0)
create_palette(palette, itr->children_[i]);
}
}
}
private:
node * root_;
private:
node * root_;
};
} // namespace mapnik

View file

@ -129,7 +129,7 @@ public:
explicit rgba_palette(std::string const& pal, palette_type type = PALETTE_RGBA);
rgba_palette();
const std::vector<rgb>& palette() const;
const std::vector<unsigned>& alphaTable() const;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -41,40 +41,40 @@ namespace mapnik
typedef boost::variant<value_null,int,double,std::string> value_holder;
typedef std::pair<std::string, value_holder> parameter;
typedef std::map<std::string, value_holder> param_map;
template <typename T>
struct value_extractor_visitor : public boost::static_visitor<>
{
value_extractor_visitor(boost::optional<T> & var)
:var_(var) {}
void operator () (T val) const
{
var_ = val;
}
template <typename T1>
void operator () (T1 val) const
void operator () (T1 val) const
{
try
try
{
var_ = boost::lexical_cast<T>(val);
}
catch (boost::bad_lexical_cast & ) {}
}
boost::optional<T> & var_;
};
class parameters : public param_map
{
template <typename T>
template <typename T>
struct converter
{
typedef boost::optional<T> return_type;
typedef boost::optional<T> return_type;
static return_type extract(parameters const& params,
std::string const& name,
std::string const& name,
boost::optional<T> const& default_value)
{
boost::optional<T> result(default_value);
@ -86,17 +86,17 @@ class parameters : public param_map
return result;
}
};
public:
parameters() {}
template <typename T>
boost::optional<T> get(std::string const& key) const
{
return converter<T>::extract(*this,key, boost::none);
}
template <typename T>
boost::optional<T> get(std::string const& key, T const& default_value) const
{

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -55,61 +55,61 @@ struct path_processor
path_visitor_ (std::string & filename, feature_type const& f)
: filename_(filename),
feature_(f) {}
void operator() (std::string const& token) const
{
filename_ += token;
}
void operator() (attribute const& attr) const
{
// convert mapnik::value to std::string
filename_ += attr.value<mapnik::value,feature_type>(feature_).to_string();
}
std::string & filename_;
feature_type const& feature_;
};
struct to_string_ : boost::static_visitor<void>
{
to_string_ (std::string & str)
: str_(str) {}
void operator() (std::string const& token) const
{
str_ += token;
}
void operator() (attribute const& attr) const
void operator() (attribute const& attr) const
{
str_ += "[";
str_ += attr.name();
str_ += "]";
}
std::string & str_;
};
template <typename T1>
struct collect_ : boost::static_visitor<void>
{
collect_ (T1 & cont)
: cont_(cont) {}
void operator() (std::string const& token) const
{
boost::ignore_unused_variable_warning(token);
}
void operator() (attribute const& attr) const
void operator() (attribute const& attr) const
{
cont_.insert(attr.name());
}
T1 & cont_;
};
static std::string evaluate(path_expression const& path,feature_type const& f)
{
std::string out;
@ -118,7 +118,7 @@ struct path_processor
boost::apply_visitor(eval,token);
return out;
}
static std::string to_string(path_expression const& path)
{
std::string str;
@ -127,7 +127,7 @@ struct path_processor
boost::apply_visitor(visitor,token);
return str;
}
template <typename T2>
static void collect_attributes(path_expression const& path, T2 & names)
{

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -63,7 +63,7 @@ using standard_wide::space;
template <typename Iterator>
struct path_expression_grammar : qi::grammar<Iterator, std::vector<path_component>(), space_type>
{
{
path_expression_grammar()
: path_expression_grammar::base_type(expr)
{
@ -74,7 +74,7 @@ struct path_expression_grammar : qi::grammar<Iterator, std::vector<path_componen
using qi::lit;
using qi::lexeme;
using phoenix::push_back;
expr =
* (
str [ push_back(_val, _1)]
@ -82,11 +82,11 @@ struct path_expression_grammar : qi::grammar<Iterator, std::vector<path_componen
( '[' >> attr [ push_back(_val, construct<mapnik::attribute>( _1 )) ] >> ']')
)
;
attr %= +(char_ - ']');
str %= lexeme[+(char_ -'[')];
}
qi::rule<Iterator, std::vector<path_component>() , space_type> expr;
qi::rule<Iterator, std::string() , space_type> attr;
qi::rule<Iterator, std::string() > str;

View file

@ -35,7 +35,7 @@ class placement_finder : boost::noncopyable
public:
placement_finder(text_placement_info &p, string_info &info, DetectorT & detector);
placement_finder(text_placement_info &p, string_info &info, DetectorT & detector, box2d<double> const& extent);
/** Try place a single label at the given point. */
void find_point_placement(double pos_x, double pos_y, double angle=0.0);
@ -50,7 +50,7 @@ public:
void update_detector();
void clear();
private:
///Helpers for find_line_placement
@ -63,8 +63,8 @@ private:
// If >= 50% of the characters end up upside down, it will be retried the other way.
// RETURN: 1/-1 depending which way up the string ends up being.
std::auto_ptr<text_path> get_placement_offset(const std::vector<vertex2d> & path_positions,
const std::vector<double> & path_distances,
int & orientation, unsigned index, double distance);
const std::vector<double> & path_distances,
int & orientation, unsigned index, double distance);
///Tests wether the given text_path be placed without a collision
// Returns true if it can

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -35,10 +35,10 @@
namespace mapnik
{
class PluginInfo : boost::noncopyable
{
{
private:
std::string name_;
lt_dlhandle module_;
lt_dlhandle module_;
public:
PluginInfo (const std::string& name,const lt_dlhandle module);
~PluginInfo();

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -40,7 +40,7 @@ extern "C"
#define MAX_OCTREE_LEVELS 4
namespace mapnik {
template <typename T>
void write_data (png_structp png_ptr, png_bytep data, png_size_t length)
{
@ -57,13 +57,13 @@ void flush_data (png_structp png_ptr)
template <typename T1, typename T2>
void save_as_png(T1 & file , T2 const& image, int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY)
{
{
png_voidp error_ptr=0;
png_structp png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING,
error_ptr,0, 0);
if (!png_ptr) return;
// switch on optimization only if supported
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) && defined(PNG_MMX_CODE_SUPPORTED)
png_uint_32 mask, flags;
@ -116,7 +116,7 @@ void reduce_8 (T const& in, image_data_8 & out, octree<rgb> trees[], unsigned l
alpha[i] = 0;
alphaCount[i] = 0;
}
for (unsigned y = 0; y < height; ++y)
{
mapnik::image_data_32::pixel_type const * row = in.getRow(y);
@ -141,7 +141,7 @@ void reduce_8 (T const& in, image_data_8 & out, octree<rgb> trees[], unsigned l
row_out[x] = index;
}
}
for(unsigned i=0; i<alpha.size(); i++)
for(unsigned i=0; i<alpha.size(); i++)
{
if (alphaCount[i]!=0)
alpha[i] /= alphaCount[i];
@ -188,7 +188,7 @@ void reduce_4 (T const& in, image_data_8 & out, octree<rgb> trees[], unsigned li
row_out[x>>1] |= index;
}
}
for(unsigned i=0; i<alpha.size(); i++)
for(unsigned i=0; i<alpha.size(); i++)
{
if (alphaCount[i]!=0)
alpha[i] /= alphaCount[i];
@ -256,7 +256,7 @@ void save_as_png(T & file, std::vector<mapnik::rgb> const& palette,
{
std::vector<png_byte> trans(alpha.size());
unsigned alphaSize=0;//truncate to nonopaque values
for(unsigned i=0; i < alpha.size(); i++)
for(unsigned i=0; i < alpha.size(); i++)
{
trans[i]=alpha[i];
if (alpha[i]<255)
@ -278,7 +278,7 @@ void save_as_png(T & file, std::vector<mapnik::rgb> const& palette,
template <typename T1,typename T2>
void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 256,
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY, int trans_mode = -1)
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY, int trans_mode = -1)
{
// number of alpha ranges in png8 format; 2 results in smallest image with binary transparency
// 3 is minimum for semitransparency, 4 is recommended, anything else is worse
@ -376,7 +376,7 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25
for (unsigned x = 0; x < width; ++x)
{
unsigned val = row[x];
// insert to proper tree based on alpha range
for(unsigned j=TRANSPARENCY_LEVELS-1; j>0; j--){
if (cols[j]>0 && U2ALPHA(val)>=limits[j]) {
@ -417,7 +417,7 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25
//alphaTable.resize(palette.size());//allow semitransparency also in almost opaque range
if (trans_mode != 0)
alphaTable.resize(palette.size() - cols[TRANSPARENCY_LEVELS-1]);
if (palette.size() > 16 )
{
// >16 && <=256 colors -> write 8-bit color depth
@ -452,8 +452,8 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25
template <typename T1, typename T2, typename T3>
void save_as_png8(T1 & file, T2 const& image, T3 const & tree,
std::vector<mapnik::rgb> const& palette, std::vector<unsigned> const& alphaTable,
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY)
std::vector<mapnik::rgb> const& palette, std::vector<unsigned> const& alphaTable,
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY)
{
unsigned width = image.width();
unsigned height = image.height();
@ -510,8 +510,8 @@ void save_as_png8(T1 & file, T2 const& image, T3 const & tree,
template <typename T1,typename T2>
void save_as_png8_hex(T1 & file, T2 const& image, int colors = 256,
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY,
int trans_mode = -1, double gamma = 2.0)
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY,
int trans_mode = -1, double gamma = 2.0)
{
unsigned width = image.width();
unsigned height = image.height();
@ -551,7 +551,7 @@ void save_as_png8_hex(T1 & file, T2 const& image, int colors = 256,
template <typename T1, typename T2>
void save_as_png8_pal(T1 & file, T2 const& image, rgba_palette const& pal,
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY)
int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY)
{
save_as_png8<T1, T2, rgba_palette>(file, image, pal, pal.palette(), pal.alphaTable(), compression, strategy);
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -24,10 +24,10 @@
#define MAPNIK_POINT_SYMBOLIZER_HPP
// mapnik
#include <mapnik/symbolizer.hpp>
#include <mapnik/symbolizer.hpp>
#include <mapnik/enumeration.hpp>
namespace mapnik
namespace mapnik
{
enum point_placement_enum {
@ -38,9 +38,9 @@ enum point_placement_enum {
DEFINE_ENUM( point_placement_e, point_placement_enum );
struct MAPNIK_DECL point_symbolizer :
struct MAPNIK_DECL point_symbolizer :
public symbolizer_with_image, public symbolizer_base
{
{
explicit point_symbolizer();
point_symbolizer(path_expression_ptr file);
point_symbolizer(point_symbolizer const& rhs);
@ -50,7 +50,7 @@ struct MAPNIK_DECL point_symbolizer :
point_placement_e get_point_placement() const;
void set_ignore_placement(bool ignore_placement);
bool get_ignore_placement() const;
private:
bool overlap_;
point_placement_e point_p_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -23,7 +23,7 @@
#ifndef MAPNIK_POLYGON_PATTERN_SYMBOLIZER_HPP
#define MAPNIK_POLYGON_PATTERN_SYMBOLIZER_HPP
// mapnik
// mapnik
#include <mapnik/symbolizer.hpp>
#include <mapnik/enumeration.hpp>
#include <mapnik/gamma_method.hpp>

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -30,7 +30,7 @@
#include <mapnik/enumeration.hpp>
#include <mapnik/gamma_method.hpp>
namespace mapnik
namespace mapnik
{
struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
@ -51,7 +51,7 @@ private:
double opacity_;
double gamma_;
gamma_method_e gamma_method_;
};
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -46,13 +46,13 @@ class PoolGuard
{
private:
const T& obj_;
PoolT& pool_;
PoolT& pool_;
public:
explicit PoolGuard(const T& ptr,PoolT& pool)
: obj_(ptr),
pool_(pool) {}
~PoolGuard()
~PoolGuard()
{
pool_->returnObject(obj_);
}
@ -67,10 +67,10 @@ template <typename T,template <typename> class Creator>
class Pool : private boost::noncopyable
{
typedef boost::shared_ptr<T> HolderType;
typedef std::deque<HolderType> ContType;
typedef std::deque<HolderType> ContType;
Creator<T> creator_;
const unsigned initialSize_;
const unsigned initialSize_;
const unsigned maxSize_;
ContType usedPool_;
ContType unusedPool_;
@ -84,7 +84,7 @@ public:
initialSize_(initialSize),
maxSize_(maxSize)
{
for (unsigned i=0; i < initialSize_; ++i)
for (unsigned i=0; i < initialSize_; ++i)
{
HolderType conn(creator_());
if (conn->isOK())
@ -93,13 +93,13 @@ public:
}
HolderType borrowObject()
{
#ifdef MAPNIK_THREADSAFE
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
#endif
typename ContType::iterator itr=unusedPool_.begin();
while ( itr!=unusedPool_.end())
{
{
#ifdef MAPNIK_DEBUG
std::clog<<"borrow "<<(*itr).get()<<"\n";
#endif
@ -113,7 +113,7 @@ public:
{
#ifdef MAPNIK_DEBUG
std::clog<<"bad connection (erase)" << (*itr).get()<<"\n";
#endif
#endif
itr=unusedPool_.erase(itr);
}
}
@ -130,7 +130,7 @@ public:
}
}
return HolderType();
}
}
void returnObject(HolderType obj)
{
@ -140,7 +140,7 @@ public:
typename ContType::iterator itr=usedPool_.begin();
while (itr != usedPool_.end())
{
if (obj.get()==(*itr).get())
if (obj.get()==(*itr).get())
{
#ifdef MAPNIK_DEBUG
std::clog<<"return "<<(*itr).get()<<"\n";
@ -152,7 +152,7 @@ public:
++itr;
}
}
std::pair<unsigned,unsigned> size() const
{
#ifdef MAPNIK_THREADSAFE

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -31,13 +31,13 @@
#include <boost/utility.hpp>
namespace mapnik {
class MAPNIK_DECL proj_transform : private boost::noncopyable
{
public:
proj_transform(projection const& source,
proj_transform(projection const& source,
projection const& dest);
bool equal() const;
bool forward (double& x, double& y , double& z) const;
bool backward (double& x, double& y , double& z) const;
@ -49,7 +49,7 @@ public:
bool backward (box2d<double> & box, int points) const;
mapnik::projection const& source() const;
mapnik::projection const& dest() const;
private:
projection const source_;
projection const dest_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -41,14 +41,14 @@
#include <stdexcept>
namespace mapnik {
class proj_init_error : public std::runtime_error
{
public:
proj_init_error(std::string const& params)
: std::runtime_error("failed to initialize projection with: '" + params + "'") {}
};
class MAPNIK_DECL projection
{
friend class proj_transform;
@ -56,23 +56,23 @@ public:
explicit projection(std::string const& params = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
projection(projection const& rhs);
~projection();
projection& operator=(projection const& rhs);
bool operator==(const projection& other) const;
bool operator!=(const projection& other) const;
bool is_initialized() const;
bool is_geographic() const;
std::string const& params() const;
void forward(double & x, double &y ) const;
void inverse(double & x,double & y) const;
std::string expanded() const;
private:
void init();
void init();
void swap (projection& rhs);
private:
std::string params_;
projPJ proj_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -99,8 +99,8 @@ inline color get_css (boost::property_tree::ptree const& node, std::string const
" but got '" + str + "'");
}
}
template <typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator << ( std::basic_ostream<charT, traits> & s, const mapnik::color & c )
@ -117,7 +117,7 @@ public:
boolean(bool b) : b_(b) {}
boolean(const boolean & b) : b_(b.b_) {}
operator bool() const
operator bool() const
{
return b_;
}
@ -142,9 +142,9 @@ operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
{
std::string word;
s >> word;
if ( s )
if ( s )
{
if ( word == "true" || word == "yes" || word == "on" ||
if ( word == "true" || word == "yes" || word == "on" ||
word == "1")
{
b = true;
@ -156,7 +156,7 @@ operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
}
else
{
s.setstate( std::ios::failbit );
s.setstate( std::ios::failbit );
}
}
return s;
@ -190,7 +190,7 @@ template <typename T>
void set_css(boost::property_tree::ptree & pt, const std::string & name, const T & v)
{
boost::property_tree::ptree & css_node = pt.push_back(
boost::property_tree::ptree::value_type("CssParameter",
boost::property_tree::ptree::value_type("CssParameter",
boost::property_tree::ptree()))->second;
css_node.put("<xmlattr>.name", name );
css_node.put_value( v );
@ -242,7 +242,7 @@ struct name_trait< mapnik::enumeration<ENUM, MAX> >
if ( i + 1 < Enum::MAX ) value_list += ", ";
}
value_list += "]";
return value_list;
}
};
@ -291,8 +291,8 @@ inline color get(boost::property_tree::ptree const& node, std::string const& nam
{
str = node.get_optional<std::string>(name+".<xmltext>");
}
if ( str )
if ( str )
{
try
{
@ -305,13 +305,13 @@ inline color get(boost::property_tree::ptree const& node, std::string const& nam
name + "'. Expected " + name_trait<color>::name() +
" but got '" + *str + "'");
}
}
else
}
else
{
return default_value;
}
}
template <typename T>
T get(const boost::property_tree::ptree & node, const std::string & name, bool is_attribute)
{
@ -350,7 +350,7 @@ T get_value(const boost::property_tree::ptree & node, const std::string & name)
{
/* NOTE: get_child works as long as there is only one child with that name.
If this function is used this used this condition must always be satisfied.
*/
*/
return node.get_child("<xmltext>").get_value<T>();
}
catch (boost::property_tree::ptree_bad_path)
@ -382,9 +382,9 @@ boost::optional<T> get_optional(const boost::property_tree::ptree & node, const
{
str = node.get_optional<std::string>(name+".<xmltext>");
}
boost::optional<T> result;
if ( str )
if ( str )
{
try
{
@ -396,13 +396,13 @@ boost::optional<T> get_optional(const boost::property_tree::ptree & node, const
(is_attribute ? "attribute" : "child node") + " '" +
name + "'. Expected " + name_trait<T>::name() +
" but got '" + *str + "'");
}
}
}
return result;
}
//
template <>
inline boost::optional<color> get_optional(const boost::property_tree::ptree & node, const std::string & name,
bool is_attribute)
@ -416,9 +416,9 @@ inline boost::optional<color> get_optional(const boost::property_tree::ptree & n
{
str = node.get_optional<std::string>(name+".<xmltext>");
}
boost::optional<color> result;
if ( str )
if ( str )
{
try
{
@ -431,9 +431,9 @@ inline boost::optional<color> get_optional(const boost::property_tree::ptree & n
(is_attribute ? "attribute" : "child node") + " '" +
name + "'. Expected " + name_trait<color>::name() +
" but got '" + *str + "'");
}
}
}
return result;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -54,104 +54,104 @@ class quad_tree : boost::noncopyable
{
std::memset(children_,0,4*sizeof(node*));
}
box2d<double> const& extent() const
{
return extent_;
}
iterator begin()
iterator begin()
{
return cont_.begin();
}
const_iterator begin() const
const_iterator begin() const
{
return cont_.begin();
}
iterator end()
iterator end()
{
return cont_.end();
}
const_iterator end() const
const_iterator end() const
{
return cont_.end();
}
~node () {}
};
typedef boost::ptr_vector<node> nodes_t;
typedef boost::ptr_vector<node> nodes_t;
typedef typename node::cont_t cont_t;
typedef typename cont_t::iterator node_data_iterator;
nodes_t nodes_;
node * root_;
node * root_;
const unsigned int max_depth_;
const double ratio_;
const double ratio_;
public:
typedef typename nodes_t::iterator iterator;
typedef typename nodes_t::const_iterator const_iterator;
typedef typename boost::ptr_vector<T,boost::view_clone_allocator> result_t;
typedef typename boost::ptr_vector<T,boost::view_clone_allocator> result_t;
typedef typename result_t::iterator query_iterator;
result_t query_result_;
explicit quad_tree(box2d<double> const& ext,
unsigned int max_depth = 8,
double ratio = 0.55)
explicit quad_tree(box2d<double> const& ext,
unsigned int max_depth = 8,
double ratio = 0.55)
: max_depth_(max_depth),
ratio_(ratio)
{
nodes_.push_back(new node(ext));
root_ = &nodes_[0];
}
void insert(T data, box2d<double> const& box)
{
unsigned int depth=0;
do_insert_data(data,box,root_,depth);
}
query_iterator query_in_box(box2d<double> const& box)
{
query_result_.clear();
query_node(box,query_result_,root_);
return query_result_.begin();
}
query_iterator query_end()
{
return query_result_.end();
}
const_iterator begin() const
{
return nodes_.begin();
}
const_iterator end() const
{
return nodes_.end();
}
void clear ()
void clear ()
{
box2d<double> ext = root_->extent_;
nodes_.clear();
nodes_.push_back(new node(ext));
root_ = &nodes_[0];
}
box2d<double> const& extent() const
{
return root_->extent_;
}
private:
void query_node(box2d<double> const& box, result_t & result, node * node_) const
{
if (node_)
@ -173,18 +173,18 @@ private:
}
}
}
void do_insert_data(T data, box2d<double> const& box, node * n, unsigned int& depth)
{
if (++depth >= max_depth_)
{
n->cont_.push_back(data);
}
else
else
{
box2d<double> const& node_extent = n->extent();
box2d<double> ext[4];
split_box(node_extent,ext);
split_box(node_extent,ext);
for (int i=0;i<4;++i)
{
if (ext[i].contains(box))
@ -201,25 +201,25 @@ private:
n->cont_.push_back(data);
}
}
void split_box(box2d<double> const& node_extent,box2d<double> * ext)
{
//coord2d c=node_extent.center();
double width=node_extent.width();
double height=node_extent.height();
double lox=node_extent.minx();
double loy=node_extent.miny();
double hix=node_extent.maxx();
double hiy=node_extent.maxy();
ext[0]=box2d<double>(lox,loy,lox + width * ratio_,loy + height * ratio_);
ext[1]=box2d<double>(hix - width * ratio_,loy,hix,loy + height * ratio_);
ext[2]=box2d<double>(lox,hiy - height*ratio_,lox + width * ratio_,hiy);
ext[3]=box2d<double>(hix - width * ratio_,hiy - height*ratio_,hix,hiy);
}
};
}
};
}
#endif // MAPNIK_QUAD_TREE_HPP

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -36,7 +36,7 @@
namespace mapnik {
class query
class query
{
public:
typedef boost::tuple<double,double> resolution_type;
@ -50,9 +50,9 @@ private:
public:
query(box2d<double> const& bbox,
resolution_type const& resolution,
double scale_denominator,
box2d<double> const& unbuffered_bbox)
resolution_type const& resolution,
double scale_denominator,
box2d<double> const& unbuffered_bbox)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(scale_denominator),
@ -61,8 +61,8 @@ public:
{}
query(box2d<double> const& bbox,
resolution_type const& resolution,
double scale_denominator = 1.0)
resolution_type const& resolution,
double scale_denominator = 1.0)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(scale_denominator),
@ -77,7 +77,7 @@ public:
filter_factor_(1.0),
unbuffered_bbox_(bbox)
{}
query(query const& other)
: bbox_(other.bbox_),
resolution_(other.resolution_),
@ -86,7 +86,7 @@ public:
unbuffered_bbox_(other.unbuffered_bbox_),
names_(other.names_)
{}
query& operator=(query const& other)
{
if (this == &other) return *this;
@ -98,12 +98,12 @@ public:
unbuffered_bbox_=other.unbuffered_bbox_;
return *this;
}
query::resolution_type const& resolution() const
{
return resolution_;
}
double scale_denominator() const
{
return scale_denominator_;
@ -133,17 +133,17 @@ public:
{
return filter_factor_;
}
void set_filter_factor(double factor)
{
filter_factor_ = factor;
}
void add_property_name(std::string const& name)
{
names_.insert(name);
}
}
std::set<std::string> const& property_names() const
{
return names_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,6 +1,6 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -22,16 +22,16 @@
*****************************************************************************/
/** \brief Raster Colouriser
*
*
* This class allows GDAL raster bands to be colourised. It only works with single
* band GDAL rasters, not greyscale, alpha, or rgb (due to the GDAL featureset loading
* single channel GDAL rasters as FLOAT32, and the others as BYTE, and not having a method
* of figuring out which).
*
*
* Every input value is translated to an output value. The output value is determined by
* what 'stop' the input value is in. Each stop covers the range of input values from its
* 'value' parameter, up to the 'value' parameter of the next stop.
*
* 'value' parameter, up to the 'value' parameter of the next stop.
*
*/
#ifndef MAPNIK_RASTER_COLORIZER_HPP
@ -61,55 +61,55 @@ enum colorizer_mode_enum
COLORIZER_DISCRETE = 2, //!< Single color for stop
COLORIZER_EXACT = 3, //!< Only the exact value specified for the stop gets translated, others use the default
colorizer_mode_enum_MAX
};
};
DEFINE_ENUM( colorizer_mode, colorizer_mode_enum );
//! \brief Structure to represent a stop position.
//! \brief Structure to represent a stop position.
class MAPNIK_DECL colorizer_stop {
public:
//! \brief Constructor
//!
//! \param[in] value The stop value
//! \param[in] mode The stop mode
//! \param[in] color The stop color
colorizer_stop(float value = 0,
colorizer_mode mode = COLORIZER_INHERIT,
color const& _color = color(0,0,0,0),
colorizer_stop(float value = 0,
colorizer_mode mode = COLORIZER_INHERIT,
color const& _color = color(0,0,0,0),
std::string const& label="");
//! \brief Copy constructor
colorizer_stop(colorizer_stop const& stop);
//! \brief Destructor
~colorizer_stop();
//! \brief Set the stop value
//! \param[in] value The stop value
inline void set_value(float value) { value_ = value; };
inline void set_value(float value) { value_ = value; };
//! \brief Get the stop value
//! \return The stop value
inline float get_value() const {return value_; };
//! \brief Set the stop mode
//! \param[in] mode The stop mode
inline void set_mode(colorizer_mode mode) { mode_ = mode; };
inline void set_mode_enum(colorizer_mode_enum mode) { set_mode(mode); };
//! \brief Get the stop mode
//! \return The stop mode
inline colorizer_mode get_mode() const { return mode_; };
inline colorizer_mode_enum get_mode_enum() const { return get_mode(); };
//! \brief set the stop color
//! \param[in] the stop color
inline void set_color(color const& _color) { color_ = _color; };
//! \brief get the stop color
//! \return The stop color
inline color const& get_color() const {return color_; };
@ -117,11 +117,11 @@ public:
//! \brief set the stop label
//! \param[in] the stop label
inline void set_label(std::string const& label) { label_ = label; };
//! \brief get the stop label
//! \return The stop label
inline std::string const& get_label() const {return label_; };
//! \brief Equality operator
//! \return True if equal, false otherwise
@ -130,7 +130,7 @@ public:
//! \brief Print the stop to a string
//! \return A string representing this stop.
std::string to_string() const;
private:
float value_; //!< The stop value
colorizer_mode mode_; //!< The stop mode
@ -143,12 +143,12 @@ typedef std::vector<colorizer_stop> colorizer_stops;
//! \brief Class representing the raster colorizer
class MAPNIK_DECL raster_colorizer
class MAPNIK_DECL raster_colorizer
{
public:
//! \brief Constructor
raster_colorizer(colorizer_mode mode = COLORIZER_LINEAR, color const& _color = color(0,0,0,0));
//! \brief Destructor
~raster_colorizer();
@ -157,23 +157,23 @@ public:
//!
//! This can not be set as INHERIT, if you do, LINEAR will be used instead.
//! \param[in] mode The default mode
void set_default_mode(colorizer_mode mode)
{
default_mode_ = (mode == COLORIZER_INHERIT) ? COLORIZER_LINEAR:(colorizer_mode_enum)mode;
void set_default_mode(colorizer_mode mode)
{
default_mode_ = (mode == COLORIZER_INHERIT) ? COLORIZER_LINEAR:(colorizer_mode_enum)mode;
};
void set_default_mode_enum(colorizer_mode_enum mode) { set_default_mode(mode); };
//! \brief Get the default mode
//! \return The default mode
colorizer_mode get_default_mode() const {return default_mode_; };
colorizer_mode_enum get_default_mode_enum() const {return get_default_mode(); };
//! \brief Set the default color
//! \param[in] color The default color
void set_default_color(color const& color) { default_color_ = color; };
//! \brief Get the default color
//! \return The default color
color const& get_default_color() const {return default_color_; };
@ -200,7 +200,7 @@ public:
//! \param[in] feature used to find 'NODATA' information if available
void colorize(raster_ptr const& raster, Feature const& f) const;
//! \brief Perform the translation of input to output
//!
//! \param[in] value Input value
@ -211,14 +211,14 @@ public:
//! \brief Set the epsilon value for exact mode
//! \param[in] e The epsilon value
inline void set_epsilon(const float e) { if(e > 0) epsilon_ = e; };
//! \brief Get the epsilon value for exact mode
//! \return The epsilon value
inline float get_epsilon() const { return epsilon_; };
private:
colorizer_stops stops_; //!< The vector of stops
colorizer_mode default_mode_; //!< The default mode inherited by stops
color default_color_; //!< The default color
float epsilon_; //!< The epsilon value for exact mode

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -31,9 +31,9 @@
namespace mapnik
{
struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
{
raster_symbolizer()
: symbolizer_base(),
mode_("normal"),
@ -51,7 +51,7 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
colorizer_(rhs.colorizer_),
filter_factor_(rhs.filter_factor_),
mesh_size_(rhs.mesh_size_) {}
std::string const& get_mode() const
{
return mode_;
@ -102,38 +102,38 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
// No filter factor specified, calculate a sensible default value
// based on the scaling algorithm being employed.
scaling_method_e scaling = get_scaling_method_by_name (scaling_);
double ff = 1.0;
switch(scaling)
{
case SCALING_NEAR:
ff = 1.0;
break;
case SCALING_NEAR:
ff = 1.0;
break;
// TODO potentially some of these algorithms would use filter_factor >2.0.
// Contributions welcome from someone who knows more about them.
case SCALING_BILINEAR:
case SCALING_BICUBIC:
case SCALING_SPLINE16:
case SCALING_SPLINE36:
case SCALING_HANNING:
case SCALING_HAMMING:
case SCALING_HERMITE:
case SCALING_KAISER:
case SCALING_QUADRIC:
case SCALING_CATROM:
case SCALING_GAUSSIAN:
case SCALING_BESSEL:
case SCALING_MITCHELL:
case SCALING_SINC:
case SCALING_LANCZOS:
case SCALING_BLACKMAN:
ff = 2.0;
break;
default:
ff = 1.0;
break;
case SCALING_BILINEAR:
case SCALING_BICUBIC:
case SCALING_SPLINE16:
case SCALING_SPLINE36:
case SCALING_HANNING:
case SCALING_HAMMING:
case SCALING_HERMITE:
case SCALING_KAISER:
case SCALING_QUADRIC:
case SCALING_CATROM:
case SCALING_GAUSSIAN:
case SCALING_BESSEL:
case SCALING_MITCHELL:
case SCALING_SINC:
case SCALING_LANCZOS:
case SCALING_BLACKMAN:
ff = 2.0;
break;
default:
ff = 1.0;
break;
}
return ff;
}
@ -146,8 +146,8 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
{
mesh_size_=mesh_size;
}
private:
std::string mode_;
std::string scaling_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -53,59 +53,59 @@ namespace mapnik
inline bool operator==(point_symbolizer const& lhs,
point_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(line_symbolizer const& lhs,
line_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(line_pattern_symbolizer const& lhs,
line_pattern_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(polygon_symbolizer const& lhs,
polygon_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(polygon_pattern_symbolizer const& lhs,
polygon_pattern_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(raster_symbolizer const& lhs,
raster_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(text_symbolizer const& lhs,
text_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(shield_symbolizer const& lhs,
shield_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(building_symbolizer const& lhs,
building_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
inline bool operator==(markers_symbolizer const& lhs,
markers_symbolizer const& rhs)
{
return (&lhs == &rhs);
return (&lhs == &rhs);
}
typedef boost::variant<point_symbolizer,
@ -118,16 +118,16 @@ typedef boost::variant<point_symbolizer,
text_symbolizer,
building_symbolizer,
markers_symbolizer> symbolizer;
class rule
{
{
public:
typedef std::vector<symbolizer> symbolizers;
private:
std::string name_;
double min_scale_;
double max_scale_;
@ -138,7 +138,7 @@ private:
struct deepcopy_symbolizer : public boost::static_visitor<>
{
void operator () (markers_symbolizer & sym) const
{
copy_path_ptr(sym);
@ -153,20 +153,20 @@ private:
{
copy_path_ptr(sym);
}
void operator () (line_pattern_symbolizer & sym) const
{
copy_path_ptr(sym);
}
void operator () (raster_symbolizer & sym) const
{
raster_colorizer_ptr old_colorizer = sym.get_colorizer();
raster_colorizer_ptr new_colorizer = raster_colorizer_ptr();
raster_colorizer_ptr new_colorizer = raster_colorizer_ptr();
new_colorizer->set_stops(old_colorizer->get_stops());
new_colorizer->set_default_mode(old_colorizer->get_default_mode());
new_colorizer->set_default_color(old_colorizer->get_default_color());
new_colorizer->set_epsilon(old_colorizer->get_epsilon());
new_colorizer->set_epsilon(old_colorizer->get_epsilon());
sym.set_colorizer(new_colorizer);
}
@ -174,7 +174,7 @@ private:
{
copy_text_ptr(sym);
}
void operator () (shield_symbolizer & sym) const
{
copy_path_ptr(sym);
@ -185,13 +185,13 @@ private:
{
copy_height_ptr(sym);
}
template <typename T> void operator () (T &sym) const
{
boost::ignore_unused_variable_warning(sym);
}
private:
template <class T>
void copy_path_ptr(T & sym) const
@ -199,25 +199,25 @@ private:
std::string path = path_processor_type::to_string(*sym.get_filename());
sym.set_filename( parse_path(path) );
}
template <class T>
void copy_text_ptr(T & sym) const
{
std::string name = to_expression_string(*sym.get_name());
sym.set_name( parse_expression(name) );
// FIXME - orientation doesn't appear to be initialized in constructor?
//std::string orientation = to_expression_string(*sym->get_orientation());
//sym->set_orientation( parse_expression(orientation) );
float text_size = sym.get_text_size();
position displace = sym.get_displacement();
vertical_alignment_e valign = sym.get_vertical_alignment();
horizontal_alignment_e halign = sym.get_horizontal_alignment();
justify_alignment_e jalign = sym.get_justify_alignment();
text_placements_ptr placements = text_placements_ptr(boost::make_shared<text_placements_dummy>());
sym.set_placement_options( placements );
sym.set_placement_options( placements );
sym.set_text_size(text_size);
sym.set_displacement(displace);
sym.set_vertical_alignment(valign);
@ -232,7 +232,7 @@ private:
sym.set_height(parse_expression(height_expr,"utf8"));
}
};
public:
rule()
: name_(),
@ -240,9 +240,9 @@ public:
max_scale_(std::numeric_limits<double>::infinity()),
syms_(),
filter_(boost::make_shared<mapnik::expr_node>(true)),
else_filter_(false),
else_filter_(false),
also_filter_(false) {}
rule(const std::string& name,
double min_scale_denominator=0,
double max_scale_denominator=std::numeric_limits<double>::infinity())
@ -251,35 +251,35 @@ public:
max_scale_(max_scale_denominator),
syms_(),
filter_(boost::make_shared<mapnik::expr_node>(true)),
else_filter_(false),
else_filter_(false),
also_filter_(false) {}
rule(const rule& rhs, bool deep_copy = false)
: name_(rhs.name_),
min_scale_(rhs.min_scale_),
max_scale_(rhs.max_scale_),
syms_(rhs.syms_),
filter_(rhs.filter_),
else_filter_(rhs.else_filter_),
also_filter_(rhs.also_filter_)
else_filter_(rhs.else_filter_),
also_filter_(rhs.also_filter_)
{
if (deep_copy) {
std::string expr = to_expression_string(*filter_);
filter_ = parse_expression(expr,"utf8");
symbolizers::const_iterator it = syms_.begin();
symbolizers::const_iterator end = syms_.end();
// FIXME - metawriter_ptr?
for(; it != end; ++it)
{
boost::apply_visitor(deepcopy_symbolizer(),*it);
for(; it != end; ++it)
{
boost::apply_visitor(deepcopy_symbolizer(),*it);
}
}
}
rule& operator=(rule const& rhs)
rule& operator=(rule const& rhs)
{
rule tmp(rhs);
swap(tmp);
@ -287,44 +287,44 @@ public:
}
bool operator==(rule const& other)
{
return (this == &other);
return (this == &other);
}
void set_max_scale(double scale)
{
max_scale_=scale;
}
double get_max_scale() const
{
return max_scale_;
}
void set_min_scale(double scale)
{
min_scale_=scale;
}
double get_min_scale() const
{
return min_scale_;
}
void set_name(std::string const& name)
{
name_=name;
}
std::string const& get_name() const
{
return name_;
}
void append(const symbolizer& sym)
{
syms_.push_back(sym);
}
void remove_at(size_t index)
{
if (index < syms_.size())
@ -332,69 +332,69 @@ public:
syms_.erase(syms_.begin()+index);
}
}
const symbolizers& get_symbolizers() const
{
return syms_;
}
symbolizers::const_iterator begin() const
{
return syms_.begin();
}
symbolizers::const_iterator end() const
{
return syms_.end();
}
symbolizers::iterator begin()
{
return syms_.begin();
}
symbolizers::iterator end()
{
return syms_.end();
}
void set_filter(const expression_ptr& filter)
{
filter_=filter;
}
expression_ptr const& get_filter() const
{
return filter_;
}
void set_else(bool else_filter)
{
else_filter_=else_filter;
}
bool has_else_filter() const
{
return else_filter_;
}
void set_also(bool also_filter)
{
also_filter_=also_filter;
}
bool has_also_filter() const
{
return also_filter_;
}
bool active(double scale) const
{
return ( scale >= min_scale_ - 1e-6 && scale < max_scale_ + 1e-6);
}
private:
void swap(rule& rhs) throw()
{
name_=rhs.name_;
@ -404,7 +404,7 @@ private:
filter_=rhs.filter_;
else_filter_=rhs.else_filter_;
also_filter_=rhs.also_filter_;
}
}
};
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -27,7 +27,7 @@
#include <mapnik/config.hpp>
namespace mapnik {
class Map;
MAPNIK_DECL double scale_denominator(Map const& map, bool geographic);
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko

View file

@ -47,12 +47,12 @@ struct MAPNIK_DECL shield_symbolizer : public text_symbolizer,
float size,
color const& fill,
path_expression_ptr file);
bool get_unlock_image() const; // image is not locked to the text placement
void set_unlock_image(bool unlock_image);
void set_shield_displacement(double shield_dx,double shield_dy);
position const& get_shield_displacement() const;
private:
bool unlock_image_;
position shield_displacement_;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -29,167 +29,167 @@
namespace mapnik { namespace sql_utils {
inline std::string unquote_double(const std::string& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\""));
return table_name;
}
inline std::string unquote(const std::string& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\"\'"));
return table_name;
}
inline void quote_attr(std::ostringstream& s, const std::string& field)
{
if (boost::algorithm::icontains(field,".")) {
std::vector<std::string> parts;
boost::split(parts, field, boost::is_any_of("."));
s << ",\"" << parts[0] << "\".\"" << parts[1] << "\"";
}
else
inline std::string unquote_double(const std::string& sql)
{
s << ",\"" + field + "\"";
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\""));
return table_name;
}
}
inline std::string table_from_sql(const std::string& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::replace_all(table_name,"\n"," ");
std::string::size_type idx = table_name.rfind(" from ");
if (idx!=std::string::npos)
inline std::string unquote(const std::string& sql)
{
idx = table_name.find_first_not_of(" ",idx+5);
if (idx != std::string::npos)
{
table_name=table_name.substr(idx);
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\"\'"));
return table_name;
}
inline void quote_attr(std::ostringstream& s, const std::string& field)
{
if (boost::algorithm::icontains(field,".")) {
std::vector<std::string> parts;
boost::split(parts, field, boost::is_any_of("."));
s << ",\"" << parts[0] << "\".\"" << parts[1] << "\"";
}
idx = table_name.find_first_of(" )");
if (idx != std::string::npos)
else
{
table_name = table_name.substr(0,idx);
s << ",\"" + field + "\"";
}
}
return table_name;
}
inline std::string numeric2string(const char* buf)
{
int16_t ndigits = int2net(buf);
int16_t weight = int2net(buf+2);
int16_t sign = int2net(buf+4);
int16_t dscale = int2net(buf+6);
boost::scoped_array<int16_t> digits(new int16_t[ndigits]);
for (int n=0; n < ndigits ;++n)
{
digits[n] = int2net(buf+8+n*2);
}
std::ostringstream ss;
if (sign == 0x4000) ss << "-";
int i = std::max(weight,int16_t(0));
int d = 0;
inline std::string table_from_sql(const std::string& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::replace_all(table_name,"\n"," ");
// Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field.
// For example, the number 1234567809990001 is stored as four digits: [1234] [5678] [999] [1].
// Note that the last two digits show that the leading 0's are lost when the number is split.
// We must be careful to re-insert these 0's when building the string.
std::string::size_type idx = table_name.rfind(" from ");
if (idx!=std::string::npos)
{
idx = table_name.find_first_not_of(" ",idx+5);
if (idx != std::string::npos)
{
table_name=table_name.substr(idx);
}
idx = table_name.find_first_of(" )");
if (idx != std::string::npos)
{
table_name = table_name.substr(0,idx);
}
}
return table_name;
}
while ( i >= 0)
{
if (i <= weight && d < ndigits)
{
// All digits after the first must be padded to make the field 4 characters long
if (d != 0)
{
inline std::string numeric2string(const char* buf)
{
int16_t ndigits = int2net(buf);
int16_t weight = int2net(buf+2);
int16_t sign = int2net(buf+4);
int16_t dscale = int2net(buf+6);
boost::scoped_array<int16_t> digits(new int16_t[ndigits]);
for (int n=0; n < ndigits ;++n)
{
digits[n] = int2net(buf+8+n*2);
}
std::ostringstream ss;
if (sign == 0x4000) ss << "-";
int i = std::max(weight,int16_t(0));
int d = 0;
// Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field.
// For example, the number 1234567809990001 is stored as four digits: [1234] [5678] [999] [1].
// Note that the last two digits show that the leading 0's are lost when the number is split.
// We must be careful to re-insert these 0's when building the string.
while ( i >= 0)
{
if (i <= weight && d < ndigits)
{
// All digits after the first must be padded to make the field 4 characters long
if (d != 0)
{
#ifdef _WINDOWS
int dig = digits[d];
if (dig < 10)
{
ss << "000"; // 0000 - 0009
}
else if (dig < 100)
{
ss << "00"; // 0010 - 0099
}
else
{
ss << "0"; // 0100 - 0999;
}
int dig = digits[d];
if (dig < 10)
{
ss << "000"; // 0000 - 0009
}
else if (dig < 100)
{
ss << "00"; // 0010 - 0099
}
else
{
ss << "0"; // 0100 - 0999;
}
#else
switch(digits[d])
{
case 0 ... 9:
ss << "000"; // 0000 - 0009
break;
case 10 ... 99:
ss << "00"; // 0010 - 0099
break;
case 100 ... 999:
ss << "0"; // 0100 - 0999
break;
}
switch(digits[d])
{
case 0 ... 9:
ss << "000"; // 0000 - 0009
break;
case 10 ... 99:
ss << "00"; // 0010 - 0099
break;
case 100 ... 999:
ss << "0"; // 0100 - 0999
break;
}
#endif
}
ss << digits[d++];
}
else
{
if (d == 0)
ss << "0";
else
ss << "0000";
}
i--;
}
if (dscale > 0)
{
ss << '.';
// dscale counts the number of decimal digits following the point, not the numeric digits
while (dscale > 0)
{
int value;
if (i <= weight && d < ndigits)
value = digits[d++];
else
value = 0;
}
ss << digits[d++];
}
else
{
if (d == 0)
ss << "0";
else
ss << "0000";
}
// Output up to 4 decimal digits for this value
if (dscale > 0) {
ss << (value / 1000);
value %= 1000;
dscale--;
}
if (dscale > 0) {
ss << (value / 100);
value %= 100;
dscale--;
}
if (dscale > 0) {
ss << (value / 10);
value %= 10;
dscale--;
}
if (dscale > 0) {
ss << value;
dscale--;
}
i--;
}
if (dscale > 0)
{
ss << '.';
// dscale counts the number of decimal digits following the point, not the numeric digits
while (dscale > 0)
{
int value;
if (i <= weight && d < ndigits)
value = digits[d++];
else
value = 0;
i--;
}
}
return ss.str();
}
}
// Output up to 4 decimal digits for this value
if (dscale > 0) {
ss << (value / 1000);
value %= 1000;
dscale--;
}
if (dscale > 0) {
ss << (value / 100);
value %= 100;
dscale--;
}
if (dscale > 0) {
ss << (value / 10);
value %= 10;
dscale--;
}
if (dscale > 0) {
ss << value;
dscale--;
}
i--;
}
}
return ss.str();
}
}
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -30,13 +30,13 @@
// stl
#include <vector>
namespace mapnik
{
using std::pair;
using std::vector;
typedef vector<pair<double,double> > dash_array;
// if you add new tokens, don't forget to add them to the corresponding
// string array in the cpp file.
enum line_cap_enum
@ -45,10 +45,10 @@ enum line_cap_enum
SQUARE_CAP,
ROUND_CAP,
line_cap_enum_MAX
};
};
DEFINE_ENUM( line_cap_e, line_cap_enum );
// if you add new tokens, don't forget to add them to the corresponding
// string array in the cpp file.
enum line_join_enum
@ -81,16 +81,16 @@ public:
void set_color(const color& c);
color const& get_color() const;
double get_width() const;
void set_width(double w);
void set_opacity(double opacity);
double get_opacity() const;
void set_line_cap(line_cap_e line_cap);
line_cap_e get_line_cap() const;
void set_line_join(line_join_e line_join);
line_join_e get_line_join() const;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -26,8 +26,8 @@
//#include <mapnik/style.hpp>
namespace mapnik {
class style_factory
class style_factory
{
};
}

View file

@ -49,21 +49,21 @@ template <typename VertexSource, typename AttributeSource>
class svg_converter : boost::noncopyable
{
public:
svg_converter(VertexSource & source, AttributeSource & attributes)
: source_(source),
attributes_(attributes) {}
void begin_path()
{
push_attr();
unsigned idx = source_.start_new_path();
attributes_.add(path_attributes(cur_attr(), idx));
}
void end_path()
{
if(attributes_.size() == 0)
if(attributes_.size() == 0)
{
throw std::runtime_error("end_path : The path was not begun");
}
@ -71,21 +71,21 @@ public:
unsigned idx = attributes_[attributes_.size() - 1].index;
attr.index = idx;
attributes_[attributes_.size() - 1] = attr;
pop_attr();
pop_attr();
}
void move_to(double x, double y, bool rel=false) // M, m
{
if(rel) source_.rel_to_abs(&x, &y);
source_.move_to(x, y);
}
void line_to(double x, double y, bool rel=false) // L, l
{
if(rel) source_.rel_to_abs(&x, &y);
source_.line_to(x, y);
source_.line_to(x, y);
}
void hline_to(double x, bool rel=false) // H, h
{
double x2 = 0.0;
@ -95,9 +95,9 @@ public:
source_.vertex(source_.total_vertices() - 1, &x2, &y2);
if(rel) x += x2;
source_.line_to(x, y2);
}
}
}
void vline_to(double y, bool rel=false) // V, v
{
double x2 = 0.0;
@ -110,32 +110,32 @@ public:
}
}
void curve3(double x1, double y1, // Q, q
double x, double y, bool rel=false)
double x, double y, bool rel=false)
{
if(rel)
if(rel)
{
source_.rel_to_abs(&x1, &y1);
source_.rel_to_abs(&x, &y);
}
source_.curve3(x1, y1, x, y);
}
void curve3(double x, double y, bool rel=false) // T, t
{
if(rel)
if(rel)
{
source_.curve3_rel(x, y);
} else
} else
{
source_.curve3(x, y);
}
}
void curve4(double x1, double y1, // C, c
double x2, double y2,
double x, double y, bool rel=false)
double x2, double y2,
double x, double y, bool rel=false)
{
if(rel)
if(rel)
{
source_.rel_to_abs(&x1, &y1);
source_.rel_to_abs(&x2, &y2);
@ -143,45 +143,45 @@ public:
}
source_.curve4(x1, y1, x2, y2, x, y);
}
void curve4(double x2, double y2, // S, s
double x, double y, bool rel=false)
double x, double y, bool rel=false)
{
if(rel)
if(rel)
{
source_.curve4_rel(x2, y2, x, y);
} else
} else
{
source_.curve4(x2, y2, x, y);
}
}
void arc_to(double rx, double ry, // A, a
double angle,
double angle,
bool large_arc_flag,
bool sweep_flag,
double x, double y,bool rel=false)
double x, double y,bool rel=false)
{
if(rel)
if(rel)
{
source_.arc_rel(rx, ry, angle, large_arc_flag, sweep_flag, x, y);
}
else
else
{
source_.arc_to(rx, ry, angle, large_arc_flag, sweep_flag, x, y);
}
}
void close_subpath() // Z, z
{
source_.end_poly(agg::path_flags_close);
}
void push_attr()
{
attr_stack_.add(attr_stack_.size() ?
attr_stack_.add(attr_stack_.size() ?
attr_stack_[attr_stack_.size() - 1] :
path_attributes());
}
@ -193,14 +193,14 @@ public:
}
attr_stack_.remove_last();
}
// Attribute setting functions.
void fill(const agg::rgba8& f)
{
path_attributes& attr = cur_attr();
double a = attr.fill_color.opacity();
attr.fill_color = f;
attr.fill_color.opacity(a * f.opacity());
attr.fill_color.opacity(a * f.opacity());
attr.fill_flag = true;
}
@ -224,7 +224,7 @@ public:
attr.stroke_color.opacity(a * s.opacity());
attr.stroke_flag = true;
}
void even_odd(bool flag)
{
cur_attr().even_odd_flag = flag;
@ -235,7 +235,7 @@ public:
cur_attr().visibility_flag = flag;
}
void stroke_width(double w)
{
cur_attr().stroke_width = w;
@ -244,12 +244,12 @@ public:
{
cur_attr().fill_flag = false;
}
void stroke_none()
{
cur_attr().stroke_flag = false;
}
void fill_opacity(double op)
{
cur_attr().fill_color.opacity(op);
@ -263,12 +263,12 @@ public:
{
cur_attr().opacity = op;
}
void line_join(agg::line_join_e join)
{
cur_attr().line_join = join;
}
void line_cap(agg::line_cap_e cap)
{
cur_attr().line_cap = cap;
@ -277,37 +277,37 @@ public:
{
cur_attr().miter_limit = ml;
}
// Make all polygons CCW-oriented
void arrange_orientations()
{
source_.arrange_orientations_all_paths(agg::path_flags_ccw);
}
// FIXME!!!!
unsigned operator [](unsigned idx)
{
transform_ = attributes_[idx].transform;
return attributes_[idx].index;
}
void bounding_rect(double* x1, double* y1, double* x2, double* y2)
{
agg::conv_transform<mapnik::svg::svg_path_adapter> trans(source_, transform_);
agg::bounding_rect(trans, *this, 0, attributes_.size(), x1, y1, x2, y2);
}
VertexSource & storage()
VertexSource & storage()
{
return source_;
}
agg::trans_affine& transform()
{
return cur_attr().transform;
}
path_attributes& cur_attr()
path_attributes& cur_attr()
{
if(attr_stack_.size() == 0)
{
@ -315,9 +315,9 @@ public:
}
return attr_stack_[attr_stack_.size() - 1];
}
private:
private:
VertexSource & source_;
AttributeSource & attributes_;
AttributeSource attr_stack_;

View file

@ -45,7 +45,7 @@ namespace mapnik { namespace svg {
class svg_generator : private boost::noncopyable
{
typedef coord_transform2<CoordTransform, geometry_type> path_type;
typedef svg::svg_root_attributes_grammar<OutputIterator> root_attributes_grammar;
typedef svg::svg_rect_attributes_grammar<OutputIterator> rect_attributes_grammar;
typedef svg::svg_path_data_grammar<OutputIterator, path_type> path_data_grammar;
@ -55,16 +55,16 @@ namespace mapnik { namespace svg {
public:
explicit svg_generator(OutputIterator& output_iterator);
~svg_generator();
void generate_header();
void generate_opening_root(root_output_attributes const& root_attributes);
void generate_closing_root();
void generate_rect(rect_output_attributes const& rect_attributes);
void generate_path(path_type const& path, path_output_attributes const& path_attributes);
private:
OutputIterator& output_iterator_;
};
}}
}}
#endif // MAPNIK_SVG_GENERATOR_HPP

Some files were not shown because too many files have changed in this diff Show more