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

@ -45,7 +45,7 @@
// apps using mapnik do not
// need agg headers
namespace agg {
struct trans_affine;
struct trans_affine;
}
namespace mapnik {

View file

@ -41,8 +41,8 @@ namespace mapnik {
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::dividable2<box2d<T>, T,
boost::multipliable2<box2d<T>, T > > > >
{
public:
typedef box2d<T> box2d_type;

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

@ -70,14 +70,14 @@ public:
{}
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
{

View file

@ -344,12 +344,12 @@ struct css_color_grammar : qi::grammar<Iterator, color(), ascii_space_type>
;
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')

View file

@ -373,12 +373,12 @@ struct css_color_grammar : qi::grammar<Iterator, css(), ascii_space_type>
;
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')

View file

@ -165,14 +165,14 @@ 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 )
Geometry const& geom,
proj_transform const& prj_trans )
: t_(t),
geom_(geom),
prj_trans_(prj_trans),
offset_(0.0),
threshold_(10),
m_status(initial) {}
geom_(geom),
prj_trans_(prj_trans),
offset_(0.0),
threshold_(10),
m_status(initial) {}
enum status
{
@ -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:
@ -290,7 +290,7 @@ 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,7 +298,7 @@ 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;
}
@ -306,25 +306,25 @@ struct MAPNIK_DECL coord_transform_parallel
// 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;
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_;
}
#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;
@ -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

@ -83,7 +83,7 @@ public:
datasource (parameters const& params)
: params_(params),
is_bound_(false)
is_bound_(false)
{}
/*!

View file

@ -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

@ -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
{

View file

@ -265,7 +265,7 @@ 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&,
@ -282,7 +282,7 @@ 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&,
@ -290,10 +290,10 @@ template MAPNIK_DECL std::string save_to_string<image_data_32>(image_data_32 con
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&);
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&,
rgba_palette const&);
#endif

View file

@ -227,8 +227,8 @@ public:
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

@ -43,18 +43,18 @@ 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
{

View file

@ -335,7 +335,7 @@ public:
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.

View file

@ -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)

View file

@ -44,9 +44,9 @@ metawriter_ptr metawriter_create(const boost::property_tree::ptree &pt);
* 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

@ -51,64 +51,64 @@ 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 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);
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;
};
/**
* 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;
typedef std::list<meta_instance> meta_instance_list;
// const-only access to the instances.
const meta_instance_list &instances() const;
// 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. */

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

@ -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

@ -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
@ -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

@ -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)

View file

@ -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),

View file

@ -107,33 +107,33 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
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;
}

View file

@ -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);
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"," ");
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::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;
}
std::ostringstream ss;
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);
if (sign == 0x4000) ss << "-";
boost::scoped_array<int16_t> digits(new int16_t[ndigits]);
for (int n=0; n < ndigits ;++n)
{
digits[n] = int2net(buf+8+n*2);
}
int i = std::max(weight,int16_t(0));
int d = 0;
std::ostringstream ss;
// 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.
if (sign == 0x4000) ss << "-";
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)
{
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";
}
}
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;
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;
// 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--;
}
// 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();
}
}
i--;
}
}
return ss.str();
}
}
}

View file

@ -145,7 +145,7 @@ public:
}
void curve4(double x2, double y2, // S, s
double x, double y, bool rel=false)
double x, double y, bool rel=false)
{
if(rel)
{

View file

@ -65,6 +65,6 @@ namespace mapnik { namespace svg {
private:
OutputIterator& output_iterator_;
};
}}
}}
#endif // MAPNIK_SVG_GENERATOR_HPP

View file

@ -58,7 +58,7 @@ namespace mapnik { namespace svg {
stroke_linejoin_("miter"),
stroke_dasharray_(),
stroke_dashoffset_(0.0)
{}
{}
void set_fill_color(color const& fill_color);
void set_fill_opacity(const double fill_opacity);
@ -85,7 +85,7 @@ namespace mapnik { namespace svg {
*/
void reset();
//private:
//private:
// polygon symbolizer attributes.
std::string fill_color_;
double fill_opacity_;
@ -147,7 +147,7 @@ namespace mapnik { namespace svg {
*/
void reset();
//private:
//private:
int x_;
int y_;
unsigned width_;
@ -168,36 +168,36 @@ namespace mapnik { namespace svg {
*/
struct root_output_attributes
{
root_output_attributes();
root_output_attributes();
root_output_attributes(const unsigned width, const unsigned height);
root_output_attributes(const unsigned width, const unsigned height);
void set_width(const unsigned width);
void set_height(const unsigned height);
void set_svg_version(const double svg_version);
void set_svg_namespace_url(std::string const& svg_namespace_url);
void set_width(const unsigned width);
void set_height(const unsigned height);
void set_svg_version(const double svg_version);
void set_svg_namespace_url(std::string const& svg_namespace_url);
const unsigned width() const;
const unsigned height() const;
const double svg_version() const;
const std::string svg_namespace_url() const;
const unsigned width() const;
const unsigned height() const;
const double svg_version() const;
const std::string svg_namespace_url() const;
/*!
* @brief Set members back to their default values.
*/
void reset();
/*!
* @brief Set members back to their default values.
*/
void reset();
// SVG version to which the generated document will be compliant.
static const double SVG_VERSION;
// SVG XML namespace url.
static const std::string SVG_NAMESPACE_URL;
// SVG version to which the generated document will be compliant.
static const double SVG_VERSION;
// SVG XML namespace url.
static const std::string SVG_NAMESPACE_URL;
//private:
unsigned width_;
unsigned height_;
double svg_version_;
std::string svg_namespace_url_;
//private:
unsigned width_;
unsigned height_;
double svg_version_;
std::string svg_namespace_url_;
};
}}
}}
#endif // MAPNIK_SVG_OUTPUT_ATTRIBUTES

View file

@ -60,7 +60,7 @@ BOOST_FUSION_ADAPT_STRUCT(
(std::string, stroke_linecap_)
(std::string, stroke_linejoin_)
(double, stroke_dashoffset_)
)
)
/*!
* mapnik::svg::rect_output_attributes is adapted as a fusion sequence
@ -73,7 +73,7 @@ BOOST_FUSION_ADAPT_STRUCT(
(unsigned, width_)
(unsigned, height_)
(std::string, fill_color_)
)
)
/*!
* mapnik::svg::root_output_attributes is adapted as a fusion sequence
@ -85,7 +85,7 @@ BOOST_FUSION_ADAPT_STRUCT(
(unsigned, height_)
(double, svg_version_)
(std::string, svg_namespace_url_)
)
)
/*!
* mapnik::geometry_type is adapted to conform to the concepts
@ -94,38 +94,38 @@ BOOST_FUSION_ADAPT_STRUCT(
*/
namespace boost { namespace spirit { namespace traits {
typedef mapnik::coord_transform2<mapnik::CoordTransform, mapnik::geometry_type> path_type;
typedef mapnik::coord_transform2<mapnik::CoordTransform, mapnik::geometry_type> path_type;
template <>
struct is_container<path_type const>
: mpl::true_ {};
template <>
struct is_container<path_type const>
: mpl::true_ {};
template <>
struct container_iterator<path_type const>
{
typedef mapnik::svg::path_iterator_type type;
};
template <>
struct begin_container<path_type const>
{
static mapnik::svg::path_iterator_type
call(path_type const& path)
template <>
struct container_iterator<path_type const>
{
return mapnik::svg::path_iterator_type(0, path);
}
};
typedef mapnik::svg::path_iterator_type type;
};
template <>
struct end_container<path_type const>
{
static mapnik::svg::path_iterator_type
call(path_type const& path)
template <>
struct begin_container<path_type const>
{
return mapnik::svg::path_iterator_type(path);
}
};
}}}
static mapnik::svg::path_iterator_type
call(path_type const& path)
{
return mapnik::svg::path_iterator_type(0, path);
}
};
template <>
struct end_container<path_type const>
{
static mapnik::svg::path_iterator_type
call(path_type const& path)
{
return mapnik::svg::path_iterator_type(path);
}
};
}}}
namespace mapnik { namespace svg {
@ -138,25 +138,25 @@ namespace mapnik { namespace svg {
typedef path_iterator_type::value_type vertex_type;
explicit svg_path_data_grammar(PathType const& path_type)
: svg_path_data_grammar::base_type(svg_path),
path_type_(path_type)
: svg_path_data_grammar::base_type(svg_path),
path_type_(path_type)
{
using karma::int_;
using karma::double_;
using repository::confix;
using karma::int_;
using karma::double_;
using repository::confix;
svg_path =
lit("d=")
<< confix('"', '"')[
-(path_vertex % lit(' '))];
svg_path =
lit("d=")
<< confix('"', '"')[
-(path_vertex % lit(' '))];
path_vertex =
path_vertex_command
<< double_
<< lit(' ')
<< double_;
path_vertex =
path_vertex_command
<< double_
<< lit(' ')
<< double_;
path_vertex_command = &int_(1) << lit('M') | lit('L');
path_vertex_command = &int_(1) << lit('M') | lit('L');
}
karma::rule<OutputIterator, PathType&()> svg_path;
@ -166,89 +166,89 @@ namespace mapnik { namespace svg {
PathType const& path_type_;
};
template <typename OutputIterator>
struct svg_path_attributes_grammar : karma::grammar<OutputIterator, mapnik::svg::path_output_attributes()>
template <typename OutputIterator>
struct svg_path_attributes_grammar : karma::grammar<OutputIterator, mapnik::svg::path_output_attributes()>
{
explicit svg_path_attributes_grammar()
: svg_path_attributes_grammar::base_type(svg_path_attributes)
{
explicit svg_path_attributes_grammar()
: svg_path_attributes_grammar::base_type(svg_path_attributes)
{
using karma::double_;
using karma::string;
using repository::confix;
using karma::double_;
using karma::string;
using repository::confix;
svg_path_attributes =
lit("fill=") << confix('"', '"')[string]
<< lit(" fill-opacity=") << confix('"', '"')[double_]
<< lit(" stroke=") << confix('"', '"')[string]
<< lit(" stroke-opacity=") << confix('"', '"')[double_]
<< lit(" stroke-width=") << confix('"', '"')[double_ << lit("px")]
<< lit(" stroke-linecap=") << confix('"', '"')[string]
<< lit(" stroke-linejoin=") << confix('"', '"')[string]
<< lit(" stroke-dashoffset=") << confix('"', '"')[double_ << lit("px")];
}
svg_path_attributes =
lit("fill=") << confix('"', '"')[string]
<< lit(" fill-opacity=") << confix('"', '"')[double_]
<< lit(" stroke=") << confix('"', '"')[string]
<< lit(" stroke-opacity=") << confix('"', '"')[double_]
<< lit(" stroke-width=") << confix('"', '"')[double_ << lit("px")]
<< lit(" stroke-linecap=") << confix('"', '"')[string]
<< lit(" stroke-linejoin=") << confix('"', '"')[string]
<< lit(" stroke-dashoffset=") << confix('"', '"')[double_ << lit("px")];
}
karma::rule<OutputIterator, mapnik::svg::path_output_attributes()> svg_path_attributes;
};
karma::rule<OutputIterator, mapnik::svg::path_output_attributes()> svg_path_attributes;
};
template <typename OutputIterator>
struct svg_path_dash_array_grammar : karma::grammar<OutputIterator, mapnik::dash_array()>
template <typename OutputIterator>
struct svg_path_dash_array_grammar : karma::grammar<OutputIterator, mapnik::dash_array()>
{
explicit svg_path_dash_array_grammar()
: svg_path_dash_array_grammar::base_type(svg_path_dash_array)
{
explicit svg_path_dash_array_grammar()
: svg_path_dash_array_grammar::base_type(svg_path_dash_array)
{
using karma::double_;
using repository::confix;
using karma::double_;
using repository::confix;
svg_path_dash_array =
lit("stroke-dasharray=")
<< confix('"', '"')[
-((double_ << lit(',') << double_) % lit(','))];
}
svg_path_dash_array =
lit("stroke-dasharray=")
<< confix('"', '"')[
-((double_ << lit(',') << double_) % lit(','))];
}
karma::rule<OutputIterator, mapnik::dash_array()> svg_path_dash_array;
};
karma::rule<OutputIterator, mapnik::dash_array()> svg_path_dash_array;
};
template <typename OutputIterator>
struct svg_rect_attributes_grammar : karma::grammar<OutputIterator, mapnik::svg::rect_output_attributes()>
template <typename OutputIterator>
struct svg_rect_attributes_grammar : karma::grammar<OutputIterator, mapnik::svg::rect_output_attributes()>
{
explicit svg_rect_attributes_grammar()
: svg_rect_attributes_grammar::base_type(svg_rect_attributes)
{
explicit svg_rect_attributes_grammar()
: svg_rect_attributes_grammar::base_type(svg_rect_attributes)
{
using karma::int_;
using karma::string;
using repository::confix;
using karma::int_;
using karma::string;
using repository::confix;
svg_rect_attributes =
lit("x=") << confix('"', '"')[int_]
<< lit(" y=") << confix('"', '"')[int_]
<< lit(" width=") << confix('"', '"')[int_ << lit("px")]
<< lit(" height=") << confix('"', '"')[int_ << lit("px")]
<< lit(" fill=") << confix('"', '"')[string];
}
svg_rect_attributes =
lit("x=") << confix('"', '"')[int_]
<< lit(" y=") << confix('"', '"')[int_]
<< lit(" width=") << confix('"', '"')[int_ << lit("px")]
<< lit(" height=") << confix('"', '"')[int_ << lit("px")]
<< lit(" fill=") << confix('"', '"')[string];
}
karma::rule<OutputIterator, mapnik::svg::rect_output_attributes()> svg_rect_attributes;
};
karma::rule<OutputIterator, mapnik::svg::rect_output_attributes()> svg_rect_attributes;
};
template <typename OutputIterator>
struct svg_root_attributes_grammar : karma::grammar<OutputIterator, mapnik::svg::root_output_attributes()>
template <typename OutputIterator>
struct svg_root_attributes_grammar : karma::grammar<OutputIterator, mapnik::svg::root_output_attributes()>
{
explicit svg_root_attributes_grammar()
: svg_root_attributes_grammar::base_type(svg_root_attributes)
{
explicit svg_root_attributes_grammar()
: svg_root_attributes_grammar::base_type(svg_root_attributes)
{
using karma::int_;
using karma::string;
using karma::double_;
using repository::confix;
using karma::int_;
using karma::string;
using karma::double_;
using repository::confix;
svg_root_attributes =
lit("width=") << confix('"', '"')[int_ << lit("px")]
<< lit(" height=") << confix('"', '"')[int_ << lit("px")]
<< " version=" << confix('"', '"')[double_]
<< " xmlns=" << confix('"', '"')[string];
}
svg_root_attributes =
lit("width=") << confix('"', '"')[int_ << lit("px")]
<< lit(" height=") << confix('"', '"')[int_ << lit("px")]
<< " version=" << confix('"', '"')[double_]
<< " xmlns=" << confix('"', '"')[string];
}
karma::rule<OutputIterator, mapnik::svg::root_output_attributes()> svg_root_attributes;
};
karma::rule<OutputIterator, mapnik::svg::root_output_attributes()> svg_root_attributes;
};
}
}

View file

@ -38,40 +38,40 @@
namespace mapnik { namespace svg {
class svg_parser : private boost::noncopyable
{
public:
explicit svg_parser(svg_converter_type & path);
~svg_parser();
void parse(std::string const& filename);
private:
void process_node(xmlTextReaderPtr reader);
void start_element(xmlTextReaderPtr reader);
void end_element(xmlTextReaderPtr reader);
void parse_path(xmlTextReaderPtr reader);
void parse_polygon(xmlTextReaderPtr reader);
void parse_polyline(xmlTextReaderPtr reader);
void parse_line(xmlTextReaderPtr reader);
void parse_rect(xmlTextReaderPtr reader);
void parse_circle(xmlTextReaderPtr reader);
void parse_ellipse(xmlTextReaderPtr reader);
void parse_linear_gradient(xmlTextReaderPtr reader);
void parse_radial_gradient(xmlTextReaderPtr reader);
bool parse_common_gradient(xmlTextReaderPtr reader);
void parse_gradient_stop(xmlTextReaderPtr reader);
void parse_pattern(xmlTextReaderPtr reader);
void parse_attr(xmlTextReaderPtr reader);
void parse_attr(const xmlChar * name, const xmlChar * value );
class svg_parser : private boost::noncopyable
{
public:
explicit svg_parser(svg_converter_type & path);
~svg_parser();
void parse(std::string const& filename);
private:
void process_node(xmlTextReaderPtr reader);
void start_element(xmlTextReaderPtr reader);
void end_element(xmlTextReaderPtr reader);
void parse_path(xmlTextReaderPtr reader);
void parse_polygon(xmlTextReaderPtr reader);
void parse_polyline(xmlTextReaderPtr reader);
void parse_line(xmlTextReaderPtr reader);
void parse_rect(xmlTextReaderPtr reader);
void parse_circle(xmlTextReaderPtr reader);
void parse_ellipse(xmlTextReaderPtr reader);
void parse_linear_gradient(xmlTextReaderPtr reader);
void parse_radial_gradient(xmlTextReaderPtr reader);
bool parse_common_gradient(xmlTextReaderPtr reader);
void parse_gradient_stop(xmlTextReaderPtr reader);
void parse_pattern(xmlTextReaderPtr reader);
void parse_attr(xmlTextReaderPtr reader);
void parse_attr(const xmlChar * name, const xmlChar * value );
private:
svg_converter_type & path_;
bool is_defs_;
std::map<std::string, gradient> gradient_map_;
std::pair<std::string, gradient> temporary_gradient_;
};
private:
svg_converter_type & path_;
bool is_defs_;
std::map<std::string, gradient> gradient_map_;
std::pair<std::string, gradient> temporary_gradient_;
};
}}
}}
#endif // MAPNIK_SVG_PARSER_HPP

View file

@ -51,13 +51,13 @@ using namespace mapnik;
*
* @tparam Value the type of sequence element dereferenced.
* @tparam Container the sequence over which it iterates.
*/
*/
template <typename Value, typename Container>
class path_iterator
: public boost::iterator_adaptor<path_iterator<Value, Container>,
Value*,
boost::use_default,
boost::forward_traversal_tag>
: public boost::iterator_adaptor<path_iterator<Value, Container>,
Value*,
boost::use_default,
boost::forward_traversal_tag>
{
public:
typedef Value value_type;
@ -72,9 +72,9 @@ public:
* @param geometry the geometry that handles the vector of vertexes.
*/
path_iterator(Container const& path)
: path_iterator::iterator_adaptor_(0),
path_(path),
first_value_(boost::make_shared<Value>(0,0,0))
: path_iterator::iterator_adaptor_(0),
path_(path),
first_value_(boost::make_shared<Value>(0,0,0))
{}
/*!
@ -89,9 +89,9 @@ public:
* @param geometry the geometry that handles the vector of vertexes.
*/
explicit path_iterator(Value* first_element, Container const& path)
: path_iterator::iterator_adaptor_(first_element),
path_(path),
first_value_(boost::make_shared<Value>(0,0,0))
: path_iterator::iterator_adaptor_(first_element),
path_(path),
first_value_(boost::make_shared<Value>(0,0,0))
{
this->increment();
}
@ -104,9 +104,9 @@ public:
*/
template <typename OtherValue>
path_iterator(path_iterator<OtherValue, Container> const& other,
typename boost::enable_if<boost::is_convertible<OtherValue*, Value*>,
enabler>::type = enabler())
: path_iterator::iterator_adaptor_(other.base()) {}
typename boost::enable_if<boost::is_convertible<OtherValue*, Value*>,
enabler>::type = enabler())
: path_iterator::iterator_adaptor_(other.base()) {}
private:

View file

@ -28,18 +28,18 @@
namespace mapnik { namespace svg {
template <typename PathType>
bool parse_path(const char * wkt, PathType & p);
template <typename PathType>
bool parse_path(const char * wkt, PathType & p);
template <typename PathType>
bool parse_points(const char * wkt, PathType & p);
template <typename PathType>
bool parse_points(const char * wkt, PathType & p);
template <typename TransformType>
bool MAPNIK_DECL parse_transform(const char * wkt, TransformType & tr);
template <typename TransformType>
bool MAPNIK_DECL parse_transform(const char * wkt, TransformType & tr);
//template <typename TransformType>
//bool MAPNIK_DECL parse_transform(std::string const& wkt, TransformType & tr);
}}
}}
#endif // MAPNIK_SVG_PATH_PARSER_HPP

View file

@ -117,13 +117,13 @@ public:
template <typename Rasterizer, typename Scanline, typename Renderer>
void render_gradient(Rasterizer& ras,
Scanline& sl,
Renderer& ren,
const gradient &grad,
agg::trans_affine const& mtx,
double opacity,
const box2d<double> &symbol_bbox,
const box2d<double> &path_bbox)
Scanline& sl,
Renderer& ren,
const gradient &grad,
agg::trans_affine const& mtx,
double opacity,
const box2d<double> &symbol_bbox,
const box2d<double> &path_bbox)
{
typedef agg::gamma_lut<agg::int8u, agg::int8u> gamma_lut_type;
typedef agg::gradient_lut<agg::color_interpolator<agg::rgba8>, 1024> color_func_type;
@ -181,9 +181,9 @@ public:
{
typedef agg::gradient_radial_focus gradient_adaptor_type;
typedef agg::span_gradient<agg::rgba8,
interpolator_type,
gradient_adaptor_type,
color_func_type> span_gradient_type;
interpolator_type,
gradient_adaptor_type,
color_func_type> span_gradient_type;
// the agg radial gradient assumes it is centred on 0
transform.translate(-x2,-y2);
@ -201,9 +201,9 @@ public:
gradient_adaptor_type gradient_adaptor(radius,(x1-x2),(y1-y2));
span_gradient_type span_gradient(span_interpolator,
gradient_adaptor,
m_gradient_lut,
0, radius);
gradient_adaptor,
m_gradient_lut,
0, radius);
render_scanlines_aa(ras, sl, ren, m_alloc, span_gradient);
}
@ -211,9 +211,9 @@ public:
{
typedef linear_gradient_from_segment gradient_adaptor_type;
typedef agg::span_gradient<agg::rgba8,
interpolator_type,
gradient_adaptor_type,
color_func_type> span_gradient_type;
interpolator_type,
gradient_adaptor_type,
color_func_type> span_gradient_type;
// scale everything up since agg turns things into integers a bit too soon
int scaleup=255;
@ -228,9 +228,9 @@ public:
gradient_adaptor_type gradient_adaptor(x1,y1,x2,y2);
span_gradient_type span_gradient(span_interpolator,
gradient_adaptor,
m_gradient_lut,
0, scaleup);
gradient_adaptor,
m_gradient_lut,
0, scaleup);
render_scanlines_aa(ras, sl, ren, m_alloc, span_gradient);
}
@ -342,12 +342,12 @@ public:
template <typename Rasterizer, typename Scanline, typename Renderer>
void render_id(Rasterizer& ras,
Scanline& sl,
Renderer& ren,
int feature_id,
agg::trans_affine const& mtx,
double opacity,
const box2d<double> &symbol_bbox)
Scanline& sl,
Renderer& ren,
int feature_id,
agg::trans_affine const& mtx,
double opacity,
const box2d<double> &symbol_bbox)
{
using namespace agg;

View file

@ -166,14 +166,14 @@ namespace mapnik { namespace svg {
// commented as this does not appear used and crashes clang when used with pch
/*
struct print_action
{
template <typename T>
void operator()(T const& c, qi::unused_type, qi::unused_type) const
{
std::cerr << typeid(c).name() << std::endl;
}
};
struct print_action
{
template <typename T>
void operator()(T const& c, qi::unused_type, qi::unused_type) const
{
std::cerr << typeid(c).name() << std::endl;
}
};
*/
template <typename Iterator, typename SkipType, typename TransformType>

View file

@ -34,114 +34,114 @@
namespace mapnik
{
// parameterized with the type of output iterator it will use for output.
// output iterators add more flexibility than streams, because iterators
// can target many other output destinations besides streams.
template <typename OutputIterator>
class MAPNIK_DECL svg_renderer : public feature_style_processor<svg_renderer<OutputIterator> >,
private boost::noncopyable
// parameterized with the type of output iterator it will use for output.
// output iterators add more flexibility than streams, because iterators
// can target many other output destinations besides streams.
template <typename OutputIterator>
class MAPNIK_DECL svg_renderer : public feature_style_processor<svg_renderer<OutputIterator> >,
private boost::noncopyable
{
public:
svg_renderer(Map const& m, OutputIterator& output_iterator, unsigned offset_x=0, unsigned offset_y=0);
~svg_renderer();
void start_map_processing(Map const& map);
void end_map_processing(Map const& map);
void start_layer_processing(layer const& lay);
void end_layer_processing(layer const& lay);
/*!
* @brief Overloads that process each kind of symbolizer individually.
*/
void process(point_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(line_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(line_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(polygon_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(polygon_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(raster_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(shield_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(text_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(building_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(markers_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
/*!
* @brief Overload that process the whole set of symbolizers of a rule.
* @return true, meaning that this renderer can process multiple symbolizers.
*/
bool process(rule::symbolizers const& syms,
Feature const& feature,
proj_transform const& prj_trans);
void painted(bool painted)
{
public:
svg_renderer(Map const& m, OutputIterator& output_iterator, unsigned offset_x=0, unsigned offset_y=0);
~svg_renderer();
// nothing to do
}
void start_map_processing(Map const& map);
void end_map_processing(Map const& map);
void start_layer_processing(layer const& lay);
void end_layer_processing(layer const& lay);
inline OutputIterator& get_output_iterator()
{
return output_iterator_;
}
/*!
* @brief Overloads that process each kind of symbolizer individually.
*/
void process(point_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(line_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(line_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(polygon_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(polygon_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(raster_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(shield_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(text_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(building_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
void process(markers_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
inline const OutputIterator& get_output_iterator() const
{
return output_iterator_;
}
/*!
* @brief Overload that process the whole set of symbolizers of a rule.
* @return true, meaning that this renderer can process multiple symbolizers.
*/
bool process(rule::symbolizers const& syms,
Feature const& feature,
proj_transform const& prj_trans);
private:
OutputIterator& output_iterator_;
const int width_;
const int height_;
CoordTransform t_;
svg::svg_generator<OutputIterator> generator_;
svg::path_output_attributes path_attributes_;
bool painted_;
void painted(bool painted)
{
// nothing to do
}
inline OutputIterator& get_output_iterator()
{
return output_iterator_;
}
inline const OutputIterator& get_output_iterator() const
{
return output_iterator_;
}
private:
OutputIterator& output_iterator_;
const int width_;
const int height_;
CoordTransform t_;
svg::svg_generator<OutputIterator> generator_;
svg::path_output_attributes path_attributes_;
bool painted_;
/*!
* @brief Visitor that makes the calls to process each symbolizer when stored in a boost::variant.
* This object follows the model of that found in feature_style_processor. It appears here, because
* the logic that iterates over the set of symbolizer has been moved to an SVG renderer's internal
* method.
*/
struct symbol_dispatch : public boost::static_visitor<>
{
symbol_dispatch(svg_renderer<OutputIterator>& processor,
Feature const& feature,
proj_transform const& prj_trans)
/*!
* @brief Visitor that makes the calls to process each symbolizer when stored in a boost::variant.
* This object follows the model of that found in feature_style_processor. It appears here, because
* the logic that iterates over the set of symbolizer has been moved to an SVG renderer's internal
* method.
*/
struct symbol_dispatch : public boost::static_visitor<>
{
symbol_dispatch(svg_renderer<OutputIterator>& processor,
Feature const& feature,
proj_transform const& prj_trans)
: processor_(processor),
feature_(feature),
prj_trans_(prj_trans) {}
template <typename Symbolizer>
void operator()(Symbolizer const& sym) const
{
processor_.process(sym, feature_, prj_trans_);
}
template <typename Symbolizer>
void operator()(Symbolizer const& sym) const
{
processor_.process(sym, feature_, prj_trans_);
}
svg_renderer<OutputIterator>& processor_;
Feature const& feature_;
proj_transform const& prj_trans_;
};
svg_renderer<OutputIterator>& processor_;
Feature const& feature_;
proj_transform const& prj_trans_;
};
};
}
#endif // MAPNIK_SVG_RENDERER_HPP

View file

@ -37,51 +37,51 @@ namespace mapnik
class Map;
class MAPNIK_DECL symbolizer_base {
public:
symbolizer_base():
properties_(),
properties_complete_(),
writer_name_(),
writer_ptr_() {}
public:
symbolizer_base():
properties_(),
properties_complete_(),
writer_name_(),
writer_ptr_() {}
/** Add a metawriter to this symbolizer using a name. */
void add_metawriter(std::string const& name, metawriter_properties const& properties);
/** Add a metawriter to this symbolizer using a pointer.
* The name is only needed if you intend to call save_map() some time.
* You don't need to call cache_metawriters() when using this function.
* Call this function with an NULL writer_ptr to remove a metawriter.
*/
void add_metawriter(metawriter_ptr writer_ptr,
metawriter_properties const& properties = metawriter_properties(),
std::string const& name = "");
/** Cache metawriter objects to avoid repeated lookups while processing.
*
* If the metawriter was added using a symbolic name (instead of a pointer)
* this function has to be called before the symbolizer is used, because
* the map object is not available in renderer::apply() to resolve the reference.
*/
void cache_metawriters(Map const &m);
/** Get the metawriter associated with this symbolizer or a NULL pointer if none exists.
*
* This functions requires that cache_metawriters() was called first.
*/
metawriter_with_properties get_metawriter() const;
/** Get metawriter properties.
* This functions returns the default attributes of the
* metawriter + symbolizer specific attributes.
* \note This function is a helperfunction for class attribute_collector.
*/
metawriter_properties const& get_metawriter_properties() const { return properties_complete_; }
/** Get metawriter properties which only apply to this symbolizer.
*/
metawriter_properties const& get_metawriter_properties_overrides() const { return properties_; }
/** Get metawriter name. */
std::string const& get_metawriter_name() const { return writer_name_; }
private:
metawriter_properties properties_;
metawriter_properties properties_complete_;
std::string writer_name_;
metawriter_ptr writer_ptr_;
/** Add a metawriter to this symbolizer using a name. */
void add_metawriter(std::string const& name, metawriter_properties const& properties);
/** Add a metawriter to this symbolizer using a pointer.
* The name is only needed if you intend to call save_map() some time.
* You don't need to call cache_metawriters() when using this function.
* Call this function with an NULL writer_ptr to remove a metawriter.
*/
void add_metawriter(metawriter_ptr writer_ptr,
metawriter_properties const& properties = metawriter_properties(),
std::string const& name = "");
/** Cache metawriter objects to avoid repeated lookups while processing.
*
* If the metawriter was added using a symbolic name (instead of a pointer)
* this function has to be called before the symbolizer is used, because
* the map object is not available in renderer::apply() to resolve the reference.
*/
void cache_metawriters(Map const &m);
/** Get the metawriter associated with this symbolizer or a NULL pointer if none exists.
*
* This functions requires that cache_metawriters() was called first.
*/
metawriter_with_properties get_metawriter() const;
/** Get metawriter properties.
* This functions returns the default attributes of the
* metawriter + symbolizer specific attributes.
* \note This function is a helperfunction for class attribute_collector.
*/
metawriter_properties const& get_metawriter_properties() const { return properties_complete_; }
/** Get metawriter properties which only apply to this symbolizer.
*/
metawriter_properties const& get_metawriter_properties_overrides() const { return properties_; }
/** Get metawriter name. */
std::string const& get_metawriter_name() const { return writer_name_; }
private:
metawriter_properties properties_;
metawriter_properties properties_complete_;
std::string writer_name_;
metawriter_ptr writer_ptr_;
};
typedef boost::array<double,6> transform_type;

View file

@ -37,7 +37,7 @@
namespace mapnik {
/** Helper object that does all the TextSymbolizer placment finding
* work except actually rendering the object. */
* work except actually rendering the object. */
template <typename FaceManagerT, typename DetectorT>
class text_symbolizer_helper
{
@ -62,20 +62,20 @@ public:
text_(font_manager, scale_factor),
angle_(0.0),
placement_valid_(true)
{
initialize_geometries();
if (!geometries_to_process_.size()) return; //TODO: Test this
placement_ = sym_.get_placement_options()->get_placement_info(
scale_factor, std::make_pair(width, height), false);
//TODO: has_dimensions? Why? When?
if (writer_.first) placement_->collect_extents = true;
next_placement();
initialize_points();
}
{
initialize_geometries();
if (!geometries_to_process_.size()) return; //TODO: Test this
placement_ = sym_.get_placement_options()->get_placement_info(
scale_factor, std::make_pair(width, height), false);
//TODO: has_dimensions? Why? When?
if (writer_.first) placement_->collect_extents = true;
next_placement();
initialize_points();
}
/** Return next placement.
* If no more placements are found returns null pointer.
*/
* If no more placements are found returns null pointer.
*/
text_placement_info_ptr get_placement();
text_placement_info_ptr get_point_placement();
text_placement_info_ptr get_line_placement();

View file

@ -105,8 +105,8 @@ public:
bool has_line_breaks() const
{
UChar break_char = '\n';
return (text_.indexOf(break_char) >= 0);
UChar break_char = '\n';
return (text_.indexOf(break_char) >= 0);
}
/** Resets object to initial state. */

View file

@ -90,7 +90,7 @@ struct text_symbolizer_properties
/** Get format tree. */
formating::node_ptr format_tree() const;
/** Get a list of all expressions used in any placement.
* This function is used to collect attributes. */
* This function is used to collect attributes. */
std::set<expression_ptr> get_all_expressions() const;
//Per symbolizer options
@ -158,13 +158,13 @@ public:
/** Constructor. Takes the parent text_placements object as a parameter
* to read defaults from it. */
text_placement_info(text_placements const* parent,
double scale_factor_, dimension_type dim, bool has_dimensions_);
double scale_factor_, dimension_type dim, bool has_dimensions_);
/** Get next placement.
* This function is also called before the first placement is tried.
* Each class has to return at least one position!
* If this functions returns false the placement data should be
* considered invalid!
*/
* This function is also called before the first placement is tried.
* Each class has to return at least one position!
* If this functions returns false the placement data should be
* considered invalid!
*/
virtual bool next()=0;
virtual ~text_placement_info() {}
/** Initialize values used by placement finder. Only has to be done once
@ -191,7 +191,7 @@ public:
double get_actual_label_spacing() { return scale_factor * properties.label_spacing; }
/** Get minimum distance taking the scale factor into account. */
double get_actual_minimum_distance() { return scale_factor * properties.minimum_distance; }
/** Get minimum padding taking the scale factor into account. */
/** Get minimum padding taking the scale factor into account. */
double get_actual_minimum_padding() { return scale_factor * properties.minimum_padding; }
/** Collect a bounding box of all texts placed. */
@ -200,9 +200,9 @@ public:
/** Bounding box of all texts placed. */
box2d<double> extents;
/** Additional boxes to take into account when finding placement.
* Used for finding line placements where multiple placements are returned.
* Boxes are relative to starting point of current placement.
*/
* Used for finding line placements where multiple placements are returned.
* Boxes are relative to starting point of current placement.
*/
std::vector<box2d<double> > additional_boxes;
/* TODO */
@ -223,23 +223,23 @@ class text_placements
public:
text_placements();
/** Get a text_placement_info object to use in rendering.
* The returned object creates a list of settings which is
* used to try to find a placement and stores all
* information that is generated by
* the placement finder.
*
* This function usually is implemented as
* text_placement_info_ptr text_placements_XXX::get_placement_info() const
* {
* return text_placement_info_ptr(new text_placement_info_XXX(this));
* }
*/
* The returned object creates a list of settings which is
* used to try to find a placement and stores all
* information that is generated by
* the placement finder.
*
* This function usually is implemented as
* text_placement_info_ptr text_placements_XXX::get_placement_info() const
* {
* return text_placement_info_ptr(new text_placement_info_XXX(this));
* }
*/
virtual text_placement_info_ptr get_placement_info(
double scale_factor_, dimension_type dim,
bool has_dimensions_) const =0;
/** Get a list of all expressions used in any placement.
* This function is used to collect attributes.
*/
* This function is used to collect attributes.
*/
virtual std::set<expression_ptr> get_all_expressions();
/** Destructor. */
@ -269,9 +269,9 @@ class MAPNIK_DECL text_placement_info_dummy : public text_placement_info
{
public:
text_placement_info_dummy(text_placements_dummy const* parent,
double scale_factor, dimension_type dim, bool has_dimensions)
double scale_factor, dimension_type dim, bool has_dimensions)
: text_placement_info(parent, scale_factor, dim, has_dimensions),
state(0), parent_(parent) {}
state(0), parent_(parent) {}
bool next();
private:
unsigned state;

View file

@ -45,12 +45,12 @@ private:
};
/** List placement strategy.
* See parent class for documentation of each function. */
* See parent class for documentation of each function. */
class text_placement_info_list : public text_placement_info
{
public:
text_placement_info_list(text_placements_list const* parent,
double scale_factor, dimension_type dim, bool has_dimensions) :
double scale_factor, dimension_type dim, bool has_dimensions) :
text_placement_info(parent, scale_factor, dim, has_dimensions),
state(0), parent_(parent) {}
bool next();

View file

@ -61,12 +61,12 @@ private:
};
/** Simple placement strategy.
* See parent class for documentation of each function. */
* See parent class for documentation of each function. */
class text_placement_info_simple : public text_placement_info
{
public:
text_placement_info_simple(text_placements_simple const* parent,
double scale_factor, dimension_type dim, bool has_dimensions)
double scale_factor, dimension_type dim, bool has_dimensions)
: text_placement_info(parent, scale_factor, dim, has_dimensions),
state(0), position_state(0), parent_(parent)
{

View file

@ -54,10 +54,10 @@ struct MAPNIK_DECL text_symbolizer : public symbolizer_base
text_symbolizer(expression_ptr name, std::string const& face_name,
float size, color const& fill,
text_placements_ptr placements = text_placements_ptr(new text_placements_dummy)
);
);
text_symbolizer(expression_ptr name, float size, color const& fill,
text_placements_ptr placements = text_placements_ptr(new text_placements_dummy)
);
);
text_symbolizer(text_symbolizer const& rhs);
text_symbolizer& operator=(text_symbolizer const& rhs);
expression_ptr get_name() const func_deprecated;

View file

@ -30,14 +30,14 @@
extern "C"
{
#ifdef HAVE_GEOTIFF
#include <xtiffio.h>
#include <geotiffio.h>
#define RealTIFFOpen XTIFFClientOpen
#define RealTIFFClose XTIFFClose
#include <xtiffio.h>
#include <geotiffio.h>
#define RealTIFFOpen XTIFFClientOpen
#define RealTIFFClose XTIFFClose
#else
#include <tiffio.h>
#define RealTIFFOpen TIFFClientOpen
#define RealTIFFClose TIFFClose
#include <tiffio.h>
#define RealTIFFOpen TIFFClientOpen
#define RealTIFFClose TIFFClose
#endif
}
@ -139,15 +139,15 @@ void save_as_tiff(T1 & file, T2 const& image)
// TODO - handle palette images
// std::vector<mapnik::rgb> const& palette
/*
unsigned short r[256], g[256], b[256];
for (int i = 0; i < (1 << 24); ++i)
{
r[i] = (unsigned short)palette[i * 3 + 0] << 8;
g[i] = (unsigned short)palette[i * 3 + 1] << 8;
b[i] = (unsigned short)palette[i * 3 + 2] << 8;
}
TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);
TIFFSetField(output, TIFFTAG_COLORMAP, r, g, b);
unsigned short r[256], g[256], b[256];
for (int i = 0; i < (1 << 24); ++i)
{
r[i] = (unsigned short)palette[i * 3 + 0] << 8;
g[i] = (unsigned short)palette[i * 3 + 1] << 8;
b[i] = (unsigned short)palette[i * 3 + 2] << 8;
}
TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);
TIFFSetField(output, TIFFTAG_COLORMAP, r, g, b);
*/
#ifdef HAVE_GEOTIFF

View file

@ -87,9 +87,9 @@ class progress_timer : public timer
{
public:
progress_timer(std::ostream & os, std::string const& base_message):
os_(os),
base_message_(base_message)
{}
os_(os),
base_message_(base_message)
{}
~progress_timer()
{

View file

@ -36,35 +36,35 @@
namespace boost { namespace spirit { namespace traits {
template <>
struct is_container<mapnik::geometry_type const> : mpl::true_ {} ;
template <>
struct is_container<mapnik::geometry_type const> : mpl::true_ {} ;
template <>
struct container_iterator<mapnik::geometry_type const>
{
typedef mapnik::util::vertex_iterator<double> type;
};
template <>
struct container_iterator<mapnik::geometry_type const>
{
typedef mapnik::util::vertex_iterator<double> type;
};
template <>
struct begin_container<mapnik::geometry_type const>
{
static mapnik::util::vertex_iterator<double>
call (mapnik::geometry_type const& g)
{
return mapnik::util::vertex_iterator<double>(g.data());
}
};
template <>
struct begin_container<mapnik::geometry_type const>
{
static mapnik::util::vertex_iterator<double>
call (mapnik::geometry_type const& g)
{
return mapnik::util::vertex_iterator<double>(g.data());
}
};
template <>
struct end_container<mapnik::geometry_type const>
{
static mapnik::util::vertex_iterator<double>
call (mapnik::geometry_type const& g)
{
return mapnik::util::vertex_iterator<double>();
}
};
template <>
struct end_container<mapnik::geometry_type const>
{
static mapnik::util::vertex_iterator<double>
call (mapnik::geometry_type const& g)
{
return mapnik::util::vertex_iterator<double>();
}
};
}}}
}}}
#endif // CONTAINER_ADAPTER_HPP

View file

@ -30,8 +30,8 @@
namespace mapnik { namespace util {
// poor man deepcopy implementation
void deepcopy(Map const& map_in, Map & map_out);
void deepcopy(Map const& map_in, Map & map_out);
}}
}}
#endif // MAPNIK_DEEPSOPY_HPP

View file

@ -44,102 +44,102 @@
namespace mapnik { namespace util {
namespace karma = boost::spirit::karma;
namespace phoenix = boost::phoenix;
namespace karma = boost::spirit::karma;
namespace phoenix = boost::phoenix;
namespace detail {
struct get_type
{
template <typename T>
struct result { typedef int type; };
int operator() (geometry_type const& geom) const
namespace detail {
struct get_type
{
return (int)geom.type();
}
};
template <typename T>
struct result { typedef int type; };
struct get_first
{
template <typename T>
struct result { typedef geometry_type::value_type const type; };
int operator() (geometry_type const& geom) const
{
return (int)geom.type();
}
};
geometry_type::value_type const operator() (geometry_type const& geom) const
struct get_first
{
geometry_type::value_type coord;
boost::get<0>(coord) = geom.get_vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
template <typename T>
struct result { typedef geometry_type::value_type const type; };
geometry_type::value_type const operator() (geometry_type const& geom) const
{
geometry_type::value_type coord;
boost::get<0>(coord) = geom.get_vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
}
};
template <typename T>
struct coordinate_policy : karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6u ;}
};
}
};
template <typename T>
struct coordinate_policy : karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6u ;}
};
}
template <typename OutputIterator>
struct svg_generator :
template <typename OutputIterator>
struct svg_generator :
karma::grammar<OutputIterator, geometry_type const& ()>
{
svg_generator()
: svg_generator::base_type(svg)
{
using boost::spirit::karma::uint_;
using boost::spirit::karma::_val;
using boost::spirit::karma::_1;
using boost::spirit::karma::lit;
using boost::spirit::karma::_a;
svg = point | linestring | polygon
;
svg_generator()
: svg_generator::base_type(svg)
{
using boost::spirit::karma::uint_;
using boost::spirit::karma::_val;
using boost::spirit::karma::_1;
using boost::spirit::karma::lit;
using boost::spirit::karma::_a;
point = &uint_(mapnik::Point)[_1 = _type(_val)]
<< svg_point [_1 = _first(_val)]
;
svg = point | linestring | polygon
;
svg_point = &uint_
<< lit("cx=\"") << coord_type
<< lit("\" cy=\"") << coord_type
<< lit('\"')
;
point = &uint_(mapnik::Point)[_1 = _type(_val)]
<< svg_point [_1 = _first(_val)]
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< svg_path
;
svg_point = &uint_
<< lit("cx=\"") << coord_type
<< lit("\" cy=\"") << coord_type
<< lit('\"')
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
<< svg_path
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< svg_path
;
svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M')
| &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ])
<< lit(' ') << coord_type << lit(' ') << coord_type) % lit(' ')
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
<< svg_path
;
svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M')
| &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ])
<< lit(' ') << coord_type << lit(' ') << coord_type) % lit(' ')
;
}
// rules
karma::rule<OutputIterator, geometry_type const& ()> svg;
karma::rule<OutputIterator, geometry_type const& ()> point;
karma::rule<OutputIterator, geometry_type const& ()> linestring;
karma::rule<OutputIterator, geometry_type const& ()> polygon;
}
// rules
karma::rule<OutputIterator, geometry_type const& ()> svg;
karma::rule<OutputIterator, geometry_type const& ()> point;
karma::rule<OutputIterator, geometry_type const& ()> linestring;
karma::rule<OutputIterator, geometry_type const& ()> polygon;
karma::rule<OutputIterator, geometry_type::value_type ()> svg_point;
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> svg_path;
karma::rule<OutputIterator, geometry_type::value_type ()> svg_point;
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> svg_path;
// phoenix functions
phoenix::function<detail::get_type > _type;
phoenix::function<detail::get_first> _first;
//
karma::real_generator<double, detail::coordinate_policy<double> > coord_type;
// phoenix functions
phoenix::function<detail::get_type > _type;
phoenix::function<detail::get_first> _first;
//
karma::real_generator<double, detail::coordinate_policy<double> > coord_type;
};
};
}}

View file

@ -35,32 +35,32 @@
namespace mapnik { namespace util {
void to_ds_type(mapnik::geometry_container const& paths,
boost::optional<mapnik::datasource::geometry_t> & result)
{
if (paths.size() == 1)
void to_ds_type(mapnik::geometry_container const& paths,
boost::optional<mapnik::datasource::geometry_t> & result)
{
result.reset(static_cast<mapnik::datasource::geometry_t>(paths.front().type()));
}
else if (paths.size() > 1)
{
int multi_type = 0;
geometry_container::const_iterator itr = paths.begin();
geometry_container::const_iterator end = paths.end();
for ( ; itr!=end; ++itr)
if (paths.size() == 1)
{
int type = static_cast<int>(itr->type());
if (multi_type > 0 && multi_type != type)
result.reset(static_cast<mapnik::datasource::geometry_t>(paths.front().type()));
}
else if (paths.size() > 1)
{
int multi_type = 0;
geometry_container::const_iterator itr = paths.begin();
geometry_container::const_iterator end = paths.end();
for ( ; itr!=end; ++itr)
{
result.reset(datasource::Collection);
int type = static_cast<int>(itr->type());
if (multi_type > 0 && multi_type != type)
{
result.reset(datasource::Collection);
}
multi_type = type;
result.reset(static_cast<mapnik::datasource::geometry_t>(type));
}
multi_type = type;
result.reset(static_cast<mapnik::datasource::geometry_t>(type));
}
}
}
}}
}}
#endif // MAPNIK_GEOMETRY_TO_DS_TYPE

View file

@ -39,238 +39,238 @@
namespace mapnik { namespace util {
std::string to_hex(const char* blob, unsigned size)
{
std::string buf;
buf.reserve(size*2);
std::ostringstream s(buf);
s.seekp(0);
char hex[3];
std::memset(hex,0,3);
for ( unsigned pos=0; pos < size; ++pos)
std::string to_hex(const char* blob, unsigned size)
{
std::sprintf (hex, "%02x", int(blob[pos]) & 0xff);
s << hex;
std::string buf;
buf.reserve(size*2);
std::ostringstream s(buf);
s.seekp(0);
char hex[3];
std::memset(hex,0,3);
for ( unsigned pos=0; pos < size; ++pos)
{
std::sprintf (hex, "%02x", int(blob[pos]) & 0xff);
s << hex;
}
return s.str();
}
return s.str();
}
enum wkbByteOrder {
wkbXDR=0,
wkbNDR=1
};
enum wkbByteOrder {
wkbXDR=0,
wkbNDR=1
};
inline void reverse_bytes(char size, char *address)
{
char * first = address;
char * last = first + size - 1;
for(;first < last;++first, --last)
inline void reverse_bytes(char size, char *address)
{
char x = *last;
*last = *first;
*first = x;
char * first = address;
char * last = first + size - 1;
for(;first < last;++first, --last)
{
char x = *last;
*last = *first;
*first = x;
}
}
}
template <typename S, typename T>
inline void write (S & stream, T val, std::size_t size, wkbByteOrder byte_order)
{
template <typename S, typename T>
inline void write (S & stream, T val, std::size_t size, wkbByteOrder byte_order)
{
#ifdef MAPNIK_BIG_ENDIAN
bool need_swap = byte_order ? wkbNDR : wkbXDR;
bool need_swap = byte_order ? wkbNDR : wkbXDR;
#else
bool need_swap = byte_order ? wkbXDR : wkbNDR;
bool need_swap = byte_order ? wkbXDR : wkbNDR;
#endif
char* buf = reinterpret_cast<char*>(&val);
if (need_swap)
{
reverse_bytes(size,buf);
}
stream.write(buf,size);
}
struct wkb_buffer
{
wkb_buffer(std::size_t size)
: size_(size),
data_( (size_!=0) ? static_cast<char*>(::operator new (size_)):0)
{}
~wkb_buffer()
{
::operator delete(data_);
char* buf = reinterpret_cast<char*>(&val);
if (need_swap)
{
reverse_bytes(size,buf);
}
stream.write(buf,size);
}
inline std::size_t size() const
struct wkb_buffer
{
return size_;
}
wkb_buffer(std::size_t size)
: size_(size),
data_( (size_!=0) ? static_cast<char*>(::operator new (size_)):0)
{}
inline char* buffer()
~wkb_buffer()
{
::operator delete(data_);
}
inline std::size_t size() const
{
return size_;
}
inline char* buffer()
{
return data_;
}
std::size_t size_;
char * data_;
};
typedef boost::shared_ptr<wkb_buffer> wkb_buffer_ptr;
wkb_buffer_ptr to_point_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
return data_;
}
std::size_t size_;
char * data_;
};
typedef boost::shared_ptr<wkb_buffer> wkb_buffer_ptr;
wkb_buffer_ptr to_point_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
assert(g.num_points() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Point);
write(ss,type,4,byte_order);
double x,y;
g.get_vertex(0,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
return wkb;
}
wkb_buffer_ptr to_line_string_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.num_points();
assert(num_points > 1);
std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::LineString);
write(ss,type,4,byte_order);
write(ss,num_points,4,byte_order);
double x,y;
for (unsigned i=0; i< num_points; ++i)
{
g.get_vertex(i,&x,&y);
assert(g.num_points() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Point);
write(ss,type,4,byte_order);
double x,y;
g.get_vertex(0,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
return wkb;
}
assert(ss.good());
return wkb;
}
wkb_buffer_ptr to_polygon_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
unsigned num_points = g.num_points();
assert(num_points > 1);
typedef std::pair<double,double> point_type;
typedef std::vector<point_type> linear_ring;
boost::ptr_vector<linear_ring> rings;
double x,y;
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i)
wkb_buffer_ptr to_line_string_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
unsigned command = g.get_vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
size += 4; // num_points
}
rings.back().push_back(std::make_pair(x,y));
size += 2 * 8; // point
}
unsigned num_rings = rings.size();
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Polygon);
write(ss,type,4,byte_order);
write(ss,num_rings,4,byte_order);
BOOST_FOREACH ( linear_ring const& ring, rings)
{
unsigned num_points = ring.size();
unsigned num_points = g.num_points();
assert(num_points > 1);
std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::LineString);
write(ss,type,4,byte_order);
write(ss,num_points,4,byte_order);
BOOST_FOREACH ( point_type const& pt, ring)
double x,y;
for (unsigned i=0; i< num_points; ++i)
{
double x = pt.first;
double y = pt.second;
g.get_vertex(i,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
}
assert(ss.good());
return wkb;
}
assert(ss.good());
return wkb;
}
wkb_buffer_ptr to_wkb(geometry_type const& g, wkbByteOrder byte_order )
{
wkb_buffer_ptr wkb;
switch (g.type())
wkb_buffer_ptr to_polygon_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
case mapnik::Point:
wkb = to_point_wkb(g, byte_order);
break;
case mapnik::LineString:
wkb = to_line_string_wkb(g, byte_order);
break;
case mapnik::Polygon:
wkb = to_polygon_wkb(g, byte_order);
break;
default:
break;
}
return wkb;
}
unsigned num_points = g.num_points();
assert(num_points > 1);
wkb_buffer_ptr to_wkb(geometry_container const& paths, wkbByteOrder byte_order )
{
if (paths.size() == 1)
{
// single geometry
return to_wkb(paths.front(), byte_order);
}
typedef std::pair<double,double> point_type;
typedef std::vector<point_type> linear_ring;
boost::ptr_vector<linear_ring> rings;
if (paths.size() > 1)
{
// multi geometry or geometry collection
std::vector<wkb_buffer_ptr> wkb_cont;
bool collection = false;
int multi_type = 0;
size_t multi_size = 1 + 4 + 4;
geometry_container::const_iterator itr = paths.begin();
geometry_container::const_iterator end = paths.end();
for ( ; itr!=end; ++itr)
double x,y;
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i)
{
wkb_buffer_ptr wkb = to_wkb(*itr,byte_order);
multi_size += wkb->size();
int type = static_cast<int>(itr->type());
if (multi_type > 0 && multi_type != itr->type())
collection = true;
multi_type = type;
wkb_cont.push_back(wkb);
unsigned command = g.get_vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
size += 4; // num_points
}
rings.back().push_back(std::make_pair(x,y));
size += 2 * 8; // point
}
unsigned num_rings = rings.size();
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
wkb_buffer_ptr multi_wkb = boost::make_shared<wkb_buffer>(multi_size);
boost::interprocess::bufferstream ss(multi_wkb->buffer(), multi_wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
multi_type = collection ? 7 : multi_type + 3;
write(ss,multi_type, 4, byte_order);
write(ss,paths.size(),4,byte_order);
int type = static_cast<int>(mapnik::Polygon);
write(ss,type,4,byte_order);
write(ss,num_rings,4,byte_order);
BOOST_FOREACH ( wkb_buffer_ptr const& wkb, wkb_cont)
BOOST_FOREACH ( linear_ring const& ring, rings)
{
ss.write(wkb->buffer(),wkb->size());
unsigned num_points = ring.size();
write(ss,num_points,4,byte_order);
BOOST_FOREACH ( point_type const& pt, ring)
{
double x = pt.first;
double y = pt.second;
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
}
}
return multi_wkb;
assert(ss.good());
return wkb;
}
return wkb_buffer_ptr();
}
wkb_buffer_ptr to_wkb(geometry_type const& g, wkbByteOrder byte_order )
{
wkb_buffer_ptr wkb;
}}
switch (g.type())
{
case mapnik::Point:
wkb = to_point_wkb(g, byte_order);
break;
case mapnik::LineString:
wkb = to_line_string_wkb(g, byte_order);
break;
case mapnik::Polygon:
wkb = to_polygon_wkb(g, byte_order);
break;
default:
break;
}
return wkb;
}
wkb_buffer_ptr to_wkb(geometry_container const& paths, wkbByteOrder byte_order )
{
if (paths.size() == 1)
{
// single geometry
return to_wkb(paths.front(), byte_order);
}
if (paths.size() > 1)
{
// multi geometry or geometry collection
std::vector<wkb_buffer_ptr> wkb_cont;
bool collection = false;
int multi_type = 0;
size_t multi_size = 1 + 4 + 4;
geometry_container::const_iterator itr = paths.begin();
geometry_container::const_iterator end = paths.end();
for ( ; itr!=end; ++itr)
{
wkb_buffer_ptr wkb = to_wkb(*itr,byte_order);
multi_size += wkb->size();
int type = static_cast<int>(itr->type());
if (multi_type > 0 && multi_type != itr->type())
collection = true;
multi_type = type;
wkb_cont.push_back(wkb);
}
wkb_buffer_ptr multi_wkb = boost::make_shared<wkb_buffer>(multi_size);
boost::interprocess::bufferstream ss(multi_wkb->buffer(), multi_wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
multi_type = collection ? 7 : multi_type + 3;
write(ss,multi_type, 4, byte_order);
write(ss,paths.size(),4,byte_order);
BOOST_FOREACH ( wkb_buffer_ptr const& wkb, wkb_cont)
{
ss.write(wkb->buffer(),wkb->size());
}
return multi_wkb;
}
return wkb_buffer_ptr();
}
}}
#endif // MAPNIK_GEOMETRY_TO_WKB_HPP

View file

@ -36,27 +36,27 @@
namespace mapnik { namespace util {
namespace karma = boost::spirit::karma;
namespace karma = boost::spirit::karma;
bool to_wkt(std::string & wkt, mapnik::geometry_type const& geom)
{
typedef std::back_insert_iterator<std::string> sink_type;
sink_type sink(wkt);
wkt_generator<sink_type> generator(true);
bool result = karma::generate(sink, generator, geom);
return result;
}
bool to_wkt(std::string & wkt, mapnik::geometry_type const& geom)
{
typedef std::back_insert_iterator<std::string> sink_type;
sink_type sink(wkt);
wkt_generator<sink_type> generator(true);
bool result = karma::generate(sink, generator, geom);
return result;
}
bool to_wkt(std::string & wkt, mapnik::geometry_container const& geom)
{
typedef std::back_insert_iterator<std::string> sink_type;
sink_type sink(wkt);
wkt_multi_generator<sink_type> generator;
bool result = karma::generate(sink, generator, geom);
return result;
}
bool to_wkt(std::string & wkt, mapnik::geometry_container const& geom)
{
typedef std::back_insert_iterator<std::string> sink_type;
sink_type sink(wkt);
wkt_multi_generator<sink_type> generator;
bool result = karma::generate(sink, generator, geom);
return result;
}
}}
}}
#endif // MAPNIK_GEOMETRY_TO_WKT_HPP

View file

@ -46,170 +46,170 @@
namespace boost { namespace spirit { namespace traits {
// make gcc and darwin toolsets happy.
template <>
struct is_container<mapnik::geometry_container>
: mpl::false_
{};
template <>
struct is_container<mapnik::geometry_container>
: mpl::false_
{};
}}}
}}}
namespace mapnik { namespace util {
namespace karma = boost::spirit::karma;
namespace phoenix = boost::phoenix;
namespace karma = boost::spirit::karma;
namespace phoenix = boost::phoenix;
namespace {
namespace {
struct get_type
{
template <typename T>
struct result { typedef int type; };
int operator() (geometry_type const& geom) const
struct get_type
{
return static_cast<int>(geom.type());
}
};
template <typename T>
struct result { typedef int type; };
struct get_first
{
template <typename T>
struct result { typedef geometry_type::value_type const type; };
geometry_type::value_type const operator() (geometry_type const& geom) const
{
geometry_type::value_type coord;
boost::get<0>(coord) = geom.get_vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
}
};
struct multi_geometry_
{
template <typename T>
struct result { typedef bool type; };
bool operator() (geometry_container const& geom) const
{
return geom.size() > 1 ? true : false;
}
};
struct multi_geometry_type
{
template <typename T>
struct result { typedef boost::tuple<unsigned,bool> type; };
boost::tuple<unsigned,bool> operator() (geometry_container const& geom) const
{
unsigned type = 0u;
bool collection = false;
geometry_container::const_iterator itr = geom.begin();
geometry_container::const_iterator end = geom.end();
for ( ; itr != end; ++itr)
int operator() (geometry_type const& geom) const
{
if (type != 0 && itr->type() != type)
{
collection = true;
break;
}
type = itr->type();
return static_cast<int>(geom.type());
}
return boost::tuple<unsigned,bool>(type, collection);
}
};
};
template <typename T>
struct wkt_coordinate_policy : karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6 ;}
};
}
template <typename OutputIterator>
struct wkt_generator :
karma::grammar<OutputIterator, geometry_type const& ()>
{
wkt_generator(bool single = false)
: wkt_generator::base_type(wkt)
struct get_first
{
using boost::spirit::karma::uint_;
using boost::spirit::karma::_val;
using boost::spirit::karma::_1;
using boost::spirit::karma::lit;
using boost::spirit::karma::_a;
using boost::spirit::karma::_r1;
using boost::spirit::karma::eps;
using boost::spirit::karma::string;
template <typename T>
struct result { typedef geometry_type::value_type const type; };
wkt = point | linestring | polygon
;
geometry_type::value_type const operator() (geometry_type const& geom) const
{
geometry_type::value_type coord;
boost::get<0>(coord) = geom.get_vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
}
};
point = &uint_(mapnik::Point)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "Point("]
.else_[_1 = "("]]
<< point_coord [_1 = _first(_val)] << lit(')')
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "LineString("]
.else_[_1 = "("]]
<< coords
<< lit(')')
;
struct multi_geometry_
{
template <typename T>
struct result { typedef bool type; };
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "Polygon("]
.else_[_1 = "("]]
<< coords2
<< lit("))")
;
bool operator() (geometry_container const& geom) const
{
return geom.size() > 1 ? true : false;
}
};
point_coord = &uint_ << coord_type << lit(' ') << coord_type
;
struct multi_geometry_type
{
template <typename T>
struct result { typedef boost::tuple<unsigned,bool> type; };
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
<< string[ if_ (_r1 > 1) [_1 = "),("]
.else_[_1 = "("] ] | &uint_ << ",")
<< coord_type
<< lit(' ')
<< coord_type
;
boost::tuple<unsigned,bool> operator() (geometry_container const& geom) const
{
unsigned type = 0u;
bool collection = false;
coords2 %= *polygon_coord(_a)
;
geometry_container::const_iterator itr = geom.begin();
geometry_container::const_iterator end = geom.end();
coords = point_coord % lit(',')
;
for ( ; itr != end; ++itr)
{
if (type != 0 && itr->type() != type)
{
collection = true;
break;
}
type = itr->type();
}
return boost::tuple<unsigned,bool>(type, collection);
}
};
template <typename T>
struct wkt_coordinate_policy : karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6 ;}
};
}
// rules
karma::rule<OutputIterator, geometry_type const& ()> wkt;
karma::rule<OutputIterator, geometry_type const& ()> point;
karma::rule<OutputIterator, geometry_type const& ()> linestring;
karma::rule<OutputIterator, geometry_type const& ()> polygon;
karma::rule<OutputIterator, geometry_type const& ()> coords;
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
karma::rule<OutputIterator, geometry_type::value_type (unsigned& )> polygon_coord;
template <typename OutputIterator>
struct wkt_generator :
karma::grammar<OutputIterator, geometry_type const& ()>
{
// phoenix functions
phoenix::function<get_type > _type;
phoenix::function<get_first> _first;
//
karma::real_generator<double, wkt_coordinate_policy<double> > coord_type;
wkt_generator(bool single = false)
: wkt_generator::base_type(wkt)
{
using boost::spirit::karma::uint_;
using boost::spirit::karma::_val;
using boost::spirit::karma::_1;
using boost::spirit::karma::lit;
using boost::spirit::karma::_a;
using boost::spirit::karma::_r1;
using boost::spirit::karma::eps;
using boost::spirit::karma::string;
};
wkt = point | linestring | polygon
;
point = &uint_(mapnik::Point)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "Point("]
.else_[_1 = "("]]
<< point_coord [_1 = _first(_val)] << lit(')')
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "LineString("]
.else_[_1 = "("]]
<< coords
<< lit(')')
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "Polygon("]
.else_[_1 = "("]]
<< coords2
<< lit("))")
;
point_coord = &uint_ << coord_type << lit(' ') << coord_type
;
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
<< string[ if_ (_r1 > 1) [_1 = "),("]
.else_[_1 = "("] ] | &uint_ << ",")
<< coord_type
<< lit(' ')
<< coord_type
;
coords2 %= *polygon_coord(_a)
;
coords = point_coord % lit(',')
;
}
// rules
karma::rule<OutputIterator, geometry_type const& ()> wkt;
karma::rule<OutputIterator, geometry_type const& ()> point;
karma::rule<OutputIterator, geometry_type const& ()> linestring;
karma::rule<OutputIterator, geometry_type const& ()> polygon;
karma::rule<OutputIterator, geometry_type const& ()> coords;
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
karma::rule<OutputIterator, geometry_type::value_type (unsigned& )> polygon_coord;
// phoenix functions
phoenix::function<get_type > _type;
phoenix::function<get_first> _first;
//
karma::real_generator<double, wkt_coordinate_policy<double> > coord_type;
};

View file

@ -35,53 +35,53 @@
namespace mapnik { namespace util {
template <typename T>
class vertex_iterator
: public boost::iterator_facade< vertex_iterator<T>,
typename boost::tuple<unsigned,T,T> const,
boost::forward_traversal_tag
>
{
public:
typedef typename boost::tuple<unsigned, T, T> value_type;
typedef vertex_vector<T> container_type;
vertex_iterator()
: v_(SEG_END,0,0)
{}
explicit vertex_iterator(container_type const& vertices)
: vertices_(&vertices),
pos_(0)
template <typename T>
class vertex_iterator
: public boost::iterator_facade< vertex_iterator<T>,
typename boost::tuple<unsigned,T,T> const,
boost::forward_traversal_tag
>
{
increment();
}
private:
friend class boost::iterator_core_access;
public:
typedef typename boost::tuple<unsigned, T, T> value_type;
typedef vertex_vector<T> container_type;
void increment()
{
boost::get<0>(v_) = vertices_->get_vertex(pos_++, &boost::get<1>(v_), &boost::get<2>(v_));
}
vertex_iterator()
: v_(SEG_END,0,0)
{}
bool equal( vertex_iterator const& other) const
{
return boost::get<0>(v_) == boost::get<0>(other.v_);
}
explicit vertex_iterator(container_type const& vertices)
: vertices_(&vertices),
pos_(0)
{
increment();
}
value_type const& dereference() const
{
return v_;
}
private:
friend class boost::iterator_core_access;
container_type const *vertices_;
value_type v_;
unsigned pos_;
};
void increment()
{
boost::get<0>(v_) = vertices_->get_vertex(pos_++, &boost::get<1>(v_), &boost::get<2>(v_));
}
}}
bool equal( vertex_iterator const& other) const
{
return boost::get<0>(v_) == boost::get<0>(other.v_);
}
value_type const& dereference() const
{
return v_;
}
container_type const *vertices_;
value_type v_;
unsigned pos_;
};
}}
#endif // MAPNIK_VERTEX_ITERATOR_HPP

View file

@ -39,160 +39,160 @@
namespace mapnik { namespace wkt {
using namespace boost::spirit;
using namespace boost::fusion;
using namespace boost::phoenix;
using namespace boost::spirit;
using namespace boost::fusion;
using namespace boost::phoenix;
struct push_vertex
{
template <typename T0,typename T1, typename T2, typename T3>
struct result
struct push_vertex
{
typedef void type;
template <typename T0,typename T1, typename T2, typename T3>
struct result
{
typedef void type;
};
template <typename T0,typename T1, typename T2, typename T3>
void operator() (T0 c, T1 path, T2 x, T3 y) const
{
BOOST_ASSERT( path!=0 );
path->push_vertex(x,y,c);
}
};
template <typename T0,typename T1, typename T2, typename T3>
void operator() (T0 c, T1 path, T2 x, T3 y) const
struct cleanup
{
BOOST_ASSERT( path!=0 );
path->push_vertex(x,y,c);
}
};
template <typename T0>
struct result
{
typedef void type;
};
struct cleanup
{
template <typename T0>
struct result
{
typedef void type;
template <typename T0>
void operator() (T0 & path) const
{
if (path) delete path,path=0;
}
};
template <typename T0>
void operator() (T0 & path) const
template <typename Iterator>
struct wkt_grammar : qi::grammar<Iterator, boost::ptr_vector<mapnik::geometry_type>() , ascii::space_type>
{
if (path) delete path,path=0;
}
};
wkt_grammar()
: wkt_grammar::base_type(geometry_tagged_text)
{
using qi::no_case;
using boost::phoenix::push_back;
template <typename Iterator>
struct wkt_grammar : qi::grammar<Iterator, boost::ptr_vector<mapnik::geometry_type>() , ascii::space_type>
{
wkt_grammar()
: wkt_grammar::base_type(geometry_tagged_text)
{
using qi::no_case;
using boost::phoenix::push_back;
geometry_tagged_text = point_tagged_text
| linestring_tagged_text
| polygon_tagged_text
| multipoint_tagged_text
| multilinestring_tagged_text
| multipolygon_tagged_text
;
geometry_tagged_text = point_tagged_text
| linestring_tagged_text
| polygon_tagged_text
| multipoint_tagged_text
| multilinestring_tagged_text
| multipolygon_tagged_text
;
// <point tagged text> ::= point <point text>
point_tagged_text = no_case[lit("POINT")] [ _a = new_<geometry_type>(Point) ]
>> ( point_text(_a) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
// <point tagged text> ::= point <point text>
point_tagged_text = no_case[lit("POINT")] [ _a = new_<geometry_type>(Point) ]
>> ( point_text(_a) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
// <point text> ::= <empty set> | <left paren> <point> <right paren>
point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')'))
| empty_set
;
// <point text> ::= <empty set> | <left paren> <point> <right paren>
point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')'))
| empty_set
;
// <linestring tagged text> ::= linestring <linestring text>
linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_<geometry_type>(LineString) ]
>> (linestring_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
// <linestring tagged text> ::= linestring <linestring text>
linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_<geometry_type>(LineString) ]
>> (linestring_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
// <linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* <right paren>
linestring_text = points(_r1) | empty_set
;
// <linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* <right paren>
linestring_text = points(_r1) | empty_set
;
// <polygon tagged text> ::= polygon <polygon text>
polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_<geometry_type>(Polygon) ]
>> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
// <polygon tagged text> ::= polygon <polygon text>
polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_<geometry_type>(Polygon) ]
>> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
// <polygon text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
polygon_text = (lit('(') >> linestring_text(_r1) % lit(',') >> lit(')')) | empty_set;
// <polygon text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
polygon_text = (lit('(') >> linestring_text(_r1) % lit(',') >> lit(')')) | empty_set;
//<multipoint tagged text> ::= multipoint <multipoint text>
multipoint_tagged_text = no_case[lit("MULTIPOINT")]
>> multipoint_text
;
//<multipoint tagged text> ::= multipoint <multipoint text>
multipoint_tagged_text = no_case[lit("MULTIPOINT")]
>> multipoint_text
;
// <multipoint text> ::= <empty set> | <left paren> <point text> {<comma> <point text>}* <right paren>
multipoint_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Point)]
>> (point_text(_a) | empty_set) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]) % lit(','))
>> lit(')')) | empty_set
;
// <multipoint text> ::= <empty set> | <left paren> <point text> {<comma> <point text>}* <right paren>
multipoint_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Point)]
>> (point_text(_a) | empty_set) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]) % lit(','))
>> lit(')')) | empty_set
;
// <multilinestring tagged text> ::= multilinestring <multilinestring text>
multilinestring_tagged_text = no_case[lit("MULTILINESTRING")]
>> multilinestring_text ;
// <multilinestring tagged text> ::= multilinestring <multilinestring text>
multilinestring_tagged_text = no_case[lit("MULTILINESTRING")]
>> multilinestring_text ;
// <multilinestring text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
multilinestring_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(LineString)]
>> ( points(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]))
% lit(','))
>> lit(')')) | empty_set;
// <multilinestring text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
multilinestring_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(LineString)]
>> ( points(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]))
% lit(','))
>> lit(')')) | empty_set;
// <multipolygon tagged text> ::= multipolygon <multipolygon text>
multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")]
>> multipolygon_text ;
// <multipolygon tagged text> ::= multipolygon <multipolygon text>
multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")]
>> multipolygon_text ;
// <multipolygon text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren>
// <multipolygon text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren>
multipolygon_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Polygon)]
>> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]))
% lit(','))
>> lit(')')) | empty_set;
multipolygon_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Polygon)]
>> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]))
% lit(','))
>> lit(')')) | empty_set;
// points
points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')');
// point
point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)];
// points
points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')');
// point
point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)];
// <empty set>
empty_set = no_case[lit("EMPTY")];
// <empty set>
empty_set = no_case[lit("EMPTY")];
}
}
// start
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> geometry_tagged_text;
// start
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> geometry_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> point_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> linestring_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> polygon_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_tagged_text;
//
qi::rule<Iterator,void(geometry_type*),ascii::space_type> point_text;
qi::rule<Iterator,void(geometry_type*),ascii::space_type> linestring_text;
qi::rule<Iterator,void(geometry_type*),ascii::space_type> polygon_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_text;
//
qi::rule<Iterator,void(CommandType,geometry_type*),ascii::space_type> point;
qi::rule<Iterator,qi::locals<CommandType>,void(geometry_type*),ascii::space_type> points;
qi::rule<Iterator,ascii::space_type> empty_set;
boost::phoenix::function<push_vertex> push_vertex_;
boost::phoenix::function<cleanup> cleanup_;
};
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> point_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> linestring_tagged_text;
qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> polygon_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_tagged_text;
qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_tagged_text;
//
qi::rule<Iterator,void(geometry_type*),ascii::space_type> point_text;
qi::rule<Iterator,void(geometry_type*),ascii::space_type> linestring_text;
qi::rule<Iterator,void(geometry_type*),ascii::space_type> polygon_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_text;
qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_text;
//
qi::rule<Iterator,void(CommandType,geometry_type*),ascii::space_type> point;
qi::rule<Iterator,qi::locals<CommandType>,void(geometry_type*),ascii::space_type> points;
qi::rule<Iterator,ascii::space_type> empty_set;
boost::phoenix::function<push_vertex> push_vertex_;
boost::phoenix::function<cleanup> cleanup_;
};
template <typename Iterator>

View file

@ -100,23 +100,23 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
ras_ptr->reset();
switch (stroke_.get_gamma_method())
{
case GAMMA_POWER:
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
break;
case GAMMA_LINEAR:
ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma()));
break;
case GAMMA_NONE:
ras_ptr->gamma(agg::gamma_none());
break;
case GAMMA_THRESHOLD:
ras_ptr->gamma(agg::gamma_threshold(stroke_.get_gamma()));
break;
case GAMMA_MULTIPLY:
ras_ptr->gamma(agg::gamma_multiply(stroke_.get_gamma()));
break;
default:
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
case GAMMA_POWER:
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
break;
case GAMMA_LINEAR:
ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma()));
break;
case GAMMA_NONE:
ras_ptr->gamma(agg::gamma_none());
break;
case GAMMA_THRESHOLD:
ras_ptr->gamma(agg::gamma_threshold(stroke_.get_gamma()));
break;
case GAMMA_MULTIPLY:
ras_ptr->gamma(agg::gamma_multiply(stroke_.get_gamma()));
break;
default:
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
}
metawriter_with_properties writer = sym.get_metawriter();

View file

@ -98,9 +98,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
vertex_stl_adapter<svg_path_storage> stl_storage((*marker)->source());
svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>,
renderer_solid,
agg::pixfmt_rgba32_plain > svg_renderer(svg_path,(*marker)->attributes());
agg::pod_bvector<path_attributes>,
renderer_solid,
agg::pixfmt_rgba32_plain > svg_renderer(svg_path,(*marker)->attributes());
for (unsigned i=0; i<feature->num_geometries(); ++i)
{

View file

@ -73,23 +73,23 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
ras_ptr->reset();
switch (sym.get_gamma_method())
{
case GAMMA_POWER:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
break;
case GAMMA_LINEAR:
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
break;
case GAMMA_NONE:
ras_ptr->gamma(agg::gamma_none());
break;
case GAMMA_THRESHOLD:
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
break;
case GAMMA_MULTIPLY:
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
break;
default:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
case GAMMA_POWER:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
break;
case GAMMA_LINEAR:
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
break;
case GAMMA_NONE:
ras_ptr->gamma(agg::gamma_none());
break;
case GAMMA_THRESHOLD:
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
break;
case GAMMA_MULTIPLY:
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
break;
default:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
}
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature);

View file

@ -65,23 +65,23 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
ras_ptr->reset();
switch (sym.get_gamma_method())
{
case GAMMA_POWER:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
break;
case GAMMA_LINEAR:
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
break;
case GAMMA_NONE:
ras_ptr->gamma(agg::gamma_none());
break;
case GAMMA_THRESHOLD:
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
break;
case GAMMA_MULTIPLY:
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
break;
default:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
case GAMMA_POWER:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
break;
case GAMMA_LINEAR:
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
break;
case GAMMA_NONE:
ras_ptr->gamma(agg::gamma_none());
break;
case GAMMA_THRESHOLD:
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
break;
case GAMMA_MULTIPLY:
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
break;
default:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
}
metawriter_with_properties writer = sym.get_metawriter();

View file

@ -42,11 +42,11 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
proj_transform const& prj_trans)
{
shield_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_,
t_, font_manager_, *detector_);
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_,
t_, font_manager_, *detector_);
text_renderer<T> ren(pixmap_, font_manager_, *(font_manager_.get_stroker()));

View file

@ -34,11 +34,11 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
proj_transform const& prj_trans)
{
text_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_,
t_, font_manager_, *detector_);
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_,
t_, font_manager_, *detector_);
text_renderer<T> ren(pixmap_, font_manager_, *(font_manager_.get_stroker()));

View file

@ -58,8 +58,8 @@ box2d<T>::box2d(const box2d &rhs)
// copy rather than init so dfl ctor (0,0,-1,-1) is not modified
// http://trac.mapnik.org/ticket/749
/*{
init(rhs.minx_,rhs.miny_,rhs.maxx_,rhs.maxy_);
}*/
init(rhs.minx_,rhs.miny_,rhs.maxx_,rhs.maxy_);
}*/
template <typename T>
#if !defined(__SUNPRO_CC)
@ -319,10 +319,10 @@ inline
#endif
void box2d<T>::clip(const box2d_type& other)
{
minx_ = std::max(minx_,other.minx());
miny_ = std::max(miny_,other.miny());
maxx_ = std::min(maxx_,other.maxx());
maxy_ = std::min(maxy_,other.maxy());
minx_ = std::max(minx_,other.minx());
miny_ = std::max(miny_,other.miny());
maxx_ = std::min(maxx_,other.maxx());
maxy_ = std::min(maxy_,other.maxy());
}

File diff suppressed because it is too large Load diff

View file

@ -87,10 +87,10 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind)
lt_dlerror());
}
// http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
#ifdef __GNUC__
#ifdef __GNUC__
__extension__
#endif
create_ds* create_datasource =
#endif
create_ds* create_datasource =
reinterpret_cast<create_ds*>(lt_dlsym(itr->second->handle(), "create"));
if ( ! create_datasource)
@ -155,49 +155,49 @@ void datasource_cache::register_datasources(const std::string& str)
#if (BOOST_FILESYSTEM_VERSION == 3)
if (!is_directory( *itr ) && is_input_plugin(itr->path().filename().string()))
#else // v2
if (!is_directory( *itr ) && is_input_plugin(itr->path().leaf()))
if (!is_directory( *itr ) && is_input_plugin(itr->path().leaf()))
#endif
{
try
{
#if (BOOST_FILESYSTEM_VERSION == 3)
lt_dlhandle module = lt_dlopen(itr->path().string().c_str());
#else // v2
lt_dlhandle module = lt_dlopen(itr->string().c_str());
#endif
if (module)
try
{
// http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
#ifdef __GNUC__
__extension__
#endif
datasource_name* ds_name =
reinterpret_cast<datasource_name*>(lt_dlsym(module, "datasource_name"));
if (ds_name && insert(ds_name(),module))
#if (BOOST_FILESYSTEM_VERSION == 3)
lt_dlhandle module = lt_dlopen(itr->path().string().c_str());
#else // v2
lt_dlhandle module = lt_dlopen(itr->string().c_str());
#endif
if (module)
{
// http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
#ifdef __GNUC__
__extension__
#endif
datasource_name* ds_name =
reinterpret_cast<datasource_name*>(lt_dlsym(module, "datasource_name"));
if (ds_name && insert(ds_name(),module))
{
#ifdef MAPNIK_DEBUG
std::clog << "Datasource loader: registered: " << ds_name() << std::endl;
std::clog << "Datasource loader: registered: " << ds_name() << std::endl;
#endif
registered_=true;
registered_=true;
}
else if (!ds_name)
{
std::clog << "Problem loading plugin library '" << itr->path().string() << "' (plugin is lacking compatible interface)" << std::endl;
}
}
else if (!ds_name)
else
{
std::clog << "Problem loading plugin library '" << itr->path().string() << "' (plugin is lacking compatible interface)" << std::endl;
#if (BOOST_FILESYSTEM_VERSION == 3)
std::clog << "Problem loading plugin library: " << itr->path().string()
<< " (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI)" << std::endl;
#else // v2
std::clog << "Problem loading plugin library: " << itr->string()
<< " (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI)" << std::endl;
#endif
}
}
else
{
#if (BOOST_FILESYSTEM_VERSION == 3)
std::clog << "Problem loading plugin library: " << itr->path().string()
<< " (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI)" << std::endl;
#else // v2
std::clog << "Problem loading plugin library: " << itr->string()
<< " (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI)" << std::endl;
#endif
}
catch (...) {}
}
catch (...) {}
}
}
}
}

View file

@ -41,8 +41,8 @@ namespace mapnik { namespace util {
// poor man's deepcopy implementation
void deepcopy(Map const& map_in, Map & map_out)
{
void deepcopy(Map const& map_in, Map & map_out)
{
// * width_(rhs.width_),
// * height_(rhs.height_),
// * srs_(rhs.srs_),
@ -60,68 +60,68 @@ void deepcopy(Map const& map_in, Map & map_out)
// extra_attr_(rhs.extra_attr_),
// extra_params_(rhs.extra_params_)
// width, height
map_out.resize(map_in.width(), map_in.height());
// srs
map_out.set_srs(map_in.srs());
// buffer_size
map_out.set_buffer_size(map_in.buffer_size());
// background
boost::optional<color> background = map_in.background();
if (background)
{
map_out.set_background(*background);
}
// background_image
boost::optional<std::string> background_image = map_in.background_image();
if (background_image)
{
map_out.set_background_image(*background_image);
}
// maximum extent
boost::optional<box2d<double> > max_extent = map_in.maximum_extent();
if (max_extent)
{
map_out.set_maximum_extent(*max_extent);
}
// base_path
map_out.set_base_path(map_in.base_path());
// fontsets
typedef std::map<std::string,font_set> fontsets;
BOOST_FOREACH ( fontsets::value_type const& kv,map_in.fontsets())
{
map_out.insert_fontset(kv.first,kv.second);
}
BOOST_FOREACH ( layer const& lyr_in, map_in.layers())
{
layer lyr_out(lyr_in);
datasource_ptr ds_in = lyr_in.datasource();
if (ds_in)
// width, height
map_out.resize(map_in.width(), map_in.height());
// srs
map_out.set_srs(map_in.srs());
// buffer_size
map_out.set_buffer_size(map_in.buffer_size());
// background
boost::optional<color> background = map_in.background();
if (background)
{
parameters p(ds_in->params());
// TODO : re-use datasource extent if already set.
datasource_ptr ds_out = datasource_cache::create(p);
if (ds_out)
{
lyr_out.set_datasource(ds_out);
}
map_out.set_background(*background);
}
// background_image
boost::optional<std::string> background_image = map_in.background_image();
if (background_image)
{
map_out.set_background_image(*background_image);
}
// maximum extent
boost::optional<box2d<double> > max_extent = map_in.maximum_extent();
if (max_extent)
{
map_out.set_maximum_extent(*max_extent);
}
// base_path
map_out.set_base_path(map_in.base_path());
// fontsets
typedef std::map<std::string,font_set> fontsets;
BOOST_FOREACH ( fontsets::value_type const& kv,map_in.fontsets())
{
map_out.insert_fontset(kv.first,kv.second);
}
BOOST_FOREACH ( layer const& lyr_in, map_in.layers())
{
layer lyr_out(lyr_in);
datasource_ptr ds_in = lyr_in.datasource();
if (ds_in)
{
parameters p(ds_in->params());
// TODO : re-use datasource extent if already set.
datasource_ptr ds_out = datasource_cache::create(p);
if (ds_out)
{
lyr_out.set_datasource(ds_out);
}
}
map_out.addLayer(lyr_out);
}
typedef std::map<std::string, feature_type_style> style_cont;
typedef style_cont::value_type value_type;
style_cont const& styles = map_in.styles();
BOOST_FOREACH ( value_type const& kv, styles )
{
feature_type_style const& style_in = kv.second;
feature_type_style style_out(style_in,true); // deep copy
map_out.insert_style(kv.first, style_out);
}
map_out.addLayer(lyr_out);
}
typedef std::map<std::string, feature_type_style> style_cont;
typedef style_cont::value_type value_type;
style_cont const& styles = map_in.styles();
BOOST_FOREACH ( value_type const& kv, styles )
{
feature_type_style const& style_in = kv.second;
feature_type_style style_out(style_in,true); // deep copy
map_out.insert_style(kv.first, style_out);
}
}
}}
}}

View file

@ -35,8 +35,8 @@ IMPLEMENT_ENUM( filter_mode_e, filter_mode_strings )
feature_type_style::feature_type_style()
: filter_mode_(FILTER_ALL),
scale_denom_validity_(-1) {}
: filter_mode_(FILTER_ALL),
scale_denom_validity_(-1) {}
feature_type_style::feature_type_style(feature_type_style const& rhs, bool deep_copy)
: filter_mode_(rhs.filter_mode_),
@ -46,7 +46,7 @@ feature_type_style::feature_type_style(feature_type_style const& rhs, bool deep_
rules_ = rhs.rules_;
} else {
rules::const_iterator it = rhs.rules_.begin(),
end = rhs.rules_.end();
end = rhs.rules_.end();
for(; it != end; ++it) {
rules_.push_back(rule(*it, deep_copy));
}

View file

@ -105,7 +105,7 @@ bool freetype_engine::register_font(std::string const& file_name)
FT_Done_FreeType(library);
std::ostringstream s;
s << "Error: unable to load invalid font file which lacks identifiable family and style name: '"
<< file_name << "'";
<< file_name << "'";
throw std::runtime_error(s.str());
}
}
@ -390,30 +390,30 @@ void text_renderer<T>::render(double x0, double y0)
// now render transformed glyphs
typename glyphs_t::iterator pos;
for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos)
for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos)
{
double halo_radius = pos->properties->halo_radius;
//make sure we've got reasonable values.
if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
stroker_.init(halo_radius);
FT_Glyph g;
error = FT_Glyph_Copy(pos->image, &g);
if (!error)
{
double halo_radius = pos->properties->halo_radius;
//make sure we've got reasonable values.
if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
stroker_.init(halo_radius);
FT_Glyph g;
error = FT_Glyph_Copy(pos->image, &g);
if (!error)
FT_Glyph_Transform(g,0,&start);
FT_Glyph_Stroke(&g,stroker_.get(),1);
error = FT_Glyph_To_Bitmap( &g,FT_RENDER_MODE_NORMAL,0,1);
if ( ! error )
{
FT_Glyph_Transform(g,0,&start);
FT_Glyph_Stroke(&g,stroker_.get(),1);
error = FT_Glyph_To_Bitmap( &g,FT_RENDER_MODE_NORMAL,0,1);
if ( ! error )
{
FT_BitmapGlyph bit = (FT_BitmapGlyph)g;
render_bitmap(&bit->bitmap, pos->properties->halo_fill.rgba(),
bit->left,
height - bit->top, pos->properties->text_opacity);
}
FT_BitmapGlyph bit = (FT_BitmapGlyph)g;
render_bitmap(&bit->bitmap, pos->properties->halo_fill.rgba(),
bit->left,
height - bit->top, pos->properties->text_opacity);
}
FT_Done_Glyph(g);
}
FT_Done_Glyph(g);
}
//render actual text
for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos)
{
@ -461,8 +461,8 @@ void text_renderer<T>::render_id(int feature_id,double x0, double y0, double min
FT_BitmapGlyph bit = (FT_BitmapGlyph)g;
render_bitmap_id(&bit->bitmap, feature_id,
bit->left,
height - bit->top);
bit->left,
height - bit->top);
}
}
FT_Done_Glyph(g);

View file

@ -37,14 +37,14 @@ IMPLEMENT_ENUM( gradient_e, gradient_strings )
gradient::gradient()
: gradient_type_(NO_GRADIENT),
stops_(),
x1_(0),
y1_(0),
x2_(0),
y2_(0),
r_(0),
units_(OBJECT_BOUNDING_BOX)
: gradient_type_(NO_GRADIENT),
stops_(),
x1_(0),
y1_(0),
x2_(0),
y2_(0),
r_(0),
units_(OBJECT_BOUNDING_BOX)
{
}

View file

@ -124,41 +124,41 @@ void image_32::set_color_to_alpha(const color& /*c*/)
void image_32::set_alpha(float opacity)
{
{
for (unsigned int y = 0; y < height_; ++y)
{
unsigned int* row_to = data_.getRow(y);
for (unsigned int x = 0; x < width_; ++x)
for (unsigned int y = 0; y < height_; ++y)
{
unsigned rgba = row_to[x];
unsigned int* row_to = data_.getRow(y);
for (unsigned int x = 0; x < width_; ++x)
{
unsigned rgba = row_to[x];
#ifdef MAPNIK_BIG_ENDIAN
unsigned a0 = (rgba & 0xff);
unsigned a1 = int( (rgba & 0xff) * opacity );
unsigned a0 = (rgba & 0xff);
unsigned a1 = int( (rgba & 0xff) * opacity );
if (a0 == a1) continue;
if (a0 == a1) continue;
unsigned r = (rgba >> 24) & 0xff;
unsigned g = (rgba >> 16 ) & 0xff;
unsigned b = (rgba >> 8) & 0xff;
unsigned r = (rgba >> 24) & 0xff;
unsigned g = (rgba >> 16 ) & 0xff;
unsigned b = (rgba >> 8) & 0xff;
row_to[x] = (a1) | (b << 8) | (g << 16) | (r << 24) ;
row_to[x] = (a1) | (b << 8) | (g << 16) | (r << 24) ;
#else
unsigned a0 = (rgba >> 24) & 0xff;
unsigned a1 = int( ((rgba >> 24) & 0xff) * opacity );
//unsigned a1 = opacity;
if (a0 == a1) continue;
unsigned a0 = (rgba >> 24) & 0xff;
unsigned a1 = int( ((rgba >> 24) & 0xff) * opacity );
//unsigned a1 = opacity;
if (a0 == a1) continue;
unsigned r = rgba & 0xff;
unsigned g = (rgba >> 8 ) & 0xff;
unsigned b = (rgba >> 16) & 0xff;
unsigned r = rgba & 0xff;
unsigned g = (rgba >> 8 ) & 0xff;
unsigned b = (rgba >> 16) & 0xff;
row_to[x] = (a1 << 24)| (b << 16) | (g << 8) | (r) ;
row_to[x] = (a1 << 24)| (b << 16) | (g << 8) | (r) ;
#endif
}
}
}
}
}

View file

@ -149,10 +149,10 @@ void grid_renderer<T>::render_marker(mapnik::feature_ptr const& feature, unsigne
vertex_stl_adapter<svg_path_storage> stl_storage((*marker.get_vector_data())->source());
svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>,
renderer,
mapnik::pixfmt_gray16> svg_renderer(svg_path,
(*marker.get_vector_data())->attributes());
agg::pod_bvector<path_attributes>,
renderer,
mapnik::pixfmt_gray16> svg_renderer(svg_path,
(*marker.get_vector_data())->attributes());
svg_renderer.render_id(*ras_ptr, sl, renb, feature->id(), mtx, opacity, bbox);
@ -169,7 +169,7 @@ void grid_renderer<T>::render_marker(mapnik::feature_ptr const& feature, unsigne
double ratio = (1.0/step);
image_data_32 target(ratio * data.width(), ratio * data.height());
mapnik::scale_image_agg<image_data_32>(target,data, SCALING_NEAR,
scale_factor_, 0.0, 0.0, 1.0, ratio);
scale_factor_, 0.0, 0.0, 1.0, ratio);
pixmap_.set_rectangle(feature->id(), target, x, y);
}
}

View file

@ -44,8 +44,8 @@ namespace mapnik
template <typename T>
void grid_renderer<T>::process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
@ -150,7 +150,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
}
template void grid_renderer<grid>::process(building_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -43,8 +43,8 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
@ -86,8 +86,8 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
template void grid_renderer<grid>::process(line_pattern_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -43,8 +43,8 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
@ -145,8 +145,8 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
template void grid_renderer<grid>::process(line_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -53,8 +53,8 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
@ -97,9 +97,9 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
vertex_stl_adapter<svg_path_storage> stl_storage((*marker)->source());
svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>,
renderer,
mapnik::pixfmt_gray16 > svg_renderer(svg_path,(*marker)->attributes());
agg::pod_bvector<path_attributes>,
renderer,
mapnik::pixfmt_gray16 > svg_renderer(svg_path,(*marker)->attributes());
bool placed = false;
for (unsigned i=0; i<feature->num_geometries(); ++i)
@ -267,6 +267,6 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
}
template void grid_renderer<grid>::process(markers_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -39,8 +39,8 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature);
@ -94,8 +94,8 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
}
template void grid_renderer<grid>::process(point_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -42,8 +42,8 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
@ -78,8 +78,8 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
template void grid_renderer<grid>::process(polygon_pattern_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -42,8 +42,8 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
@ -77,8 +77,8 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
template void grid_renderer<grid>::process(polygon_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -29,14 +29,14 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(raster_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
std::clog << "grid_renderer does not yet support raster_symbolizer\n";
}
template void grid_renderer<grid>::process(raster_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -41,15 +41,15 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(shield_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
shield_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_,
t_, font_manager_, detector_);
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_,
t_, font_manager_, detector_);
bool placement_found = false;
@ -77,7 +77,7 @@ void grid_renderer<T>::process(shield_symbolizer const& sym,
}
template void grid_renderer<grid>::process(shield_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -29,15 +29,15 @@ namespace mapnik {
template <typename T>
void grid_renderer<T>::process(text_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
text_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_ * (1.0/pixmap_.get_resolution()),
t_, font_manager_, detector_);
label_collision_detector4> helper(
sym, *feature, prj_trans,
width_, height_,
scale_factor_ * (1.0/pixmap_.get_resolution()),
t_, font_manager_, detector_);
bool placement_found = false;
text_renderer<T> ren(pixmap_, font_manager_, *(font_manager_.get_stroker()));
@ -58,8 +58,8 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
}
template void grid_renderer<grid>::process(text_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -124,12 +124,12 @@ void save_to_file(T const& image,
}
void handle_png_options(std::string const& type,
int * colors,
int * compression,
int * strategy,
int * trans_mode,
double * gamma,
bool * use_octree)
int * colors,
int * compression,
int * strategy,
int * trans_mode,
double * gamma,
bool * use_octree)
{
if (type == "png" || type == "png24" || type == "png32")
{
@ -207,12 +207,12 @@ void handle_png_options(std::string const& type,
{
*compression = boost::lexical_cast<int>(t.substr(2));
/*
#define Z_NO_COMPRESSION 0
#define Z_BEST_SPEED 1
#define Z_BEST_COMPRESSION 9
#define Z_DEFAULT_COMPRESSION (-1)
#define Z_NO_COMPRESSION 0
#define Z_BEST_SPEED 1
#define Z_BEST_COMPRESSION 9
#define Z_DEFAULT_COMPRESSION (-1)
*/
if (*compression < Z_DEFAULT_COMPRESSION || *compression > Z_BEST_COMPRESSION)
if (*compression < Z_DEFAULT_COMPRESSION || *compression > Z_BEST_COMPRESSION)
throw ImageWriterException("invalid compression parameter: " + t.substr(2) + " out of bounds (only -1 through 9 are valid)");
}
catch(boost::bad_lexical_cast &)
@ -260,12 +260,12 @@ void save_to_stream(T const& image,
bool use_octree = true;
handle_png_options(type,
&colors,
&compression,
&strategy,
&trans_mode,
&gamma,
&use_octree);
&colors,
&compression,
&strategy,
&trans_mode,
&gamma,
&use_octree);
if (palette.valid())
save_as_png8_pal(stream, image, palette, compression, strategy);
@ -310,12 +310,12 @@ void save_to_stream(T const& image,
bool use_octree = true;
handle_png_options(type,
&colors,
&compression,
&strategy,
&trans_mode,
&gamma,
&use_octree);
&colors,
&compression,
&strategy,
&trans_mode,
&gamma,
&use_octree);
if (colors < 0)
save_as_png(stream, image, compression, strategy);
@ -730,45 +730,45 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin
switch(scaling_method)
{
case SCALING_NEAR:
{
typedef agg::span_image_filter_rgba_nn<img_src_type, interpolator_type> span_gen_type;
span_gen_type sg(img_src, interpolator);
agg::render_scanlines_aa(ras, sl, rb_dst, sa, sg);
return;
}
case SCALING_BILINEAR:
filter.calculate(agg::image_filter_bilinear(), true); break;
case SCALING_BICUBIC:
filter.calculate(agg::image_filter_bicubic(), true); break;
case SCALING_SPLINE16:
filter.calculate(agg::image_filter_spline16(), true); break;
case SCALING_SPLINE36:
filter.calculate(agg::image_filter_spline36(), true); break;
case SCALING_HANNING:
filter.calculate(agg::image_filter_hanning(), true); break;
case SCALING_HAMMING:
filter.calculate(agg::image_filter_hamming(), true); break;
case SCALING_HERMITE:
filter.calculate(agg::image_filter_hermite(), true); break;
case SCALING_KAISER:
filter.calculate(agg::image_filter_kaiser(), true); break;
case SCALING_QUADRIC:
filter.calculate(agg::image_filter_quadric(), true); break;
case SCALING_CATROM:
filter.calculate(agg::image_filter_catrom(), true); break;
case SCALING_GAUSSIAN:
filter.calculate(agg::image_filter_gaussian(), true); break;
case SCALING_BESSEL:
filter.calculate(agg::image_filter_bessel(), true); break;
case SCALING_MITCHELL:
filter.calculate(agg::image_filter_mitchell(), true); break;
case SCALING_SINC:
filter.calculate(agg::image_filter_sinc(filter_radius), true); break;
case SCALING_LANCZOS:
filter.calculate(agg::image_filter_lanczos(filter_radius), true); break;
case SCALING_BLACKMAN:
filter.calculate(agg::image_filter_blackman(filter_radius), true); break;
case SCALING_NEAR:
{
typedef agg::span_image_filter_rgba_nn<img_src_type, interpolator_type> span_gen_type;
span_gen_type sg(img_src, interpolator);
agg::render_scanlines_aa(ras, sl, rb_dst, sa, sg);
return;
}
case SCALING_BILINEAR:
filter.calculate(agg::image_filter_bilinear(), true); break;
case SCALING_BICUBIC:
filter.calculate(agg::image_filter_bicubic(), true); break;
case SCALING_SPLINE16:
filter.calculate(agg::image_filter_spline16(), true); break;
case SCALING_SPLINE36:
filter.calculate(agg::image_filter_spline36(), true); break;
case SCALING_HANNING:
filter.calculate(agg::image_filter_hanning(), true); break;
case SCALING_HAMMING:
filter.calculate(agg::image_filter_hamming(), true); break;
case SCALING_HERMITE:
filter.calculate(agg::image_filter_hermite(), true); break;
case SCALING_KAISER:
filter.calculate(agg::image_filter_kaiser(), true); break;
case SCALING_QUADRIC:
filter.calculate(agg::image_filter_quadric(), true); break;
case SCALING_CATROM:
filter.calculate(agg::image_filter_catrom(), true); break;
case SCALING_GAUSSIAN:
filter.calculate(agg::image_filter_gaussian(), true); break;
case SCALING_BESSEL:
filter.calculate(agg::image_filter_bessel(), true); break;
case SCALING_MITCHELL:
filter.calculate(agg::image_filter_mitchell(), true); break;
case SCALING_SINC:
filter.calculate(agg::image_filter_sinc(filter_radius), true); break;
case SCALING_LANCZOS:
filter.calculate(agg::image_filter_lanczos(filter_radius), true); break;
case SCALING_BLACKMAN:
filter.calculate(agg::image_filter_blackman(filter_radius), true); break;
}
typedef agg::span_image_resample_rgba_affine<img_src_type> span_gen_type;
span_gen_type sg(img_src, interpolator, filter);

View file

@ -45,134 +45,134 @@ extern "C"
namespace mapnik
{
class JpegReader : public image_reader, boost::noncopyable
{
private:
std::string fileName_;
unsigned width_;
unsigned height_;
public:
explicit JpegReader(const std::string& fileName);
~JpegReader();
unsigned width() const;
unsigned height() const;
void read(unsigned x,unsigned y,image_data_32& image);
private:
void init();
};
class JpegReader : public image_reader, boost::noncopyable
{
private:
std::string fileName_;
unsigned width_;
unsigned height_;
public:
explicit JpegReader(const std::string& fileName);
~JpegReader();
unsigned width() const;
unsigned height() const;
void read(unsigned x,unsigned y,image_data_32& image);
private:
void init();
};
namespace
{
image_reader* createJpegReader(const std::string& file)
{
return new JpegReader(file);
}
const bool registered = register_image_reader("jpeg",createJpegReader);
}
JpegReader::JpegReader(const std::string& fileName)
: fileName_(fileName),
width_(0),
height_(0)
{
init();
}
JpegReader::~JpegReader() {}
void JpegReader::init()
{
FILE *fp = fopen(fileName_.c_str(),"rb");
if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_);
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
width_ = cinfo.output_width;
height_ = cinfo.output_height;
// if enabled: "Application transferred too few scanlines"
//jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(fp);
}
unsigned JpegReader::width() const
{
return width_;
}
unsigned JpegReader::height() const
{
return height_;
}
void JpegReader::read(unsigned x0, unsigned y0, image_data_32& image)
{
struct jpeg_decompress_struct cinfo;
FILE *fp = fopen(fileName_.c_str(),"rb");
if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_);
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp);
jpeg_read_header(&cinfo, TRUE);
if (cinfo.out_color_space == JCS_UNKNOWN)
throw image_reader_exception("JPEG Reader: failed to read unknown color space in " + fileName_);
jpeg_start_decompress(&cinfo);
if (cinfo.output_width == 0) {
jpeg_destroy_decompress (&cinfo);
fclose(fp);
throw image_reader_exception("JPEG Reader: failed to read image size of " + fileName_);
}
JSAMPARRAY buffer;
int row_stride;
unsigned char a,r,g,b;
row_stride = cinfo.output_width * cinfo.output_components;
buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
unsigned w = std::min(unsigned(image.width()),width_);
unsigned h = std::min(unsigned(image.height()),height_);
boost::scoped_array<unsigned int> out_row(new unsigned int[w]);
// TODO - handle x0
for (unsigned i=0;i<h;++i)
{
jpeg_read_scanlines(&cinfo, buffer, 1);
if (i>=y0 && i<h)
{
for (unsigned int x=0; x<w; x++)
{
a = 255; // alpha not supported in jpg
r = buffer[0][cinfo.output_components * x];
if (cinfo.output_components > 2)
{
g = buffer[0][cinfo.output_components*x+1];
b = buffer[0][cinfo.output_components*x+2];
} else {
g = r;
b = r;
}
out_row[x] = color(r, g, b, a).rgba();
}
image.setRow(i-y0, out_row.get(), w);
}
}
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(fp);
}
namespace
{
image_reader* createJpegReader(const std::string& file)
{
return new JpegReader(file);
}
const bool registered = register_image_reader("jpeg",createJpegReader);
}
JpegReader::JpegReader(const std::string& fileName)
: fileName_(fileName),
width_(0),
height_(0)
{
init();
}
JpegReader::~JpegReader() {}
void JpegReader::init()
{
FILE *fp = fopen(fileName_.c_str(),"rb");
if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_);
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
width_ = cinfo.output_width;
height_ = cinfo.output_height;
// if enabled: "Application transferred too few scanlines"
//jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(fp);
}
unsigned JpegReader::width() const
{
return width_;
}
unsigned JpegReader::height() const
{
return height_;
}
void JpegReader::read(unsigned x0, unsigned y0, image_data_32& image)
{
struct jpeg_decompress_struct cinfo;
FILE *fp = fopen(fileName_.c_str(),"rb");
if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_);
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp);
jpeg_read_header(&cinfo, TRUE);
if (cinfo.out_color_space == JCS_UNKNOWN)
throw image_reader_exception("JPEG Reader: failed to read unknown color space in " + fileName_);
jpeg_start_decompress(&cinfo);
if (cinfo.output_width == 0) {
jpeg_destroy_decompress (&cinfo);
fclose(fp);
throw image_reader_exception("JPEG Reader: failed to read image size of " + fileName_);
}
JSAMPARRAY buffer;
int row_stride;
unsigned char a,r,g,b;
row_stride = cinfo.output_width * cinfo.output_components;
buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
unsigned w = std::min(unsigned(image.width()),width_);
unsigned h = std::min(unsigned(image.height()),height_);
boost::scoped_array<unsigned int> out_row(new unsigned int[w]);
// TODO - handle x0
for (unsigned i=0;i<h;++i)
{
jpeg_read_scanlines(&cinfo, buffer, 1);
if (i>=y0 && i<h)
{
for (unsigned int x=0; x<w; x++)
{
a = 255; // alpha not supported in jpg
r = buffer[0][cinfo.output_components * x];
if (cinfo.output_components > 2)
{
g = buffer[0][cinfo.output_components*x+1];
b = buffer[0][cinfo.output_components*x+2];
} else {
g = r;
b = r;
}
out_row[x] = color(r, g, b, a).rgba();
}
image.setRow(i-y0, out_row.get(), w);
}
}
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(fp);
}
}

View file

@ -219,11 +219,11 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base
{
boost::filesystem::path xml_path(filename_);
// TODO - should we make this absolute?
#if (BOOST_FILESYSTEM_VERSION == 3)
std::string base = xml_path.parent_path().string();
#else // v2
std::string base = xml_path.branch_path().string();
#endif
#if (BOOST_FILESYSTEM_VERSION == 3)
std::string base = xml_path.parent_path().string();
#else // v2
std::string base = xml_path.branch_path().string();
#endif
map.set_base_path( base );
}
@ -380,7 +380,7 @@ void map_parser::parse_map_include( Map & map, ptree const & include )
{
std::string name = get_attr<std::string>(param, "name");
std::string value = get_value<std::string>( param,
"datasource parameter");
"datasource parameter");
params[name] = value;
}
else if( paramIter->first != "<xmlattr>" &&
@ -427,7 +427,7 @@ void map_parser::parse_map_include( Map & map, ptree const & include )
if (is_string)
{
std::string value = get_value<std::string>( param,
"parameter");
"parameter");
params[name] = value;
}
}
@ -694,7 +694,7 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
ensure_attrs(param, "Parameter", "name");
std::string name = get_attr<std::string>(param, "name");
std::string value = get_value<std::string>( param,
"datasource parameter");
"datasource parameter");
params[name] = value;
}
else if( paramIter->first != "<xmlattr>" &&
@ -960,7 +960,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
catch (image_reader_exception const & ex )
{
std::string msg("Failed to load image file '" + * file +
"': " + ex.what());
"': " + ex.what());
if (strict_)
{
throw config_error(msg);
@ -1021,7 +1021,7 @@ void map_parser::parse_markers_symbolizer( rule & rule, ptree const & sym )
<< "width,height,placement,marker-type,"
<< "stroke,stroke-width,stroke-opacity,stroke-linejoin,"
<< "stroke-linecap,stroke-dashoffset,stroke-dasharray,"
// note: stroke-gamma intentionally left off here as markers do not support them
// note: stroke-gamma intentionally left off here as markers do not support them
<< "meta-writer,meta-output";
ensure_attrs(sym, "MarkersSymbolizer", s.str());
@ -1056,10 +1056,10 @@ void map_parser::parse_markers_symbolizer( rule & rule, ptree const & sym )
}
}
/*else
{
//s << "fill,marker-type,width,height";
//ensure_attrs(sym, "MarkersSymbolizer", s.str());
}*/
{
//s << "fill,marker-type,width,height";
//ensure_attrs(sym, "MarkersSymbolizer", s.str());
}*/
markers_symbolizer symbol(parse_path(filename));
optional<float> opacity = get_opt_attr<float>(sym, "opacity");
@ -1165,7 +1165,7 @@ void map_parser::parse_line_pattern_symbolizer( rule & rule, ptree const & sym )
catch (image_reader_exception const & ex )
{
std::string msg("Failed to load image file '" + file +
"': " + ex.what());
"': " + ex.what());
if (strict_)
{
throw config_error(msg);
@ -1225,7 +1225,7 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
catch (image_reader_exception const & ex )
{
std::string msg("Failed to load image file '" + file +
"': " + ex.what());
"': " + ex.what());
if (strict_)
{
throw config_error(msg);
@ -1247,17 +1247,17 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
{
std::stringstream s_common;
s_common << "name,face-name,fontset-name,size,fill,orientation,"
<< "dx,dy,placement,vertical-alignment,halo-fill,"
<< "halo-radius,text-ratio,wrap-width,wrap-before,"
<< "wrap-character,text-transform,line-spacing,"
<< "label-position-tolerance,character-spacing,"
<< "spacing,minimum-distance,minimum-padding,minimum-path-length,"
<< "avoid-edges,allow-overlap,opacity,max-char-angle-delta,"
<< "horizontal-alignment,justify-alignment";
<< "dx,dy,placement,vertical-alignment,halo-fill,"
<< "halo-radius,text-ratio,wrap-width,wrap-before,"
<< "wrap-character,text-transform,line-spacing,"
<< "label-position-tolerance,character-spacing,"
<< "spacing,minimum-distance,minimum-padding,minimum-path-length,"
<< "avoid-edges,allow-overlap,opacity,max-char-angle-delta,"
<< "horizontal-alignment,justify-alignment";
std::stringstream s_symbolizer;
s_symbolizer << s_common.str() << ",placements,placement-type,"
<< "meta-writer,meta-output";
<< "meta-writer,meta-output";
ensure_attrs(sym, "TextSymbolizer", s_symbolizer.str());
try
@ -1314,19 +1314,19 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
{
std::string s_common(
"name,face-name,fontset-name,size,fill,orientation,"
"dx,dy,placement,vertical-alignment,halo-fill,"
"halo-radius,text-ratio,wrap-width,wrap-before,"
"wrap-character,text-transform,line-spacing,"
"label-position-tolerance,character-spacing,"
"spacing,minimum-distance,minimum-padding,minimum-path-length,"
"avoid-edges,allow-overlap,opacity,max-char-angle-delta,"
"horizontal-alignment,justify-alignment");
"name,face-name,fontset-name,size,fill,orientation,"
"dx,dy,placement,vertical-alignment,halo-fill,"
"halo-radius,text-ratio,wrap-width,wrap-before,"
"wrap-character,text-transform,line-spacing,"
"label-position-tolerance,character-spacing,"
"spacing,minimum-distance,minimum-padding,minimum-path-length,"
"avoid-edges,allow-overlap,opacity,max-char-angle-delta,"
"horizontal-alignment,justify-alignment");
std::string s_symbolizer(s_common + ",file,base,"
"transform,shield-dx,shield-dy,text-opacity,"
"unlock-image"
"placements,placement-type,meta-writer,meta-output");
"transform,shield-dx,shield-dy,text-opacity,"
"unlock-image"
"placements,placement-type,meta-writer,meta-output");
ensure_attrs(sym, "ShieldSymbolizer", s_symbolizer);
try
@ -1439,7 +1439,7 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
catch (image_reader_exception const & ex )
{
std::string msg("Failed to load image file '" + image_file +
"': " + ex.what());
"': " + ex.what());
if (strict_)
{
throw config_error(msg);
@ -1794,18 +1794,18 @@ std::string map_parser::ensure_relative_to_xml( boost::optional<std::string> opt
boost::filesystem::path rel_path = *opt_path;
if ( !rel_path.has_root_path() )
{
#if (BOOST_FILESYSTEM_VERSION == 3)
#if (BOOST_FILESYSTEM_VERSION == 3)
// TODO - normalize is now deprecated, use make_preferred?
boost::filesystem::path full = boost::filesystem::absolute(xml_path.parent_path()/rel_path);
#else // v2
#else // v2
boost::filesystem::path full = boost::filesystem::complete(xml_path.branch_path()/rel_path).normalize();
#endif
#endif
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_DEBUG
std::clog << "\nModifying relative paths to be relative to xml...\n";
std::clog << "original base path: " << *opt_path << "\n";
std::clog << "relative base path: " << full.string() << "\n";
#endif
#endif
return full.string();
}
}

View file

@ -63,12 +63,12 @@ static const char * aspect_fix_mode_strings[] = {
IMPLEMENT_ENUM( aspect_fix_mode_e, aspect_fix_mode_strings )
Map::Map()
: width_(400),
height_(400),
srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"),
buffer_size_(0),
aspectFixMode_(GROW_BBOX),
base_path_("") {}
: width_(400),
height_(400),
srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"),
buffer_size_(0),
aspectFixMode_(GROW_BBOX),
base_path_("") {}
Map::Map(int width,int height, std::string const& srs)
: width_(width),
@ -371,9 +371,9 @@ void Map::zoom(double factor)
double w = factor * current_extent_.width();
double h = factor * current_extent_.height();
current_extent_ = box2d<double>(center.x - 0.5 * w,
center.y - 0.5 * h,
center.x + 0.5 * w,
center.y + 0.5 * h);
center.y - 0.5 * h,
center.x + 0.5 * w,
center.y + 0.5 * h);
fixAspectRatio();
}
@ -408,10 +408,10 @@ void Map::zoom_all()
if (prj_trans.backward(layer_ext))
{
success = true;
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_DEBUG
std::clog << " layer " << itr->name() << " original ext: " << itr->envelope() << "\n";
std::clog << " layer " << itr->name() << " transformed to map srs: " << layer_ext << "\n";
#endif
#endif
if (first)
{
ext = layer_ext;

View file

@ -79,9 +79,9 @@ boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const&
}
}
/*else
{
std::cerr << "### WARNING Memory region does not exist file: " << uri << std::endl;
}*/
{
std::cerr << "### WARNING Memory region does not exist file: " << uri << std::endl;
}*/
return result;
}

View file

@ -44,17 +44,17 @@ static const char * marker_type_strings[] = {
IMPLEMENT_ENUM( marker_type_e, marker_type_strings )
markers_symbolizer::markers_symbolizer()
: symbolizer_with_image(path_expression_ptr(new path_expression)),
symbolizer_base(),
allow_overlap_(false),
fill_(color(0,0,255)),
spacing_(100.0),
max_error_(0.2),
width_(5.0),
height_(5.0),
stroke_(),
marker_p_(MARKER_LINE_PLACEMENT),
marker_type_(ARROW) {}
: symbolizer_with_image(path_expression_ptr(new path_expression)),
symbolizer_base(),
allow_overlap_(false),
fill_(color(0,0,255)),
spacing_(100.0),
max_error_(0.2),
width_(5.0),
height_(5.0),
stroke_(),
marker_p_(MARKER_LINE_PLACEMENT),
marker_type_(ARROW) {}
markers_symbolizer::markers_symbolizer(path_expression_ptr filename)
: symbolizer_with_image(filename),

View file

@ -104,7 +104,7 @@ metawriter_json_stream::metawriter_json_stream(metawriter_properties dflt_proper
void metawriter_json_stream::write_properties(Feature const& feature, metawriter_properties const& properties)
{
*f_ << "}," << //Close coordinates object
"\n \"properties\": {";
"\n \"properties\": {";
int i = 0;
BOOST_FOREACH(std::string const& p, properties)
@ -142,7 +142,7 @@ void metawriter_json_stream::write_properties(Feature const& feature, metawriter
void metawriter_json_stream::add_box(box2d<double> const &box, Feature const& feature,
CoordTransform const& t, metawriter_properties const& properties)
CoordTransform const& t, metawriter_properties const& properties)
{
/* Check if feature is in bounds. */
if (box.maxx() < 0 || box.maxy() < 0 || box.minx() > width_ || box.miny() > height_) return;
@ -165,33 +165,33 @@ void metawriter_json_stream::add_box(box2d<double> const &box, Feature const& fe
write_feature_header("Polygon");
*f_ << " [ [ [" <<
minx << ", " << miny << "], [" <<
maxx << ", " << miny << "], [" <<
maxx << ", " << maxy << "], [" <<
minx << ", " << maxy << "] ] ]";
minx << ", " << miny << "], [" <<
maxx << ", " << miny << "], [" <<
maxx << ", " << maxy << "], [" <<
minx << ", " << maxy << "] ] ]";
write_properties(feature, properties);
}
void metawriter_json_stream::add_text(text_placement_info const& p,
face_manager_freetype &font_manager,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties)
face_manager_freetype &font_manager,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties)
{
/* Note:
Map coordinate system (and starting_{x,y}) starts in upper left corner
and grows towards lower right corner.
and grows towards lower right corner.
Font + placement vertex coordinate system starts in lower left corner
and grows towards upper right corner.
and grows towards upper right corner.
Therefore y direction is different. Keep this in mind while doing calculations.
The y value returned by vertex() is always the baseline.
Lowest y = baseline of bottom line
Hightest y = baseline of top line
*/
*/
for (unsigned n = 0; n < p.placements.size(); n++) {
text_path & current_placement = const_cast<text_path &>(p.placements[n]);
@ -269,9 +269,9 @@ void metawriter_json_stream::add_text(text_placement_info const& p,
}
void metawriter_json_stream::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)
{
write_feature_header("Polygon");
write_line_polygon(path, t, true);
@ -279,9 +279,9 @@ void metawriter_json_stream::add_polygon(path_type & path,
}
void metawriter_json_stream::add_line(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties)
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties)
{
write_feature_header("MultiLineString");
write_line_polygon(path, t, false);
@ -365,7 +365,7 @@ void metawriter_json::set_filename(path_expression_ptr fn)
path_expression_ptr metawriter_json::get_filename() const
{
return fn_;
return fn_;
}
}

View file

@ -38,54 +38,54 @@ namespace mapnik
metawriter_ptr
metawriter_create(const boost::property_tree::ptree &pt) {
metawriter_ptr writer;
string type = get_attr<string>(pt, "type");
metawriter_ptr writer;
string type = get_attr<string>(pt, "type");
optional<string> properties = get_opt_attr<string>(pt, "default-output");
if (type == "json") {
string file = get_attr<string>(pt, "file");
metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file)));
optional<boolean> output_empty = get_opt_attr<boolean>(pt, "output-empty");
if (output_empty) {
json->set_output_empty(*output_empty);
optional<string> properties = get_opt_attr<string>(pt, "default-output");
if (type == "json") {
string file = get_attr<string>(pt, "file");
metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file)));
optional<boolean> output_empty = get_opt_attr<boolean>(pt, "output-empty");
if (output_empty) {
json->set_output_empty(*output_empty);
}
optional<boolean> pixel_coordinates = get_opt_attr<boolean>(pt, "pixel-coordinates");
if (pixel_coordinates) {
json->set_pixel_coordinates(*pixel_coordinates);
}
writer = json;
} else if (type == "inmem") {
metawriter_inmem_ptr inmem = metawriter_inmem_ptr(new metawriter_inmem(properties));
writer = inmem;
} else {
throw config_error(string("Unknown type '") + type + "'");
}
optional<boolean> pixel_coordinates = get_opt_attr<boolean>(pt, "pixel-coordinates");
if (pixel_coordinates) {
json->set_pixel_coordinates(*pixel_coordinates);
}
writer = json;
} else if (type == "inmem") {
metawriter_inmem_ptr inmem = metawriter_inmem_ptr(new metawriter_inmem(properties));
writer = inmem;
} else {
throw config_error(string("Unknown type '") + type + "'");
}
return writer;
return writer;
}
void
metawriter_save(const metawriter_ptr &metawriter, ptree &metawriter_node, bool explicit_defaults) {
metawriter_json *json = dynamic_cast<metawriter_json *>(metawriter.get());
if (json) {
set_attr(metawriter_node, "type", "json");
std::string const& filename = path_processor_type::to_string(*(json->get_filename()));
if (!filename.empty() || explicit_defaults) {
set_attr(metawriter_node, "file", filename);
metawriter_json *json = dynamic_cast<metawriter_json *>(metawriter.get());
if (json) {
set_attr(metawriter_node, "type", "json");
std::string const& filename = path_processor_type::to_string(*(json->get_filename()));
if (!filename.empty() || explicit_defaults) {
set_attr(metawriter_node, "file", filename);
}
}
}
metawriter_inmem *inmem = dynamic_cast<metawriter_inmem *>(metawriter.get());
if (inmem) {
set_attr(metawriter_node, "type", "inmem");
}
metawriter_inmem *inmem = dynamic_cast<metawriter_inmem *>(metawriter.get());
if (inmem) {
set_attr(metawriter_node, "type", "inmem");
}
if (!metawriter->get_default_properties().empty() || explicit_defaults) {
set_attr(metawriter_node, "default-output", metawriter->get_default_properties().to_string());
}
if (!metawriter->get_default_properties().empty() || explicit_defaults) {
set_attr(metawriter_node, "default-output", metawriter->get_default_properties().to_string());
}
}
} // namespace mapnik

View file

@ -36,9 +36,9 @@ bool rgba::mean_sort_cmp::operator() (const rgba& x, const rgba& y) const
if (t1 != t2) return t1 < t2;
return (((int)x.a - y.a) >> 24) +
(((int)x.r - y.r) >> 16) +
(((int)x.g - y.g) >> 8) +
(((int)x.b - y.b));
(((int)x.r - y.r) >> 16) +
(((int)x.g - y.g) >> 8) +
(((int)x.b - y.b));
}
std::size_t rgba::hash_func::operator()(rgba const& p) const

View file

@ -112,7 +112,7 @@ placement_finder<DetectorT>::placement_finder(text_placement_info &placement_inf
dimensions_(extent),
info_(info), p(placement_info.properties), pi(placement_info), string_width_(0), string_height_(0), first_line_space_(0), valign_(V_AUTO), halign_(H_AUTO), line_breaks_(), line_sizes_()
{
placement_info.placements.clear(); //Remove left overs
placement_info.placements.clear(); //Remove left overs
}
template <typename DetectorT>
@ -260,7 +260,7 @@ void placement_finder<DetectorT>::find_line_breaks()
// wrap text at first wrap_char after (default) the wrap width or immediately before the current word
if ((c == '\n') ||
(line_width > 0 && ((line_width > wrap_at && !ci.format->wrap_before) ||
((line_width + last_wrap_char_width + word_width) > wrap_at && ci.format->wrap_before)) ))
((line_width + last_wrap_char_width + word_width) > wrap_at && ci.format->wrap_before)) ))
{
string_width_ = std::max(string_width_, line_width); //Total width is the longest line
string_height_ += line_height;
@ -443,9 +443,9 @@ void placement_finder<DetectorT>::find_point_placement(double label_x, double la
{
double min_pad = pi.get_actual_minimum_padding();
box2d<double> epad(e.minx()-min_pad,
e.miny()-min_pad,
e.maxx()+min_pad,
e.maxy()+min_pad);
e.miny()-min_pad,
e.maxx()+min_pad,
e.maxy()+min_pad);
if (!dimensions_.contains(epad))
{
return;

View file

@ -37,11 +37,11 @@ static const char * point_placement_strings[] = {
IMPLEMENT_ENUM( point_placement_e, point_placement_strings )
point_symbolizer::point_symbolizer()
: symbolizer_with_image(path_expression_ptr(new path_expression)), // FIXME
symbolizer_base(),
overlap_(false),
point_p_(CENTROID_POINT_PLACEMENT),
ignore_placement_(false) {}
: symbolizer_with_image(path_expression_ptr(new path_expression)), // FIXME
symbolizer_base(),
overlap_(false),
point_p_(CENTROID_POINT_PLACEMENT),
ignore_placement_(false) {}
point_symbolizer::point_symbolizer(path_expression_ptr file)
: symbolizer_with_image(file),

View file

@ -36,10 +36,10 @@ static const char * pattern_alignment_strings[] = {
IMPLEMENT_ENUM( pattern_alignment_e, pattern_alignment_strings )
polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file)
: symbolizer_with_image(file), symbolizer_base(),
alignment_(LOCAL_ALIGNMENT),
gamma_(1.0),
gamma_method_(GAMMA_POWER) {}
: symbolizer_with_image(file), symbolizer_base(),
alignment_(LOCAL_ALIGNMENT),
gamma_(1.0),
gamma_method_(GAMMA_POWER) {}
polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs)
: symbolizer_with_image(rhs), symbolizer_base(rhs),

View file

@ -92,7 +92,7 @@ bool proj_transform::forward (double * x, double * y , double * z, int point_cou
return true;
}
if (is_source_longlat_)
if (is_source_longlat_)
{
int i;
for(i=0; i<point_count; i++) {

View file

@ -358,10 +358,10 @@ private:
text_placements_ptr p = sym.get_placement_options();
p->properties.to_xml(node, explicit_defaults_);
/* Known types:
- text_placements_dummy: no handling required
- text_placements_simple: positions string
- text_placements_list: list string
*/
- text_placements_dummy: no handling required
- text_placements_simple: positions string
- text_placements_list: list string
*/
text_placements_simple *simple = dynamic_cast<text_placements_simple *>(p.get());
text_placements_list *list = dynamic_cast<text_placements_list *>(p.get());
if (simple) {
@ -566,7 +566,7 @@ void serialize_datasource( ptree & layer_node, datasource_ptr datasource)
class serialize_type : public boost::static_visitor<>
{
public:
public:
serialize_type( boost::property_tree::ptree & node):
node_(node) {}
@ -590,7 +590,7 @@ class serialize_type : public boost::static_visitor<>
node_.put("<xmlattr>.type", "string" );
}
private:
private:
boost::property_tree::ptree & node_;
};

View file

@ -47,15 +47,15 @@ static const char * line_join_strings[] = {
IMPLEMENT_ENUM( line_join_e, line_join_strings )
stroke::stroke()
: c_(0,0,0),
width_(1.0),
opacity_(1.0),
line_cap_(BUTT_CAP),
line_join_(MITER_JOIN),
gamma_(1.0),
gamma_method_(GAMMA_POWER),
dash_(),
dash_offset_(0) {}
: c_(0,0,0),
width_(1.0),
opacity_(1.0),
line_cap_(BUTT_CAP),
line_join_(MITER_JOIN),
gamma_(1.0),
gamma_method_(GAMMA_POWER),
dash_(),
dash_offset_(0) {}
stroke::stroke(color const& c, double width)
: c_(c),

View file

@ -26,15 +26,15 @@
namespace mapnik
{
template <typename T>
void svg_renderer<T>::process(building_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(building_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
template <typename T>
void svg_renderer<T>::process(building_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(building_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

View file

@ -26,15 +26,15 @@
namespace mapnik
{
template <typename T>
void svg_renderer<T>::process(line_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(line_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
template <typename T>
void svg_renderer<T>::process(line_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(line_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

View file

@ -26,24 +26,24 @@
namespace mapnik
{
/*!
* @brief Collect presentation attributes found in line symbolizer.
*/
template <typename T>
void svg_renderer<T>::process(line_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
path_attributes_.set_stroke_color(sym.get_stroke().get_color());
path_attributes_.set_stroke_opacity(sym.get_stroke().get_opacity());
path_attributes_.set_stroke_width(sym.get_stroke().get_width());
path_attributes_.set_stroke_linecap(sym.get_stroke().get_line_cap());
path_attributes_.set_stroke_linejoin(sym.get_stroke().get_line_join());
path_attributes_.set_stroke_dasharray(sym.get_stroke().get_dash_array());
path_attributes_.set_stroke_dashoffset(sym.get_stroke().dash_offset());
}
template void svg_renderer<std::ostream_iterator<char> >::process(line_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
/*!
* @brief Collect presentation attributes found in line symbolizer.
*/
template <typename T>
void svg_renderer<T>::process(line_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
path_attributes_.set_stroke_color(sym.get_stroke().get_color());
path_attributes_.set_stroke_opacity(sym.get_stroke().get_opacity());
path_attributes_.set_stroke_width(sym.get_stroke().get_width());
path_attributes_.set_stroke_linecap(sym.get_stroke().get_line_cap());
path_attributes_.set_stroke_linejoin(sym.get_stroke().get_line_join());
path_attributes_.set_stroke_dasharray(sym.get_stroke().get_dash_array());
path_attributes_.set_stroke_dashoffset(sym.get_stroke().dash_offset());
}
template void svg_renderer<std::ostream_iterator<char> >::process(line_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

View file

@ -26,15 +26,15 @@
namespace mapnik
{
template <typename T>
void svg_renderer<T>::process(markers_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(markers_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
template <typename T>
void svg_renderer<T>::process(markers_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(markers_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

View file

@ -26,15 +26,15 @@
namespace mapnik
{
template <typename T>
void svg_renderer<T>::process(point_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(point_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
template <typename T>
void svg_renderer<T>::process(point_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(point_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

View file

@ -26,15 +26,15 @@
namespace mapnik
{
template <typename T>
void svg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(polygon_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
template <typename T>
void svg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(polygon_pattern_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

View file

@ -26,19 +26,19 @@
namespace mapnik
{
/*!
* @brief Collect presentation attributes found in polygon symbolizer.
*/
template <typename T>
void svg_renderer<T>::process(polygon_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
path_attributes_.set_fill_color(sym.get_fill());
path_attributes_.set_fill_opacity(sym.get_opacity());
}
template void svg_renderer<std::ostream_iterator<char> >::process(polygon_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
/*!
* @brief Collect presentation attributes found in polygon symbolizer.
*/
template <typename T>
void svg_renderer<T>::process(polygon_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
path_attributes_.set_fill_color(sym.get_fill());
path_attributes_.set_fill_opacity(sym.get_opacity());
}
template void svg_renderer<std::ostream_iterator<char> >::process(polygon_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

View file

@ -26,15 +26,15 @@
namespace mapnik
{
template <typename T>
void svg_renderer<T>::process(raster_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(raster_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
template <typename T>
void svg_renderer<T>::process(raster_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
// nothing yet.
}
template void svg_renderer<std::ostream_iterator<char> >::process(raster_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans);
}

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