From 17d13cff675ff7d030dc8fc94a145fd2794b51df Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 1 Feb 2012 17:53:35 -0800 Subject: [PATCH] whitespace fixes - closes #911 --- include/mapnik/agg_renderer.hpp | 12 +- include/mapnik/arrow.hpp | 6 +- include/mapnik/attribute.hpp | 8 +- include/mapnik/attribute_collector.hpp | 52 +- include/mapnik/attribute_descriptor.hpp | 14 +- include/mapnik/box2d.hpp | 22 +- include/mapnik/building_symbolizer.hpp | 12 +- include/mapnik/cairo_renderer.hpp | 6 +- include/mapnik/color.hpp | 52 +- include/mapnik/color_factory.hpp | 40 +- include/mapnik/config.hpp | 2 +- include/mapnik/config_error.hpp | 4 +- include/mapnik/coord.hpp | 30 +- include/mapnik/coord_array.hpp | 30 +- include/mapnik/css_color_grammar.hpp | 72 +- .../mapnik/css_color_grammar_deprecated.hpp | 84 +- include/mapnik/ctrans.hpp | 124 +- include/mapnik/datasource.hpp | 28 +- include/mapnik/datasource_cache.hpp | 6 +- include/mapnik/distance.hpp | 12 +- include/mapnik/ellipsoid.hpp | 4 +- include/mapnik/enumeration.hpp | 46 +- include/mapnik/expression_evaluator.hpp | 32 +- include/mapnik/expression_grammar.hpp | 76 +- include/mapnik/expression_node.hpp | 66 +- include/mapnik/expression_string.hpp | 2 +- include/mapnik/factory.hpp | 2 +- include/mapnik/feature.hpp | 82 +- include/mapnik/feature_factory.hpp | 4 +- include/mapnik/feature_kv_iterator.hpp | 10 +- include/mapnik/feature_layer_desc.hpp | 2 +- include/mapnik/feature_style_processor.hpp | 6 +- include/mapnik/fill.hpp | 4 +- include/mapnik/filter_factory.hpp | 4 +- include/mapnik/filter_featureset.hpp | 14 +- include/mapnik/font_engine_freetype.hpp | 18 +- include/mapnik/font_set.hpp | 6 +- include/mapnik/gamma.hpp | 4 +- include/mapnik/geom_util.hpp | 44 +- include/mapnik/geometry.hpp | 84 +- include/mapnik/global.hpp | 32 +- include/mapnik/gradient.hpp | 10 +- include/mapnik/graphics.hpp | 10 +- include/mapnik/hextree.hpp | 16 +- include/mapnik/hit_test_filter.hpp | 8 +- include/mapnik/image_compositing.hpp | 16 +- include/mapnik/image_data.hpp | 24 +- include/mapnik/image_reader.hpp | 8 +- include/mapnik/image_util.hpp | 34 +- include/mapnik/image_view.hpp | 26 +- include/mapnik/jpeg_io.hpp | 30 +- include/mapnik/label_collision_detector.hpp | 76 +- include/mapnik/layer.hpp | 58 +- include/mapnik/libxml2_loader.hpp | 4 +- include/mapnik/line_pattern_symbolizer.hpp | 8 +- include/mapnik/line_symbolizer.hpp | 26 +- include/mapnik/load_map.hpp | 2 +- include/mapnik/map.hpp | 70 +- include/mapnik/mapped_memory_cache.hpp | 2 +- include/mapnik/marker.hpp | 4 +- include/mapnik/marker_cache.hpp | 2 +- include/mapnik/markers_placement.hpp | 6 +- include/mapnik/markers_symbolizer.hpp | 4 +- include/mapnik/memory.hpp | 2 +- include/mapnik/memory_datasource.hpp | 8 +- include/mapnik/memory_featureset.hpp | 12 +- include/mapnik/metawriter.hpp | 14 +- include/mapnik/metawriter_factory.hpp | 8 +- include/mapnik/metawriter_inmem.hpp | 102 +- include/mapnik/metawriter_json.hpp | 20 +- include/mapnik/octree.hpp | 32 +- include/mapnik/palette.hpp | 2 +- include/mapnik/params.hpp | 32 +- include/mapnik/parse_path.hpp | 32 +- include/mapnik/path_expression_grammar.hpp | 10 +- include/mapnik/placement_finder.hpp | 8 +- include/mapnik/plugin.hpp | 6 +- include/mapnik/png_io.hpp | 34 +- include/mapnik/point_symbolizer.hpp | 14 +- include/mapnik/polygon_pattern_symbolizer.hpp | 4 +- include/mapnik/polygon_symbolizer.hpp | 6 +- include/mapnik/pool.hpp | 28 +- include/mapnik/proj_transform.hpp | 10 +- include/mapnik/projection.hpp | 16 +- include/mapnik/ptree_helpers.hpp | 48 +- include/mapnik/quad_tree.hpp | 78 +- include/mapnik/query.hpp | 30 +- include/mapnik/raster.hpp | 2 +- include/mapnik/raster_colorizer.hpp | 76 +- include/mapnik/raster_symbolizer.hpp | 66 +- include/mapnik/rule.hpp | 148 +-- include/mapnik/save_map.hpp | 2 +- include/mapnik/scale_denominator.hpp | 4 +- include/mapnik/segment.hpp | 2 +- include/mapnik/shield_symbolizer.hpp | 4 +- include/mapnik/sql_utils.hpp | 292 ++--- include/mapnik/stroke.hpp | 16 +- include/mapnik/style_factory.hpp | 6 +- include/mapnik/svg/svg_converter.hpp | 104 +- include/mapnik/svg/svg_generator.hpp | 8 +- include/mapnik/svg/svg_output_attributes.hpp | 94 +- include/mapnik/svg/svg_output_grammars.hpp | 256 ++-- include/mapnik/svg/svg_parser.hpp | 64 +- include/mapnik/svg/svg_path_adapter.hpp | 220 ++-- include/mapnik/svg/svg_path_attributes.hpp | 6 +- include/mapnik/svg/svg_path_commands.hpp | 82 +- include/mapnik/svg/svg_path_grammar.hpp | 62 +- include/mapnik/svg/svg_path_iterator.hpp | 48 +- include/mapnik/svg/svg_path_parser.hpp | 14 +- include/mapnik/svg/svg_points_grammar.hpp | 8 +- include/mapnik/svg/svg_renderer.hpp | 94 +- include/mapnik/svg/svg_storage.hpp | 14 +- include/mapnik/svg/svg_transform_grammar.hpp | 116 +- include/mapnik/svg_renderer.hpp | 206 +-- include/mapnik/symbolizer.hpp | 96 +- include/mapnik/symbolizer_helpers.hpp | 26 +- include/mapnik/text_path.hpp | 44 +- include/mapnik/text_placements.hpp | 60 +- include/mapnik/text_placements_list.hpp | 4 +- include/mapnik/text_placements_simple.hpp | 4 +- include/mapnik/text_symbolizer.hpp | 6 +- include/mapnik/tiff_io.hpp | 34 +- include/mapnik/timer.hpp | 22 +- include/mapnik/unicode.hpp | 6 +- include/mapnik/util/container_adapter.hpp | 54 +- include/mapnik/util/deepcopy.hpp | 6 +- .../mapnik/util/geometry_svg_generator.hpp | 172 +-- include/mapnik/util/geometry_to_ds_type.hpp | 42 +- include/mapnik/util/geometry_to_wkb.hpp | 382 +++--- include/mapnik/util/geometry_to_wkt.hpp | 38 +- .../mapnik/util/geometry_wkt_generator.hpp | 338 ++--- include/mapnik/util/vertex_iterator.hpp | 92 +- include/mapnik/utils.hpp | 22 +- include/mapnik/value.hpp | 200 +-- include/mapnik/value_error.hpp | 4 +- include/mapnik/version.hpp | 2 +- include/mapnik/vertex.hpp | 22 +- include/mapnik/vertex_transform.hpp | 22 +- include/mapnik/vertex_vector.hpp | 30 +- include/mapnik/warp.hpp | 2 +- include/mapnik/wkb.hpp | 12 +- include/mapnik/wkt/wkt_factory.hpp | 4 +- include/mapnik/wkt/wkt_grammar.hpp | 300 ++--- src/agg/process_building_symbolizer.cpp | 10 +- src/agg/process_line_pattern_symbolizer.cpp | 4 +- src/agg/process_line_symbolizer.cpp | 66 +- src/agg/process_markers_symbolizer.cpp | 58 +- src/agg/process_point_symbolizer.cpp | 12 +- .../process_polygon_pattern_symbolizer.cpp | 50 +- src/agg/process_polygon_symbolizer.cpp | 36 +- src/agg/process_raster_symbolizer.cpp | 6 +- src/agg/process_shield_symbolizer.cpp | 10 +- src/agg/process_text_symbolizer.cpp | 12 +- src/arrow.cpp | 10 +- src/box2d.cpp | 38 +- src/building_symbolizer.cpp | 4 +- src/cairo_renderer.cpp | 1106 ++++++++--------- src/color.cpp | 22 +- src/datasource_cache.cpp | 98 +- src/deepcopy.cpp | 132 +- src/distance.cpp | 16 +- src/expression_string.cpp | 22 +- src/feature_kv_iterator.cpp | 10 +- src/feature_style_processor.cpp | 16 +- src/feature_type_style.cpp | 18 +- src/filter_factory.cpp | 8 +- src/font_engine_freetype.cpp | 84 +- src/font_set.cpp | 10 +- src/gamma_method.cpp | 2 +- src/gradient.cpp | 26 +- src/graphics.cpp | 50 +- src/grid/grid_renderer.cpp | 20 +- src/grid/process_building_symbolizer.cpp | 14 +- src/grid/process_line_pattern_symbolizer.cpp | 10 +- src/grid/process_line_symbolizer.cpp | 14 +- src/grid/process_markers_symbolizer.cpp | 52 +- src/grid/process_point_symbolizer.cpp | 12 +- .../process_polygon_pattern_symbolizer.cpp | 12 +- src/grid/process_polygon_symbolizer.cpp | 12 +- src/grid/process_raster_symbolizer.cpp | 8 +- src/grid/process_shield_symbolizer.cpp | 18 +- src/grid/process_text_symbolizer.cpp | 20 +- src/image_reader.cpp | 16 +- src/image_util.cpp | 186 +-- src/jpeg_reader.cpp | 260 ++-- src/layer.cpp | 30 +- src/libxml2_loader.cpp | 16 +- src/line_pattern_symbolizer.cpp | 6 +- src/line_symbolizer.cpp | 2 +- src/load_map.cpp | 180 +-- src/map.cpp | 150 +-- src/mapped_memory_cache.cpp | 16 +- src/marker_cache.cpp | 4 +- src/markers_symbolizer.cpp | 56 +- src/memory.cpp | 2 +- src/memory_datasource.cpp | 26 +- src/metawriter.cpp | 50 +- src/metawriter_factory.cpp | 84 +- src/metawriter_inmem.cpp | 28 +- src/palette.cpp | 6 +- src/parse_path.cpp | 2 +- src/placement_finder.cpp | 28 +- src/plugin.cpp | 2 +- src/png_reader.cpp | 32 +- src/point_symbolizer.cpp | 20 +- src/polygon_pattern_symbolizer.cpp | 12 +- src/polygon_symbolizer.cpp | 6 +- src/proj_transform.cpp | 44 +- src/projection.cpp | 52 +- src/raster_colorizer.cpp | 92 +- src/save_map.cpp | 60 +- src/scale_denominator.cpp | 10 +- src/shield_symbolizer.cpp | 2 +- src/stroke.cpp | 38 +- src/svg/process_building_symbolizer.cpp | 22 +- src/svg/process_line_pattern_symbolizer.cpp | 22 +- src/svg/process_line_symbolizer.cpp | 40 +- src/svg/process_markers_symbolizer.cpp | 22 +- src/svg/process_point_symbolizer.cpp | 22 +- .../process_polygon_pattern_symbolizer.cpp | 22 +- src/svg/process_polygon_symbolizer.cpp | 30 +- src/svg/process_raster_symbolizer.cpp | 24 +- src/svg/process_shield_symbolizer.cpp | 22 +- src/svg/process_symbolizers.cpp | 2 +- src/svg/process_text_symbolizer.cpp | 24 +- src/svg/svg_generator.cpp | 12 +- src/svg/svg_output_attributes.cpp | 86 +- src/svg/svg_renderer.cpp | 124 +- src/svg_parser.cpp | 176 +-- src/svg_path_parser.cpp | 28 +- src/svg_points_parser.cpp | 28 +- src/svg_transform_parser.cpp | 50 +- src/symbolizer.cpp | 10 +- src/symbolizer_helpers.cpp | 32 +- src/text_placements.cpp | 36 +- src/text_processing.cpp | 4 +- src/text_symbolizer.cpp | 4 +- src/tiff_reader.cpp | 22 +- src/unicode.cpp | 10 +- src/warp.cpp | 68 +- src/wkb.cpp | 54 +- src/wkt/wkt_factory.cpp | 2 +- 242 files changed, 5431 insertions(+), 5431 deletions(-) diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 230eaf65a..ebe8bec02 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -45,20 +45,20 @@ // apps using mapnik do not // need agg headers namespace agg { - struct trans_affine; +struct trans_affine; } namespace mapnik { class marker; - + struct rasterizer; - + template class MAPNIK_DECL agg_renderer : public feature_style_processor >, private boost::noncopyable { - + public: // create with default, empty placement detector agg_renderer(Map const& m, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); @@ -101,7 +101,7 @@ public: proj_transform const& prj_trans); void process(markers_symbolizer const& sym, mapnik::feature_ptr const& feature, - proj_transform const& prj_trans); + proj_transform const& prj_trans); inline bool process(rule::symbolizers const& /*syms*/, Feature const& /*feature*/, proj_transform const& /*prj_trans*/) diff --git a/include/mapnik/arrow.hpp b/include/mapnik/arrow.hpp index 93a56db67..0391228a5 100644 --- a/include/mapnik/arrow.hpp +++ b/include/mapnik/arrow.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -33,13 +33,13 @@ public: arrow(); void rewind(unsigned path_id); unsigned vertex(double* x, double* y); - box2d extent() const; + box2d extent() const; private: unsigned pos_; double x_[7]; double y_[7]; unsigned cmd_[9]; -}; +}; } #endif // MAPNIK_ARROW_HPP diff --git a/include/mapnik/attribute.hpp b/include/mapnik/attribute.hpp index bc37461b6..b38292c48 100644 --- a/include/mapnik/attribute.hpp +++ b/include/mapnik/attribute.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,13 +35,13 @@ struct attribute std::string name_; explicit attribute(std::string const& name) : name_(name) {} - + template V const& value(F const& f) const { - return f.get(name_); + return f.get(name_); } - + std::string const& name() const { return name_;} }; } diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index 8efd91911..3e4d3b681 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -39,41 +39,41 @@ struct expression_attributes : boost::static_visitor { explicit expression_attributes(std::set & names) : names_(names) {} - - void operator() (value_type const& x) const + + void operator() (value_type const& x) const { boost::ignore_unused_variable_warning(x); } - + void operator() (attribute const& attr) const { names_.insert(attr.name()); } - - template + + template void operator() (binary_node const& x) const { boost::apply_visitor(expression_attributes(names_),x.left); boost::apply_visitor(expression_attributes(names_),x.right); - + } template void operator() (unary_node const& x) const { - boost::apply_visitor(expression_attributes(names_),x.expr); + boost::apply_visitor(expression_attributes(names_),x.expr); } - + void operator() (regex_match_node const& x) const { boost::apply_visitor(expression_attributes(names_),x.expr); } - + void operator() (regex_replace_node const& x) const { boost::apply_visitor(expression_attributes(names_),x.expr); } - + private: std::set& names_; }; @@ -82,10 +82,10 @@ struct symbolizer_attributes : public boost::static_visitor<> { symbolizer_attributes(std::set& names) : names_(names) {} - + template void operator () (T const&) const {} - + void operator () (text_symbolizer const& sym) { std::set::const_iterator it; @@ -97,9 +97,9 @@ struct symbolizer_attributes : public boost::static_visitor<> } collect_metawriter(sym); } - + void operator () (point_symbolizer const& sym) - { + { path_expression_ptr const& filename_expr = sym.get_filename(); if (filename_expr) { @@ -115,7 +115,7 @@ struct symbolizer_attributes : public boost::static_visitor<> } void operator () (line_pattern_symbolizer const& sym) - { + { path_expression_ptr const& filename_expr = sym.get_filename(); if (filename_expr) { @@ -130,7 +130,7 @@ struct symbolizer_attributes : public boost::static_visitor<> } void operator () (polygon_pattern_symbolizer const& sym) - { + { path_expression_ptr const& filename_expr = sym.get_filename(); if (filename_expr) { @@ -138,7 +138,7 @@ struct symbolizer_attributes : public boost::static_visitor<> } collect_metawriter(sym); } - + void operator () (shield_symbolizer const& sym) { std::set::const_iterator it; @@ -148,7 +148,7 @@ struct symbolizer_attributes : public boost::static_visitor<> { if (*it) boost::apply_visitor(f_attr, **it); } - + path_expression_ptr const& filename_expr = sym.get_filename(); if (filename_expr) { @@ -173,7 +173,7 @@ struct symbolizer_attributes : public boost::static_visitor<> collect_metawriter(sym); } // TODO - support remaining syms - + private: std::set& names_; void collect_metawriter(symbolizer_base const& sym) @@ -189,10 +189,10 @@ class attribute_collector : public boost::noncopyable private: std::set& names_; public: - + attribute_collector(std::set& names) : names_(names) {} - + template void operator() (RuleType const& r) { @@ -203,21 +203,21 @@ public: { boost::apply_visitor(s_attr,*symIter++); } - + expression_ptr const& expr = r.get_filter(); expression_attributes f_attr(names_); boost::apply_visitor(f_attr,*expr); - } + } }; struct directive_collector : public boost::static_visitor<> { directive_collector(double * filter_factor) : filter_factor_(filter_factor) {} - + template void operator () (T const&) const {} - + void operator () (raster_symbolizer const& sym) { *filter_factor_ = sym.calculate_filter_factor(); diff --git a/include/mapnik/attribute_descriptor.hpp b/include/mapnik/attribute_descriptor.hpp index 7ba2e665d..235935486 100644 --- a/include/mapnik/attribute_descriptor.hpp +++ b/include/mapnik/attribute_descriptor.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -34,7 +34,7 @@ enum eAttributeType { String =4, Boolean =5, Geometry=6, - Object=7 + Object=7 }; class attribute_descriptor @@ -49,7 +49,7 @@ public: primary_key_(primary_key), size_(size), precision_(precision) {} - + attribute_descriptor(attribute_descriptor const& other) : name_(other.name_), type_(other.type_), @@ -60,7 +60,7 @@ public: attribute_descriptor& operator=(attribute_descriptor const& other) { if (this == &other) - return *this; + return *this; name_=other.name_; type_=other.type_; primary_key_=other.primary_key_; @@ -87,8 +87,8 @@ public: int get_size() const { return size_; - } - + } + int get_precision() const { return precision_; @@ -101,7 +101,7 @@ private: int size_; int precision_; }; - + template inline std::basic_ostream& operator << (std::basic_ostream& out, diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 16d7f85c4..2f2c88127 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -34,15 +34,15 @@ #include namespace mapnik { - + /*! * A spatial envelope (i.e. bounding box) which also defines some basic operators. */ -template class MAPNIK_DECL box2d +template class MAPNIK_DECL box2d : boost::equality_comparable , - boost::addable, - boost::dividable2, T, - boost::multipliable2, T > > > > + boost::addable, + boost::dividable2, T, + boost::multipliable2, T > > > > { public: typedef box2d box2d_type; @@ -82,14 +82,14 @@ public: void clip(const box2d_type &other); bool from_string(const std::string& s); bool valid() const; - - // define some operators + + // define some operators box2d_type& operator+=(box2d_type const& other); box2d_type& operator*=(T); box2d_type& operator/=(T); T operator[](int index) const; }; - + template inline std::basic_ostream& operator << (std::basic_ostream& out, @@ -98,8 +98,8 @@ operator << (std::basic_ostream& out, std::basic_ostringstream s; s.copyfmt(out); s.width(0); - s <<"box2d(" << std::setprecision(16) - << e.minx() << "," << e.miny() <<"," + s <<"box2d(" << std::setprecision(16) + << e.minx() << "," << e.miny() <<"," << e.maxx() << "," << e.maxy() <<")"; out << s.str(); return out; diff --git a/include/mapnik/building_symbolizer.hpp b/include/mapnik/building_symbolizer.hpp index 08eed1bcb..c2fe8ffb4 100644 --- a/include/mapnik/building_symbolizer.hpp +++ b/include/mapnik/building_symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -28,15 +28,15 @@ #include #include -namespace mapnik +namespace mapnik { - + struct MAPNIK_DECL building_symbolizer : public symbolizer_base { building_symbolizer(); - building_symbolizer(color const& fill, expression_ptr height); + building_symbolizer(color const& fill, expression_ptr height); color const& get_fill() const; - void set_fill(color const& fill); + void set_fill(color const& fill); expression_ptr height() const; void set_height(expression_ptr height); void set_opacity(double opacity); @@ -46,7 +46,7 @@ private: color fill_; expression_ptr height_; double opacity_; -}; +}; } diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index 1b0e23ae2..da83844b6 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -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; diff --git a/include/mapnik/color.hpp b/include/mapnik/color.hpp index 37c10cc93..c7f2de610 100644 --- a/include/mapnik/color.hpp +++ b/include/mapnik/color.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,8 +35,8 @@ #include namespace mapnik { - -class MAPNIK_DECL color + +class MAPNIK_DECL color : boost::equality_comparable { private: @@ -44,7 +44,7 @@ private: boost::uint8_t green_; boost::uint8_t blue_; boost::uint8_t alpha_; - + public: color() : red_(0xff), @@ -52,38 +52,38 @@ public: blue_(0xff), alpha_(0xff) {} - + color(unsigned red, unsigned green, unsigned blue, unsigned alpha = 0xff) : red_(red), green_(green), blue_(blue), alpha_(alpha) {} - + color( std::string const& css_string); - + color(const color& rhs) : red_(rhs.red_), green_(rhs.green_), blue_(rhs.blue_), - alpha_(rhs.alpha_) + alpha_(rhs.alpha_) {} color& operator=(const color& rhs) - { - if (this==&rhs) return *this; - red_=rhs.red_; - green_=rhs.green_; - blue_=rhs.blue_; - alpha_=rhs.alpha_; - return *this; - } - + { + if (this==&rhs) return *this; + red_=rhs.red_; + green_=rhs.green_; + blue_=rhs.blue_; + alpha_=rhs.alpha_; + return *this; + } + inline unsigned red() const { return red_; } - + inline unsigned green() const { return green_; @@ -95,8 +95,8 @@ public: inline unsigned alpha() const { return alpha_; - } - + } + inline void set_red(unsigned red) { red_ = red; @@ -105,7 +105,7 @@ public: { green_ = green; } - + inline void set_blue(unsigned blue) { blue_ = blue; @@ -123,19 +123,19 @@ public: return (alpha_ << 24) | (blue_ << 16) | (green_ << 8) | (red_) ; #endif } - + inline bool operator==(color const& rhs) const { return (red_== rhs.red()) && (green_ == rhs.green()) && (blue_ == rhs.blue()) && (alpha_ == rhs.alpha()); - + } - - std::string to_string() const; + + std::string to_string() const; std::string to_hex_string() const; -}; +}; } diff --git a/include/mapnik/color_factory.hpp b/include/mapnik/color_factory.hpp index c27af5fa4..181bffb2e 100644 --- a/include/mapnik/color_factory.hpp +++ b/include/mapnik/color_factory.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -36,17 +36,17 @@ #if BOOST_VERSION >= 104500 #include -namespace mapnik { - +namespace mapnik { + class MAPNIK_DECL color_factory : boost::noncopyable { public: - + static void init_from_string(color & c, std::string const& css_color) - { + { typedef std::string::const_iterator iterator_type; - typedef mapnik::css_color_grammar css_color_grammar; - + typedef mapnik::css_color_grammar css_color_grammar; + css_color_grammar g; iterator_type first = css_color.begin(); iterator_type last = css_color.end(); @@ -56,15 +56,15 @@ public: g, boost::spirit::ascii::space, c); - if (!result) + if (!result) { throw config_error(std::string("Failed to parse color value: ") + "Expected a CSS color, but got '" + css_color + "'"); } - } - + } + static color from_string(std::string const& css_color) - { + { color c; init_from_string(c,css_color); return c; @@ -75,16 +75,16 @@ public: #else #include -namespace mapnik { - +namespace mapnik { + class MAPNIK_DECL color_factory : boost::noncopyable { public: - + static void init_from_string(color & c, std::string const& css_color) - { + { typedef std::string::const_iterator iterator_type; - typedef mapnik::css_color_grammar css_color_grammar; + typedef mapnik::css_color_grammar css_color_grammar; css_color_grammar g; iterator_type first = css_color.begin(); @@ -96,7 +96,7 @@ public: g, boost::spirit::ascii::space, css_); - if (!result) + if (!result) { throw config_error(std::string("Failed to parse color value: ") + "Expected a CSS color, but got '" + css_color + "'"); @@ -105,10 +105,10 @@ public: c.set_green(css_.g); c.set_blue(css_.b); c.set_alpha(css_.a); - } - + } + static color from_string(std::string const& css_color) - { + { color c; init_from_string(c,css_color); return c; diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index a79ade04d..d25d74f62 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/config_error.hpp b/include/mapnik/config_error.hpp index c43169e50..8b80430f1 100644 --- a/include/mapnik/config_error.hpp +++ b/include/mapnik/config_error.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -41,7 +41,7 @@ public: virtual const char * what() const throw() { - return what_.c_str(); + return what_.c_str(); } void append_context(const std::string & ctx) const diff --git a/include/mapnik/coord.hpp b/include/mapnik/coord.hpp index 340929801..76cbb671a 100644 --- a/include/mapnik/coord.hpp +++ b/include/mapnik/coord.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,21 +30,21 @@ #include #include -namespace mapnik { +namespace mapnik { template struct coord { typedef T type; }; - + template -struct coord +struct coord : boost::addable, boost::addable2,T, boost::subtractable, boost::subtractable2,T, boost::dividable2, T, boost::multipliable2, T > > > > > > - + { typedef T type; T x; @@ -82,28 +82,28 @@ public: y+=rhs.y; return *this; } - + coord& operator+=(T rhs) { x+=rhs; y+=rhs; return *this; } - + coord& operator-=(coord const& rhs) { x-=rhs.x; y-=rhs.y; return *this; } - + coord& operator-=(T rhs) { x-=rhs; y-=rhs; return *this; } - + coord& operator*=(T t) { x*=t; @@ -119,7 +119,7 @@ public: }; template -struct coord +struct coord { typedef T type; T x; @@ -153,12 +153,12 @@ public: typedef coord coord2d; typedef coord coord2i; - + template inline std::basic_ostream& operator << (std::basic_ostream& out, const coord& c); - + template inline std::basic_ostream& operator << (std::basic_ostream& out, @@ -167,7 +167,7 @@ operator << (std::basic_ostream& out, std::basic_ostringstream s; s.copyfmt(out); s.width(0); - s << "coord2(" << std::setprecision(16) + s << "coord2(" << std::setprecision(16) << c.x << "," << c.y<< ")"; out << s.str(); return out; @@ -181,11 +181,11 @@ operator << (std::basic_ostream& out, std::basic_ostringstream s; s.copyfmt(out); s.width(0); - s << "coord3(" << std::setprecision(16) + s << "coord3(" << std::setprecision(16) << c.x << "," << c.y<< "," << c.z<<")"; out << s.str(); return out; -} +} } #endif // MAPNIK_COORD_HPP diff --git a/include/mapnik/coord_array.hpp b/include/mapnik/coord_array.hpp index 410e8e5d0..08c54617c 100644 --- a/include/mapnik/coord_array.hpp +++ b/include/mapnik/coord_array.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -31,57 +31,57 @@ namespace mapnik { template -class coord_array -{ +class coord_array +{ typedef T coord_type; coord_type* pt_; const unsigned size_; -public: +public: coord_array(unsigned size=0) : pt_(static_cast(size==0?0: ::operator new (sizeof(coord_type)*size))), size_(size) {} - + coord_array(const coord_array& rhs) : pt_(static_cast(rhs.size_==0?0: ::operator new (sizeof(coord_type)*rhs.size_))), size_(rhs.size_) { memcpy(pt_,rhs.pt_,sizeof(coord_type)*rhs.size_); } - - ~coord_array() + + ~coord_array() { ::operator delete (pt_); } - - unsigned size() const + + unsigned size() const { return size_; } - + void set(unsigned index,double x,double y) { assert(index #include -// phoenix +// phoenix #include #include #include @@ -234,7 +234,7 @@ struct percent_conv_impl { typedef unsigned type; }; - + unsigned operator() (double val) const { return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5)); @@ -248,7 +248,7 @@ struct alpha_conv_impl { typedef unsigned type; }; - + unsigned operator() (double val) const { return clip_int<0,255>(int((255.0 * val) + 0.5)); @@ -260,8 +260,8 @@ inline double hue_to_rgb( double m1, double m2, double h) { if (h < 0.0) h = h + 1.0; else if (h > 1) h = h - 1.0; - - if (h * 6 < 1.0) + + if (h * 6 < 1.0) return m1 + (m2 - m1) * h * 6.0; if (h * 2 < 1.0) return m2; @@ -277,7 +277,7 @@ struct hsl_conv_impl { typedef void type; }; - + template void operator() (T0 & c, T1 h, T2 s, T3 l) const { @@ -286,17 +286,17 @@ struct hsl_conv_impl h /= 360.0; s /= 100.0; l /= 100.0; - + if (l <= 0.5) m2 = l * (s + 1.0); else - m2 = l + s - l*s; + m2 = l + s - l*s; m1 = l * 2 - m2; - + double r = hue_to_rgb(m1, m2, h + 1.0/3.0); double g = hue_to_rgb(m1, m2, h); double b = hue_to_rgb(m1, m2, h - 1.0/3.0); - + c.set_red(clip_int<0,255>(int((255.0 * r) + 0.5))); c.set_green(clip_int<0,255>(int((255.0 * g) + 0.5))); c.set_blue(clip_int<0,255>(int((255.0 * b) + 0.5))); @@ -307,10 +307,10 @@ struct hsl_conv_impl template struct css_color_grammar : qi::grammar { - + css_color_grammar() : css_color_grammar::base_type(css_color) - + { using qi::lit; using qi::_val; @@ -319,58 +319,58 @@ struct css_color_grammar : qi::grammar using qi::_a; using qi::_b; using qi::_c; - using ascii::no_case; + using ascii::no_case; using phoenix::at_c; - + css_color %= rgba_color - | rgba_percent_color + | rgba_percent_color | hsl_percent_color - | hex_color - | hex_color_small + | hex_color + | hex_color_small | no_case[named]; - - hex_color = lit('#') + + hex_color = lit('#') >> hex2 [ at_c<0>(_val) = _1 ] >> hex2 [ at_c<1>(_val) = _1 ] >> hex2 [ at_c<2>(_val) = _1 ] >>-hex2 [ at_c<3>(_val) = _1 ] ; - + hex_color_small = lit('#') >> hex1 [ at_c<0>(_val) = _1 | _1 << 4 ] >> hex1 [ at_c<1>(_val) = _1 | _1 << 4 ] >> hex1 [ at_c<2>(_val) = _1 | _1 << 4 ] >>-hex1 [ at_c<3>(_val) = _1 | _1 << 4 ] ; - + rgba_color = lit("rgb") >> -lit('a') - >> lit('(') - >> dec3 [at_c<0>(_val) = _1] >> ',' - >> dec3 [at_c<1>(_val) = _1] >> ',' - >> dec3 [at_c<2>(_val) = _1] - >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) - >> lit(')') + >> lit('(') + >> dec3 [at_c<0>(_val) = _1] >> ',' + >> dec3 [at_c<1>(_val) = _1] >> ',' + >> dec3 [at_c<2>(_val) = _1] + >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) + >> lit(')') ; - + rgba_percent_color = lit("rgb") >> -lit('a') >> lit('(') >> double_ [at_c<0>(_val) = percent_converter(_1)] >> '%' >> ',' >> double_ [at_c<1>(_val) = percent_converter(_1)] >> '%' >> ',' - >> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%' + >> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%' >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) >> lit(')') ; - + hsl_percent_color = lit("hsl") >> -lit('a') - >> lit('(') - >> double_ [ _a = _1] >> ',' // hue 0..360 + >> lit('(') + >> double_ [ _a = _1] >> ',' // hue 0..360 >> double_ [ _b = _1] >> '%' >> ',' // saturation 0..100% >> double_ [ _c = _1] >> '%' // lightness 0..100% >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) // opacity 0...1 >> lit (')') [ hsl_converter(_val,_a,_b,_c)] ; } - + qi::uint_parser< unsigned, 16, 2, 2 > hex2 ; qi::uint_parser< unsigned, 16, 1, 1 > hex1 ; qi::uint_parser< unsigned, 10, 1, 3 > dec3 ; @@ -382,8 +382,8 @@ struct css_color_grammar : qi::grammar qi::rule css_color; named_colors_ named; phoenix::function percent_converter; - phoenix::function alpha_converter; - phoenix::function hsl_converter; + phoenix::function alpha_converter; + phoenix::function hsl_converter; }; } diff --git a/include/mapnik/css_color_grammar_deprecated.hpp b/include/mapnik/css_color_grammar_deprecated.hpp index 336dd2f56..d2987b660 100644 --- a/include/mapnik/css_color_grammar_deprecated.hpp +++ b/include/mapnik/css_color_grammar_deprecated.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -31,7 +31,7 @@ #include #include -// phoenix +// phoenix #include #include #include @@ -40,7 +40,7 @@ // fusion #include -// not in boost 1.41 +// not in boost 1.41 //#include // stl @@ -59,11 +59,11 @@ namespace mapnik // temp workaround . TODO: adapt mapnik::color struct css { - css () + css () : r(255),g(255),b(255),a(255) {} css(unsigned r_,unsigned g_, unsigned b_,unsigned a_ = 0xff) : r(r_),g(g_),b(b_),a(a_) {} - + unsigned r; unsigned g; unsigned b; @@ -262,7 +262,7 @@ struct percent_conv_impl { typedef unsigned type; }; - + unsigned operator() (double val) const { return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5)); @@ -276,7 +276,7 @@ struct alpha_conv_impl { typedef unsigned type; }; - + unsigned operator() (double val) const { return clip_int<0,255>(int((255.0 * val) + 0.5)); @@ -289,8 +289,8 @@ inline double hue_to_rgb( double m1, double m2, double h) { if (h < 0.0) h = h + 1.0; else if (h > 1) h = h - 1.0; - - if (h * 6 < 1.0) + + if (h * 6 < 1.0) return m1 + (m2 - m1) * h * 6.0; if (h * 2 < 1.0) return m2; @@ -306,7 +306,7 @@ struct hsl_conv_impl { typedef void type; }; - + template void operator() (T0 & c, T1 h, T2 s, T3 l) const { @@ -315,17 +315,17 @@ struct hsl_conv_impl h /= 360.0; s /= 100.0; l /= 100.0; - + if (l <= 0.5) m2 = l * (s + 1.0); else - m2 = l + s - l*s; + m2 = l + s - l*s; m1 = l * 2 - m2; - + double r = hue_to_rgb(m1, m2, h + 1.0/3.0); double g = hue_to_rgb(m1, m2, h); double b = hue_to_rgb(m1, m2, h - 1.0/3.0); - + c.r = clip_int<0,255>(int((255.0 * r) + 0.5)); c.g = clip_int<0,255>(int((255.0 * g) + 0.5)); c.b = clip_int<0,255>(int((255.0 * b) + 0.5)); @@ -336,10 +336,10 @@ struct hsl_conv_impl template struct css_color_grammar : qi::grammar { - + css_color_grammar() : css_color_grammar::base_type(css_color) - + { using qi::lit; using qi::_val; @@ -348,58 +348,58 @@ struct css_color_grammar : qi::grammar using qi::_a; using qi::_b; using qi::_c; - using ascii::no_case; + using ascii::no_case; using phoenix::at_c; - + css_color %= rgba_color | rgba_percent_color - | hsl_percent_color - | hex_color - | hex_color_small + | hsl_percent_color + | hex_color + | hex_color_small | no_case[named]; - - hex_color %= lit('#') - >> hex2 - >> hex2 - >> hex2 - >> -hex2 + + hex_color %= lit('#') + >> hex2 + >> hex2 + >> hex2 + >> -hex2 ; - + hex_color_small = lit('#') >> hex1 [ at_c<0>(_val) = _1 | _1 << 4 ] >> hex1 [ at_c<1>(_val) = _1 | _1 << 4 ] >> hex1 [ at_c<2>(_val) = _1 | _1 << 4 ] >> -hex1[ at_c<3>(_val) = _1 | _1 << 4 ] ; - + rgba_color = lit("rgb") >> -lit('a') - >> lit('(') - >> dec3 [at_c<0>(_val) = _1] >> ',' - >> dec3 [at_c<1>(_val) = _1] >> ',' - >> dec3 [at_c<2>(_val) = _1] - >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) - >> lit(')') + >> lit('(') + >> dec3 [at_c<0>(_val) = _1] >> ',' + >> dec3 [at_c<1>(_val) = _1] >> ',' + >> dec3 [at_c<2>(_val) = _1] + >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) + >> lit(')') ; - + rgba_percent_color = lit("rgb") >> -lit('a') >> lit('(') >> double_ [at_c<0>(_val) = percent_converter(_1)] >> '%' >> ',' >> double_ [at_c<1>(_val) = percent_converter(_1)] >> '%' >> ',' - >> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%' + >> double_ [at_c<2>(_val) = percent_converter(_1)] >> '%' >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) >> lit(')') ; - + hsl_percent_color = lit("hsl") >> -lit('a') - >> lit('(') - >> double_ [ _a = _1] >> ',' // hue 0..360 + >> lit('(') + >> double_ [ _a = _1] >> ',' // hue 0..360 >> double_ [ _b = _1] >> '%' >> ',' // saturation 0..100% >> double_ [ _c = _1] >> '%' // lightness 0..100% >> -(','>> -double_ [at_c<3>(_val) = alpha_converter(_1)]) // opacity 0...1 >> lit (')') [ hsl_converter(_val,_a,_b,_c)] ; } - + qi::uint_parser< unsigned, 16, 2, 2 > hex2 ; qi::uint_parser< unsigned, 16, 1, 1 > hex1 ; qi::uint_parser< unsigned, 10, 1, 3 > dec3 ; @@ -411,7 +411,7 @@ struct css_color_grammar : qi::grammar qi::rule css_color; named_colors_ named; phoenix::function percent_converter; - phoenix::function alpha_converter; + phoenix::function alpha_converter; phoenix::function hsl_converter; }; diff --git a/include/mapnik/ctrans.hpp b/include/mapnik/ctrans.hpp index 6fc2297f4..6d350c540 100644 --- a/include/mapnik/ctrans.hpp +++ b/include/mapnik/ctrans.hpp @@ -165,31 +165,31 @@ struct MAPNIK_DECL coord_transform_parallel typedef typename Geometry::value_type value_type; coord_transform_parallel(Transform const& t, - Geometry const& geom, - proj_transform const& prj_trans ) - : t_(t), - geom_(geom), - prj_trans_(prj_trans), - offset_(0.0), - threshold_(10), - m_status(initial) {} - + Geometry const& geom, + proj_transform const& prj_trans ) + : t_(t), + geom_(geom), + prj_trans_(prj_trans), + offset_(0.0), + threshold_(10), + m_status(initial) {} + enum status - { - initial, + { + initial, start, - first, + first, process, last_vertex, angle_joint, - end + end }; double get_offset() const { return offset_; } - + void set_offset(double offset) { offset_ = offset; @@ -199,7 +199,7 @@ struct MAPNIK_DECL coord_transform_parallel { return threshold_; } - + void set_threshold(unsigned int t) { threshold_ = t; @@ -208,7 +208,7 @@ struct MAPNIK_DECL coord_transform_parallel unsigned vertex(double * x , double * y) { double z=0; - + if (offset_==0.0) { unsigned command = geom_.vertex(x,y); @@ -239,10 +239,10 @@ struct MAPNIK_DECL coord_transform_parallel angle_a = atan2((m_pre_y-m_cur_y),(m_pre_x-m_cur_x)); dx_pre = cos(angle_a + pi_by_2); dy_pre = sin(angle_a + pi_by_2); - #ifdef MAPNIK_DEBUG - std::clog << "offsetting line by: " << offset_ << "\n"; - std::clog << "initial dx=" << (dx_pre * offset_) << " dy=" << (dy_pre * offset_) << "\n"; - #endif +#ifdef MAPNIK_DEBUG + std::clog << "offsetting line by: " << offset_ << "\n"; + std::clog << "initial dx=" << (dx_pre * offset_) << " dy=" << (dy_pre * offset_) << "\n"; +#endif *x = m_pre_x + (dx_pre * offset_); *y = m_pre_y + (dy_pre * offset_); m_status = process; @@ -250,23 +250,23 @@ struct MAPNIK_DECL coord_transform_parallel case process: switch(m_cur_cmd) { + case SEG_LINETO: + m_next_cmd = geom_.vertex(&m_next_x, &m_next_y); + prj_trans_.backward(m_next_x,m_next_y,z); + t_.forward(&m_next_x,&m_next_y); + switch(m_next_cmd) + { case SEG_LINETO: - m_next_cmd = geom_.vertex(&m_next_x, &m_next_y); - prj_trans_.backward(m_next_x,m_next_y,z); - t_.forward(&m_next_x,&m_next_y); - switch(m_next_cmd) - { - case SEG_LINETO: - m_status = angle_joint; - break; - default: - m_status = last_vertex; - break; - } + m_status = angle_joint; break; - case SEG_END: - m_status = end; - return SEG_END; + default: + m_status = last_vertex; + break; + } + break; + case SEG_END: + m_status = end; + return SEG_END; } break; case last_vertex: @@ -289,8 +289,8 @@ struct MAPNIK_DECL coord_transform_parallel } else // skip sharp spikes { - - #ifdef MAPNIK_DEBUG + +#ifdef MAPNIK_DEBUG dx_curr = cos(angle_a + pi_by_2); dy_curr = sin(angle_a + pi_by_2); sin_curve = dx_curr*dy_pre-dy_curr*dx_pre; @@ -298,35 +298,35 @@ struct MAPNIK_DECL coord_transform_parallel std::clog << "angle b: " << angle_b << "\n"; std::clog << "h: " << h << "\n"; std::clog << "sin_curve: " << sin_curve << "\n"; - #endif +#endif m_status = process; break; } // alternate sharp spike fix, but suboptimal... - + /* - sin_curve = dx_curr*dy_pre-dy_curr*dx_pre; - cos_curve = -dx_pre*dx_curr-dy_pre*dy_curr; - - #ifdef MAPNIK_DEBUG - std::clog << "sin_curve value: " << sin_curve << "\n"; - #endif - if(sin_curve > -0.3 && sin_curve < 0.3) { - angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x)); - h = tan((angle_b - angle_a)/2.0); - *x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_); - *y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_); - } else { - if (angle_b - angle_a > 0) - h = -1.0*(1.0+cos_curve)/sin_curve; - else - h = (1.0+cos_curve)/sin_curve; - *x = m_cur_x + (dx_curr + base_shift*dy_curr)*offset_; - *y = m_cur_y + (dy_curr - base_shift*dx_curr)*offset_; - } + sin_curve = dx_curr*dy_pre-dy_curr*dx_pre; + cos_curve = -dx_pre*dx_curr-dy_pre*dy_curr; + + #ifdef MAPNIK_DEBUG + std::clog << "sin_curve value: " << sin_curve << "\n"; + #endif + if(sin_curve > -0.3 && sin_curve < 0.3) { + angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x)); + h = tan((angle_b - angle_a)/2.0); + *x = m_cur_x + (dx_curr * offset_) - h * (dy_curr * offset_); + *y = m_cur_y + (dy_curr * offset_) + h * (dx_curr * offset_); + } else { + if (angle_b - angle_a > 0) + h = -1.0*(1.0+cos_curve)/sin_curve; + else + h = (1.0+cos_curve)/sin_curve; + *x = m_cur_x + (dx_curr + base_shift*dy_curr)*offset_; + *y = m_cur_y + (dy_curr - base_shift*dx_curr)*offset_; + } */ - + m_pre_x = *x; m_pre_x = *y; m_cur_x = m_next_x; @@ -337,7 +337,7 @@ struct MAPNIK_DECL coord_transform_parallel m_status = process; return m_pre_cmd; } - } + } } } @@ -346,7 +346,7 @@ struct MAPNIK_DECL coord_transform_parallel geom_.rewind(pos); m_status = initial; } - + private: Transform const& t_; Geometry const& geom_; @@ -390,7 +390,7 @@ public: CoordTransform(int width, int height, const box2d& 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(width_) / extent_.width(); sy_ = static_cast(height_) / extent_.height(); diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 0902a72fb..5cfd1bde5 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -42,15 +42,15 @@ namespace mapnik { typedef MAPNIK_DECL boost::shared_ptr feature_ptr; - + struct MAPNIK_DECL Featureset : private boost::noncopyable { virtual feature_ptr next()=0; virtual ~Featureset() {}; }; - + typedef MAPNIK_DECL boost::shared_ptr featureset_ptr; - + class MAPNIK_DECL datasource_exception : public std::exception { private: @@ -65,7 +65,7 @@ public: return message_.c_str(); } }; - + class MAPNIK_DECL datasource : private boost::noncopyable { public: @@ -83,9 +83,9 @@ public: datasource (parameters const& params) : params_(params), - is_bound_(false) + is_bound_(false) {} - + /*! * @brief Get the configuration parameters of the data source. * @@ -97,18 +97,18 @@ public: { return params_; } - + /*! * @brief Get the type of the datasource * @return The type of the datasource (Vector or Raster) */ virtual datasource_t type() const=0; - + /*! * @brief Connect to the datasource */ virtual void bind() const {}; - + virtual featureset_ptr features(const query& q) const=0; virtual featureset_ptr features_at_point(coord2d const& pt) const=0; virtual box2d envelope() const=0; @@ -119,12 +119,12 @@ protected: parameters params_; mutable bool is_bound_; }; - + typedef std::string datasource_name(); typedef datasource* create_ds(const parameters& params, bool bind); typedef void destroy_ds(datasource *ds); - + class datasource_deleter { public: @@ -135,8 +135,8 @@ public: }; typedef boost::shared_ptr datasource_ptr; - - + + #define DATASOURCE_PLUGIN(classname) \ extern "C" MAPNIK_EXP std::string datasource_name() \ { \ diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index d98a96db1..845abd764 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -37,7 +37,7 @@ #include namespace mapnik { -class MAPNIK_DECL datasource_cache : +class MAPNIK_DECL datasource_cache : public singleton , private boost::noncopyable { @@ -53,7 +53,7 @@ private: static std::vector plugin_directories_; public: static std::vector plugin_names(); - static std::string plugin_directories(); + static std::string plugin_directories(); static void register_datasources(const std::string& path); static boost::shared_ptr create(parameters const& params, bool bind=true); }; diff --git a/include/mapnik/distance.hpp b/include/mapnik/distance.hpp index 5c1b8f7eb..83511c1ca 100644 --- a/include/mapnik/distance.hpp +++ b/include/mapnik/distance.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -28,16 +28,16 @@ namespace mapnik { struct ellipsoid; - -// great-circle distance - + +// great-circle distance + class great_circle_distance { public: double operator() (coord2d const& pt0, coord2d const& pt1) const; }; - -// vincenty distance + +// vincenty distance /* class vincenty_distance : boost::noncopyble { diff --git a/include/mapnik/ellipsoid.hpp b/include/mapnik/ellipsoid.hpp index 82c3e7231..018a0170f 100644 --- a/include/mapnik/ellipsoid.hpp +++ b/include/mapnik/ellipsoid.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -26,7 +26,7 @@ namespace mapnik { struct ellipsoid { - double a; // semi mayor axis + double a; // semi mayor axis double b; // semi minor axis }; } diff --git a/include/mapnik/enumeration.hpp b/include/mapnik/enumeration.hpp index 19ffc2828..0e069e4f1 100644 --- a/include/mapnik/enumeration.hpp +++ b/include/mapnik/enumeration.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -47,7 +47,7 @@ public: virtual const char * what() const throw() { - return what_.c_str(); + return what_.c_str(); } protected: @@ -63,14 +63,14 @@ protected: * are provided to help with instanciation. * * @par Limitations: - * - The enum must start at zero. - * - The enum must be consecutive. + * - The enum must start at zero. + * - The enum must be consecutive. * - The enum must be terminated with a special token consisting of the enum's * name plus "_MAX". * - The corresponding char pointer array must be terminated with an empty string. * - The names must only consist of characters and digits (a-z, A-Z, 0-9), * underscores (_) and dashes (-). - * + * * * @warning At the moment the verify() method is called during static initialization. * It quits the application with exit code 1 if any error is detected. The other solution @@ -103,7 +103,7 @@ protected: * @endcode * And here is how to use the resulting type Fruit * @code - * + * * int * main(int argc, char * argv[]) { * fruit f(APPLE); @@ -116,11 +116,11 @@ protected: * cerr << "Hmmm ... yummy " << f << endl; * break; * } - * + * * f = CHERRY; * * fruit_enum native_enum = f; - * + * * f.from_string("passion_fruit"); * * for (unsigned i = 0; i < fruit::MAX; ++i) { @@ -139,9 +139,9 @@ class MAPNIK_DECL enumeration { public: typedef ENUM native_type; enumeration() {}; - enumeration( ENUM v ) : value_(v) {} - enumeration( const enumeration & other ) : value_(other.value_) {} - + enumeration( ENUM v ) : value_(v) {} + enumeration( const enumeration & other ) : value_(other.value_) {} + /** Assignment operator for native enum values. */ void operator=(ENUM v) { @@ -160,7 +160,7 @@ public: return value_; } - enum Max + enum Max { MAX = THE_MAX }; @@ -168,7 +168,7 @@ public: { return THE_MAX; } - /** Converts @p str to an enum. + /** Converts @p str to an enum. * @throw illegal_enum_value @p str is not a legal identifier. * */ void from_string(const std::string & str) @@ -181,7 +181,7 @@ public: return; } } - throw illegal_enum_value(std::string("Illegal enumeration value '") + + throw illegal_enum_value(std::string("Illegal enumeration value '") + str + "' for enum " + our_name_); } @@ -210,7 +210,7 @@ public: is.unget(); break; } - } + } try { @@ -231,11 +231,11 @@ public: } /** Prints the string identifier to the output stream @p os. */ - std::ostream & print(std::ostream & os = std::cerr) const + std::ostream & print(std::ostream & os = std::cerr) const { return os << our_strings_[value_]; } - + /** Static helper function to iterate over valid identifiers. */ static const char * get_string(unsigned i) { @@ -252,14 +252,14 @@ public: if (our_strings_[i] == 0 ) { std::cerr << "### FATAL: Not enough strings for enum " - << our_name_ << " defined in file '" << filename + << our_name_ << " defined in file '" << filename << "' at line " << line_no << std::endl; //std::exit(1); } } if ( std::string("") != our_strings_[THE_MAX]) { - std::cerr << "### FATAL: The string array for enum " << our_name_ + std::cerr << "### FATAL: The string array for enum " << our_name_ << " defined in file '" << filename << "' at line " << line_no << " has too many items or is not terminated with an " << "empty string." << std::endl; @@ -285,10 +285,10 @@ private: ENUM value_; static const char ** our_strings_ ; static std::string our_name_ ; - static bool our_verified_flag_; + static bool our_verified_flag_; }; -/** ostream operator for enumeration +/** ostream operator for enumeration * @relates mapnik::enumeration */ template @@ -299,7 +299,7 @@ operator<<(std::ostream & os, const mapnik::enumeration & e) return os; } -/** istream operator for enumeration +/** istream operator for enumeration * @relates mapnik::enumeration */ template @@ -315,7 +315,7 @@ operator>>(std::istream & is, mapnik::enumeration & e) /** Helper macro. Creates a typedef. * @relates mapnik::enumeration */ -#define DEFINE_ENUM( name, e) \ +#define DEFINE_ENUM( name, e) \ typedef enumeration name /** Helper macro. Runs the verify() method during static initialization. diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp index ded3c7e79..b2155f9da 100644 --- a/include/mapnik/expression_evaluator.hpp +++ b/include/mapnik/expression_evaluator.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -36,47 +36,47 @@ struct evaluate : boost::static_visitor { typedef T0 feature_type; typedef T1 value_type; - + explicit evaluate(feature_type const& f) : feature_(f) {} - + value_type operator() (value_type x) const { return x; } - + value_type operator() (attribute const& attr) const { return attr.value(feature_); } - - + + value_type operator() (binary_node const & x) const { return (boost::apply_visitor(evaluate(feature_),x.left).to_bool()) && (boost::apply_visitor(evaluate(feature_),x.right).to_bool()); } - + value_type operator() (binary_node const & x) const { - return (boost::apply_visitor(evaluate(feature_),x.left).to_bool()) + return (boost::apply_visitor(evaluate(feature_),x.left).to_bool()) || (boost::apply_visitor(evaluate(feature_),x.right).to_bool()); } - template + template value_type operator() (binary_node const& x) const { typename make_op::type operation; - return operation(boost::apply_visitor(evaluate(feature_),x.left), + return operation(boost::apply_visitor(evaluate(feature_),x.left), boost::apply_visitor(evaluate(feature_),x.right)); } template value_type operator() (unary_node const& x) const { - return ! (boost::apply_visitor(evaluate(feature_),x.expr).to_bool()); + return ! (boost::apply_visitor(evaluate(feature_),x.expr).to_bool()); } - + value_type operator() (regex_match_node const& x) const { value_type v = boost::apply_visitor(evaluate(feature_),x.expr); @@ -84,10 +84,10 @@ struct evaluate : boost::static_visitor return boost::u32regex_match(v.to_unicode(),x.pattern); #else return boost::regex_match(v.to_string(),x.pattern); -#endif +#endif } - + value_type operator() (regex_replace_node const& x) const { value_type v = boost::apply_visitor(evaluate(feature_),x.expr); @@ -97,9 +97,9 @@ struct evaluate : boost::static_visitor std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format); mapnik::transcoder tr_("utf8"); return tr_.transcode(repl.c_str()); -#endif +#endif } - + feature_type const& feature_; }; diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index b562447ef..2e1f7939f 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -63,15 +63,15 @@ struct unicode_impl { typedef UnicodeString type; }; - + explicit unicode_impl(mapnik::transcoder const& tr) : tr_(tr) {} - + UnicodeString operator()(std::string const& str) const { return tr_.transcode(str.c_str()); } - + mapnik::transcoder const& tr_; }; @@ -82,10 +82,10 @@ struct regex_match_impl { typedef expr_node type; }; - + explicit regex_match_impl(mapnik::transcoder const& tr) : tr_(tr) {} - + template expr_node operator() (T0 & node, T1 const& pattern) const { @@ -95,7 +95,7 @@ struct regex_match_impl return regex_match_node(node,pattern); #endif } - + mapnik::transcoder const& tr_; }; @@ -106,10 +106,10 @@ struct regex_replace_impl { typedef expr_node type; }; - + explicit regex_replace_impl(mapnik::transcoder const& tr) : tr_(tr) {} - + template expr_node operator() (T0 & node, T1 const& pattern, T2 const& format) const { @@ -119,15 +119,15 @@ struct regex_replace_impl return regex_replace_node(node,pattern,format); #endif } - + mapnik::transcoder const& tr_; }; template struct expression_grammar : qi::grammar -{ +{ typedef qi::rule rule_type; - + explicit expression_grammar(mapnik::transcoder const& tr) : expression_grammar::base_type(expr), unicode_(unicode_impl(tr)), @@ -151,22 +151,22 @@ struct expression_grammar : qi::grammar using qi::hex; using qi::omit; using standard_wide::char_; - + expr = logical_expr.alias(); - - logical_expr = not_expr [_val = _1] + + logical_expr = not_expr [_val = _1] >> *( ( ( lit("and") | lit("&&")) >> not_expr [_val && _1] ) | (( lit("or") | lit("||")) >> not_expr [_val || _1]) ) ; - - not_expr = + + not_expr = cond_expr [_val = _1 ] | ((lit("not") | lit('!')) >> cond_expr [ _val = !_1 ]) ; - - cond_expr = equality_expr [_val = _1] | additive_expr [_val = _1] + + cond_expr = equality_expr [_val = _1] | additive_expr [_val = _1] ; equality_expr = @@ -175,24 +175,24 @@ struct expression_grammar : qi::grammar | (( lit("!=") | lit("<>") | lit("neq") ) >> relational_expr [_val != _1]) ) ; - + regex_match_expr = lit(".match") - >> lit('(') - >> ustring [_val = _1] + >> lit('(') + >> ustring [_val = _1] >> lit(')') ; - - regex_replace_expr = + + regex_replace_expr = lit(".replace") - >> lit('(') + >> lit('(') >> ustring [_a = _1] - >> lit(',') + >> lit(',') >> ustring [_b = _1] >> lit(')') [_val = regex_replace_(_r1,_a,_b)] ; - - relational_expr = additive_expr[_val = _1] - >> + + relational_expr = additive_expr[_val = _1] + >> *( ( (lit("<=") | lit("le") ) >> additive_expr [ _val <= _1 ]) | ( (lit('<') | lit("lt") ) >> additive_expr [ _val < _1 ]) | ( (lit(">=") | lit("ge") ) >> additive_expr [ _val >= _1 ]) @@ -204,7 +204,7 @@ struct expression_grammar : qi::grammar | '-' >> multiplicative_expr[_val -= _1] ) ; - + multiplicative_expr = primary_expr [_val = _1] >> *( '*' >> primary_expr [_val *= _1] | '/' >> primary_expr [_val /= _1] @@ -213,8 +213,8 @@ struct expression_grammar : qi::grammar | regex_replace_expr(_val) [_val = _1] ) ; - - + + primary_expr = strict_double [_val = _1] | int_ [_val = _1] | lit("true") [_val = true] @@ -224,26 +224,26 @@ struct expression_grammar : qi::grammar | attr [_val = construct( _1 ) ] | '(' >> expr [_val = _1 ] >> ')' ; - + unesc_char.add("\\a", '\a')("\\b", '\b')("\\f", '\f')("\\n", '\n') ("\\r", '\r')("\\t", '\t')("\\v", '\v')("\\\\", '\\') ("\\\'", '\'')("\\\"", '\"') ; - + ustring %= omit[quote_char[_a = _1]] >> *(unesc_char | "\\x" >> hex | (char_ - lit(_a))) >> lit(_a); - + quote_char %= char_('\'') | char_('"'); - + #if BOOST_VERSION > 104200 attr %= '[' >> no_skip[+~char_(']')] >> ']'; #else attr %= '[' >> lexeme[+(char_ - ']')] >> ']'; #endif - + } - + qi::real_parser > strict_double; boost::phoenix::function unicode_; boost::phoenix::function regex_match_; diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index c83ed795d..97608ec3b 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -39,7 +39,7 @@ namespace mapnik { -namespace tags { +namespace tags { struct plus { static const char* str() @@ -163,14 +163,14 @@ struct regex_replace_node; typedef mapnik::value value_type; -typedef boost::variant < +typedef boost::variant < value_type, attribute, -boost::recursive_wrapper >, +boost::recursive_wrapper >, boost::recursive_wrapper >, -boost::recursive_wrapper >, +boost::recursive_wrapper >, boost::recursive_wrapper >, -boost::recursive_wrapper >, +boost::recursive_wrapper >, boost::recursive_wrapper >, boost::recursive_wrapper >, boost::recursive_wrapper >, @@ -210,7 +210,7 @@ struct unary_node { return Tag::str(); } - + expr_node expr; }; @@ -220,7 +220,7 @@ struct binary_node binary_node(expr_node const& a, expr_node const& b) : left(a), right(b) {} - + static const char* type() { return Tag::str(); @@ -234,7 +234,7 @@ struct regex_match_node regex_match_node (expr_node const& a, UnicodeString const& ustr) : expr(a), pattern(boost::make_u32regex(ustr)) {} - + expr_node expr; boost::u32regex pattern; }; @@ -246,7 +246,7 @@ struct regex_replace_node : expr(a), pattern(boost::make_u32regex(ustr)), format(f) {} - + expr_node expr; boost::u32regex pattern; UnicodeString format; @@ -257,7 +257,7 @@ struct regex_match_node regex_match_node (expr_node const& a, std::string const& str) : expr(a), pattern(str) {} - + expr_node expr; boost::regex pattern; }; @@ -269,7 +269,7 @@ struct regex_replace_node : expr(a), pattern(str), format(f) {} - + expr_node expr; boost::regex pattern; std::string format; @@ -289,50 +289,50 @@ struct function_call // ops -inline expr_node & operator += ( expr_node &left ,const expr_node &right) -{ - return left = binary_node(left,right); -} - -inline expr_node & operator -= ( expr_node &left ,const expr_node &right) -{ - return left = binary_node(left,right); +inline expr_node & operator += ( expr_node &left ,const expr_node &right) +{ + return left = binary_node(left,right); } -inline expr_node & operator *= ( expr_node &left ,const expr_node &right) -{ - return left = binary_node(left,right); +inline expr_node & operator -= ( expr_node &left ,const expr_node &right) +{ + return left = binary_node(left,right); } -inline expr_node & operator /= ( expr_node &left ,const expr_node &right) -{ - return left = binary_node(left,right); +inline expr_node & operator *= ( expr_node &left ,const expr_node &right) +{ + return left = binary_node(left,right); } -inline expr_node & operator %= ( expr_node &left ,const expr_node &right) -{ - return left = binary_node(left,right); +inline expr_node & operator /= ( expr_node &left ,const expr_node &right) +{ + return left = binary_node(left,right); +} + +inline expr_node & operator %= ( expr_node &left ,const expr_node &right) +{ + return left = binary_node(left,right); } inline expr_node & operator < ( expr_node &left, expr_node const& right) { return left = binary_node(left,right); -} +} inline expr_node & operator <= ( expr_node &left, expr_node const& right) { return left = binary_node(left,right); -} +} inline expr_node & operator > ( expr_node &left, expr_node const& right) { return left = binary_node(left,right); -} +} inline expr_node & operator >= ( expr_node &left, expr_node const& right) { return left = binary_node(left,right); -} +} inline expr_node & operator == ( expr_node &left, expr_node const& right) { diff --git a/include/mapnik/expression_string.hpp b/include/mapnik/expression_string.hpp index 1f8279a87..d6f69a8cb 100644 --- a/include/mapnik/expression_string.hpp +++ b/include/mapnik/expression_string.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/factory.hpp b/include/mapnik/factory.hpp index 71d09d703..e9e7d755a 100644 --- a/include/mapnik/factory.hpp +++ b/include/mapnik/factory.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 082bb43b3..557fdea3b 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -46,16 +46,16 @@ namespace mapnik { -typedef boost::shared_ptr raster_ptr; +typedef boost::shared_ptr raster_ptr; class feature_impl; -template -class context : private boost::noncopyable, +template +class context : private boost::noncopyable, public boost::associative_property_map { - friend class feature_impl; + friend class feature_impl; public: typedef T map_type; typedef typename boost::associative_property_map base_type; @@ -65,21 +65,21 @@ public: typedef typename map_type::difference_type difference_type; typedef typename map_type::iterator iterator; typedef typename map_type::const_iterator const_iterator; - + context() : base_type(mapping_) {} - + size_type push(key_type const& name) { size_type index = mapping_.size(); mapping_.insert(std::make_pair(name, index)); return index; } - + size_type size() const { return mapping_.size(); } const_iterator begin() const { return mapping_.begin();} const_iterator end() const { return mapping_.end();} - + private: map_type mapping_; }; @@ -92,37 +92,37 @@ class feature_impl : private boost::noncopyable friend class feature_kv_iterator; public: - typedef mapnik::value value_type; + typedef mapnik::value value_type; typedef std::vector cont_type; typedef feature_kv_iterator iterator; - - feature_impl(context_ptr const& ctx, int id) + + feature_impl(context_ptr const& ctx, int id) : id_(id), ctx_(ctx), data_(ctx_->mapping_.size()) {} - + inline int id() const { return id_;} inline void set_id(int id) { id_ = id;} - + template void put(context_type::key_type const& key, T const& val) { put(key,value(val)); - } - + } + template void put_new(context_type::key_type const& key, T const& val) { put_new(key,value(val)); - } - + } + void put(context_type::key_type const& key, value const& val) { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); - if (itr != ctx_->mapping_.end() + if (itr != ctx_->mapping_.end() && itr->second < data_.size()) { data_[itr->second] = val; @@ -131,11 +131,11 @@ public: throw std::out_of_range("Key doesn't exist"); } - + void put_new(context_type::key_type const& key, value const& val) { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); - if (itr != ctx_->mapping_.end() + if (itr != ctx_->mapping_.end() && itr->second < data_.size()) { data_[itr->second] = val; @@ -146,25 +146,25 @@ public: if (index == data_.size()) data_.push_back(val); } - } - - + } + + bool has_key(context_type::key_type const& key) const { return (ctx_->mapping_.find(key) != ctx_->mapping_.end()); } - + value_type const& get(context_type::key_type const& key) const { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); - if (itr != ctx_->mapping_.end() + if (itr != ctx_->mapping_.end() && itr->second < data_.size()) { return data_[itr->second]; } throw std::out_of_range("Key doesn't exist"); } - + value_type const& get(std::size_t index) const { if (index < data_.size()) @@ -176,7 +176,7 @@ public: { return data_.size(); } - + context_ptr context() { return ctx_; @@ -186,32 +186,32 @@ public: { return geom_cont_; } - - boost::ptr_vector & paths() + + boost::ptr_vector & paths() { return geom_cont_; } - + void add_geometry(geometry_type * geom) { geom_cont_.push_back(geom); } - + unsigned num_geometries() const { return geom_cont_.size(); } - + geometry_type const& get_geometry(unsigned index) const { return geom_cont_[index]; } - + geometry_type& get_geometry(unsigned index) { return geom_cont_[index]; } - + box2d envelope() const { box2d result; @@ -229,13 +229,13 @@ public: } } return result; - } - + } + const raster_ptr& get_raster() const { return raster_; } - + void set_raster(raster_ptr const& raster) { raster_ = raster; @@ -250,9 +250,9 @@ public: { return feature_kv_iterator(*this); } - + std::string to_string() const - { + { std::stringstream ss; ss << "Feature (" << std::endl; context_type::map_type::const_iterator itr = ctx_->mapping_.begin(); @@ -273,7 +273,7 @@ private: cont_type data_; }; - + inline std::ostream& operator<< (std::ostream & out,feature_impl const& f) { out << f.to_string(); diff --git a/include/mapnik/feature_factory.hpp b/include/mapnik/feature_factory.hpp index 29921da64..955ca2431 100644 --- a/include/mapnik/feature_factory.hpp +++ b/include/mapnik/feature_factory.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -40,7 +40,7 @@ struct feature_factory //return boost::allocate_shared(boost::fast_pool_allocator(),fid); return boost::make_shared(ctx,fid); } -}; +}; } #endif // MAPNIK_FEATURE_FACTORY_HPP diff --git a/include/mapnik/feature_kv_iterator.hpp b/include/mapnik/feature_kv_iterator.hpp index 001302034..7717c5462 100644 --- a/include/mapnik/feature_kv_iterator.hpp +++ b/include/mapnik/feature_kv_iterator.hpp @@ -30,7 +30,7 @@ //#include #include -namespace mapnik { +namespace mapnik { class feature_impl; @@ -41,20 +41,20 @@ class feature_kv_iterator : { public: typedef boost::tuple value_type; - + feature_kv_iterator (feature_impl const& f, bool begin = false); private: - friend class boost::iterator_core_access; + friend class boost::iterator_core_access; void increment(); bool equal( feature_kv_iterator const& other) const; value_type const& dereference() const; - + feature_impl const& f_; std::map::const_iterator itr_; mutable value_type kv_; - + }; } diff --git a/include/mapnik/feature_layer_desc.hpp b/include/mapnik/feature_layer_desc.hpp index 35b2a21c1..7c1b63027 100644 --- a/include/mapnik/feature_layer_desc.hpp +++ b/include/mapnik/feature_layer_desc.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/feature_style_processor.hpp b/include/mapnik/feature_style_processor.hpp index 4e20c2e42..4e799e69f 100644 --- a/include/mapnik/feature_style_processor.hpp +++ b/include/mapnik/feature_style_processor.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -40,9 +40,9 @@ namespace mapnik class Map; class layer; class projection; - + template -class feature_style_processor +class feature_style_processor { struct symbol_dispatch; public: diff --git a/include/mapnik/fill.hpp b/include/mapnik/fill.hpp index a802c4925..37df0bb43 100644 --- a/include/mapnik/fill.hpp +++ b/include/mapnik/fill.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -26,7 +26,7 @@ namespace mapnik { -class fill +class fill { }; diff --git a/include/mapnik/filter_factory.hpp b/include/mapnik/filter_factory.hpp index 3e25c4014..b9b2481b4 100644 --- a/include/mapnik/filter_factory.hpp +++ b/include/mapnik/filter_factory.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -37,7 +37,7 @@ typedef boost::shared_ptr expression_ptr; MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt, std::string const& encoding); MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt); - + } #endif // MAPNIK_FILTER_FACTORY_HPP diff --git a/include/mapnik/filter_featureset.hpp b/include/mapnik/filter_featureset.hpp index 37b57803f..faa049b02 100644 --- a/include/mapnik/filter_featureset.hpp +++ b/include/mapnik/filter_featureset.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -27,16 +27,16 @@ #include namespace mapnik { - -template -class filter_featureset : public Featureset + +template +class filter_featureset : public Featureset { typedef T filter_type; - + public: filter_featureset(featureset_ptr fs, filter_type const& filter) : fs_(fs), filter_(filter) {} - + feature_ptr next() { feature_ptr feature = fs_->next(); @@ -46,7 +46,7 @@ public: } return feature; } - + private: featureset_ptr fs_; filter_type filter_; diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index 5ded5076d..cbce5e43e 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -183,7 +183,7 @@ public: (*face)->set_pixel_sizes(size); } } - + void set_character_sizes(float size) { for (std::vector::iterator face = faces_.begin(); face != faces_.end(); ++face) @@ -202,25 +202,25 @@ class stroker : boost::noncopyable public: explicit stroker(FT_Stroker s) : s_(s) {} - + void init(double radius) { - FT_Stroker_Set(s_, (FT_Fixed) (radius * (1<<6)), - FT_STROKER_LINECAP_ROUND, - FT_STROKER_LINEJOIN_ROUND, - 0); + FT_Stroker_Set(s_, (FT_Fixed) (radius * (1<<6)), + FT_STROKER_LINECAP_ROUND, + FT_STROKER_LINEJOIN_ROUND, + 0); } - + FT_Stroker const& get() const { return s_; } - + ~stroker() { #ifdef MAPNIK_DEBUG std::clog << "~stroker: destroy stroker:" << s_ << std::endl; -#endif +#endif FT_Stroker_Done(s_); } private: diff --git a/include/mapnik/font_set.hpp b/include/mapnik/font_set.hpp index 11c73a316..d74a01483 100644 --- a/include/mapnik/font_set.hpp +++ b/include/mapnik/font_set.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,8 +35,8 @@ namespace mapnik class MAPNIK_DECL font_set { public: - font_set(); - font_set(std::string const& name); + font_set(); + font_set(std::string const& name); font_set(font_set const& rhs); font_set& operator=(font_set const& rhs); unsigned size() const; diff --git a/include/mapnik/gamma.hpp b/include/mapnik/gamma.hpp index 5267c3e89..fc0441c59 100644 --- a/include/mapnik/gamma.hpp +++ b/include/mapnik/gamma.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -25,7 +25,7 @@ #include -namespace mapnik +namespace mapnik { struct MAPNIK_DECL gamma { diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp index 87c91e02a..ce9440dcc 100644 --- a/include/mapnik/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -54,7 +54,7 @@ bool clip_test(T p,T q,double& tmin,double& tmax) } else if (q<0.0) result=false; return result; } - + template bool clip_line(T& x0,T& y0,T& x1,T& y1,box2d const& box) { @@ -87,26 +87,26 @@ bool clip_line(T& x0,T& y0,T& x1,T& y1,box2d const& box) } return false; } - -template + +template inline bool point_inside_path(double x,double y,Iter start,Iter end) { bool inside=false; double x0=boost::get<0>(*start); double y0=boost::get<1>(*start); - + double x1,y1; - while (++start!=end) + while (++start!=end) { if ( boost::get<2>(*start) == SEG_MOVETO) { x0 = boost::get<0>(*start); y0 = boost::get<1>(*start); continue; - } + } x1=boost::get<0>(*start); y1=boost::get<1>(*start); - + if ((((y1 <= y) && (y < y0)) || ((y0 <= y) && (y < y1))) && ( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1)) @@ -124,7 +124,7 @@ inline bool point_in_circle(double x,double y,double cx,double cy,double r) double d2 = dx * dx + dy * dy; return (d2 <= r * r); } - + template inline T sqr(T x) { @@ -137,23 +137,23 @@ inline double distance2(double x0,double y0,double x1,double y1) double dy = y1 - y0; return sqr(dx) + sqr(dy); } - + inline double distance(double x0,double y0, double x1,double y1) { return std::sqrt(distance2(x0,y0,x1,y1)); } - -inline double point_to_segment_distance(double x, double y, - double ax, double ay, + +inline double point_to_segment_distance(double x, double y, + double ax, double ay, double bx, double by) { double len2 = distance2(ax,ay,bx,by); - - if (len2 < 1e-14) + + if (len2 < 1e-14) { return distance(x,y,ax,ay); } - + double r = ((x - ax)*(bx - ax) + (y - ay)*(by -ay))/len2; if ( r < 0 ) { @@ -166,24 +166,24 @@ inline double point_to_segment_distance(double x, double y, double s = ((ay - y)*(bx - ax) - (ax - x)*(by - ay))/len2; return std::fabs(s) * std::sqrt(len2); } - -template + +template inline bool point_on_path(double x,double y,Iter start,Iter end, double tol) { double x0=boost::get<0>(*start); double y0=boost::get<1>(*start); double x1,y1; - while (++start != end) + while (++start != end) { if ( boost::get<2>(*start) == SEG_MOVETO) { x0 = boost::get<0>(*start); y0 = boost::get<1>(*start); continue; - } + } x1=boost::get<0>(*start); y1=boost::get<1>(*start); - + double distance = point_to_segment_distance(x,y,x0,y0,x1,y1); if (distance < tol) return true; @@ -192,7 +192,7 @@ inline bool point_on_path(double x,double y,Iter start,Iter end, double tol) } return false; } - + // filters struct filter_in_box { diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 1b07f4c86..3e993013d 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -53,32 +53,32 @@ private: eGeomType type_; mutable unsigned itr_; public: - + geometry() : type_(Unknown), itr_(0) {} - + explicit geometry(eGeomType type) : type_(type), itr_(0) {} - - eGeomType type() const + + eGeomType type() const { return type_; } - + void set_type(eGeomType type) { type_ = type; } - + container_type const& data() const { return cont_; } - + box2d envelope() const { box2d result; @@ -134,7 +134,7 @@ public: } // if the path segment crosses the bisector else if ((y0 <= *y && y1 >= *y) || - (y0 >= *y && y1 <= *y)) + (y0 >= *y && y1 <= *y)) { // then calculate the intersection double xi = x0; @@ -170,7 +170,7 @@ public: } /* center of gravity centroid - - best visually but does not work with multipolygons + - best visually but does not work with multipolygons */ void label_position(double *x, double *y) const { @@ -179,14 +179,14 @@ public: middle_point(x,y); return; } - + unsigned size = cont_.size(); - if (size < 3) + if (size < 3) { cont_.get_vertex(0,x,y); return; } - + double ai; double atmp = 0; double xtmp = 0; @@ -197,9 +197,9 @@ public: double y1 =0; double ox =0; double oy =0; - + unsigned i; - + // Use first point as origin to improve numerical accuracy cont_.get_vertex(0,&ox,&oy); @@ -207,7 +207,7 @@ public: { cont_.get_vertex(i,&x0,&y0); cont_.get_vertex(i+1,&x1,&y1); - + x0 -= ox; y0 -= oy; x1 -= ox; y1 -= oy; @@ -215,7 +215,7 @@ public: atmp += ai; xtmp += (x1 + x0) * ai; ytmp += (y1 + y0) * ai; - } + } if (atmp != 0) { *x = (xtmp/(3*atmp)) + ox; @@ -223,7 +223,7 @@ public: return; } *x=x0; - *y=y0; + *y=y0; } /* center of bounding box centroid */ @@ -232,7 +232,7 @@ public: box2d box = envelope(); *x = box.center().x; - *y = box.center().y; + *y = box.center().y; } /* summarized distance centroid */ @@ -253,7 +253,7 @@ public: double y0 = 0.0; double x1 = 0.0; double y1 = 0.0; - unsigned size = cont_.size(); + unsigned size = cont_.size(); for (i = 0; i < size-1; i++) { cont_.get_vertex(i,&x0,&y0); @@ -266,7 +266,7 @@ public: *x = cx / tl; *y = cy / tl; } - + void middle_point(double *x, double *y) const { // calculate mid point on path @@ -274,18 +274,18 @@ public: double y0=0; double x1=0; double y1=0; - + unsigned size = cont_.size(); if (size == 1) { - cont_.get_vertex(0,x,y); + cont_.get_vertex(0,x,y); } else if (size == 2) { cont_.get_vertex(0,&x0,&y0); cont_.get_vertex(1,&x1,&y1); *x = 0.5 * (x1 + x0); - *y = 0.5 * (y1 + y0); + *y = 0.5 * (y1 + y0); } else { @@ -305,7 +305,7 @@ public: cont_.get_vertex(pos-1,&x0,&y0); cont_.get_vertex(pos,&x1,&y1); double dx = x1 - x0; - double dy = y1 - y0; + double dy = y1 - y0; double seg_len = std::sqrt(dx * dx + dy * dy); if (( dist + seg_len) >= midlen) { @@ -316,10 +316,10 @@ public: } dist += seg_len; } - } + } } - - void push_vertex(coord_type x, coord_type y, CommandType c) + + void push_vertex(coord_type x, coord_type y, CommandType c) { cont_.push_back(x,y,c); } @@ -328,34 +328,34 @@ public: { push_vertex(x,y,SEG_LINETO); } - + void move_to(coord_type x,coord_type y) { push_vertex(x,y,SEG_MOVETO); } - + unsigned num_points() const { return cont_.size(); } - + unsigned vertex(double* x, double* y) const { return cont_.get_vertex(itr_++,x,y); - } + } unsigned get_vertex(unsigned pos, double* x, double* y) const { return cont_.get_vertex(pos, x, y); - } + } void rewind(unsigned ) const { itr_=0; } - + bool hit_test(coord_type x, coord_type y, double tol) const - { + { if (cont_.size() == 1) { // Handle points double x0, y0; @@ -367,7 +367,7 @@ public: double y0=0; rewind(0); vertex(&x0, &y0); - + unsigned command; double x1,y1; while (SEG_END != (command=vertex(&x1, &y1))) @@ -377,7 +377,7 @@ public: x0 = x1; y0 = y1; continue; - } + } if ((((y1 <= y) && (y < y0)) || ((y0 <= y) && (y < y1))) && ( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1)) @@ -388,15 +388,15 @@ public: return inside; } return false; - } - - void set_capacity(size_t size) + } + + void set_capacity(size_t size) { cont_.set_capacity(size); } }; - -typedef geometry geometry_type; + +typedef geometry geometry_type; typedef boost::shared_ptr geometry_ptr; typedef boost::ptr_vector geometry_container; diff --git a/include/mapnik/global.hpp b/include/mapnik/global.hpp index 767ecc73a..6e43d0a8d 100644 --- a/include/mapnik/global.hpp +++ b/include/mapnik/global.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -32,7 +32,7 @@ namespace mapnik { - + #ifdef BOOST_BIG_ENDIAN #define MAPNIK_BIG_ENDIAN #endif @@ -72,38 +72,38 @@ typedef boost::uint8_t byte; ((byte*) &def_temp)[3]=(M)[0]; \ (V)=def_temp; } while(0) - + // read int16_t NDR (little endian) inline void read_int16_ndr(const char* data, boost::int16_t & val) { #ifndef MAPNIK_BIG_ENDIAN std::memcpy(&val,data,2); #else - val = (data[0]&0xff) | + val = (data[0]&0xff) | ((data[1]&0xff)<<8); #endif } - + // read int32_t NDR (little endian) inline void read_int32_ndr(const char* data, boost::int32_t & val) { #ifndef MAPNIK_BIG_ENDIAN std::memcpy(&val,data,4); #else - val = (data[0]&0xff) | - ((data[1]&0xff)<<8) | - ((data[2]&0xff)<<16) | + val = (data[0]&0xff) | + ((data[1]&0xff)<<8) | + ((data[2]&0xff)<<16) | ((data[3]&0xff)<<24); #endif } - + // read double NDR (little endian) inline void read_double_ndr(const char* data, double & val) { #ifndef MAPNIK_BIG_ENDIAN std::memcpy(&val,&data[0],8); #else - boost::int64_t bits = ((boost::int64_t)data[0] & 0xff) | + boost::int64_t bits = ((boost::int64_t)data[0] & 0xff) | ((boost::int64_t)data[1] & 0xff) << 8 | ((boost::int64_t)data[2] & 0xff) << 16 | ((boost::int64_t)data[3] & 0xff) << 24 | @@ -113,8 +113,8 @@ inline void read_double_ndr(const char* data, double & val) ((boost::int64_t)data[7] & 0xff) << 56 ; std::memcpy(&val,&bits,8); #endif -} - +} + // read int16_t XDR (big endian) inline void read_int16_xdr(const char* data, boost::int16_t & val) { @@ -124,7 +124,7 @@ inline void read_int16_xdr(const char* data, boost::int16_t & val) std::memcpy(&val,data,2); #endif } - + // read int32_t XDR (big endian) inline void read_int32_xdr(const char* data, boost::int32_t & val) { @@ -134,12 +134,12 @@ inline void read_int32_xdr(const char* data, boost::int32_t & val) std::memcpy(&val,data,4); #endif } - + // read double XDR (big endian) inline void read_double_xdr(const char* data, double & val) { #ifndef MAPNIK_BIG_ENDIAN - boost::int64_t bits = ((boost::int64_t)data[7] & 0xff) | + boost::int64_t bits = ((boost::int64_t)data[7] & 0xff) | ((boost::int64_t)data[6] & 0xff) << 8 | ((boost::int64_t)data[5] & 0xff) << 16 | ((boost::int64_t)data[4] & 0xff) << 24 | @@ -163,7 +163,7 @@ inline int rint( double val) inline double round (double val) { return floor(val); -} +} #define _USE_MATH_DEFINES #ifndef M_PI diff --git a/include/mapnik/gradient.hpp b/include/mapnik/gradient.hpp index 896765133..0f7f838a8 100644 --- a/include/mapnik/gradient.hpp +++ b/include/mapnik/gradient.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -32,13 +32,13 @@ // stl #include - + namespace mapnik { typedef std::pair stop_pair; typedef std::vector stop_array; - + enum gradient_enum { NO_GRADIENT, @@ -60,7 +60,7 @@ enum gradient_unit_enum DEFINE_ENUM( gradient_unit_e, gradient_unit_enum ); class MAPNIK_DECL gradient -{ +{ gradient_e gradient_type_; stop_array stops_; // control points for the gradient, x1/y1 is the start point, x2/y2 the stop point. @@ -92,7 +92,7 @@ public: void add_stop(double offset, color const& c); bool has_stop() const; - + stop_array const& get_stop_array() const; void set_control_points(double x1, double y1, double x2, double y2, double r=0); diff --git a/include/mapnik/graphics.hpp b/include/mapnik/graphics.hpp index 6774da392..72ea1fa02 100644 --- a/include/mapnik/graphics.hpp +++ b/include/mapnik/graphics.hpp @@ -164,7 +164,7 @@ public: } boost::optional const& get_background() const; - + void set_background(const color& c); void set_grayscale_to_alpha(); @@ -172,12 +172,12 @@ public: void set_color_to_alpha(color const& c); void set_alpha(float opacity); - + inline const image_data_32& data() const { return data_; } - + inline image_data_32& data() { return data_; @@ -435,7 +435,7 @@ public: unsigned r0 = rgba0 & 0xff ; unsigned g0 = (rgba0 >> 8 ) & 0xff; unsigned b0 = (rgba0 >> 16) & 0xff; - + unsigned atmp = a1 + a0 - ((a1 * a0 + 255) >> 8); if (atmp) { @@ -444,7 +444,7 @@ public: b0 = byte((b1 * a1 + (b0 * a0) - ((b0 * a0 * a1 + 255) >> 8)) / atmp); } a0 = byte(atmp); - + row_to[x] = (a0 << 24)| (b0 << 16) | (g0 << 8) | (r0) ; #endif } diff --git a/include/mapnik/hextree.hpp b/include/mapnik/hextree.hpp index 9c42d5798..25b9625ab 100644 --- a/include/mapnik/hextree.hpp +++ b/include/mapnik/hextree.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -130,7 +130,7 @@ class hextree : private boost::noncopyable { return 255 * std::pow(b/255, g); } - + public: explicit hextree(unsigned max_colors=256, const double &g=2.0) : max_colors_(max_colors), @@ -233,7 +233,7 @@ public: int dist, newdist; // find closest match based on mean of r,g,b,a - std::vector::const_iterator pit = + std::vector::const_iterator pit = std::lower_bound(sorted_pal_.begin(), sorted_pal_.end(), c, rgba::mean_sort_cmp()); ind = pit-sorted_pal_.begin(); if (ind == sorted_pal_.size()) @@ -337,11 +337,11 @@ private: printf("%d: (+%d/%d/%.5f) (%d %d %d %d)\n", id, (int)r->count, (int)r->pixel_count, r->reduce_cost, (int)round(gamma(r->reds / r->count, gamma_)), - (int)round(gamma(r->greens / r->count, gamma_)), + (int)round(gamma(r->greens / r->count, gamma_)), (int)round(gamma(r->blues / r->count, gamma_)), (int)(r->alphas / r->count)); else - printf("%d: (%d/%d/%.5f) (%d %d %d %d)\n", id, + printf("%d: (%d/%d/%.5f) (%d %d %d %d)\n", id, (int)r->count, (int)r->pixel_count, r->reduce_cost, (int)round(gamma(r->reds / r->pixel_count, gamma_)), (int)round(gamma(r->greens / r->pixel_count, gamma_)), @@ -387,7 +387,7 @@ private: double mean_g = r->greens / r->pixel_count; double mean_b = r->blues / r->pixel_count; double mean_a = r->alphas / r->pixel_count; - for (unsigned idx=0; idx < 16; ++idx) + for (unsigned idx=0; idx < 16; ++idx) { if (r->children_[idx] != 0) { @@ -406,7 +406,7 @@ private: } } } - + // starting from root_, unfold nodes with biggest penalty // until all available colors are assigned to processed nodes void assign_node_colors() @@ -438,7 +438,7 @@ private: { colors_--; cur_node->count = 0; - for (unsigned idx=0; idx < 16; ++idx) + for (unsigned idx=0; idx < 16; ++idx) { if (cur_node->children_[idx] != 0) { diff --git a/include/mapnik/hit_test_filter.hpp b/include/mapnik/hit_test_filter.hpp index 67c3837ca..461c7daba 100644 --- a/include/mapnik/hit_test_filter.hpp +++ b/include/mapnik/hit_test_filter.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -32,9 +32,9 @@ class hit_test_filter public: hit_test_filter(double x, double y, double tol) : x_(x), - y_(y), + y_(y), tol_(tol) {} - + bool pass(Feature const& feature) { for (unsigned i=0;i renderer_type; typedef agg::comp_op_adaptor_rgba blender_type; typedef agg::renderer_base renderer_type; - + agg::rendering_buffer source(im.getBytes(),im.width(),im.height(),im.width() * 4); agg::rendering_buffer mask(im2.getBytes(),im2.width(),im2.height(),im2.width() * 4); - + agg::pixfmt_custom_blend_rgba pixf(source); agg::pixfmt_custom_blend_rgba pixf_mask(mask); - + switch(mode) { case clear : @@ -132,7 +132,7 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode) break; case multiply: pixf.comp_op(agg::comp_op_multiply); - break; + break; case screen: pixf.comp_op(agg::comp_op_screen); break; @@ -141,7 +141,7 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode) break; case darken: pixf.comp_op(agg::comp_op_darken); - break; + break; case lighten: pixf.comp_op(agg::comp_op_lighten); break; @@ -174,7 +174,7 @@ void composite(T1 & im, T2 & im2, composite_mode_e mode) break; default: break; - + } renderer_type ren(pixf); agg::renderer_base rb(pixf); diff --git a/include/mapnik/image_data.hpp b/include/mapnik/image_data.hpp index d381f1393..fde6f9518 100644 --- a/include/mapnik/image_data.hpp +++ b/include/mapnik/image_data.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,13 +30,13 @@ #include #include -namespace mapnik +namespace mapnik { template class ImageData { public: typedef T pixel_type; - + ImageData(unsigned width,unsigned height) : width_(width), height_(height), @@ -44,11 +44,11 @@ public: { if (pData_) std::memset(pData_,0,sizeof(T)*width_*height_); } - + ImageData(const ImageData& rhs) :width_(rhs.width_), height_(rhs.height_), - pData_((rhs.width_!=0 && rhs.height_!=0)? + pData_((rhs.width_!=0 && rhs.height_!=0)? static_cast(::operator new(sizeof(T)*rhs.width_*rhs.height_)) :0) { if (pData_) std::memcpy(pData_,rhs.pData_,sizeof(T)*rhs.width_* rhs.height_); @@ -75,14 +75,14 @@ public: { for (unsigned y = 0; y < height_; ++y) { - T * row = getRow(y); + T * row = getRow(y); for (unsigned x = 0; x < width_; ++x) { row[x] = t; } } } - + inline const T* getData() const { return pData_; @@ -97,22 +97,22 @@ public: { return (unsigned char*)pData_; } - + inline unsigned char* getBytes() { return (unsigned char*)pData_; } - + inline const T* getRow(unsigned row) const { return pData_+row*width_; } - + inline T* getRow(unsigned row) { return pData_+row*width_; } - + inline void setRow(unsigned row,const T* buf,unsigned size) { assert(row #include -namespace mapnik +namespace mapnik { class image_reader_exception : public std::exception { private: std::string message_; public: - image_reader_exception(const std::string& message) + image_reader_exception(const std::string& message) : message_(message) {} ~image_reader_exception() throw() {} @@ -60,7 +60,7 @@ struct MAPNIK_DECL image_reader bool register_image_reader(const std::string& type,image_reader* (*)(const std::string&)); MAPNIK_DECL image_reader* get_image_reader(const std::string& file,const std::string& type); MAPNIK_DECL image_reader* get_image_reader(const std::string& file); - + } #endif // MAPNIK_IMAGE_READER_HPP diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 604b34b78..efbed9eea 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -37,13 +37,13 @@ namespace mapnik { -class Map; +class Map; class ImageWriterException : public std::exception { private: std::string message_; public: - ImageWriterException(const std::string& message) + ImageWriterException(const std::string& message) : message_(message) {} ~ImageWriterException() throw() {} @@ -70,7 +70,7 @@ MAPNIK_DECL void save_to_file(T const& image, std::string const& filename, std::string const& type, rgba_palette const& palette); - + // guess type from file extension template MAPNIK_DECL void save_to_file(T const& image, @@ -80,7 +80,7 @@ template MAPNIK_DECL void save_to_file(T const& image, std::string const& filename, rgba_palette const& palette); - + template MAPNIK_DECL std::string save_to_string(T const& image, std::string const& type); @@ -133,7 +133,7 @@ inline bool is_ps (std::string const& filename) { return boost::algorithm::iends_with(filename,std::string(".ps")); } - + inline boost::optional type_from_filename(std::string const& filename) { @@ -176,7 +176,7 @@ void add_border(T & image) } for (unsigned y = 0; y < image.height();++y) { - image(0,y) = 0xff00ffff; //yellow + image(0,y) = 0xff00ffff; //yellow image(image.width()-1,y) = 0xffff0000; // blue } } @@ -214,7 +214,7 @@ void scale_image_bilinear_old (Image& target,const Image& source, double x_off_f template void scale_image_bilinear8 (Image& target,const Image& source, double x_off_f=0, double y_off_f=0); -/////////// save_to_file //////////////////////////////////////////////// +/////////// save_to_file //////////////////////////////////////////////// inline MAPNIK_DECL void save_to_file(image_32 const& image, std::string const& file) @@ -252,7 +252,7 @@ inline MAPNIK_DECL std::string save_to_string(image_32 const& image, { return save_to_string(image.data(), type, palette); } - + /////////////////////////////////////////////////////////////////////////// #ifdef _MSC_VER @@ -265,14 +265,14 @@ template MAPNIK_DECL void save_to_file(image_data_32 const&, rgba_palette const&); template MAPNIK_DECL void save_to_file(image_data_32 const&, - std::string const&); + std::string const&); template MAPNIK_DECL void save_to_file > (image_view const&, std::string const&, std::string const&, rgba_palette const&); - + template MAPNIK_DECL void save_to_file > (image_view const&, std::string const&, std::string const&); @@ -282,18 +282,18 @@ template MAPNIK_DECL void save_to_file > (image_view > (image_view const&, - std::string const&); - + std::string const&); + template MAPNIK_DECL std::string save_to_string(image_data_32 const&, std::string const&, rgba_palette const&); - -template MAPNIK_DECL std::string save_to_string > (image_view const&, - std::string const&); template MAPNIK_DECL std::string save_to_string > (image_view const&, - std::string const&, + std::string const&); + +template MAPNIK_DECL std::string save_to_string > (image_view const&, + std::string const&, rgba_palette const&); #endif diff --git a/include/mapnik/image_view.hpp b/include/mapnik/image_view.hpp index c942d17d2..1008a6d2a 100644 --- a/include/mapnik/image_view.hpp +++ b/include/mapnik/image_view.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -24,35 +24,35 @@ #define MAPNIK_IMAGE_VIEW_HPP namespace mapnik { - -template -class image_view + +template +class image_view { public: typedef typename T::pixel_type pixel_type; - + image_view(unsigned x, unsigned y, unsigned width, unsigned height, T const& data) : x_(x), y_(y), width_(width), height_(height), - data_(data) + data_(data) { if (x_ >= data_.width()) x_=data_.width()-1; if (y_ >= data_.height()) x_=data_.height()-1; if (x_ + width_ > data_.width()) width_= data_.width() - x_; if (y_ + height_ > data_.height()) height_= data_.height() - y_; } - + ~image_view() {} - + image_view(image_view const& rhs) : x_(rhs.x_), y_(rhs.y_), width_(rhs.width_), height_(rhs.height_), data_(rhs.data_) {} - + image_view & operator=(image_view const& rhs) { if (&rhs==this) return *this; @@ -62,7 +62,7 @@ public: height_ = rhs.height_; data_ = rhs.data_; } - + inline unsigned x() const { return x_; @@ -72,7 +72,7 @@ public: { return y_; } - + inline unsigned width() const { return width_; @@ -81,7 +81,7 @@ public: { return height_; } - + inline const pixel_type* getRow(unsigned row) const { return data_.getRow(row + y_) + x_; @@ -94,7 +94,7 @@ public: { return data_; } - + private: unsigned x_; unsigned y_; diff --git a/include/mapnik/jpeg_io.hpp b/include/mapnik/jpeg_io.hpp index 0f681d017..370a187c0 100644 --- a/include/mapnik/jpeg_io.hpp +++ b/include/mapnik/jpeg_io.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -38,14 +38,14 @@ extern "C" namespace mapnik { #define BUFFER_SIZE 4096 - -typedef struct + +typedef struct { struct jpeg_destination_mgr pub; std::ostream * out; JOCTET * buffer; } dest_mgr; - + inline void init_destination( j_compress_ptr cinfo) { dest_mgr * dest = reinterpret_cast(cinfo->dest); @@ -64,30 +64,30 @@ inline boolean empty_output_buffer (j_compress_ptr cinfo) dest->pub.free_in_buffer = BUFFER_SIZE; return true; } - + inline void term_destination( j_compress_ptr cinfo) { dest_mgr * dest = reinterpret_cast(cinfo->dest); size_t size = BUFFER_SIZE - dest->pub.free_in_buffer; - if (size > 0) + if (size > 0) { dest->out->write((char*)dest->buffer, size); } dest->out->flush(); } - + template void save_as_jpeg(T1 & file,int quality, T2 const& image) -{ +{ struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; int width=image.width(); int height=image.height(); - + cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); - + cinfo.dest = (struct jpeg_destination_mgr *)(*cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof(dest_mgr)); dest_mgr * dest = (dest_mgr*) cinfo.dest; @@ -95,18 +95,18 @@ void save_as_jpeg(T1 & file,int quality, T2 const& image) dest->pub.empty_output_buffer = empty_output_buffer; dest->pub.term_destination = term_destination; dest->out = &file; - + //jpeg_stdio_dest(&cinfo, fp); cinfo.image_width = width; cinfo.image_height = height; cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; + cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, quality,1); jpeg_start_compress(&cinfo, 1); JSAMPROW row_pointer[1]; JSAMPLE* row=reinterpret_cast( ::operator new (sizeof(JSAMPLE) * width*3)); - while (cinfo.next_scanline < cinfo.image_height) + while (cinfo.next_scanline < cinfo.image_height) { const unsigned* imageRow=image.getRow(cinfo.next_scanline); int index=0; @@ -126,10 +126,10 @@ void save_as_jpeg(T1 & file,int quality, T2 const& image) (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } ::operator delete(row); - + jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); -} +} } #endif diff --git a/include/mapnik/label_collision_detector.hpp b/include/mapnik/label_collision_detector.hpp index 48de5f647..fa23b7ca0 100644 --- a/include/mapnik/label_collision_detector.hpp +++ b/include/mapnik/label_collision_detector.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -32,8 +32,8 @@ namespace mapnik { -//this needs to be tree structure -//as a proof of a concept _only_ we use sequential scan +//this needs to be tree structure +//as a proof of a concept _only_ we use sequential scan struct label_collision_detector { @@ -56,7 +56,7 @@ struct label_collision_detector { labels_.clear(); } - + private: label_placements labels_; @@ -71,12 +71,12 @@ public: explicit label_collision_detector2(box2d const& extent) : tree_(extent) {} - + bool has_placement(box2d const& box) { tree_t::query_iterator itr = tree_.query_in_box(box); tree_t::query_iterator end = tree_.query_end(); - + for ( ;itr != end; ++itr) { if (itr->intersects(box)) @@ -84,33 +84,33 @@ public: return false; } } - + tree_.insert(box,box); return true; } - + void clear() { tree_.clear(); - } - + } + }; - + // quad_tree based label collision detector with seperate check/insert class label_collision_detector3 : boost::noncopyable { typedef quad_tree< box2d > tree_t; tree_t tree_; public: - + explicit label_collision_detector3(box2d const& extent) : tree_(extent) {} - + bool has_placement(box2d const& box) { tree_t::query_iterator itr = tree_.query_in_box(box); tree_t::query_iterator end = tree_.query_end(); - + for ( ;itr != end; ++itr) { if (itr->intersects(box)) @@ -118,7 +118,7 @@ public: return false; } } - + return true; } @@ -126,14 +126,14 @@ public: { tree_.insert(box, box); } - + void clear() { tree_.clear(); } }; - + //quad tree based label collission detector so labels dont appear within a given distance class label_collision_detector4 : boost::noncopyable { @@ -142,26 +142,26 @@ public: { label(box2d const& b) : box(b) {} label(box2d const& b, UnicodeString const& t) : box(b), text(t) {} - + box2d box; UnicodeString text; }; - -private: + +private: typedef quad_tree< label > tree_t; tree_t tree_; - + public: typedef tree_t::query_iterator query_iterator; - + explicit label_collision_detector4(box2d const& extent) : tree_(extent) {} - + bool has_placement(box2d const& box) { tree_t::query_iterator itr = tree_.query_in_box(box); tree_t::query_iterator end = tree_.query_end(); - + for ( ;itr != end; ++itr) { if (itr->box.intersects(box)) @@ -169,16 +169,16 @@ public: return false; } } - + return true; - } + } bool has_placement(box2d const& box, UnicodeString const& text, double distance) { box2d bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance); tree_t::query_iterator itr = tree_.query_in_box(bigger_box); tree_t::query_iterator end = tree_.query_end(); - + for ( ;itr != end; ++itr) { if (itr->box.intersects(box) || (text == itr->text && itr->box.intersects(bigger_box))) @@ -186,16 +186,16 @@ public: return false; } } - + return true; - } + } bool has_point_placement(box2d const& box, double distance) { box2d bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance); tree_t::query_iterator itr = tree_.query_in_box(bigger_box); tree_t::query_iterator end = tree_.query_end(); - + for ( ;itr != end; ++itr) { if (itr->box.intersects(bigger_box)) @@ -203,32 +203,32 @@ public: return false; } } - + return true; - } - + } + void insert(box2d const& box) { tree_.insert(label(box), box); } - + void insert(box2d const& box, UnicodeString const& text) { tree_.insert(label(box, text), box); } - + void clear() { tree_.clear(); } - + box2d const& extent() const { return tree_.extent(); } - query_iterator begin() { return tree_.query_in_box(extent()); } - query_iterator end() { return tree_.query_end(); } + query_iterator begin() { return tree_.query_in_box(extent()); } + query_iterator end() { return tree_.query_end(); } }; } diff --git a/include/mapnik/layer.hpp b/include/mapnik/layer.hpp index 98d3b6fd9..f9f5826e7 100644 --- a/include/mapnik/layer.hpp +++ b/include/mapnik/layer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,9 +35,9 @@ namespace mapnik /*! * @brief A Mapnik map layer. * - * Create a layer with a named string and, optionally, an srs string either - * with a Proj.4 epsg code ('+init=epsg:') or with a Proj.4 literal - * ('+proj='). If no srs is specified it will default to + * Create a layer with a named string and, optionally, an srs string either + * with a Proj.4 epsg code ('+init=epsg:') or with a Proj.4 literal + * ('+proj='). If no srs is specified it will default to * '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' */ class MAPNIK_DECL layer @@ -47,7 +47,7 @@ public: layer(layer const& l); layer& operator=(layer const& l); bool operator==(layer const& other) const; - + /*! * @brief Set the name of the layer. */ @@ -56,77 +56,77 @@ public: /*! * @return the name of the layer. */ - + const std::string& name() const; /*! * @brief Set the SRS of the layer. */ void set_srs(std::string const& srs); - + /*! * @return the SRS of the layer. */ std::string const& srs() const; - + /*! * @brief Add a new style to this layer. * * @param stylename The name of the style to add. */ void add_style(std::string const& stylename); - + /*! * @return the styles list attached to this layer. */ std::vector const& styles() const; - + /*! * @return the styles list attached to this layer * (const version). */ std::vector& styles(); - + /*! * @param maxZoom The minimum zoom level to set */ void setMinZoom(double minZoom); - + /*! * @param maxZoom The maximum zoom level to set */ void setMaxZoom(double maxZoom); - + /*! * @return the minimum zoom level of the layer. */ double getMinZoom() const; - + /*! * @return the maximum zoom level of the layer. */ double getMaxZoom() const; - + /*! * @brief Set whether this layer is active and will be rendered. */ void setActive(bool active); - + /*! * @return whether this layer is active and will be rendered. */ bool isActive() const; - + /*! * @brief Set whether this layer is queryable. */ void setQueryable(bool queryable); - + /*! * @return whether this layer is queryable or not. */ bool isQueryable() const; - + /*! * @brief Get the visability for a specific scale. * @@ -140,27 +140,27 @@ public: * scale < maxzoom + 1e-6 */ bool isVisible(double scale) const; - + /*! * @param clear_cache Set whether this layer's labels are cached. */ void set_clear_label_cache(bool clear_cache); - + /*! * @return whether this layer's labels are cached. */ - bool clear_label_cache() const; + bool clear_label_cache() const; /*! * @param clear_cache Set whether this layer's features should be cached if used by multiple styles. */ void set_cache_features(bool cache_features); - + /*! * @return whether this layer's features will be cached if used by multiple styles */ - bool cache_features() const; - + bool cache_features() const; + /*! * @param group_by Set the field rendering of this layer is grouped by. */ @@ -177,24 +177,24 @@ public: * @param ds The datasource to attach. */ void set_datasource(datasource_ptr const& ds); - + /*! * @return the datasource attached to this layer. */ datasource_ptr datasource() const; - + /*! * @return the geographic envelope/bounding box of the data in the layer. */ box2d envelope() const; - + ~layer(); private: void swap(const layer& other); std::string name_; std::string srs_; - + double minZoom_; double maxZoom_; bool active_; diff --git a/include/mapnik/libxml2_loader.hpp b/include/mapnik/libxml2_loader.hpp index c4e5ca893..105a5f8b2 100644 --- a/include/mapnik/libxml2_loader.hpp +++ b/include/mapnik/libxml2_loader.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -29,7 +29,7 @@ // stl #include -namespace mapnik +namespace mapnik { void read_xml2( std::string const & filename, boost::property_tree::ptree & pt); void read_xml2_string( std::string const & str, boost::property_tree::ptree & pt, std::string const & base_path=""); diff --git a/include/mapnik/line_pattern_symbolizer.hpp b/include/mapnik/line_pattern_symbolizer.hpp index 8a65bf043..1143c37c2 100644 --- a/include/mapnik/line_pattern_symbolizer.hpp +++ b/include/mapnik/line_pattern_symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -27,14 +27,14 @@ #include //#include -namespace mapnik -{ +namespace mapnik +{ struct MAPNIK_DECL line_pattern_symbolizer : public symbolizer_with_image, public symbolizer_base { line_pattern_symbolizer(path_expression_ptr file); line_pattern_symbolizer(line_pattern_symbolizer const& rhs); -}; +}; } #endif // MAPNIK_LINE_PATTERN_SYMBOLIZER_HPP diff --git a/include/mapnik/line_symbolizer.hpp b/include/mapnik/line_symbolizer.hpp index 39df6685d..84c845098 100644 --- a/include/mapnik/line_symbolizer.hpp +++ b/include/mapnik/line_symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -28,7 +28,7 @@ #include #include -namespace mapnik +namespace mapnik { enum line_rasterizer_enum { @@ -43,19 +43,19 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base { explicit line_symbolizer() : symbolizer_base(), - stroke_(), - rasterizer_p_(RASTERIZER_FULL) {} - + stroke_(), + rasterizer_p_(RASTERIZER_FULL) {} + line_symbolizer(stroke const& stroke) : symbolizer_base(), - stroke_(stroke), - rasterizer_p_(RASTERIZER_FULL) {} - + stroke_(stroke), + rasterizer_p_(RASTERIZER_FULL) {} + line_symbolizer(color const& pen,float width=1.0) : symbolizer_base(), - stroke_(pen,width), - rasterizer_p_(RASTERIZER_FULL) {} - + stroke_(pen,width), + rasterizer_p_(RASTERIZER_FULL) {} + stroke const& get_stroke() const { return stroke_; @@ -65,12 +65,12 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base { stroke_ = stk; } - + void set_rasterizer(line_rasterizer_e rasterizer_p) { rasterizer_p_ = rasterizer_p; } - + line_rasterizer_e get_rasterizer() const { return rasterizer_p_; diff --git a/include/mapnik/load_map.hpp b/include/mapnik/load_map.hpp index c94342bd4..3dbba801f 100644 --- a/include/mapnik/load_map.hpp +++ b/include/mapnik/load_map.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp index 5611e5e17..f98a90a9c 100644 --- a/include/mapnik/map.hpp +++ b/include/mapnik/map.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -37,16 +37,16 @@ namespace mapnik { class MAPNIK_DECL Map -{ +{ public: - enum aspect_fix_mode + enum aspect_fix_mode { // grow the width or height of the specified geo bbox to fill the map size. default behaviour. GROW_BBOX, // grow the width or height of the map to accomodate the specified geo bbox. GROW_CANVAS, - // shrink the width or height of the specified geo bbox to fill the map size. + // shrink the width or height of the specified geo bbox to fill the map size. SHRINK_BBOX, // shrink the width or height of the map to accomodate the specified geo bbox. SHRINK_CANVAS, @@ -56,12 +56,12 @@ public: ADJUST_BBOX_HEIGHT, // adjust the width of the map, leave height and geo bbox unchanged ADJUST_CANVAS_WIDTH, - //adjust the height of the map, leave width and geo bbox unchanged + //adjust the height of the map, leave width and geo bbox unchanged ADJUST_CANVAS_HEIGHT, - // + // aspect_fix_mode_MAX }; - + private: static const unsigned MIN_MAPSIZE=16; static const unsigned MAX_MAPSIZE=MIN_MAPSIZE<<10; @@ -81,7 +81,7 @@ private: std::string base_path_; parameters extra_attr_; parameters extra_params_; - + public: typedef std::map::const_iterator const_style_iterator; @@ -89,7 +89,7 @@ public: typedef std::map::const_iterator const_fontset_iterator; typedef std::map::iterator fontset_iterator; typedef std::map::const_iterator const_metawriter_iterator; - + /*! \brief Default constructor. * * Creates a map with these parameters: @@ -115,20 +115,20 @@ public: /*! \brief Assignment operator * * TODO: to be documented - * + * */ Map& operator=(const Map& rhs); - + /*! \brief Get all styles * @return Const reference to styles */ - std::map const& styles() const; - - /*! \brief Get all styles + std::map const& styles() const; + + /*! \brief Get all styles * @return Non-constant reference to styles */ std::map & styles(); - + /*! \brief Get first iterator in styles. * @return Constant style iterator. */ @@ -201,7 +201,7 @@ public: * @return Constant metawriter iterator. */ const_metawriter_iterator end_metawriters() const; - + /*! \brief Insert a fontset into the map. * @param name The name of the fontset. * @param style The fontset to insert. @@ -209,7 +209,7 @@ public: * @return false If failure. */ bool insert_fontset(std::string const& name, font_set const& fontset); - + /*! \brief Find a fontset. * @param name The name of the fontset. * @return The fontset if found. If not found return the default map fontset. @@ -246,7 +246,7 @@ public: * @return Non-constant layer. */ layer& getLayer(size_t index); - + /*! \brief Remove a layer. * @param index layer number. */ @@ -300,31 +300,31 @@ public: * @param c Background color. */ void set_background(const color& c); - - /*! \brief Get the map background color + + /*! \brief Get the map background color * @return Background color as boost::optional * object */ boost::optional const& background() const; - + /*! \brief Set the map background image filename. * @param c Background image filename. */ void set_background_image(std::string const& image_filename); - + /*! \brief Get the map background image * @return Background image path as std::string * object */ boost::optional const& background_image() const; - - /*! \brief Set buffer size + + /*! \brief Set buffer size * @param buffer_size Buffer size in pixels. */ - + void set_buffer_size(int buffer_size); - - /*! \brief Get the map buffer size + + /*! \brief Get the map buffer size * @return Buffer size as int */ int buffer_size() const; @@ -333,9 +333,9 @@ public: * @param box The bounding box for the maximum extent. */ void set_maximum_extent(box2dconst& box); - + /*! \brief Get the map maximum extent as box2d - */ + */ boost::optional > const& maximum_extent() const; /*! \brief Get the map base path where paths should be relative to. @@ -352,7 +352,7 @@ public: */ void zoom(double factor); - /*! \brief Zoom the map to a bounding box. + /*! \brief Zoom the map to a bounding box. * * Aspect is handled automatic if not fitting to width/height. * @param box The bounding box where to zoom. @@ -376,16 +376,16 @@ public: * @return The current buffered bounding box. */ box2d get_buffered_extent() const; - + /*! * @return The Map Scale. */ double scale() const; - + double scale_denominator() const; CoordTransform view_transform() const; - + /*! * @brief Query a Map layer (by layer index) for features * @@ -416,7 +416,7 @@ public: * @brief Resolve names to object references for metawriters. */ void init_metawriters(); - + ~Map(); inline void set_aspect_fix_mode(aspect_fix_mode afm) { aspectFixMode_ = afm; } @@ -473,7 +473,7 @@ public: private: void fixAspectRatio(); }; - + DEFINE_ENUM(aspect_fix_mode_e,Map::aspect_fix_mode); } diff --git a/include/mapnik/mapped_memory_cache.hpp b/include/mapnik/mapped_memory_cache.hpp index e44a468b4..8836a5049 100644 --- a/include/mapnik/mapped_memory_cache.hpp +++ b/include/mapnik/mapped_memory_cache.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/marker.hpp b/include/mapnik/marker.hpp index 257c597cb..3bfd6e5a5 100644 --- a/include/mapnik/marker.hpp +++ b/include/mapnik/marker.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -44,7 +44,7 @@ #include #include -namespace mapnik +namespace mapnik { typedef agg::pod_bvector attr_storage; diff --git a/include/mapnik/marker_cache.hpp b/include/mapnik/marker_cache.hpp index b37aa2be8..5b56770b0 100644 --- a/include/mapnik/marker_cache.hpp +++ b/include/mapnik/marker_cache.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index b69ef1dd5..a3eabb6d3 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -137,7 +137,7 @@ template bool markers_placement bool markers_placement namespace mapnik { - + class MAPNIK_DECL memory_datasource : public datasource { friend class memory_featureset; @@ -50,8 +50,8 @@ public: private: std::vector features_; mapnik::layer_descriptor desc_; -}; - +}; + } #endif // MAPNIK_MEMORY_DATASOURCE_HPP diff --git a/include/mapnik/memory_featureset.hpp b/include/mapnik/memory_featureset.hpp index 2b6557521..438f8cd30 100644 --- a/include/mapnik/memory_featureset.hpp +++ b/include/mapnik/memory_featureset.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,7 +30,7 @@ #include namespace mapnik { - + class memory_featureset : public Featureset, private boost::noncopyable { public: @@ -47,7 +47,7 @@ public: {} virtual ~memory_featureset() {} - + feature_ptr next() { while (pos_ != end_) @@ -64,14 +64,14 @@ public: } ++pos_; } - + return feature_ptr(); } - + private: box2d bbox_; std::vector::const_iterator pos_; - std::vector::const_iterator end_; + std::vector::const_iterator end_; }; } diff --git a/include/mapnik/metawriter.hpp b/include/mapnik/metawriter.hpp index 68792f4e4..62a28f49b 100644 --- a/include/mapnik/metawriter.hpp +++ b/include/mapnik/metawriter.hpp @@ -49,7 +49,7 @@ class metawriter_property_map public: typedef std::map property_map; typedef property_map::const_iterator const_iterator; - + metawriter_property_map() {} UnicodeString const& operator[](std::string const& key) const; UnicodeString& operator[](std::string const& key) {return m_[key];} @@ -61,7 +61,7 @@ public: { return m_.end(); } - + UnicodeString const& get(std::string const& key) const { return (*this)[key]; @@ -89,9 +89,9 @@ class metawriter public: typedef coord_transform2 path_type; metawriter(metawriter_properties dflt_properties) : - dflt_properties_(dflt_properties), - width_(0), - height_(0) {} + dflt_properties_(dflt_properties), + width_(0), + height_(0) {} virtual ~metawriter() {}; /** Output a rectangular area. * \param box Area (in pixel coordinates) @@ -123,11 +123,11 @@ public: * \param properties metawriter_property_map object with userdefined values. * Useful for setting filename etc. */ - virtual void start(metawriter_property_map const& properties) + virtual void start(metawriter_property_map const& properties) { boost::ignore_unused_variable_warning(properties); }; - + /** Stop processing. * Write file footer, close database connection, ... */ diff --git a/include/mapnik/metawriter_factory.hpp b/include/mapnik/metawriter_factory.hpp index cb0150fd4..d5b8911fd 100644 --- a/include/mapnik/metawriter_factory.hpp +++ b/include/mapnik/metawriter_factory.hpp @@ -40,13 +40,13 @@ namespace mapnik { metawriter_ptr metawriter_create(const boost::property_tree::ptree &pt); /** - * Writes properties into the given property tree representing the + * Writes properties into the given property tree representing the * metawriter argument, and which can be used to reconstruct it. */ void metawriter_save( - const metawriter_ptr &m, - boost::property_tree::ptree &pt, - bool explicit_defaults); + const metawriter_ptr &m, + boost::property_tree::ptree &pt, + bool explicit_defaults); } diff --git a/include/mapnik/metawriter_inmem.hpp b/include/mapnik/metawriter_inmem.hpp index 870bdcb2d..044ed64b6 100644 --- a/include/mapnik/metawriter_inmem.hpp +++ b/include/mapnik/metawriter_inmem.hpp @@ -37,13 +37,13 @@ namespace mapnik { /** * Keeps metadata information in-memory, where it can be retrieved by whatever's - * calling Mapnik and custom output provided. + * calling Mapnik and custom output provided. * * Stored data is all in image coordinates in the current implementation. * * This is most useful when Mapnik is being called from Python, and the result * of the metawriter can be queried and injected into the (meta)tile or whatever - * in a very flexible way. E.g: for a GUI app the metawriter can be used to + * in a very flexible way. E.g: for a GUI app the metawriter can be used to * create hit areas, for a web app it could be used to create an HTML image map. * * Because this is kept in-memory, applying this metawriter to features which are @@ -51,66 +51,66 @@ namespace mapnik { * many attributes are also kept. */ class MAPNIK_DECL metawriter_inmem - : public metawriter, private boost::noncopyable { + : public metawriter, private boost::noncopyable { public: - /** - * Construct an in-memory writer which keeps properties specified by the - * dflt_properties argument. For example: if dflt_properties contains "name", - * then the name attribute of rendered features referencing this metawriter - * will be kept in memory. - */ + /** + * Construct an in-memory writer which keeps properties specified by the + * dflt_properties argument. For example: if dflt_properties contains "name", + * then the name attribute of rendered features referencing this metawriter + * will be kept in memory. + */ metawriter_inmem(metawriter_properties dflt_properties); ~metawriter_inmem(); - - virtual void add_box(box2d const& box, Feature const& feature, - CoordTransform const& t, - metawriter_properties const& properties); - virtual void add_text(text_placement_info const& p, - face_manager_freetype &font_manager, - Feature const& feature, - CoordTransform const& t, - metawriter_properties const& properties); - virtual void add_polygon(path_type & path, - Feature const& feature, - CoordTransform const& t, - metawriter_properties const& properties); - virtual void add_line(path_type & path, - Feature const& feature, - CoordTransform const& t, - metawriter_properties const& properties); - - virtual void start(metawriter_property_map const& properties); - /** - * An instance of a rendered feature. The box represents the image - * coordinates of a bounding box around the feature. The properties - * are the intersection of the features' properties and the "kept" - * properties of the metawriter. - */ - struct MAPNIK_DECL meta_instance { - box2d box; - std::map properties; - }; + virtual void add_box(box2d const& box, Feature const& feature, + CoordTransform const& t, + metawriter_properties const& properties); + virtual void add_text(text_placement_info const& p, + face_manager_freetype &font_manager, + Feature const& feature, + CoordTransform const& t, + metawriter_properties const& properties); + virtual void add_polygon(path_type & path, + Feature const& feature, + CoordTransform const& t, + metawriter_properties const& properties); + virtual void add_line(path_type & path, + Feature const& feature, + CoordTransform const& t, + metawriter_properties const& properties); - typedef std::list meta_instance_list; + virtual void start(metawriter_property_map const& properties); - // const-only access to the instances. - const meta_instance_list &instances() const; + /** + * An instance of a rendered feature. The box represents the image + * coordinates of a bounding box around the feature. The properties + * are the intersection of the features' properties and the "kept" + * properties of the metawriter. + */ + struct MAPNIK_DECL meta_instance { + box2d box; + std::map properties; + }; + + typedef std::list meta_instance_list; + + // const-only access to the instances. + const meta_instance_list &instances() const; + + // utility iterators for use in the python bindings. + meta_instance_list::const_iterator inst_begin() const; + meta_instance_list::const_iterator inst_end() const; - // utility iterators for use in the python bindings. - meta_instance_list::const_iterator inst_begin() const; - meta_instance_list::const_iterator inst_end() const; - private: - std::list instances_; + std::list instances_; - void add_vertices(path_type & path, - Feature const& feature, - CoordTransform const& t, - metawriter_properties const& properties); + void add_vertices(path_type & path, + Feature const& feature, + CoordTransform const& t, + metawriter_properties const& properties); }; - + /** Shared pointer to metawriter_inmem object. */ typedef boost::shared_ptr metawriter_inmem_ptr; diff --git a/include/mapnik/metawriter_json.hpp b/include/mapnik/metawriter_json.hpp index 6c30c2355..029e52973 100644 --- a/include/mapnik/metawriter_json.hpp +++ b/include/mapnik/metawriter_json.hpp @@ -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; diff --git a/include/mapnik/octree.hpp b/include/mapnik/octree.hpp index bdba82890..533cafbc2 100644 --- a/include/mapnik/octree.hpp +++ b/include/mapnik/octree.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -45,16 +45,16 @@ struct RGBPolicy inline static unsigned index_from_level(unsigned level, rgb const& c) { unsigned shift = 7 - level; - return (((c.r >> shift) & 1) << 2) - | (((c.g >> shift) & 1) << 1) + return (((c.r >> shift) & 1) << 2) + | (((c.g >> shift) & 1) << 1) | ((c.b >> shift) & 1); } }; template class octree : private boost::noncopyable -{ - struct node +{ + struct node { node () : reds(0), @@ -182,7 +182,7 @@ public: node * cur_node = root_; while (cur_node) { - if (cur_node->children_count == 0) + if (cur_node->children_count == 0) return cur_node->index + offset_; unsigned idx = InsertPolicy::index_from_level(level,c); cur_node = cur_node->children_[idx]; @@ -202,7 +202,7 @@ public: palette.reserve(colors_); create_palette(palette, root_); } - + void computeCost(node *r) { r->reduce_cost = 0; @@ -220,7 +220,7 @@ public: dr = r->children_[idx]->reds / r->children_[idx]->count_cum - mean_r; dg = r->children_[idx]->greens / r->children_[idx]->count_cum - mean_g; db = r->children_[idx]->blues / r->children_[idx]->count_cum - mean_b; - + r->reduce_cost += r->children_[idx]->reduce_cost; r->reduce_cost += (dr*dr + dg*dg + db*db) * r->children_[idx]->count_cum; } @@ -230,7 +230,7 @@ public: { computeCost(root_); reducible_[0].push_back(root_); - + // sort reducible by reduce_cost for (unsigned i=0;ichildren_[idx], cur_node->children_[idx]=0; } } - + reducible_[red_idx].erase(pos); - if (num_children > 0 ) + if (num_children > 0 ) { colors_ -= (num_children - 1); } } } - + void create_palette(std::vector & palette, node * itr) const { if (itr->count != 0) @@ -296,12 +296,12 @@ public: } for (unsigned i=0; i < 8 ;++i) { - if (itr->children_[i] != 0) + if (itr->children_[i] != 0) create_palette(palette, itr->children_[i]); - } + } } -private: - node * root_; +private: + node * root_; }; } // namespace mapnik diff --git a/include/mapnik/palette.hpp b/include/mapnik/palette.hpp index ea1f66a33..de58bbe10 100644 --- a/include/mapnik/palette.hpp +++ b/include/mapnik/palette.hpp @@ -129,7 +129,7 @@ public: explicit rgba_palette(std::string const& pal, palette_type type = PALETTE_RGBA); rgba_palette(); - + const std::vector& palette() const; const std::vector& alphaTable() const; diff --git a/include/mapnik/params.hpp b/include/mapnik/params.hpp index 8703b86d3..6f76b365d 100644 --- a/include/mapnik/params.hpp +++ b/include/mapnik/params.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -41,40 +41,40 @@ namespace mapnik typedef boost::variant value_holder; typedef std::pair parameter; typedef std::map param_map; - + template struct value_extractor_visitor : public boost::static_visitor<> { value_extractor_visitor(boost::optional & var) :var_(var) {} - + void operator () (T val) const { var_ = val; } - + template - void operator () (T1 val) const + void operator () (T1 val) const { - try + try { var_ = boost::lexical_cast(val); } catch (boost::bad_lexical_cast & ) {} } - + boost::optional & var_; }; - - + + class parameters : public param_map { - template + template struct converter { - typedef boost::optional return_type; + typedef boost::optional return_type; static return_type extract(parameters const& params, - std::string const& name, + std::string const& name, boost::optional const& default_value) { boost::optional result(default_value); @@ -86,17 +86,17 @@ class parameters : public param_map return result; } }; - + public: - + parameters() {} - + template boost::optional get(std::string const& key) const { return converter::extract(*this,key, boost::none); } - + template boost::optional get(std::string const& key, T const& default_value) const { diff --git a/include/mapnik/parse_path.hpp b/include/mapnik/parse_path.hpp index 250a175ef..a98189ca8 100644 --- a/include/mapnik/parse_path.hpp +++ b/include/mapnik/parse_path.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -55,61 +55,61 @@ struct path_processor path_visitor_ (std::string & filename, feature_type const& f) : filename_(filename), feature_(f) {} - + void operator() (std::string const& token) const { filename_ += token; } - + void operator() (attribute const& attr) const { // convert mapnik::value to std::string filename_ += attr.value(feature_).to_string(); } - + std::string & filename_; feature_type const& feature_; }; - + struct to_string_ : boost::static_visitor { to_string_ (std::string & str) : str_(str) {} - + void operator() (std::string const& token) const { str_ += token; } - void operator() (attribute const& attr) const + void operator() (attribute const& attr) const { str_ += "["; str_ += attr.name(); str_ += "]"; } - + std::string & str_; }; - + template struct collect_ : boost::static_visitor { collect_ (T1 & cont) : cont_(cont) {} - + void operator() (std::string const& token) const { boost::ignore_unused_variable_warning(token); } - - void operator() (attribute const& attr) const + + void operator() (attribute const& attr) const { cont_.insert(attr.name()); } - + T1 & cont_; }; - + static std::string evaluate(path_expression const& path,feature_type const& f) { std::string out; @@ -118,7 +118,7 @@ struct path_processor boost::apply_visitor(eval,token); return out; } - + static std::string to_string(path_expression const& path) { std::string str; @@ -127,7 +127,7 @@ struct path_processor boost::apply_visitor(visitor,token); return str; } - + template static void collect_attributes(path_expression const& path, T2 & names) { diff --git a/include/mapnik/path_expression_grammar.hpp b/include/mapnik/path_expression_grammar.hpp index 632745dad..5da749b11 100644 --- a/include/mapnik/path_expression_grammar.hpp +++ b/include/mapnik/path_expression_grammar.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -63,7 +63,7 @@ using standard_wide::space; template struct path_expression_grammar : qi::grammar(), space_type> -{ +{ path_expression_grammar() : path_expression_grammar::base_type(expr) { @@ -74,7 +74,7 @@ struct path_expression_grammar : qi::grammar> attr [ push_back(_val, construct( _1 )) ] >> ']') ) ; - + attr %= +(char_ - ']'); str %= lexeme[+(char_ -'[')]; } - + qi::rule() , space_type> expr; qi::rule attr; qi::rule str; diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index f565a90f6..1e3ef5e98 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -35,7 +35,7 @@ class placement_finder : boost::noncopyable public: placement_finder(text_placement_info &p, string_info &info, DetectorT & detector); placement_finder(text_placement_info &p, string_info &info, DetectorT & detector, box2d const& extent); - + /** Try place a single label at the given point. */ void find_point_placement(double pos_x, double pos_y, double angle=0.0); @@ -50,7 +50,7 @@ public: void update_detector(); void clear(); - + private: ///Helpers for find_line_placement @@ -63,8 +63,8 @@ private: // If >= 50% of the characters end up upside down, it will be retried the other way. // RETURN: 1/-1 depending which way up the string ends up being. std::auto_ptr get_placement_offset(const std::vector & path_positions, - const std::vector & path_distances, - int & orientation, unsigned index, double distance); + const std::vector & path_distances, + int & orientation, unsigned index, double distance); ///Tests wether the given text_path be placed without a collision // Returns true if it can diff --git a/include/mapnik/plugin.hpp b/include/mapnik/plugin.hpp index 5ccd3ca78..b8259e029 100644 --- a/include/mapnik/plugin.hpp +++ b/include/mapnik/plugin.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,10 +35,10 @@ namespace mapnik { class PluginInfo : boost::noncopyable -{ +{ private: std::string name_; - lt_dlhandle module_; + lt_dlhandle module_; public: PluginInfo (const std::string& name,const lt_dlhandle module); ~PluginInfo(); diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index fd47535b3..e048446c2 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -40,7 +40,7 @@ extern "C" #define MAX_OCTREE_LEVELS 4 namespace mapnik { - + template void write_data (png_structp png_ptr, png_bytep data, png_size_t length) { @@ -57,13 +57,13 @@ void flush_data (png_structp png_ptr) template void save_as_png(T1 & file , T2 const& image, int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY) -{ +{ png_voidp error_ptr=0; png_structp png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING, error_ptr,0, 0); - + if (!png_ptr) return; - + // switch on optimization only if supported #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) && defined(PNG_MMX_CODE_SUPPORTED) png_uint_32 mask, flags; @@ -116,7 +116,7 @@ void reduce_8 (T const& in, image_data_8 & out, octree trees[], unsigned l alpha[i] = 0; alphaCount[i] = 0; } - + for (unsigned y = 0; y < height; ++y) { mapnik::image_data_32::pixel_type const * row = in.getRow(y); @@ -141,7 +141,7 @@ void reduce_8 (T const& in, image_data_8 & out, octree trees[], unsigned l row_out[x] = index; } } - for(unsigned i=0; i trees[], unsigned li row_out[x>>1] |= index; } } - for(unsigned i=0; i const& palette, { std::vector trans(alpha.size()); unsigned alphaSize=0;//truncate to nonopaque values - for(unsigned i=0; i < alpha.size(); i++) + for(unsigned i=0; i < alpha.size(); i++) { trans[i]=alpha[i]; if (alpha[i]<255) @@ -278,7 +278,7 @@ void save_as_png(T & file, std::vector const& palette, template void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 256, - int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY, int trans_mode = -1) + int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY, int trans_mode = -1) { // number of alpha ranges in png8 format; 2 results in smallest image with binary transparency // 3 is minimum for semitransparency, 4 is recommended, anything else is worse @@ -376,7 +376,7 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25 for (unsigned x = 0; x < width; ++x) { unsigned val = row[x]; - + // insert to proper tree based on alpha range for(unsigned j=TRANSPARENCY_LEVELS-1; j>0; j--){ if (cols[j]>0 && U2ALPHA(val)>=limits[j]) { @@ -417,7 +417,7 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25 //alphaTable.resize(palette.size());//allow semitransparency also in almost opaque range if (trans_mode != 0) alphaTable.resize(palette.size() - cols[TRANSPARENCY_LEVELS-1]); - + if (palette.size() > 16 ) { // >16 && <=256 colors -> write 8-bit color depth @@ -452,8 +452,8 @@ void save_as_png8_oct(T1 & file, T2 const& image, const unsigned max_colors = 25 template void save_as_png8(T1 & file, T2 const& image, T3 const & tree, - std::vector const& palette, std::vector const& alphaTable, - int compression = Z_DEFAULT_COMPRESSION, int strategy = Z_DEFAULT_STRATEGY) + std::vector const& palette, std::vector 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 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 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(file, image, pal, pal.palette(), pal.alphaTable(), compression, strategy); } diff --git a/include/mapnik/point_symbolizer.hpp b/include/mapnik/point_symbolizer.hpp index c1f7c1382..792f0cbb6 100644 --- a/include/mapnik/point_symbolizer.hpp +++ b/include/mapnik/point_symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -24,10 +24,10 @@ #define MAPNIK_POINT_SYMBOLIZER_HPP // mapnik -#include +#include #include - -namespace mapnik + +namespace mapnik { enum point_placement_enum { @@ -38,9 +38,9 @@ enum point_placement_enum { DEFINE_ENUM( point_placement_e, point_placement_enum ); -struct MAPNIK_DECL point_symbolizer : +struct MAPNIK_DECL point_symbolizer : public symbolizer_with_image, public symbolizer_base -{ +{ explicit point_symbolizer(); point_symbolizer(path_expression_ptr file); point_symbolizer(point_symbolizer const& rhs); @@ -50,7 +50,7 @@ struct MAPNIK_DECL point_symbolizer : point_placement_e get_point_placement() const; void set_ignore_placement(bool ignore_placement); bool get_ignore_placement() const; - + private: bool overlap_; point_placement_e point_p_; diff --git a/include/mapnik/polygon_pattern_symbolizer.hpp b/include/mapnik/polygon_pattern_symbolizer.hpp index f886cae1e..9d342feb7 100644 --- a/include/mapnik/polygon_pattern_symbolizer.hpp +++ b/include/mapnik/polygon_pattern_symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -23,7 +23,7 @@ #ifndef MAPNIK_POLYGON_PATTERN_SYMBOLIZER_HPP #define MAPNIK_POLYGON_PATTERN_SYMBOLIZER_HPP -// mapnik +// mapnik #include #include #include diff --git a/include/mapnik/polygon_symbolizer.hpp b/include/mapnik/polygon_symbolizer.hpp index 3734a2edb..d39e1b867 100644 --- a/include/mapnik/polygon_symbolizer.hpp +++ b/include/mapnik/polygon_symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,7 +30,7 @@ #include #include -namespace mapnik +namespace mapnik { struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base @@ -51,7 +51,7 @@ private: double opacity_; double gamma_; gamma_method_e gamma_method_; -}; +}; } diff --git a/include/mapnik/pool.hpp b/include/mapnik/pool.hpp index 518744a9c..26fa2d520 100644 --- a/include/mapnik/pool.hpp +++ b/include/mapnik/pool.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -46,13 +46,13 @@ class PoolGuard { private: const T& obj_; - PoolT& pool_; + PoolT& pool_; public: explicit PoolGuard(const T& ptr,PoolT& pool) : obj_(ptr), pool_(pool) {} - ~PoolGuard() + ~PoolGuard() { pool_->returnObject(obj_); } @@ -67,10 +67,10 @@ template class Creator> class Pool : private boost::noncopyable { typedef boost::shared_ptr HolderType; - typedef std::deque ContType; - + typedef std::deque ContType; + Creator creator_; - const unsigned initialSize_; + const unsigned initialSize_; const unsigned maxSize_; ContType usedPool_; ContType unusedPool_; @@ -84,7 +84,7 @@ public: initialSize_(initialSize), maxSize_(maxSize) { - for (unsigned i=0; i < initialSize_; ++i) + for (unsigned i=0; i < initialSize_; ++i) { HolderType conn(creator_()); if (conn->isOK()) @@ -93,13 +93,13 @@ public: } HolderType borrowObject() - { -#ifdef MAPNIK_THREADSAFE + { +#ifdef MAPNIK_THREADSAFE mutex::scoped_lock lock(mutex_); #endif typename ContType::iterator itr=unusedPool_.begin(); while ( itr!=unusedPool_.end()) - { + { #ifdef MAPNIK_DEBUG std::clog<<"borrow "<<(*itr).get()<<"\n"; #endif @@ -113,7 +113,7 @@ public: { #ifdef MAPNIK_DEBUG std::clog<<"bad connection (erase)" << (*itr).get()<<"\n"; -#endif +#endif itr=unusedPool_.erase(itr); } } @@ -130,7 +130,7 @@ public: } } return HolderType(); - } + } void returnObject(HolderType obj) { @@ -140,7 +140,7 @@ public: typename ContType::iterator itr=usedPool_.begin(); while (itr != usedPool_.end()) { - if (obj.get()==(*itr).get()) + if (obj.get()==(*itr).get()) { #ifdef MAPNIK_DEBUG std::clog<<"return "<<(*itr).get()<<"\n"; @@ -152,7 +152,7 @@ public: ++itr; } } - + std::pair size() const { #ifdef MAPNIK_THREADSAFE diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp index 8c156a0a8..607e99fb9 100644 --- a/include/mapnik/proj_transform.hpp +++ b/include/mapnik/proj_transform.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -31,13 +31,13 @@ #include namespace mapnik { - + class MAPNIK_DECL proj_transform : private boost::noncopyable { public: - proj_transform(projection const& source, + proj_transform(projection const& source, projection const& dest); - + bool equal() const; bool forward (double& x, double& y , double& z) const; bool backward (double& x, double& y , double& z) const; @@ -49,7 +49,7 @@ public: bool backward (box2d & box, int points) const; mapnik::projection const& source() const; mapnik::projection const& dest() const; - + private: projection const source_; projection const dest_; diff --git a/include/mapnik/projection.hpp b/include/mapnik/projection.hpp index 26d64466a..a1578eba4 100644 --- a/include/mapnik/projection.hpp +++ b/include/mapnik/projection.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -41,14 +41,14 @@ #include namespace mapnik { - + class proj_init_error : public std::runtime_error { public: proj_init_error(std::string const& params) : std::runtime_error("failed to initialize projection with: '" + params + "'") {} }; - + class MAPNIK_DECL projection { friend class proj_transform; @@ -56,23 +56,23 @@ public: explicit projection(std::string const& params = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"); projection(projection const& rhs); ~projection(); - + projection& operator=(projection const& rhs); bool operator==(const projection& other) const; bool operator!=(const projection& other) const; bool is_initialized() const; bool is_geographic() const; std::string const& params() const; - + void forward(double & x, double &y ) const; void inverse(double & x,double & y) const; std::string expanded() const; - + private: - void init(); + void init(); void swap (projection& rhs); - + private: std::string params_; projPJ proj_; diff --git a/include/mapnik/ptree_helpers.hpp b/include/mapnik/ptree_helpers.hpp index c3790ebdf..5a7bd7362 100644 --- a/include/mapnik/ptree_helpers.hpp +++ b/include/mapnik/ptree_helpers.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -99,8 +99,8 @@ inline color get_css (boost::property_tree::ptree const& node, std::string const " but got '" + str + "'"); } } - - + + template std::basic_ostream & operator << ( std::basic_ostream & s, const mapnik::color & c ) @@ -117,7 +117,7 @@ public: boolean(bool b) : b_(b) {} boolean(const boolean & b) : b_(b.b_) {} - operator bool() const + operator bool() const { return b_; } @@ -142,9 +142,9 @@ operator >> ( std::basic_istream & s, boolean & b ) { std::string word; s >> word; - if ( s ) + if ( s ) { - if ( word == "true" || word == "yes" || word == "on" || + if ( word == "true" || word == "yes" || word == "on" || word == "1") { b = true; @@ -156,7 +156,7 @@ operator >> ( std::basic_istream & s, boolean & b ) } else { - s.setstate( std::ios::failbit ); + s.setstate( std::ios::failbit ); } } return s; @@ -190,7 +190,7 @@ template void set_css(boost::property_tree::ptree & pt, const std::string & name, const T & v) { boost::property_tree::ptree & css_node = pt.push_back( - boost::property_tree::ptree::value_type("CssParameter", + boost::property_tree::ptree::value_type("CssParameter", boost::property_tree::ptree()))->second; css_node.put(".name", name ); css_node.put_value( v ); @@ -242,7 +242,7 @@ struct name_trait< mapnik::enumeration > if ( i + 1 < Enum::MAX ) value_list += ", "; } value_list += "]"; - + return value_list; } }; @@ -291,8 +291,8 @@ inline color get(boost::property_tree::ptree const& node, std::string const& nam { str = node.get_optional(name+"."); } - - if ( str ) + + if ( str ) { try { @@ -305,13 +305,13 @@ inline color get(boost::property_tree::ptree const& node, std::string const& nam name + "'. Expected " + name_trait::name() + " but got '" + *str + "'"); } - } - else + } + else { return default_value; } } - + template T get(const boost::property_tree::ptree & node, const std::string & name, bool is_attribute) { @@ -350,7 +350,7 @@ T get_value(const boost::property_tree::ptree & node, const std::string & name) { /* NOTE: get_child works as long as there is only one child with that name. If this function is used this used this condition must always be satisfied. - */ + */ return node.get_child("").get_value(); } catch (boost::property_tree::ptree_bad_path) @@ -382,9 +382,9 @@ boost::optional get_optional(const boost::property_tree::ptree & node, const { str = node.get_optional(name+"."); } - + boost::optional result; - if ( str ) + if ( str ) { try { @@ -396,13 +396,13 @@ boost::optional get_optional(const boost::property_tree::ptree & node, const (is_attribute ? "attribute" : "child node") + " '" + name + "'. Expected " + name_trait::name() + " but got '" + *str + "'"); - } + } } - + return result; } // - + template <> inline boost::optional get_optional(const boost::property_tree::ptree & node, const std::string & name, bool is_attribute) @@ -416,9 +416,9 @@ inline boost::optional get_optional(const boost::property_tree::ptree & n { str = node.get_optional(name+"."); } - + boost::optional result; - if ( str ) + if ( str ) { try { @@ -431,9 +431,9 @@ inline boost::optional get_optional(const boost::property_tree::ptree & n (is_attribute ? "attribute" : "child node") + " '" + name + "'. Expected " + name_trait::name() + " but got '" + *str + "'"); - } + } } - + return result; } diff --git a/include/mapnik/quad_tree.hpp b/include/mapnik/quad_tree.hpp index 63b305c73..af7423440 100644 --- a/include/mapnik/quad_tree.hpp +++ b/include/mapnik/quad_tree.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -54,104 +54,104 @@ class quad_tree : boost::noncopyable { std::memset(children_,0,4*sizeof(node*)); } - + box2d const& extent() const { return extent_; } - - iterator begin() + + iterator begin() { return cont_.begin(); } - - const_iterator begin() const + + const_iterator begin() const { return cont_.begin(); } - - iterator end() + + iterator end() { return cont_.end(); } - - const_iterator end() const + + const_iterator end() const { return cont_.end(); } ~node () {} }; - - typedef boost::ptr_vector nodes_t; + + typedef boost::ptr_vector nodes_t; typedef typename node::cont_t cont_t; typedef typename cont_t::iterator node_data_iterator; - + nodes_t nodes_; - node * root_; + node * root_; const unsigned int max_depth_; - const double ratio_; + const double ratio_; public: typedef typename nodes_t::iterator iterator; typedef typename nodes_t::const_iterator const_iterator; - typedef typename boost::ptr_vector result_t; + typedef typename boost::ptr_vector result_t; typedef typename result_t::iterator query_iterator; - + result_t query_result_; - - explicit quad_tree(box2d const& ext, - unsigned int max_depth = 8, - double ratio = 0.55) + + explicit quad_tree(box2d const& ext, + unsigned int max_depth = 8, + double ratio = 0.55) : max_depth_(max_depth), ratio_(ratio) { nodes_.push_back(new node(ext)); root_ = &nodes_[0]; } - + void insert(T data, box2d const& box) { unsigned int depth=0; do_insert_data(data,box,root_,depth); } - + query_iterator query_in_box(box2d const& box) { query_result_.clear(); query_node(box,query_result_,root_); return query_result_.begin(); } - + query_iterator query_end() { return query_result_.end(); } - + const_iterator begin() const { return nodes_.begin(); } - + const_iterator end() const { return nodes_.end(); } - - void clear () + + void clear () { box2d ext = root_->extent_; nodes_.clear(); nodes_.push_back(new node(ext)); root_ = &nodes_[0]; } - + box2d const& extent() const { return root_->extent_; } - + private: - + void query_node(box2d const& box, result_t & result, node * node_) const { if (node_) @@ -173,18 +173,18 @@ private: } } } - + void do_insert_data(T data, box2d const& box, node * n, unsigned int& depth) { if (++depth >= max_depth_) { n->cont_.push_back(data); } - else + else { box2d const& node_extent = n->extent(); box2d ext[4]; - split_box(node_extent,ext); + split_box(node_extent,ext); for (int i=0;i<4;++i) { if (ext[i].contains(box)) @@ -201,25 +201,25 @@ private: n->cont_.push_back(data); } } - + void split_box(box2d const& node_extent,box2d * ext) { //coord2d c=node_extent.center(); double width=node_extent.width(); double height=node_extent.height(); - + double lox=node_extent.minx(); double loy=node_extent.miny(); double hix=node_extent.maxx(); double hiy=node_extent.maxy(); - + ext[0]=box2d(lox,loy,lox + width * ratio_,loy + height * ratio_); ext[1]=box2d(hix - width * ratio_,loy,hix,loy + height * ratio_); ext[2]=box2d(lox,hiy - height*ratio_,lox + width * ratio_,hiy); ext[3]=box2d(hix - width * ratio_,hiy - height*ratio_,hix,hiy); } -}; -} +}; +} #endif // MAPNIK_QUAD_TREE_HPP diff --git a/include/mapnik/query.hpp b/include/mapnik/query.hpp index 4b468efa4..85c11bfa9 100644 --- a/include/mapnik/query.hpp +++ b/include/mapnik/query.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -36,7 +36,7 @@ namespace mapnik { -class query +class query { public: typedef boost::tuple resolution_type; @@ -50,9 +50,9 @@ private: public: query(box2d const& bbox, - resolution_type const& resolution, - double scale_denominator, - box2d const& unbuffered_bbox) + resolution_type const& resolution, + double scale_denominator, + box2d const& unbuffered_bbox) : bbox_(bbox), resolution_(resolution), scale_denominator_(scale_denominator), @@ -61,8 +61,8 @@ public: {} query(box2d const& bbox, - resolution_type const& resolution, - double scale_denominator = 1.0) + resolution_type const& resolution, + double scale_denominator = 1.0) : bbox_(bbox), resolution_(resolution), scale_denominator_(scale_denominator), @@ -77,7 +77,7 @@ public: filter_factor_(1.0), unbuffered_bbox_(bbox) {} - + query(query const& other) : bbox_(other.bbox_), resolution_(other.resolution_), @@ -86,7 +86,7 @@ public: unbuffered_bbox_(other.unbuffered_bbox_), names_(other.names_) {} - + query& operator=(query const& other) { if (this == &other) return *this; @@ -98,12 +98,12 @@ public: unbuffered_bbox_=other.unbuffered_bbox_; return *this; } - + query::resolution_type const& resolution() const { return resolution_; } - + double scale_denominator() const { return scale_denominator_; @@ -133,17 +133,17 @@ public: { return filter_factor_; } - + void set_filter_factor(double factor) { filter_factor_ = factor; } - + void add_property_name(std::string const& name) { names_.insert(name); - } - + } + std::set const& property_names() const { return names_; diff --git a/include/mapnik/raster.hpp b/include/mapnik/raster.hpp index cd26af27a..4a0757938 100644 --- a/include/mapnik/raster.hpp +++ b/include/mapnik/raster.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/raster_colorizer.hpp b/include/mapnik/raster_colorizer.hpp index 090900dd8..74fcf4853 100644 --- a/include/mapnik/raster_colorizer.hpp +++ b/include/mapnik/raster_colorizer.hpp @@ -1,6 +1,6 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -22,16 +22,16 @@ *****************************************************************************/ /** \brief Raster Colouriser - * + * * This class allows GDAL raster bands to be colourised. It only works with single * band GDAL rasters, not greyscale, alpha, or rgb (due to the GDAL featureset loading * single channel GDAL rasters as FLOAT32, and the others as BYTE, and not having a method * of figuring out which). - * + * * Every input value is translated to an output value. The output value is determined by * what 'stop' the input value is in. Each stop covers the range of input values from its - * 'value' parameter, up to the 'value' parameter of the next stop. - * + * 'value' parameter, up to the 'value' parameter of the next stop. + * */ #ifndef MAPNIK_RASTER_COLORIZER_HPP @@ -61,55 +61,55 @@ enum colorizer_mode_enum COLORIZER_DISCRETE = 2, //!< Single color for stop COLORIZER_EXACT = 3, //!< Only the exact value specified for the stop gets translated, others use the default colorizer_mode_enum_MAX -}; +}; DEFINE_ENUM( colorizer_mode, colorizer_mode_enum ); - -//! \brief Structure to represent a stop position. + +//! \brief Structure to represent a stop position. class MAPNIK_DECL colorizer_stop { public: - + //! \brief Constructor //! //! \param[in] value The stop value //! \param[in] mode The stop mode //! \param[in] color The stop color - colorizer_stop(float value = 0, - colorizer_mode mode = COLORIZER_INHERIT, - color const& _color = color(0,0,0,0), + colorizer_stop(float value = 0, + colorizer_mode mode = COLORIZER_INHERIT, + color const& _color = color(0,0,0,0), std::string const& label=""); - + //! \brief Copy constructor colorizer_stop(colorizer_stop const& stop); - + //! \brief Destructor ~colorizer_stop(); //! \brief Set the stop value //! \param[in] value The stop value - inline void set_value(float value) { value_ = value; }; - + inline void set_value(float value) { value_ = value; }; + //! \brief Get the stop value //! \return The stop value inline float get_value() const {return value_; }; - - + + //! \brief Set the stop mode //! \param[in] mode The stop mode inline void set_mode(colorizer_mode mode) { mode_ = mode; }; inline void set_mode_enum(colorizer_mode_enum mode) { set_mode(mode); }; - + //! \brief Get the stop mode //! \return The stop mode inline colorizer_mode get_mode() const { return mode_; }; inline colorizer_mode_enum get_mode_enum() const { return get_mode(); }; - - + + //! \brief set the stop color //! \param[in] the stop color inline void set_color(color const& _color) { color_ = _color; }; - + //! \brief get the stop color //! \return The stop color inline color const& get_color() const {return color_; }; @@ -117,11 +117,11 @@ public: //! \brief set the stop label //! \param[in] the stop label inline void set_label(std::string const& label) { label_ = label; }; - + //! \brief get the stop label //! \return The stop label inline std::string const& get_label() const {return label_; }; - + //! \brief Equality operator //! \return True if equal, false otherwise @@ -130,7 +130,7 @@ public: //! \brief Print the stop to a string //! \return A string representing this stop. std::string to_string() const; - + private: float value_; //!< The stop value colorizer_mode mode_; //!< The stop mode @@ -143,12 +143,12 @@ typedef std::vector colorizer_stops; //! \brief Class representing the raster colorizer -class MAPNIK_DECL raster_colorizer +class MAPNIK_DECL raster_colorizer { public: //! \brief Constructor raster_colorizer(colorizer_mode mode = COLORIZER_LINEAR, color const& _color = color(0,0,0,0)); - + //! \brief Destructor ~raster_colorizer(); @@ -157,23 +157,23 @@ public: //! //! This can not be set as INHERIT, if you do, LINEAR will be used instead. //! \param[in] mode The default mode - - void set_default_mode(colorizer_mode mode) - { - default_mode_ = (mode == COLORIZER_INHERIT) ? COLORIZER_LINEAR:(colorizer_mode_enum)mode; + + void set_default_mode(colorizer_mode mode) + { + default_mode_ = (mode == COLORIZER_INHERIT) ? COLORIZER_LINEAR:(colorizer_mode_enum)mode; }; - + void set_default_mode_enum(colorizer_mode_enum mode) { set_default_mode(mode); }; - + //! \brief Get the default mode //! \return The default mode colorizer_mode get_default_mode() const {return default_mode_; }; colorizer_mode_enum get_default_mode_enum() const {return get_default_mode(); }; - + //! \brief Set the default color //! \param[in] color The default color void set_default_color(color const& color) { default_color_ = color; }; - + //! \brief Get the default color //! \return The default color color const& get_default_color() const {return default_color_; }; @@ -200,7 +200,7 @@ public: //! \param[in] feature used to find 'NODATA' information if available void colorize(raster_ptr const& raster, Feature const& f) const; - + //! \brief Perform the translation of input to output //! //! \param[in] value Input value @@ -211,14 +211,14 @@ public: //! \brief Set the epsilon value for exact mode //! \param[in] e The epsilon value inline void set_epsilon(const float e) { if(e > 0) epsilon_ = e; }; - + //! \brief Get the epsilon value for exact mode //! \return The epsilon value inline float get_epsilon() const { return epsilon_; }; private: colorizer_stops stops_; //!< The vector of stops - + colorizer_mode default_mode_; //!< The default mode inherited by stops color default_color_; //!< The default color float epsilon_; //!< The epsilon value for exact mode diff --git a/include/mapnik/raster_symbolizer.hpp b/include/mapnik/raster_symbolizer.hpp index 76366b4a8..6c22ea3aa 100644 --- a/include/mapnik/raster_symbolizer.hpp +++ b/include/mapnik/raster_symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -31,9 +31,9 @@ namespace mapnik { -struct MAPNIK_DECL raster_symbolizer : public symbolizer_base +struct MAPNIK_DECL raster_symbolizer : public symbolizer_base { - + raster_symbolizer() : symbolizer_base(), mode_("normal"), @@ -51,7 +51,7 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base colorizer_(rhs.colorizer_), filter_factor_(rhs.filter_factor_), mesh_size_(rhs.mesh_size_) {} - + std::string const& get_mode() const { return mode_; @@ -102,38 +102,38 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base // No filter factor specified, calculate a sensible default value // based on the scaling algorithm being employed. scaling_method_e scaling = get_scaling_method_by_name (scaling_); - + double ff = 1.0; - + switch(scaling) { - case SCALING_NEAR: - ff = 1.0; - break; - + case SCALING_NEAR: + ff = 1.0; + break; + // TODO potentially some of these algorithms would use filter_factor >2.0. // Contributions welcome from someone who knows more about them. - case SCALING_BILINEAR: - case SCALING_BICUBIC: - case SCALING_SPLINE16: - case SCALING_SPLINE36: - case SCALING_HANNING: - case SCALING_HAMMING: - case SCALING_HERMITE: - case SCALING_KAISER: - case SCALING_QUADRIC: - case SCALING_CATROM: - case SCALING_GAUSSIAN: - case SCALING_BESSEL: - case SCALING_MITCHELL: - case SCALING_SINC: - case SCALING_LANCZOS: - case SCALING_BLACKMAN: - ff = 2.0; - break; - default: - ff = 1.0; - break; + case SCALING_BILINEAR: + case SCALING_BICUBIC: + case SCALING_SPLINE16: + case SCALING_SPLINE36: + case SCALING_HANNING: + case SCALING_HAMMING: + case SCALING_HERMITE: + case SCALING_KAISER: + case SCALING_QUADRIC: + case SCALING_CATROM: + case SCALING_GAUSSIAN: + case SCALING_BESSEL: + case SCALING_MITCHELL: + case SCALING_SINC: + case SCALING_LANCZOS: + case SCALING_BLACKMAN: + ff = 2.0; + break; + default: + ff = 1.0; + break; } return ff; } @@ -146,8 +146,8 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base { mesh_size_=mesh_size; } - - + + private: std::string mode_; std::string scaling_; diff --git a/include/mapnik/rule.hpp b/include/mapnik/rule.hpp index 9895578c3..42c2a3571 100644 --- a/include/mapnik/rule.hpp +++ b/include/mapnik/rule.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -53,59 +53,59 @@ namespace mapnik inline bool operator==(point_symbolizer const& lhs, point_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } inline bool operator==(line_symbolizer const& lhs, line_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } inline bool operator==(line_pattern_symbolizer const& lhs, line_pattern_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } inline bool operator==(polygon_symbolizer const& lhs, polygon_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } - + inline bool operator==(polygon_pattern_symbolizer const& lhs, polygon_pattern_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } - + inline bool operator==(raster_symbolizer const& lhs, raster_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } - + inline bool operator==(text_symbolizer const& lhs, text_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } - + inline bool operator==(shield_symbolizer const& lhs, shield_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } - + inline bool operator==(building_symbolizer const& lhs, building_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } - + inline bool operator==(markers_symbolizer const& lhs, markers_symbolizer const& rhs) { - return (&lhs == &rhs); + return (&lhs == &rhs); } typedef boost::variant symbolizer; - - + + class rule -{ +{ public: typedef std::vector symbolizers; private: - + std::string name_; double min_scale_; double max_scale_; @@ -138,7 +138,7 @@ private: struct deepcopy_symbolizer : public boost::static_visitor<> { - + void operator () (markers_symbolizer & sym) const { copy_path_ptr(sym); @@ -153,20 +153,20 @@ private: { copy_path_ptr(sym); } - + void operator () (line_pattern_symbolizer & sym) const { copy_path_ptr(sym); } - + void operator () (raster_symbolizer & sym) const { raster_colorizer_ptr old_colorizer = sym.get_colorizer(); - raster_colorizer_ptr new_colorizer = raster_colorizer_ptr(); + raster_colorizer_ptr new_colorizer = raster_colorizer_ptr(); new_colorizer->set_stops(old_colorizer->get_stops()); new_colorizer->set_default_mode(old_colorizer->get_default_mode()); new_colorizer->set_default_color(old_colorizer->get_default_color()); - new_colorizer->set_epsilon(old_colorizer->get_epsilon()); + new_colorizer->set_epsilon(old_colorizer->get_epsilon()); sym.set_colorizer(new_colorizer); } @@ -174,7 +174,7 @@ private: { copy_text_ptr(sym); } - + void operator () (shield_symbolizer & sym) const { copy_path_ptr(sym); @@ -185,13 +185,13 @@ private: { copy_height_ptr(sym); } - - + + template void operator () (T &sym) const { boost::ignore_unused_variable_warning(sym); } - + private: template void copy_path_ptr(T & sym) const @@ -199,25 +199,25 @@ private: std::string path = path_processor_type::to_string(*sym.get_filename()); sym.set_filename( parse_path(path) ); } - + template void copy_text_ptr(T & sym) const { std::string name = to_expression_string(*sym.get_name()); sym.set_name( parse_expression(name) ); - + // FIXME - orientation doesn't appear to be initialized in constructor? //std::string orientation = to_expression_string(*sym->get_orientation()); //sym->set_orientation( parse_expression(orientation) ); - + float text_size = sym.get_text_size(); position displace = sym.get_displacement(); vertical_alignment_e valign = sym.get_vertical_alignment(); horizontal_alignment_e halign = sym.get_horizontal_alignment(); justify_alignment_e jalign = sym.get_justify_alignment(); - + text_placements_ptr placements = text_placements_ptr(boost::make_shared()); - sym.set_placement_options( placements ); + sym.set_placement_options( placements ); sym.set_text_size(text_size); sym.set_displacement(displace); sym.set_vertical_alignment(valign); @@ -232,7 +232,7 @@ private: sym.set_height(parse_expression(height_expr,"utf8")); } }; - + public: rule() : name_(), @@ -240,9 +240,9 @@ public: max_scale_(std::numeric_limits::infinity()), syms_(), filter_(boost::make_shared(true)), - else_filter_(false), + else_filter_(false), also_filter_(false) {} - + rule(const std::string& name, double min_scale_denominator=0, double max_scale_denominator=std::numeric_limits::infinity()) @@ -251,35 +251,35 @@ public: max_scale_(max_scale_denominator), syms_(), filter_(boost::make_shared(true)), - else_filter_(false), + else_filter_(false), also_filter_(false) {} - + rule(const rule& rhs, bool deep_copy = false) : name_(rhs.name_), min_scale_(rhs.min_scale_), max_scale_(rhs.max_scale_), syms_(rhs.syms_), filter_(rhs.filter_), - else_filter_(rhs.else_filter_), - also_filter_(rhs.also_filter_) + else_filter_(rhs.else_filter_), + also_filter_(rhs.also_filter_) { if (deep_copy) { - + std::string expr = to_expression_string(*filter_); filter_ = parse_expression(expr,"utf8"); symbolizers::const_iterator it = syms_.begin(); symbolizers::const_iterator end = syms_.end(); - + // FIXME - metawriter_ptr? - - for(; it != end; ++it) - { - boost::apply_visitor(deepcopy_symbolizer(),*it); + + for(; it != end; ++it) + { + boost::apply_visitor(deepcopy_symbolizer(),*it); } } } - - rule& operator=(rule const& rhs) + + rule& operator=(rule const& rhs) { rule tmp(rhs); swap(tmp); @@ -287,44 +287,44 @@ public: } bool operator==(rule const& other) { - return (this == &other); + return (this == &other); } - + void set_max_scale(double scale) { max_scale_=scale; } - + double get_max_scale() const { return max_scale_; } - + void set_min_scale(double scale) { min_scale_=scale; } - + double get_min_scale() const { return min_scale_; } - + void set_name(std::string const& name) { name_=name; } - + std::string const& get_name() const { return name_; } - + void append(const symbolizer& sym) { syms_.push_back(sym); } - + void remove_at(size_t index) { if (index < syms_.size()) @@ -332,69 +332,69 @@ public: syms_.erase(syms_.begin()+index); } } - + const symbolizers& get_symbolizers() const { return syms_; } - + symbolizers::const_iterator begin() const { return syms_.begin(); } - + symbolizers::const_iterator end() const { return syms_.end(); } - + symbolizers::iterator begin() { return syms_.begin(); } - + symbolizers::iterator end() { return syms_.end(); } - + void set_filter(const expression_ptr& filter) { filter_=filter; } - + expression_ptr const& get_filter() const { return filter_; } - + void set_else(bool else_filter) { else_filter_=else_filter; } - + bool has_else_filter() const { return else_filter_; } - + void set_also(bool also_filter) { also_filter_=also_filter; } - + bool has_also_filter() const { return also_filter_; } - + bool active(double scale) const { return ( scale >= min_scale_ - 1e-6 && scale < max_scale_ + 1e-6); } - + private: - + void swap(rule& rhs) throw() { name_=rhs.name_; @@ -404,7 +404,7 @@ private: filter_=rhs.filter_; else_filter_=rhs.else_filter_; also_filter_=rhs.also_filter_; - } + } }; } diff --git a/include/mapnik/save_map.hpp b/include/mapnik/save_map.hpp index 65ca13dac..ed950efc5 100644 --- a/include/mapnik/save_map.hpp +++ b/include/mapnik/save_map.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/scale_denominator.hpp b/include/mapnik/scale_denominator.hpp index c42b15788..85c313b5f 100644 --- a/include/mapnik/scale_denominator.hpp +++ b/include/mapnik/scale_denominator.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -27,7 +27,7 @@ #include namespace mapnik { - + class Map; MAPNIK_DECL double scale_denominator(Map const& map, bool geographic); } diff --git a/include/mapnik/segment.hpp b/include/mapnik/segment.hpp index 12fa2a74b..754c61d5b 100644 --- a/include/mapnik/segment.hpp +++ b/include/mapnik/segment.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/shield_symbolizer.hpp b/include/mapnik/shield_symbolizer.hpp index 06b12fb2e..44600a082 100644 --- a/include/mapnik/shield_symbolizer.hpp +++ b/include/mapnik/shield_symbolizer.hpp @@ -47,12 +47,12 @@ struct MAPNIK_DECL shield_symbolizer : public text_symbolizer, float size, color const& fill, path_expression_ptr file); - + bool get_unlock_image() const; // image is not locked to the text placement void set_unlock_image(bool unlock_image); void set_shield_displacement(double shield_dx,double shield_dy); position const& get_shield_displacement() const; - + private: bool unlock_image_; position shield_displacement_; diff --git a/include/mapnik/sql_utils.hpp b/include/mapnik/sql_utils.hpp index ee6805cb7..d4a3b05ec 100644 --- a/include/mapnik/sql_utils.hpp +++ b/include/mapnik/sql_utils.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -29,167 +29,167 @@ namespace mapnik { namespace sql_utils { -inline std::string unquote_double(const std::string& sql) -{ - std::string table_name = boost::algorithm::to_lower_copy(sql); - boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\"")); - return table_name; -} - -inline std::string unquote(const std::string& sql) -{ - std::string table_name = boost::algorithm::to_lower_copy(sql); - boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\"\'")); - return table_name; -} - -inline void quote_attr(std::ostringstream& s, const std::string& field) -{ - if (boost::algorithm::icontains(field,".")) { - std::vector 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 parts; + boost::split(parts, field, boost::is_any_of(".")); + s << ",\"" << parts[0] << "\".\"" << parts[1] << "\""; } - idx = table_name.find_first_of(" )"); - if (idx != std::string::npos) + else { - table_name = table_name.substr(0,idx); + s << ",\"" + field + "\""; } } - return table_name; -} -inline std::string numeric2string(const char* buf) -{ - int16_t ndigits = int2net(buf); - int16_t weight = int2net(buf+2); - int16_t sign = int2net(buf+4); - int16_t dscale = int2net(buf+6); - - boost::scoped_array digits(new int16_t[ndigits]); - for (int n=0; n < ndigits ;++n) - { - digits[n] = int2net(buf+8+n*2); - } - - std::ostringstream ss; - - if (sign == 0x4000) ss << "-"; - - int i = std::max(weight,int16_t(0)); - int d = 0; + inline std::string table_from_sql(const std::string& sql) + { + std::string table_name = boost::algorithm::to_lower_copy(sql); + boost::algorithm::replace_all(table_name,"\n"," "); - // Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field. - // For example, the number 1234567809990001 is stored as four digits: [1234] [5678] [999] [1]. - // Note that the last two digits show that the leading 0's are lost when the number is split. - // We must be careful to re-insert these 0's when building the string. + std::string::size_type idx = table_name.rfind(" from "); + if (idx!=std::string::npos) + { + idx = table_name.find_first_not_of(" ",idx+5); + if (idx != std::string::npos) + { + table_name=table_name.substr(idx); + } + idx = table_name.find_first_of(" )"); + if (idx != std::string::npos) + { + table_name = table_name.substr(0,idx); + } + } + return table_name; + } - while ( i >= 0) - { - if (i <= weight && d < ndigits) - { - // All digits after the first must be padded to make the field 4 characters long - if (d != 0) - { + inline std::string numeric2string(const char* buf) + { + int16_t ndigits = int2net(buf); + int16_t weight = int2net(buf+2); + int16_t sign = int2net(buf+4); + int16_t dscale = int2net(buf+6); + + boost::scoped_array digits(new int16_t[ndigits]); + for (int n=0; n < ndigits ;++n) + { + digits[n] = int2net(buf+8+n*2); + } + + std::ostringstream ss; + + if (sign == 0x4000) ss << "-"; + + int i = std::max(weight,int16_t(0)); + int d = 0; + + // Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field. + // For example, the number 1234567809990001 is stored as four digits: [1234] [5678] [999] [1]. + // Note that the last two digits show that the leading 0's are lost when the number is split. + // We must be careful to re-insert these 0's when building the string. + + while ( i >= 0) + { + if (i <= weight && d < ndigits) + { + // All digits after the first must be padded to make the field 4 characters long + if (d != 0) + { #ifdef _WINDOWS - int dig = digits[d]; - if (dig < 10) - { - ss << "000"; // 0000 - 0009 - } - else if (dig < 100) - { - ss << "00"; // 0010 - 0099 - } - else - { - ss << "0"; // 0100 - 0999; - } + int dig = digits[d]; + if (dig < 10) + { + ss << "000"; // 0000 - 0009 + } + else if (dig < 100) + { + ss << "00"; // 0010 - 0099 + } + else + { + ss << "0"; // 0100 - 0999; + } #else - switch(digits[d]) - { - case 0 ... 9: - ss << "000"; // 0000 - 0009 - break; - case 10 ... 99: - ss << "00"; // 0010 - 0099 - break; - case 100 ... 999: - ss << "0"; // 0100 - 0999 - break; - } + switch(digits[d]) + { + case 0 ... 9: + ss << "000"; // 0000 - 0009 + break; + case 10 ... 99: + ss << "00"; // 0010 - 0099 + break; + case 100 ... 999: + ss << "0"; // 0100 - 0999 + break; + } #endif - } - ss << digits[d++]; - } - else - { - if (d == 0) - ss << "0"; - else - ss << "0000"; - } - - i--; - } - if (dscale > 0) - { - ss << '.'; - // dscale counts the number of decimal digits following the point, not the numeric digits - while (dscale > 0) - { - int value; - if (i <= weight && d < ndigits) - value = digits[d++]; - else - value = 0; + } + ss << digits[d++]; + } + else + { + if (d == 0) + ss << "0"; + else + ss << "0000"; + } - // Output up to 4 decimal digits for this value - if (dscale > 0) { - ss << (value / 1000); - value %= 1000; - dscale--; - } - if (dscale > 0) { - ss << (value / 100); - value %= 100; - dscale--; - } - if (dscale > 0) { - ss << (value / 10); - value %= 10; - dscale--; - } - if (dscale > 0) { - ss << value; - dscale--; - } + i--; + } + if (dscale > 0) + { + ss << '.'; + // dscale counts the number of decimal digits following the point, not the numeric digits + while (dscale > 0) + { + int value; + if (i <= weight && d < ndigits) + value = digits[d++]; + else + value = 0; - i--; - } - } - return ss.str(); -} -} + // Output up to 4 decimal digits for this value + if (dscale > 0) { + ss << (value / 1000); + value %= 1000; + dscale--; + } + if (dscale > 0) { + ss << (value / 100); + value %= 100; + dscale--; + } + if (dscale > 0) { + ss << (value / 10); + value %= 10; + dscale--; + } + if (dscale > 0) { + ss << value; + dscale--; + } + + i--; + } + } + return ss.str(); + } + } } diff --git a/include/mapnik/stroke.hpp b/include/mapnik/stroke.hpp index 9d1b77492..11d38a9f2 100644 --- a/include/mapnik/stroke.hpp +++ b/include/mapnik/stroke.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,13 +30,13 @@ // stl #include - + namespace mapnik { using std::pair; using std::vector; typedef vector > dash_array; - + // if you add new tokens, don't forget to add them to the corresponding // string array in the cpp file. enum line_cap_enum @@ -45,10 +45,10 @@ enum line_cap_enum SQUARE_CAP, ROUND_CAP, line_cap_enum_MAX -}; +}; DEFINE_ENUM( line_cap_e, line_cap_enum ); - + // if you add new tokens, don't forget to add them to the corresponding // string array in the cpp file. enum line_join_enum @@ -81,16 +81,16 @@ public: void set_color(const color& c); color const& get_color() const; - + double get_width() const; void set_width(double w); void set_opacity(double opacity); double get_opacity() const; - + void set_line_cap(line_cap_e line_cap); line_cap_e get_line_cap() const; - + void set_line_join(line_join_e line_join); line_join_e get_line_join() const; diff --git a/include/mapnik/style_factory.hpp b/include/mapnik/style_factory.hpp index fb0982f40..952afe2e1 100644 --- a/include/mapnik/style_factory.hpp +++ b/include/mapnik/style_factory.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -26,8 +26,8 @@ //#include namespace mapnik { - -class style_factory + +class style_factory { }; } diff --git a/include/mapnik/svg/svg_converter.hpp b/include/mapnik/svg/svg_converter.hpp index 74689971c..61da1cc57 100644 --- a/include/mapnik/svg/svg_converter.hpp +++ b/include/mapnik/svg/svg_converter.hpp @@ -49,21 +49,21 @@ template class svg_converter : boost::noncopyable { public: - + svg_converter(VertexSource & source, AttributeSource & attributes) : source_(source), attributes_(attributes) {} - + void begin_path() { push_attr(); unsigned idx = source_.start_new_path(); attributes_.add(path_attributes(cur_attr(), idx)); } - + void end_path() { - if(attributes_.size() == 0) + if(attributes_.size() == 0) { throw std::runtime_error("end_path : The path was not begun"); } @@ -71,21 +71,21 @@ public: unsigned idx = attributes_[attributes_.size() - 1].index; attr.index = idx; attributes_[attributes_.size() - 1] = attr; - pop_attr(); + pop_attr(); } - + void move_to(double x, double y, bool rel=false) // M, m { if(rel) source_.rel_to_abs(&x, &y); source_.move_to(x, y); } - + void line_to(double x, double y, bool rel=false) // L, l { if(rel) source_.rel_to_abs(&x, &y); - source_.line_to(x, y); + source_.line_to(x, y); } - + void hline_to(double x, bool rel=false) // H, h { double x2 = 0.0; @@ -95,9 +95,9 @@ public: source_.vertex(source_.total_vertices() - 1, &x2, &y2); if(rel) x += x2; source_.line_to(x, y2); - } + } } - + void vline_to(double y, bool rel=false) // V, v { double x2 = 0.0; @@ -110,32 +110,32 @@ public: } } void curve3(double x1, double y1, // Q, q - double x, double y, bool rel=false) + double x, double y, bool rel=false) { - if(rel) + if(rel) { source_.rel_to_abs(&x1, &y1); source_.rel_to_abs(&x, &y); } source_.curve3(x1, y1, x, y); } - + void curve3(double x, double y, bool rel=false) // T, t { - if(rel) + if(rel) { source_.curve3_rel(x, y); - } else + } else { source_.curve3(x, y); } } - + void curve4(double x1, double y1, // C, c - double x2, double y2, - double x, double y, bool rel=false) + double x2, double y2, + double x, double y, bool rel=false) { - if(rel) + if(rel) { source_.rel_to_abs(&x1, &y1); source_.rel_to_abs(&x2, &y2); @@ -143,45 +143,45 @@ public: } source_.curve4(x1, y1, x2, y2, x, y); } - + void curve4(double x2, double y2, // S, s - double x, double y, bool rel=false) + double x, double y, bool rel=false) { - if(rel) + if(rel) { source_.curve4_rel(x2, y2, x, y); - } else + } else { source_.curve4(x2, y2, x, y); } } - + void arc_to(double rx, double ry, // A, a - double angle, + double angle, bool large_arc_flag, bool sweep_flag, - double x, double y,bool rel=false) + double x, double y,bool rel=false) { - - if(rel) + + if(rel) { source_.arc_rel(rx, ry, angle, large_arc_flag, sweep_flag, x, y); } - else + else { source_.arc_to(rx, ry, angle, large_arc_flag, sweep_flag, x, y); - + } } - + void close_subpath() // Z, z { source_.end_poly(agg::path_flags_close); } - + void push_attr() { - attr_stack_.add(attr_stack_.size() ? + attr_stack_.add(attr_stack_.size() ? attr_stack_[attr_stack_.size() - 1] : path_attributes()); } @@ -193,14 +193,14 @@ public: } attr_stack_.remove_last(); } - + // Attribute setting functions. void fill(const agg::rgba8& f) { path_attributes& attr = cur_attr(); double a = attr.fill_color.opacity(); attr.fill_color = f; - attr.fill_color.opacity(a * f.opacity()); + attr.fill_color.opacity(a * f.opacity()); attr.fill_flag = true; } @@ -224,7 +224,7 @@ public: attr.stroke_color.opacity(a * s.opacity()); attr.stroke_flag = true; } - + void even_odd(bool flag) { cur_attr().even_odd_flag = flag; @@ -235,7 +235,7 @@ public: cur_attr().visibility_flag = flag; } - + void stroke_width(double w) { cur_attr().stroke_width = w; @@ -244,12 +244,12 @@ public: { cur_attr().fill_flag = false; } - + void stroke_none() { cur_attr().stroke_flag = false; } - + void fill_opacity(double op) { cur_attr().fill_color.opacity(op); @@ -263,12 +263,12 @@ public: { cur_attr().opacity = op; } - + void line_join(agg::line_join_e join) { cur_attr().line_join = join; } - + void line_cap(agg::line_cap_e cap) { cur_attr().line_cap = cap; @@ -277,37 +277,37 @@ public: { cur_attr().miter_limit = ml; } - + // Make all polygons CCW-oriented void arrange_orientations() { source_.arrange_orientations_all_paths(agg::path_flags_ccw); } - + // FIXME!!!! unsigned operator [](unsigned idx) { transform_ = attributes_[idx].transform; return attributes_[idx].index; } - + void bounding_rect(double* x1, double* y1, double* x2, double* y2) { agg::conv_transform trans(source_, transform_); agg::bounding_rect(trans, *this, 0, attributes_.size(), x1, y1, x2, y2); } - - VertexSource & storage() + + VertexSource & storage() { return source_; } - + agg::trans_affine& transform() { return cur_attr().transform; } - path_attributes& cur_attr() + path_attributes& cur_attr() { if(attr_stack_.size() == 0) { @@ -315,9 +315,9 @@ public: } return attr_stack_[attr_stack_.size() - 1]; } - -private: - + +private: + VertexSource & source_; AttributeSource & attributes_; AttributeSource attr_stack_; diff --git a/include/mapnik/svg/svg_generator.hpp b/include/mapnik/svg/svg_generator.hpp index c7bf407c0..73cce0199 100644 --- a/include/mapnik/svg/svg_generator.hpp +++ b/include/mapnik/svg/svg_generator.hpp @@ -45,7 +45,7 @@ namespace mapnik { namespace svg { class svg_generator : private boost::noncopyable { typedef coord_transform2 path_type; - + typedef svg::svg_root_attributes_grammar root_attributes_grammar; typedef svg::svg_rect_attributes_grammar rect_attributes_grammar; typedef svg::svg_path_data_grammar path_data_grammar; @@ -55,16 +55,16 @@ namespace mapnik { namespace svg { public: explicit svg_generator(OutputIterator& output_iterator); ~svg_generator(); - + void generate_header(); void generate_opening_root(root_output_attributes const& root_attributes); void generate_closing_root(); void generate_rect(rect_output_attributes const& rect_attributes); void generate_path(path_type const& path, path_output_attributes const& path_attributes); - + private: OutputIterator& output_iterator_; }; -}} + }} #endif // MAPNIK_SVG_GENERATOR_HPP diff --git a/include/mapnik/svg/svg_output_attributes.hpp b/include/mapnik/svg/svg_output_attributes.hpp index af6e6b031..7c899b3e4 100644 --- a/include/mapnik/svg/svg_output_attributes.hpp +++ b/include/mapnik/svg/svg_output_attributes.hpp @@ -48,18 +48,18 @@ namespace mapnik { namespace svg { */ struct path_output_attributes { - path_output_attributes() + path_output_attributes() : fill_color_("none"), fill_opacity_(1.0), stroke_color_("none"), stroke_opacity_(1.0), - stroke_width_(0.0), + stroke_width_(0.0), stroke_linecap_("butt"), 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); void set_stroke_color(color const& stroke_color); @@ -69,7 +69,7 @@ namespace mapnik { namespace svg { void set_stroke_linejoin(const line_join_e stroke_linejoin); void set_stroke_dasharray(const dash_array stroke_dasharray); void set_stroke_dashoffset(const double stroke_dashoffset); - + const std::string fill_color() const; const double fill_opacity() const; const std::string stroke_color() const; @@ -79,26 +79,26 @@ namespace mapnik { namespace svg { const std::string stroke_linejoin() const; const dash_array stroke_dasharray() const; const double stroke_dashoffset() const; - + /*! * @brief Set members back to their default values. */ void reset(); - - //private: + + //private: // polygon symbolizer attributes. std::string fill_color_; double fill_opacity_; - + // line symbolizer attributes. std::string stroke_color_; double stroke_opacity_; double stroke_width_; std::string stroke_linecap_; - std::string stroke_linejoin_; + std::string stroke_linejoin_; dash_array stroke_dasharray_; double stroke_dashoffset_; - }; + }; /*! * @brief SVG rect tag attributes. @@ -121,7 +121,7 @@ namespace mapnik { namespace svg { height_(400), fill_color_("#000000") {} - + rect_output_attributes(const int x, const int y, const unsigned width, const unsigned height, color const& fill_color) : x_(x), y_(y), @@ -129,25 +129,25 @@ namespace mapnik { namespace svg { height_(height), fill_color_(fill_color.to_hex_string()) {} - + void set_x(const int x); void set_y(const int y); void set_width(const unsigned width); void set_height(const unsigned height); void set_fill_color(color const& fill_color); - + const int x() const; const int y() const; const int width() const; const int height() const; const std::string fill_color() const; - + /*! * @brief Set members back to their default values. */ 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(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); - - 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(); - - // 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_; + root_output_attributes(); + + 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); + + 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(); + + // 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_; }; -}} + }} #endif // MAPNIK_SVG_OUTPUT_ATTRIBUTES diff --git a/include/mapnik/svg/svg_output_grammars.hpp b/include/mapnik/svg/svg_output_grammars.hpp index 5ea5b0626..016d8edd0 100644 --- a/include/mapnik/svg/svg_output_grammars.hpp +++ b/include/mapnik/svg/svg_output_grammars.hpp @@ -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 path_type; + typedef mapnik::coord_transform2 path_type; - template <> - struct is_container - : mpl::true_ {}; + template <> + struct is_container + : mpl::true_ {}; - template <> - struct container_iterator - { - typedef mapnik::svg::path_iterator_type type; - }; - - template <> - struct begin_container - { - static mapnik::svg::path_iterator_type - call(path_type const& path) + template <> + struct container_iterator { - return mapnik::svg::path_iterator_type(0, path); - } - }; + typedef mapnik::svg::path_iterator_type type; + }; - template <> - struct end_container - { - static mapnik::svg::path_iterator_type - call(path_type const& path) + template <> + struct begin_container { - 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 + { + static mapnik::svg::path_iterator_type + call(path_type const& path) + { + return mapnik::svg::path_iterator_type(path); + } + }; + }}} namespace mapnik { namespace svg { @@ -138,117 +138,117 @@ 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; - - svg_path = - lit("d=") - << confix('"', '"')[ - -(path_vertex % lit(' '))]; - - path_vertex = - path_vertex_command - << double_ - << lit(' ') - << double_; - - path_vertex_command = &int_(1) << lit('M') | lit('L'); + using karma::int_; + using karma::double_; + using repository::confix; + + svg_path = + lit("d=") + << confix('"', '"')[ + -(path_vertex % lit(' '))]; + + path_vertex = + path_vertex_command + << double_ + << lit(' ') + << double_; + + path_vertex_command = &int_(1) << lit('M') | lit('L'); } - + karma::rule svg_path; karma::rule path_vertex; karma::rule path_vertex_command; - + PathType const& path_type_; }; - template - struct svg_path_attributes_grammar : karma::grammar +template +struct svg_path_attributes_grammar : karma::grammar +{ + 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; - - 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 svg_path_attributes; - }; + using karma::double_; + using karma::string; + using repository::confix; - template - struct svg_path_dash_array_grammar : karma::grammar - { - explicit svg_path_dash_array_grammar() - : svg_path_dash_array_grammar::base_type(svg_path_dash_array) - { - using karma::double_; - using repository::confix; - - svg_path_dash_array = - lit("stroke-dasharray=") - << confix('"', '"')[ - -((double_ << lit(',') << double_) % lit(','))]; - } - - karma::rule svg_path_dash_array; - }; + 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")]; + } - template - struct svg_rect_attributes_grammar : karma::grammar - { - explicit svg_rect_attributes_grammar() - : svg_rect_attributes_grammar::base_type(svg_rect_attributes) - { - 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]; - } - - karma::rule svg_rect_attributes; - }; + karma::rule svg_path_attributes; +}; - template - struct svg_root_attributes_grammar : karma::grammar +template +struct svg_path_dash_array_grammar : karma::grammar +{ + explicit svg_path_dash_array_grammar() + : svg_path_dash_array_grammar::base_type(svg_path_dash_array) { - 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; - - svg_root_attributes = - lit("width=") << confix('"', '"')[int_ << lit("px")] - << lit(" height=") << confix('"', '"')[int_ << lit("px")] - << " version=" << confix('"', '"')[double_] - << " xmlns=" << confix('"', '"')[string]; - } - - karma::rule svg_root_attributes; - }; + using karma::double_; + using repository::confix; + + svg_path_dash_array = + lit("stroke-dasharray=") + << confix('"', '"')[ + -((double_ << lit(',') << double_) % lit(','))]; + } + + karma::rule svg_path_dash_array; +}; + +template +struct svg_rect_attributes_grammar : karma::grammar +{ + explicit svg_rect_attributes_grammar() + : svg_rect_attributes_grammar::base_type(svg_rect_attributes) + { + 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]; + } + + karma::rule svg_rect_attributes; +}; + +template +struct svg_root_attributes_grammar : karma::grammar +{ + 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; + + svg_root_attributes = + lit("width=") << confix('"', '"')[int_ << lit("px")] + << lit(" height=") << confix('"', '"')[int_ << lit("px")] + << " version=" << confix('"', '"')[double_] + << " xmlns=" << confix('"', '"')[string]; + } + + karma::rule svg_root_attributes; +}; } } diff --git a/include/mapnik/svg/svg_parser.hpp b/include/mapnik/svg/svg_parser.hpp index 468fc1e94..726b2fd4b 100644 --- a/include/mapnik/svg/svg_parser.hpp +++ b/include/mapnik/svg/svg_parser.hpp @@ -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 gradient_map_; - std::pair temporary_gradient_; -}; -}} + private: + svg_converter_type & path_; + bool is_defs_; + std::map gradient_map_; + std::pair temporary_gradient_; + }; + + }} #endif // MAPNIK_SVG_PARSER_HPP diff --git a/include/mapnik/svg/svg_path_adapter.hpp b/include/mapnik/svg/svg_path_adapter.hpp index 86e6f728f..8dfc6fe7c 100644 --- a/include/mapnik/svg/svg_path_adapter.hpp +++ b/include/mapnik/svg/svg_path_adapter.hpp @@ -35,7 +35,7 @@ #include #include -namespace mapnik { +namespace mapnik { namespace svg { using namespace agg; @@ -45,62 +45,62 @@ template class path_adapter : boost::noncopyable public: typedef VertexContainer container_type; typedef path_adapter self_type; - + //-------------------------------------------------------------------- path_adapter(VertexContainer & vertices) : m_vertices(vertices), m_iterator(0) {} //void remove_all() { m_vertices.remove_all(); m_iterator = 0; } //void free_all() { m_vertices.free_all(); m_iterator = 0; } - + // Make path functions //-------------------------------------------------------------------- unsigned start_new_path(); - + void move_to(double x, double y); void move_rel(double dx, double dy); - + void line_to(double x, double y); void line_rel(double dx, double dy); - + void hline_to(double x); void hline_rel(double dx); - + void vline_to(double y); void vline_rel(double dy); - + void arc_to(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x, double y); - + void arc_rel(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double dx, double dy); - - void curve3(double x_ctrl, double y_ctrl, + + void curve3(double x_ctrl, double y_ctrl, double x_to, double y_to); - - void curve3_rel(double dx_ctrl, double dy_ctrl, + + void curve3_rel(double dx_ctrl, double dy_ctrl, double dx_to, double dy_to); - + void curve3(double x_to, double y_to); - + void curve3_rel(double dx_to, double dy_to); - - void curve4(double x_ctrl1, double y_ctrl1, - double x_ctrl2, double y_ctrl2, + + void curve4(double x_ctrl1, double y_ctrl1, + double x_ctrl2, double y_ctrl2, double x_to, double y_to); - void curve4_rel(double dx_ctrl1, double dy_ctrl1, - double dx_ctrl2, double dy_ctrl2, + void curve4_rel(double dx_ctrl1, double dy_ctrl1, + double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to); - void curve4(double x_ctrl2, double y_ctrl2, + void curve4(double x_ctrl2, double y_ctrl2, double x_to, double y_to); - void curve4_rel(double x_ctrl2, double y_ctrl2, + void curve4_rel(double x_ctrl2, double y_ctrl2, double x_to, double y_to); @@ -109,8 +109,8 @@ public: // Accessors //-------------------------------------------------------------------- - const container_type& vertices() const { return m_vertices; } - container_type& vertices() { return m_vertices; } + const container_type& vertices() const { return m_vertices; } + container_type& vertices() { return m_vertices; } unsigned total_vertices() const; @@ -134,9 +134,9 @@ public: void rewind(unsigned path_id); unsigned vertex(double* x, double* y); - // Arrange the orientation of a polygon, all polygons in a path, - // or in all paths. After calling arrange_orientations() or - // arrange_orientations_all_paths(), all the polygons will have + // Arrange the orientation of a polygon, all polygons in a path, + // or in all paths. After calling arrange_orientations() or + // arrange_orientations_all_paths(), all the polygons will have // the same orientation, i.e. path_flags_cw or path_flags_ccw //-------------------------------------------------------------------- unsigned arrange_polygon_orientation(unsigned start, path_flags_e orientation); @@ -144,7 +144,7 @@ public: void arrange_orientations_all_paths(path_flags_e orientation); void invert_polygon(unsigned start); - // Flip all vertices horizontally or vertically, + // Flip all vertices horizontally or vertically, // between x1 and x2, or between y1 and y2 respectively //-------------------------------------------------------------------- void flip_x(double x1, double x2); @@ -152,7 +152,7 @@ public: // Concatenate path. The path is added as is. //-------------------------------------------------------------------- - template + template void concat_path(VertexSource& vs, unsigned path_id = 0) { double x(0), y(0); @@ -165,9 +165,9 @@ public: } //-------------------------------------------------------------------- - // Join path. The path is joined with the existing one, that is, + // Join path. The path is joined with the existing one, that is, // it behaves as if the pen of a plotter was always down (drawing) - template + template void join_path(VertexSource& vs, unsigned path_id = 0) { double x, y; @@ -203,13 +203,13 @@ public: } while(!is_stop(cmd = vs.vertex(&x, &y))) { - m_vertices.add_vertex(x, y, is_move_to(cmd) ? - unsigned(path_cmd_line_to) : + m_vertices.add_vertex(x, y, is_move_to(cmd) ? + unsigned(path_cmd_line_to) : cmd); } } } - + //-------------------------------------------------------------------- void translate(double dx, double dy, unsigned path_id=0); void translate_all_paths(double dx, double dy); @@ -260,7 +260,7 @@ private: }; //------------------------------------------------------------------------ -template +template unsigned path_adapter::start_new_path() { if(!is_stop(m_vertices.last_command())) @@ -272,7 +272,7 @@ unsigned path_adapter::start_new_path() //------------------------------------------------------------------------ -template +template inline void path_adapter::rel_to_abs(double* x, double* y) const { if(m_vertices.total_vertices()) @@ -284,7 +284,7 @@ inline void path_adapter::rel_to_abs(double* x, double* y) const *x += x2; *y += y2; } - else if (!is_stop(m_vertices.last_command()) && + else if (!is_stop(m_vertices.last_command()) && is_vertex(m_vertices.prev_vertex(&x2, &y2))) { *x += x2; @@ -294,14 +294,14 @@ inline void path_adapter::rel_to_abs(double* x, double* y) const } //------------------------------------------------------------------------ -template +template inline void path_adapter::move_to(double x, double y) { m_vertices.add_vertex(x, y, path_cmd_move_to); } //------------------------------------------------------------------------ -template +template inline void path_adapter::move_rel(double dx, double dy) { rel_to_abs(&dx, &dy); @@ -309,14 +309,14 @@ inline void path_adapter::move_rel(double dx, double dy) } //------------------------------------------------------------------------ -template +template inline void path_adapter::line_to(double x, double y) { m_vertices.add_vertex(x, y, path_cmd_line_to); } //------------------------------------------------------------------------ -template +template inline void path_adapter::line_rel(double dx, double dy) { rel_to_abs(&dx, &dy); @@ -324,14 +324,14 @@ inline void path_adapter::line_rel(double dx, double dy) } //------------------------------------------------------------------------ -template +template inline void path_adapter::hline_to(double x) { m_vertices.add_vertex(x, last_y(), path_cmd_line_to); } //------------------------------------------------------------------------ -template +template inline void path_adapter::hline_rel(double dx) { double dy = 0; @@ -340,14 +340,14 @@ inline void path_adapter::hline_rel(double dx) } //------------------------------------------------------------------------ -template +template inline void path_adapter::vline_to(double y) { m_vertices.add_vertex(last_x(), y, path_cmd_line_to); } //------------------------------------------------------------------------ -template +template inline void path_adapter::vline_rel(double dy) { double dx = 0; @@ -356,7 +356,7 @@ inline void path_adapter::vline_rel(double dy) } //------------------------------------------------------------------------ -template +template void path_adapter::arc_to(double rx, double ry, double angle, bool large_arc_flag, @@ -375,7 +375,7 @@ void path_adapter::arc_to(double rx, double ry, // Ensure radii are valid //------------------------- - if(rx < epsilon || ry < epsilon) + if(rx < epsilon || ry < epsilon) { line_to(x, y); return; @@ -404,7 +404,7 @@ void path_adapter::arc_to(double rx, double ry, } //------------------------------------------------------------------------ -template +template void path_adapter::arc_rel(double rx, double ry, double angle, bool large_arc_flag, @@ -416,8 +416,8 @@ void path_adapter::arc_rel(double rx, double ry, } //------------------------------------------------------------------------ -template -void path_adapter::curve3(double x_ctrl, double y_ctrl, +template +void path_adapter::curve3(double x_ctrl, double y_ctrl, double x_to, double y_to) { m_vertices.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3); @@ -425,8 +425,8 @@ void path_adapter::curve3(double x_ctrl, double y_ctrl, } //------------------------------------------------------------------------ -template -void path_adapter::curve3_rel(double dx_ctrl, double dy_ctrl, +template +void path_adapter::curve3_rel(double dx_ctrl, double dy_ctrl, double dx_to, double dy_to) { rel_to_abs(&dx_ctrl, &dy_ctrl); @@ -436,7 +436,7 @@ void path_adapter::curve3_rel(double dx_ctrl, double dy_ctrl, } //------------------------------------------------------------------------ -template +template void path_adapter::curve3(double x_to, double y_to) { double x0; @@ -444,7 +444,7 @@ void path_adapter::curve3(double x_to, double y_to) if(is_vertex(m_vertices.last_vertex(&x0, &y0))) { double x_ctrl; - double y_ctrl; + double y_ctrl; unsigned cmd = m_vertices.prev_vertex(&x_ctrl, &y_ctrl); if(is_curve(cmd)) { @@ -461,7 +461,7 @@ void path_adapter::curve3(double x_to, double y_to) } //------------------------------------------------------------------------ -template +template void path_adapter::curve3_rel(double dx_to, double dy_to) { rel_to_abs(&dx_to, &dy_to); @@ -469,9 +469,9 @@ void path_adapter::curve3_rel(double dx_to, double dy_to) } //------------------------------------------------------------------------ -template -void path_adapter::curve4(double x_ctrl1, double y_ctrl1, - double x_ctrl2, double y_ctrl2, +template +void path_adapter::curve4(double x_ctrl1, double y_ctrl1, + double x_ctrl2, double y_ctrl2, double x_to, double y_to) { m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4); @@ -480,9 +480,9 @@ void path_adapter::curve4(double x_ctrl1, double y_ctrl1, } //------------------------------------------------------------------------ -template -void path_adapter::curve4_rel(double dx_ctrl1, double dy_ctrl1, - double dx_ctrl2, double dy_ctrl2, +template +void path_adapter::curve4_rel(double dx_ctrl1, double dy_ctrl1, + double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to) { rel_to_abs(&dx_ctrl1, &dy_ctrl1); @@ -494,8 +494,8 @@ void path_adapter::curve4_rel(double dx_ctrl1, double dy_ctrl1, } //------------------------------------------------------------------------ -template -void path_adapter::curve4(double x_ctrl2, double y_ctrl2, +template +void path_adapter::curve4(double x_ctrl2, double y_ctrl2, double x_to, double y_to) { double x0; @@ -503,7 +503,7 @@ void path_adapter::curve4(double x_ctrl2, double y_ctrl2, if(is_vertex(last_vertex(&x0, &y0))) { double x_ctrl1; - double y_ctrl1; + double y_ctrl1; unsigned cmd = prev_vertex(&x_ctrl1, &y_ctrl1); if(is_curve(cmd)) { @@ -520,8 +520,8 @@ void path_adapter::curve4(double x_ctrl2, double y_ctrl2, } //------------------------------------------------------------------------ -template -void path_adapter::curve4_rel(double dx_ctrl2, double dy_ctrl2, +template +void path_adapter::curve4_rel(double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to) { rel_to_abs(&dx_ctrl2, &dy_ctrl2); @@ -530,7 +530,7 @@ void path_adapter::curve4_rel(double dx_ctrl2, double dy_ctrl2, } //------------------------------------------------------------------------ -template +template inline void path_adapter::end_poly(unsigned flags) { if(is_vertex(m_vertices.last_command())) @@ -540,91 +540,91 @@ inline void path_adapter::end_poly(unsigned flags) } //------------------------------------------------------------------------ -template +template inline void path_adapter::close_polygon(unsigned flags) { end_poly(path_flags_close | flags); } //------------------------------------------------------------------------ -template +template inline unsigned path_adapter::total_vertices() const { return m_vertices.total_vertices(); } //------------------------------------------------------------------------ -template +template inline unsigned path_adapter::last_vertex(double* x, double* y) const { return m_vertices.last_vertex(x, y); } //------------------------------------------------------------------------ -template +template inline unsigned path_adapter::prev_vertex(double* x, double* y) const { return m_vertices.prev_vertex(x, y); } //------------------------------------------------------------------------ -template +template inline double path_adapter::last_x() const { return m_vertices.last_x(); } //------------------------------------------------------------------------ -template +template inline double path_adapter::last_y() const { return m_vertices.last_y(); } //------------------------------------------------------------------------ -template +template inline unsigned path_adapter::vertex(unsigned idx, double* x, double* y) const { return m_vertices.vertex(idx, x, y); } - + //------------------------------------------------------------------------ -template +template inline unsigned path_adapter::command(unsigned idx) const { return m_vertices.command(idx); } //------------------------------------------------------------------------ -template +template void path_adapter::modify_vertex(unsigned idx, double x, double y) { m_vertices.modify_vertex(idx, x, y); } //------------------------------------------------------------------------ -template +template void path_adapter::modify_vertex(unsigned idx, double x, double y, unsigned cmd) { m_vertices.modify_vertex(idx, x, y, cmd); } //------------------------------------------------------------------------ -template +template void path_adapter::modify_command(unsigned idx, unsigned cmd) { m_vertices.modify_command(idx, cmd); } //------------------------------------------------------------------------ -template +template inline void path_adapter::rewind(unsigned path_id) { m_iterator = path_id; } //------------------------------------------------------------------------ -template +template inline unsigned path_adapter::vertex(double* x, double* y) { if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop; @@ -632,7 +632,7 @@ inline unsigned path_adapter::vertex(double* x, double* y) } //------------------------------------------------------------------------ -template +template unsigned path_adapter::perceive_polygon_orientation(unsigned start, unsigned end) { @@ -652,12 +652,12 @@ unsigned path_adapter::perceive_polygon_orientation(unsigned start, } //------------------------------------------------------------------------ -template +template void path_adapter::invert_polygon(unsigned start, unsigned end) { unsigned i; unsigned tmp_cmd = m_vertices.command(start); - + --end; // Make "end" inclusive // Shift all commands to one position @@ -677,45 +677,45 @@ void path_adapter::invert_polygon(unsigned start, unsigned end) } //------------------------------------------------------------------------ -template +template void path_adapter::invert_polygon(unsigned start) { // Skip all non-vertices at the beginning - while(start < m_vertices.total_vertices() && + while(start < m_vertices.total_vertices() && !is_vertex(m_vertices.command(start))) ++start; // Skip all insignificant move_to - while(start+1 < m_vertices.total_vertices() && + while(start+1 < m_vertices.total_vertices() && is_move_to(m_vertices.command(start)) && is_move_to(m_vertices.command(start+1))) ++start; // Find the last vertex unsigned end = start + 1; - while(end < m_vertices.total_vertices() && + while(end < m_vertices.total_vertices() && !is_next_poly(m_vertices.command(end))) ++end; invert_polygon(start, end); } //------------------------------------------------------------------------ -template -unsigned path_adapter::arrange_polygon_orientation(unsigned start, +template +unsigned path_adapter::arrange_polygon_orientation(unsigned start, path_flags_e orientation) { if(orientation == path_flags_none) return start; - + // Skip all non-vertices at the beginning - while(start < m_vertices.total_vertices() && + while(start < m_vertices.total_vertices() && !is_vertex(m_vertices.command(start))) ++start; // Skip all insignificant move_to - while(start+1 < m_vertices.total_vertices() && + while(start+1 < m_vertices.total_vertices() && is_move_to(m_vertices.command(start)) && is_move_to(m_vertices.command(start+1))) ++start; // Find the last vertex unsigned end = start + 1; - while(end < m_vertices.total_vertices() && + while(end < m_vertices.total_vertices() && !is_next_poly(m_vertices.command(end))) ++end; if(end - start > 2) @@ -725,7 +725,7 @@ unsigned path_adapter::arrange_polygon_orientation(unsigned start, // Invert polygon, set orientation flag, and skip all end_poly invert_polygon(start, end); unsigned cmd; - while(end < m_vertices.total_vertices() && + while(end < m_vertices.total_vertices() && is_end_poly(cmd = m_vertices.command(end))) { m_vertices.modify_command(end++, set_orientation(cmd, orientation)); @@ -736,8 +736,8 @@ unsigned path_adapter::arrange_polygon_orientation(unsigned start, } //------------------------------------------------------------------------ -template -unsigned path_adapter::arrange_orientations(unsigned start, +template +unsigned path_adapter::arrange_orientations(unsigned start, path_flags_e orientation) { if(orientation != path_flags_none) @@ -756,7 +756,7 @@ unsigned path_adapter::arrange_orientations(unsigned start, } //------------------------------------------------------------------------ -template +template void path_adapter::arrange_orientations_all_paths(path_flags_e orientation) { if(orientation != path_flags_none) @@ -770,7 +770,7 @@ void path_adapter::arrange_orientations_all_paths(path_flags_e orientation) } //------------------------------------------------------------------------ -template +template void path_adapter::flip_x(double x1, double x2) { unsigned i; @@ -786,7 +786,7 @@ void path_adapter::flip_x(double x1, double x2) } //------------------------------------------------------------------------ -template +template void path_adapter::flip_y(double y1, double y2) { unsigned i; @@ -802,7 +802,7 @@ void path_adapter::flip_y(double y1, double y2) } //------------------------------------------------------------------------ -template +template void path_adapter::translate(double dx, double dy, unsigned path_id) { unsigned num_ver = m_vertices.total_vertices(); @@ -821,7 +821,7 @@ void path_adapter::translate(double dx, double dy, unsigned path_id) } //------------------------------------------------------------------------ -template +template void path_adapter::translate_all_paths(double dx, double dy) { unsigned idx; @@ -842,17 +842,17 @@ void path_adapter::translate_all_paths(double dx, double dy) template class vertex_stl_adapter : boost::noncopyable { public: - + typedef typename Container::value_type vertex_type; typedef typename vertex_type::value_type value_type; - + explicit vertex_stl_adapter(Container & vertices) : m_vertices(vertices) {} - + void add_vertex(double x, double y, unsigned cmd) { - m_vertices.push_back(vertex_type(value_type(x), - value_type(y), + m_vertices.push_back(vertex_type(value_type(x), + value_type(y), int8u(cmd))); } @@ -885,8 +885,8 @@ public: unsigned last_command() const { - return m_vertices.size() ? - m_vertices[m_vertices.size() - 1].cmd : + return m_vertices.size() ? + m_vertices[m_vertices.size() - 1].cmd : (unsigned)path_cmd_stop; } @@ -945,7 +945,7 @@ private: typedef std::vector svg_path_storage; -typedef path_adapter > svg_path_adapter; +typedef path_adapter > svg_path_adapter; }} diff --git a/include/mapnik/svg/svg_path_attributes.hpp b/include/mapnik/svg/svg_path_attributes.hpp index 66df711fb..28f533617 100644 --- a/include/mapnik/svg/svg_path_attributes.hpp +++ b/include/mapnik/svg/svg_path_attributes.hpp @@ -52,7 +52,7 @@ struct path_attributes agg::trans_affine transform; mapnik::gradient fill_gradient; mapnik::gradient stroke_gradient; - + // Empty constructor path_attributes() : index(0), @@ -74,7 +74,7 @@ struct path_attributes } // Copy constructor - path_attributes(const path_attributes& attr) + path_attributes(const path_attributes& attr) : index(attr.index), fill_color(attr.fill_color), stroke_color(attr.stroke_color), @@ -93,7 +93,7 @@ struct path_attributes {} // Copy constructor with new index value - path_attributes(path_attributes const& attr, unsigned idx) + path_attributes(path_attributes const& attr, unsigned idx) : index(idx), fill_color(attr.fill_color), stroke_color(attr.stroke_color), diff --git a/include/mapnik/svg/svg_path_commands.hpp b/include/mapnik/svg/svg_path_commands.hpp index ab6bcee46..3b1e09dee 100644 --- a/include/mapnik/svg/svg_path_commands.hpp +++ b/include/mapnik/svg/svg_path_commands.hpp @@ -41,25 +41,25 @@ namespace mapnik { namespace svg { { return (M_PI * deg)/180.0; } - + template struct move_to { template struct result { - typedef void type; + typedef void type; }; - + explicit move_to(PathType & path) : path_(path) {} - + template void operator() (T0 v, T1 rel) const { path_.move_to(at_c<0>(v),at_c<1>(v),rel); // impl } - + PathType & path_; }; @@ -69,18 +69,18 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit hline_to(PathType & path) : path_(path) {} - + template void operator() (T0 const& x, T1 rel) const { path_.hline_to(x,rel); } - + PathType & path_; }; @@ -91,18 +91,18 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit vline_to(PathType & path) : path_(path) {} - + template void operator() (T0 const& y, T1 rel) const { path_.vline_to(y,rel); } - + PathType & path_; }; @@ -112,18 +112,18 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit line_to(PathType & path) : path_(path) {} - + template void operator() (T0 const& v, T1 rel) const { path_.line_to(at_c<0>(v),at_c<1>(v),rel); // impl } - + PathType & path_; }; @@ -134,12 +134,12 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit curve4(PathType & path) : path_(path) {} - + template void operator() (T0 const& v0, T1 const& v1, T2 const& v2, T3 rel) const { @@ -148,7 +148,7 @@ namespace mapnik { namespace svg { at_c<0>(v2),at_c<1>(v2), rel); // impl } - + PathType & path_; }; @@ -159,12 +159,12 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit curve4_smooth(PathType & path) : path_(path) {} - + template void operator() (T0 const& v0, T1 const& v1, T2 rel) const { @@ -181,12 +181,12 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit curve3(PathType & path) : path_(path) {} - + template void operator() (T0 const& v0, T1 const& v1, T2 rel) const { @@ -194,7 +194,7 @@ namespace mapnik { namespace svg { at_c<0>(v1),at_c<1>(v1), rel); // impl } - + PathType & path_; }; @@ -204,19 +204,19 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit curve3_smooth(PathType & path) : path_(path) {} - + template void operator() (T0 const& v0, T1 rel) const { path_.curve3(at_c<0>(v0),at_c<1>(v0), rel); // impl } - + PathType & path_; }; @@ -226,21 +226,21 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit arc_to(PathType & path) : path_(path) {} - + template void operator() (T0 const& rv, T1 const& angle, T2 large_arc_flag, T3 sweep_flag, T4 const& v, T5 rel) const { path_.arc_to(at_c<0>(rv),at_c<1>(rv), - deg2rad(angle),large_arc_flag,sweep_flag, + deg2rad(angle),large_arc_flag,sweep_flag, at_c<0>(v),at_c<1>(v), - rel); + rel); } - + PathType & path_; }; @@ -248,15 +248,15 @@ namespace mapnik { namespace svg { struct close { typedef void result_type; - + explicit close(PathType & path) : path_(path) {} - + void operator()() const { path_.close_subpath(); } - + PathType & path_; }; diff --git a/include/mapnik/svg/svg_path_grammar.hpp b/include/mapnik/svg/svg_path_grammar.hpp index 5411db679..db670cceb 100644 --- a/include/mapnik/svg/svg_path_grammar.hpp +++ b/include/mapnik/svg/svg_path_grammar.hpp @@ -37,7 +37,7 @@ namespace mapnik { namespace svg { using namespace boost::spirit; using namespace boost::fusion; using namespace boost::phoenix; - + template struct svg_path_grammar : qi::grammar { @@ -64,62 +64,62 @@ namespace mapnik { namespace svg { using qi::double_; using qi::int_; using qi::no_case; - + start = +cmd; cmd = M >> *drawto_cmd; drawto_cmd = L | H | V | C | S | Q | T | A | Z; - - M = (lit('M')[_a = false] | lit('m')[_a = true] ) + + M = (lit('M')[_a = false] | lit('m')[_a = true] ) >> coord[move_to_(_1,_a)] // move_to >> *(-lit(',') >> coord [ line_to_(_1,_a) ] ); // *line_to - + H = (lit('H')[_a = false] | lit('h')[_a = true]) >> +double_[ hline_to_(_1,_a) ] ; // +hline_to - + V = (lit('V')[_a = false] | lit('v')[_a = true]) >> +double_ [ vline_to_(_1,_a) ]; // +vline_to - + L = (lit('L')[_a = false] | lit('l')[_a = true]) >> +coord [ line_to_(_1,_a) ]; // +line_to - + C = (lit('C')[_a = false] | lit('c')[_a = true]) - >> +(coord - >> -lit(',') - >> coord - >> -lit(',') + >> +(coord + >> -lit(',') + >> coord + >> -lit(',') >> coord) [ curve4_(_1,_2,_3,_a) ]; // +curve4 - + S = (lit('S')[_a = false] | lit('s')[_a = true]) - >> +(coord - >> -lit(',') + >> +(coord + >> -lit(',') >> coord) [ curve4_smooth_(_1,_2,_a) ]; // +curve4_smooth (smooth curveto) - + Q = (lit('Q')[_a = false] | lit('q')[_a = true]) - >> +(coord - >> -lit(',') + >> +(coord + >> -lit(',') >> coord) [ curve3_(_1,_2,_a) ]; // +curve3 (quadratic-bezier-curveto) - + T = (lit('T')[_a = false] | lit('t')[_a = true]) >> +(coord ) [ curve3_smooth_(_1,_a) ]; // +curve3_smooth (smooth-quadratic-bezier-curveto) - + A = (lit('A')[_a = false] | lit('a')[_a = true]) - >> +(coord + >> +(coord >> -lit(',') - >> double_ + >> double_ >> -lit(',') - >> int_ + >> int_ + >> -lit(',') + >> int_ >> -lit(',') - >> int_ - >> -lit(',') >> coord) [arc_to_(_1,_2,_3,_4,_5,_a)]; // arc_to; - - + + Z = no_case[lit('z')] [close_()]; // close path - + coord = double_ >> -lit(',') >> double_; } - + // rules qi::rule start; qi::rule cmd; @@ -134,9 +134,9 @@ namespace mapnik { namespace svg { qi::rule,SkipType> T; // T,t qi::rule,SkipType> A; // A,a qi::rule Z; // Z,z - + qi::rule(),SkipType> coord; - + // commands function > move_to_; function > hline_to_; diff --git a/include/mapnik/svg/svg_path_iterator.hpp b/include/mapnik/svg/svg_path_iterator.hpp index 5f5ad6395..bd8e0c082 100644 --- a/include/mapnik/svg/svg_path_iterator.hpp +++ b/include/mapnik/svg/svg_path_iterator.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -40,7 +40,7 @@ using namespace mapnik; /* * @brief Iterator class used to iterate over geometry vertexes. - * Since mapnik::geometry provides access to the components of + * Since mapnik::geometry provides access to the components of * a vertex only through variables passed by reference, * geometry_iterator retrieves these components (command, x coord, * and y coord) and makes them available inside tuples. @@ -51,47 +51,47 @@ using namespace mapnik; * * @tparam Value the type of sequence element dereferenced. * @tparam Container the sequence over which it iterates. -*/ + */ template class path_iterator - : public boost::iterator_adaptor, - Value*, - boost::use_default, - boost::forward_traversal_tag> + : public boost::iterator_adaptor, + Value*, + boost::use_default, + boost::forward_traversal_tag> { public: typedef Value value_type; typedef Container container_type; typedef typename Container::value_type value_component_type; - /*! + /*! * @brief Constructor that initializes the reference to the current element to null. - * This constructor is suitable to mark the end of the iterator (analogous to + * This constructor is suitable to mark the end of the iterator (analogous to * calling end_iterator() in an STL container). * * @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(0,0,0)) + : path_iterator::iterator_adaptor_(0), + path_(path), + first_value_(boost::make_shared(0,0,0)) {} /*! * This constructor receives the first element of the sequence as a pointer. - * Since the container type will likely be a mapnik::geometry, this + * Since the container type will likely be a mapnik::geometry, this * first element would need to be obtained in a similar way as the increment * method below. For this reason, most of the time this constructor will * be called with a null pointer. The body of the constructor makes a call * to increment() in order to obtain this first element from the container. * * @param p pointer to the first element of the sequence. - * @param geometry the geometry that handles the vector of vertexes. + * @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(0,0,0)) + explicit path_iterator(Value* first_element, Container const& path) + : path_iterator::iterator_adaptor_(first_element), + path_(path), + first_value_(boost::make_shared(0,0,0)) { this->increment(); } @@ -104,9 +104,9 @@ public: */ template path_iterator(path_iterator const& other, - typename boost::enable_if, - enabler>::type = enabler()) - : path_iterator::iterator_adaptor_(other.base()) {} + typename boost::enable_if, + enabler>::type = enabler()) + : path_iterator::iterator_adaptor_(other.base()) {} private: @@ -129,13 +129,13 @@ private: { // if the end of the sequence is reached, set the reference // to the current element to null, so it matches the value - // that marks the end of the sequence as defined in the + // that marks the end of the sequence as defined in the // "end_iterator" constructor. this->base_reference() = 0; } else if(this->base_reference() == 0) { - // the first element of the container is stored in the + // the first element of the container is stored in the // member variable 'first_value_' and later assigned // to the reference that boost::iterator_adaptor stores // to track the current element. @@ -173,7 +173,7 @@ private: * The Value type is a boost::tuple that holds 5 elements, the command and the x and y coordinate. * Each coordinate is stored twice to match the needs of the grammar. */ -typedef path_iterator, +typedef path_iterator, coord_transform2 > path_iterator_type; }} diff --git a/include/mapnik/svg/svg_path_parser.hpp b/include/mapnik/svg/svg_path_parser.hpp index 4d249cb9d..a738ce9d7 100644 --- a/include/mapnik/svg/svg_path_parser.hpp +++ b/include/mapnik/svg/svg_path_parser.hpp @@ -28,18 +28,18 @@ namespace mapnik { namespace svg { -template -bool parse_path(const char * wkt, PathType & p); + template + bool parse_path(const char * wkt, PathType & p); -template -bool parse_points(const char * wkt, PathType & p); + template + bool parse_points(const char * wkt, PathType & p); -template -bool MAPNIK_DECL parse_transform(const char * wkt, TransformType & tr); + template + bool MAPNIK_DECL parse_transform(const char * wkt, TransformType & tr); //template //bool MAPNIK_DECL parse_transform(std::string const& wkt, TransformType & tr); -}} + }} #endif // MAPNIK_SVG_PATH_PARSER_HPP diff --git a/include/mapnik/svg/svg_points_grammar.hpp b/include/mapnik/svg/svg_points_grammar.hpp index e6deb843d..2c7913cdb 100644 --- a/include/mapnik/svg/svg_points_grammar.hpp +++ b/include/mapnik/svg/svg_points_grammar.hpp @@ -49,17 +49,17 @@ namespace mapnik { namespace svg { using qi::_1; using qi::_2; using qi::double_; - + start = coord[move_to_(_1,false)] // move_to >> *(-lit(',') >> coord [ line_to_(_1,false) ] ); // *line_to - + coord = double_ >> -lit(',') >> double_; } - + // rules qi::rule start; qi::rule(),SkipType> coord; - + // commands function > move_to_; function > line_to_; diff --git a/include/mapnik/svg/svg_renderer.hpp b/include/mapnik/svg/svg_renderer.hpp index 50260fc0a..aa2743ec1 100644 --- a/include/mapnik/svg/svg_renderer.hpp +++ b/include/mapnik/svg/svg_renderer.hpp @@ -98,32 +98,32 @@ private: }; -template +template class svg_renderer : boost::noncopyable { typedef agg::conv_curve curved_type; typedef agg::conv_stroke curved_stroked_type; - typedef agg::conv_transform curved_stroked_trans_type; + typedef agg::conv_transform curved_stroked_trans_type; typedef agg::conv_transform curved_trans_type; typedef agg::conv_contour curved_trans_contour_type; typedef agg::renderer_base renderer_base; - + public: svg_renderer(VertexSource & source, AttributeSource const& attributes) : source_(source), curved_(source_), curved_stroked_(curved_), attributes_(attributes) {} - + template void render_gradient(Rasterizer& ras, - Scanline& sl, - Renderer& ren, - const gradient &grad, - agg::trans_affine const& mtx, - double opacity, - const box2d &symbol_bbox, - const box2d &path_bbox) + Scanline& sl, + Renderer& ren, + const gradient &grad, + agg::trans_affine const& mtx, + double opacity, + const box2d &symbol_bbox, + const box2d &path_bbox) { typedef agg::gamma_lut gamma_lut_type; typedef agg::gradient_lut, 1024> color_func_type; @@ -181,9 +181,9 @@ public: { typedef agg::gradient_radial_focus gradient_adaptor_type; typedef agg::span_gradient 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 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,32 +228,32 @@ 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); } } template - void render(Rasterizer& ras, + void render(Rasterizer& ras, Scanline& sl, - Renderer& ren, - agg::trans_affine const& mtx, + Renderer& ren, + agg::trans_affine const& mtx, double opacity, const box2d &symbol_bbox) - + { using namespace agg; - + trans_affine transform; curved_stroked_trans_type curved_stroked_trans(curved_stroked_,transform); curved_trans_type curved_trans(curved_,transform); curved_trans_contour_type curved_trans_contour(curved_trans); - + curved_trans_contour.auto_detect_orientation(true); - + for(unsigned i = 0; i < attributes_.size(); ++i) { mapnik::svg::path_attributes const& attr = attributes_[i]; @@ -271,7 +271,7 @@ public: //curved_.approximation_method(curve_inc); curved_.approximation_scale(scl); curved_.angle_tolerance(0.0); - + rgba8 color; if (attr.fill_flag || attr.fill_gradient.get_gradient_type() != NO_GRADIENT) @@ -313,7 +313,7 @@ public: curved_stroked_.inner_join(inner_round); curved_stroked_.approximation_scale(scl); - // If the *visual* line width is considerable we + // If the *visual* line width is considerable we // turn on processing of curve cusps. //--------------------- if(attr.stroke_width * scl > 1.0) @@ -341,24 +341,24 @@ public: } template - void render_id(Rasterizer& ras, - Scanline& sl, - Renderer& ren, - int feature_id, - agg::trans_affine const& mtx, - double opacity, - const box2d &symbol_bbox) - + void render_id(Rasterizer& ras, + Scanline& sl, + Renderer& ren, + int feature_id, + agg::trans_affine const& mtx, + double opacity, + const box2d &symbol_bbox) + { using namespace agg; - + trans_affine transform; curved_stroked_trans_type curved_stroked_trans(curved_stroked_,transform); curved_trans_type curved_trans(curved_,transform); curved_trans_contour_type curved_trans_contour(curved_trans); - + curved_trans_contour.auto_detect_orientation(true); - + for(unsigned i = 0; i < attributes_.size(); ++i) { mapnik::svg::path_attributes const& attr = attributes_[i]; @@ -376,7 +376,7 @@ public: //curved_.approximation_method(curve_inc); curved_.approximation_scale(scl); curved_.angle_tolerance(0.0); - + mapnik::gray16 color(feature_id); if (attr.fill_flag || attr.fill_gradient.get_gradient_type() != NO_GRADIENT) @@ -409,7 +409,7 @@ public: curved_stroked_.inner_join(inner_round); curved_stroked_.approximation_scale(scl); - // If the *visual* line width is considerable we + // If the *visual* line width is considerable we // turn on processing of curve cusps. //--------------------- if(attr.stroke_width * scl > 1.0) @@ -426,9 +426,9 @@ public: } } } - + private: - + VertexSource & source_; curved_type curved_; curved_stroked_type curved_stroked_; diff --git a/include/mapnik/svg/svg_storage.hpp b/include/mapnik/svg/svg_storage.hpp index f3600646a..4d229cd81 100644 --- a/include/mapnik/svg/svg_storage.hpp +++ b/include/mapnik/svg/svg_storage.hpp @@ -37,34 +37,34 @@ class svg_storage : boost::noncopyable { public: svg_storage() {} - + VertexSource & source() // FIXME!! make const { return source_; } - + AttributeSource & attributes() // FIXME!! make const { return attributes_; } - + void set_bounding_box(box2d const& b) { bounding_box_ = b; } - + void set_bounding_box(double x0, double y0, double x1, double y1) { bounding_box_.init(x0,y0,x1,y1); } - + box2d const& bounding_box() const { return bounding_box_; } - + private: - + VertexSource source_; AttributeSource attributes_; box2d bounding_box_; diff --git a/include/mapnik/svg/svg_transform_grammar.hpp b/include/mapnik/svg/svg_transform_grammar.hpp index 9d9bab750..dd23bad39 100644 --- a/include/mapnik/svg/svg_transform_grammar.hpp +++ b/include/mapnik/svg/svg_transform_grammar.hpp @@ -53,17 +53,17 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; - + explicit process_matrix( TransformType & tr) :tr_(tr) {} - + void operator () (double a, double b, double c, double d, double e, double f) const { - tr_ = agg::trans_affine(a,b,c,d,e,f) * tr_; + tr_ = agg::trans_affine(a,b,c,d,e,f) * tr_; } - + TransformType & tr_; }; @@ -73,12 +73,12 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; explicit process_rotate( TransformType & tr) :tr_(tr) {} - + template void operator () (T0 a, T1 cx, T2 cy) const { @@ -94,8 +94,8 @@ namespace mapnik { namespace svg { tr_ = t * tr_; } } - - TransformType & tr_; + + TransformType & tr_; }; template @@ -104,20 +104,20 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; explicit process_translate( TransformType & tr) :tr_(tr) {} - + template void operator () (T0 tx, T1 ty) const { if (ty) tr_ = agg::trans_affine_translation(tx,*ty) * tr_; else tr_ = agg::trans_affine_translation(tx,0.0) * tr_; } - - TransformType & tr_; + + TransformType & tr_; }; template @@ -126,20 +126,20 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; explicit process_scale( TransformType & tr) :tr_(tr) {} - + template void operator () (T0 sx, T1 sy) const { if (sy) tr_ = agg::trans_affine_scaling(sx,*sy) * tr_; else tr_ = agg::trans_affine_scaling(sx,sx) * tr_; } - - TransformType & tr_; + + TransformType & tr_; }; @@ -149,31 +149,31 @@ namespace mapnik { namespace svg { template struct result { - typedef void type; + typedef void type; }; explicit process_skew( TransformType & tr) :tr_(tr) {} - + template void operator () (T0 skew_x, T1 skew_y) const { tr_ = agg::trans_affine_skewing(deg2rad(skew_x),deg2rad(skew_y)) * tr_; } - - TransformType & tr_; + + TransformType & tr_; }; // commented as this does not appear used and crashes clang when used with pch /* - struct print_action - { - template - void operator()(T const& c, qi::unused_type, qi::unused_type) const - { - std::cerr << typeid(c).name() << std::endl; - } - }; + struct print_action + { + template + void operator()(T const& c, qi::unused_type, qi::unused_type) const + { + std::cerr << typeid(c).name() << std::endl; + } + }; */ template @@ -199,45 +199,45 @@ namespace mapnik { namespace svg { using qi::_val; using qi::double_; using qi::no_case; - + start = +transform_ ; - + transform_ = matrix | rotate | translate | scale | rotate | skewX | skewY ; - - matrix = no_case[lit("matrix")] - >> lit('(') - >> ( - double_ >> -lit(',') - >> double_ >> -lit(',') - >> double_ >> -lit(',') - >> double_ >> -lit(',') - >> double_ >> -lit(',') + + matrix = no_case[lit("matrix")] + >> lit('(') + >> ( + double_ >> -lit(',') + >> double_ >> -lit(',') + >> double_ >> -lit(',') + >> double_ >> -lit(',') + >> double_ >> -lit(',') >> double_) [ matrix_action(_1,_2,_3,_4,_5,_6) ] >> lit(')') ; - - translate = no_case[lit("translate")] - >> lit('(') - >> (double_ >> -lit(',') + + translate = no_case[lit("translate")] + >> lit('(') + >> (double_ >> -lit(',') >> -double_) [ translate_action(_1,_2) ] >> lit(')'); - - scale = no_case[lit("scale")] - >> lit('(') - >> (double_ >> -lit(',') - >> -double_ )[ scale_action(_1,_2)] + + scale = no_case[lit("scale")] + >> lit('(') + >> (double_ >> -lit(',') + >> -double_ )[ scale_action(_1,_2)] >> lit(')'); - - rotate = no_case[lit("rotate")] - >> lit('(') - >> double_[_a = _1] >> -lit(',') - >> -(double_ [_b = _1] >> -lit(',') >> double_[_c = _1]) + + rotate = no_case[lit("rotate")] + >> lit('(') + >> double_[_a = _1] >> -lit(',') + >> -(double_ [_b = _1] >> -lit(',') >> double_[_c = _1]) >> lit(')') [ rotate_action(_a,_b,_c)]; - + skewX = no_case[lit("skewX")] >> lit('(') >> double_ [ skew_action(_1, 0.0)] >> lit(')'); - + skewY = no_case[lit("skewY")] >> lit('(') >> double_ [ skew_action(0.0, _1)] >> lit(')'); - + } // rules @@ -249,7 +249,7 @@ namespace mapnik { namespace svg { qi::rule, SkipType> rotate; qi::rule skewX; qi::rule skewY; - + // actions function > matrix_action; function > rotate_action; diff --git a/include/mapnik/svg_renderer.hpp b/include/mapnik/svg_renderer.hpp index d4e5e1773..fe91de259 100644 --- a/include/mapnik/svg_renderer.hpp +++ b/include/mapnik/svg_renderer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -32,116 +32,116 @@ // stl #include -namespace mapnik +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 - class MAPNIK_DECL svg_renderer : public feature_style_processor >, - 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 +class MAPNIK_DECL svg_renderer : public feature_style_processor >, + 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(); - - 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) - { - // nothing to do - } + // nothing to do + } - inline OutputIterator& get_output_iterator() - { - return output_iterator_; - } - - inline const OutputIterator& get_output_iterator() const - { - return output_iterator_; - } + inline OutputIterator& get_output_iterator() + { + return output_iterator_; + } - private: - OutputIterator& output_iterator_; - const int width_; - const int height_; - CoordTransform t_; - svg::svg_generator 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& processor, - Feature const& feature, - proj_transform const& prj_trans) + 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 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& processor, + Feature const& feature, + proj_transform const& prj_trans) : processor_(processor), feature_(feature), prj_trans_(prj_trans) {} - - template - void operator()(Symbolizer const& sym) const - { - processor_.process(sym, feature_, prj_trans_); - } - - svg_renderer& processor_; - Feature const& feature_; - proj_transform const& prj_trans_; - }; + + template + void operator()(Symbolizer const& sym) const + { + processor_.process(sym, feature_, prj_trans_); + } + + svg_renderer& processor_; + Feature const& feature_; + proj_transform const& prj_trans_; }; +}; } #endif // MAPNIK_SVG_RENDERER_HPP diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 159664617..804aaf519 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -31,57 +31,57 @@ // boost #include -namespace mapnik +namespace mapnik { class Map; class MAPNIK_DECL symbolizer_base { - 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_; +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_; }; typedef boost::array transform_type; @@ -98,7 +98,7 @@ public: protected: symbolizer_with_image(path_expression_ptr filename = path_expression_ptr()); symbolizer_with_image(symbolizer_with_image const& rhs); - path_expression_ptr image_filename_; + path_expression_ptr image_filename_; float image_opacity_; transform_type matrix_; }; diff --git a/include/mapnik/symbolizer_helpers.hpp b/include/mapnik/symbolizer_helpers.hpp index 6c9dcdcb5..552df12ce 100644 --- a/include/mapnik/symbolizer_helpers.hpp +++ b/include/mapnik/symbolizer_helpers.hpp @@ -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 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(); diff --git a/include/mapnik/text_path.hpp b/include/mapnik/text_path.hpp index b7d7daaf1..3f4db3b31 100644 --- a/include/mapnik/text_path.hpp +++ b/include/mapnik/text_path.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -38,7 +38,7 @@ namespace mapnik { - + class string_info : private boost::noncopyable { protected: @@ -72,12 +72,12 @@ public: { text_ += text; } - + unsigned num_characters() const { return characters_.size(); } - + void set_rtl(bool value) { is_rtl = value; @@ -87,26 +87,26 @@ public: { return is_rtl; } - + char_info const& at(unsigned i) const { return characters_[i]; } - + char_info const& operator[](unsigned i) const { return at(i); } - UnicodeString const& get_string() const + UnicodeString const& get_string() const { return text_; } 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. */ @@ -116,7 +116,7 @@ public: characters_.clear(); } }; - + /** List of all characters and their positions and formats for a placement. */ class text_path : boost::noncopyable @@ -126,11 +126,11 @@ class text_path : boost::noncopyable int c; double x, y, angle; char_properties *format; - + character_node(int c_, double x_, double y_, double angle_, char_properties *format_) : c(c_), x(x_), y(y_), angle(angle_), format(format_) {} ~character_node() {} - + void vertex(int *c_, double *x_, double *y_, double *angle_, char_properties **format_) { *c_ = c; @@ -140,17 +140,17 @@ class text_path : boost::noncopyable *format_ = format; } }; - + int itr_; public: typedef std::vector character_nodes_t; character_nodes_t nodes_; double starting_x; double starting_y; - + // std::pair string_dimensions; - - text_path() + + text_path() : itr_(0), starting_x(0), starting_y(0) @@ -158,33 +158,33 @@ public: { } - + ~text_path() {} - + /** Adds a new char to the list. */ void add_node(int c, double x, double y, double angle, char_properties *format) { nodes_.push_back(character_node(c, x, y, angle, format)); } - + /** Return node. Always returns a new node. Has no way to report that there are no more nodes. */ void vertex(int *c, double *x, double *y, double *angle, char_properties **format) { nodes_[itr_++].vertex(c, x, y, angle, format); } - + /** Start again at first node. */ void rewind() { itr_ = 0; } - + /** Number of nodes. */ int num_nodes() const { return nodes_.size(); } - + /** Delete all nodes. */ void clear() { diff --git a/include/mapnik/text_placements.hpp b/include/mapnik/text_placements.hpp index ab90c6768..fe2d52f7a 100644 --- a/include/mapnik/text_placements.hpp +++ b/include/mapnik/text_placements.hpp @@ -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 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 @@ -176,7 +176,7 @@ public: /** Properties actually used by placement finder and renderer. Values in * here are modified each time next() is called. */ text_symbolizer_properties properties; - + /** Scale factor used by the renderer. */ double scale_factor; /* TODO: Don't know what this is used for. */ @@ -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 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 > additional_boxes; /* TODO */ @@ -214,8 +214,8 @@ public: typedef boost::shared_ptr text_placement_info_ptr; /** This object handles the management of all TextSymbolizer properties. It can - * be used as a base class for own objects which implement new processing - * semantics. Basically this class just makes sure a pointer of the right + * be used as a base class for own objects which implement new processing + * semantics. Basically this class just makes sure a pointer of the right * class is returned by the get_placement_info call. */ class text_placements @@ -223,28 +223,28 @@ 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 get_all_expressions(); /** Destructor. */ virtual ~text_placements() {} - + /** List of all properties used as the default for the subclasses. */ text_symbolizer_properties properties; }; @@ -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; diff --git a/include/mapnik/text_placements_list.hpp b/include/mapnik/text_placements_list.hpp index 3453c3010..1010816be 100644 --- a/include/mapnik/text_placements_list.hpp +++ b/include/mapnik/text_placements_list.hpp @@ -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(); diff --git a/include/mapnik/text_placements_simple.hpp b/include/mapnik/text_placements_simple.hpp index 575dee4cd..2c25f2e88 100644 --- a/include/mapnik/text_placements_simple.hpp +++ b/include/mapnik/text_placements_simple.hpp @@ -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) { diff --git a/include/mapnik/text_symbolizer.hpp b/include/mapnik/text_symbolizer.hpp index cba2fdfe0..33996968a 100644 --- a/include/mapnik/text_symbolizer.hpp +++ b/include/mapnik/text_symbolizer.hpp @@ -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; @@ -65,7 +65,7 @@ struct MAPNIK_DECL text_symbolizer : public symbolizer_base expression_ptr get_orientation() const func_deprecated; // orienation (rotation angle atm) void set_orientation(expression_ptr expr); - + unsigned get_text_ratio() const func_deprecated; // target ratio for text bounding box in pixels void set_text_ratio(unsigned ratio); unsigned get_wrap_width() const func_deprecated; // width to wrap text at, or trigger ratio diff --git a/include/mapnik/tiff_io.hpp b/include/mapnik/tiff_io.hpp index 52616f36b..8d6dc8833 100644 --- a/include/mapnik/tiff_io.hpp +++ b/include/mapnik/tiff_io.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,14 +30,14 @@ extern "C" { #ifdef HAVE_GEOTIFF - #include - #include - #define RealTIFFOpen XTIFFClientOpen - #define RealTIFFClose XTIFFClose +#include +#include +#define RealTIFFOpen XTIFFClientOpen +#define RealTIFFClose XTIFFClose #else - #include - #define RealTIFFOpen TIFFClientOpen - #define RealTIFFClose TIFFClose +#include +#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 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 diff --git a/include/mapnik/timer.hpp b/include/mapnik/timer.hpp index 4518159c1..8122aad85 100644 --- a/include/mapnik/timer.hpp +++ b/include/mapnik/timer.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace mapnik { @@ -41,8 +41,8 @@ public: restart(); } - void restart() - { + void restart() + { _stopped = false; gettimeofday(&_wall_clock_start, NULL); _cpu_start = clock(); @@ -87,16 +87,16 @@ 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() { if (!_stopped) stop(); } - + void stop() const { timer::stop(); @@ -104,9 +104,9 @@ public: { std::ostringstream s; s.precision(2); - s << std::fixed; + s << std::fixed; s << wall_clock_elapsed() << "ms (cpu " << cpu_elapsed() << "ms)"; - s << std::setw(30 - (int)s.tellp()) << std::right << "| " << base_message_ << "\n"; + s << std::setw(30 - (int)s.tellp()) << std::right << "| " << base_message_ << "\n"; os_ << s.str(); } catch (...) {} // eat any exceptions @@ -120,6 +120,6 @@ private: std::ostream & os_; std::string base_message_; }; - + }; #endif // MAPNIK_TIMER_HPP diff --git a/include/mapnik/unicode.hpp b/include/mapnik/unicode.hpp index 1d9cb077d..2e8a64656 100644 --- a/include/mapnik/unicode.hpp +++ b/include/mapnik/unicode.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -43,8 +43,8 @@ class MAPNIK_DECL transcoder : private boost::noncopyable { public: explicit transcoder (std::string const& encoding); - UnicodeString transcode(const char* data, boost::int32_t length = -1) const; - ~transcoder(); + UnicodeString transcode(const char* data, boost::int32_t length = -1) const; + ~transcoder(); private: bool ok_; UConverter * conv_; diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp index 799cd59e5..79639c31a 100644 --- a/include/mapnik/util/container_adapter.hpp +++ b/include/mapnik/util/container_adapter.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -36,35 +36,35 @@ namespace boost { namespace spirit { namespace traits { -template <> -struct is_container : mpl::true_ {} ; + template <> + struct is_container : mpl::true_ {} ; -template <> -struct container_iterator -{ - typedef mapnik::util::vertex_iterator type; -}; + template <> + struct container_iterator + { + typedef mapnik::util::vertex_iterator type; + }; -template <> -struct begin_container -{ - static mapnik::util::vertex_iterator - call (mapnik::geometry_type const& g) - { - return mapnik::util::vertex_iterator(g.data()); - } -}; + template <> + struct begin_container + { + static mapnik::util::vertex_iterator + call (mapnik::geometry_type const& g) + { + return mapnik::util::vertex_iterator(g.data()); + } + }; -template <> -struct end_container -{ - static mapnik::util::vertex_iterator - call (mapnik::geometry_type const& g) - { - return mapnik::util::vertex_iterator(); - } -}; + template <> + struct end_container + { + static mapnik::util::vertex_iterator + call (mapnik::geometry_type const& g) + { + return mapnik::util::vertex_iterator(); + } + }; -}}} + }}} #endif // CONTAINER_ADAPTER_HPP diff --git a/include/mapnik/util/deepcopy.hpp b/include/mapnik/util/deepcopy.hpp index c81814518..3a191f5bf 100644 --- a/include/mapnik/util/deepcopy.hpp +++ b/include/mapnik/util/deepcopy.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -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 diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 22337ed1c..29231124c 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -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 - struct result { typedef int type; }; - - int operator() (geometry_type const& geom) const + namespace detail { + struct get_type { - return (int)geom.type(); - } -}; + template + struct result { typedef int type; }; -struct get_first -{ - template - 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 + 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 + struct coordinate_policy : karma::real_policies + { + typedef boost::spirit::karma::real_policies base_type; + static int floatfield(T n) { return base_type::fmtflags::fixed; } + static unsigned precision(T n) { return 6u ;} + }; } -}; -template -struct coordinate_policy : karma::real_policies -{ - typedef boost::spirit::karma::real_policies base_type; - static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return 6u ;} -}; -} - -template -struct svg_generator : + template + struct svg_generator : karma::grammar -{ - - 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 - ; - - point = &uint_(mapnik::Point)[_1 = _type(_val)] - << svg_point [_1 = _first(_val)] - ; - - svg_point = &uint_ - << lit("cx=\"") << coord_type - << lit("\" cy=\"") << coord_type - << lit('\"') - ; - - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] - << svg_path - ; - - 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 svg; - karma::rule point; - karma::rule linestring; - karma::rule polygon; - karma::rule svg_point; - karma::rule, geometry_type const& ()> svg_path; + 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; - // phoenix functions - phoenix::function _type; - phoenix::function _first; - // - karma::real_generator > coord_type; - -}; + svg = point | linestring | polygon + ; + + point = &uint_(mapnik::Point)[_1 = _type(_val)] + << svg_point [_1 = _first(_val)] + ; + + svg_point = &uint_ + << lit("cx=\"") << coord_type + << lit("\" cy=\"") << coord_type + << lit('\"') + ; + + linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + << svg_path + ; + + 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 svg; + karma::rule point; + karma::rule linestring; + karma::rule polygon; + + karma::rule svg_point; + karma::rule, geometry_type const& ()> svg_path; + + // phoenix functions + phoenix::function _type; + phoenix::function _first; + // + karma::real_generator > coord_type; + + }; }} diff --git a/include/mapnik/util/geometry_to_ds_type.hpp b/include/mapnik/util/geometry_to_ds_type.hpp index e29642bb8..ca0a3c657 100644 --- a/include/mapnik/util/geometry_to_ds_type.hpp +++ b/include/mapnik/util/geometry_to_ds_type.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2012 Artem Pavlenko @@ -35,32 +35,32 @@ namespace mapnik { namespace util { -void to_ds_type(mapnik::geometry_container const& paths, - boost::optional & result) -{ - if (paths.size() == 1) + void to_ds_type(mapnik::geometry_container const& paths, + boost::optional & result) { - result.reset(static_cast(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(itr->type()); - if (multi_type > 0 && multi_type != type) + result.reset(static_cast(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(itr->type()); + if (multi_type > 0 && multi_type != type) + { + result.reset(datasource::Collection); + } + multi_type = type; + result.reset(static_cast(type)); } - multi_type = type; - result.reset(static_cast(type)); } } -} - -}} + + }} #endif // MAPNIK_GEOMETRY_TO_DS_TYPE diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index e26935262..3680410d0 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -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 -inline void write (S & stream, T val, std::size_t size, wkbByteOrder byte_order) -{ + template + 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(&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(::operator new (size_)):0) - {} - - ~wkb_buffer() - { - ::operator delete(data_); + char* buf = reinterpret_cast(&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(::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_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_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(size); - boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); - ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(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(size); - boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); - ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(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(size); + boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); + ss.write(reinterpret_cast(&byte_order),1); + int type = static_cast(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 point_type; - typedef std::vector linear_ring; - boost::ptr_vector 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(size); - boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); - - ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(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(size); + boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); + ss.write(reinterpret_cast(&byte_order),1); + int type = static_cast(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 point_type; + typedef std::vector linear_ring; + boost::ptr_vector rings; - if (paths.size() > 1) - { - // multi geometry or geometry collection - std::vector 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(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(size); + boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); - wkb_buffer_ptr multi_wkb = boost::make_shared(multi_size); - boost::interprocess::bufferstream ss(multi_wkb->buffer(), multi_wkb->size(), std::ios::out | std::ios::binary); ss.write(reinterpret_cast(&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(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_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(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(multi_size); + boost::interprocess::bufferstream ss(multi_wkb->buffer(), multi_wkb->size(), std::ios::out | std::ios::binary); + ss.write(reinterpret_cast(&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 diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index 42735c3a2..9f533e8bb 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -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 sink_type; - sink_type sink(wkt); - wkt_generator 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 sink_type; + sink_type sink(wkt); + wkt_generator 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 sink_type; - sink_type sink(wkt); - wkt_multi_generator 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 sink_type; + sink_type sink(wkt); + wkt_multi_generator generator; + bool result = karma::generate(sink, generator, geom); + return result; + } -}} + }} #endif // MAPNIK_GEOMETRY_TO_WKT_HPP diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index bd3b71a65..e826dca41 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -46,178 +46,178 @@ namespace boost { namespace spirit { namespace traits { // make gcc and darwin toolsets happy. -template <> -struct is_container - : mpl::false_ -{}; - -}}} + template <> + struct is_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 - struct result { typedef int type; }; - - int operator() (geometry_type const& geom) const + struct get_type { - return static_cast(geom.type()); - } -}; + template + struct result { typedef int type; }; -struct get_first -{ - template - 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 - struct result { typedef bool type; }; - - bool operator() (geometry_container const& geom) const - { - return geom.size() > 1 ? true : false; - } -}; - -struct multi_geometry_type -{ - template - struct result { typedef boost::tuple type; }; - - boost::tuple 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) - { - if (type != 0 && itr->type() != type) - { - collection = true; - break; - } - type = itr->type(); + int operator() (geometry_type const& geom) const + { + return static_cast(geom.type()); } - return boost::tuple(type, collection); - } -}; + }; - -template -struct wkt_coordinate_policy : karma::real_policies -{ - typedef boost::spirit::karma::real_policies base_type; - static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return 6 ;} -}; - -} - -template -struct wkt_generator : - karma::grammar -{ - - 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; - - 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) - ; + template + 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 + struct result { typedef bool type; }; + + bool operator() (geometry_container const& geom) const + { + return geom.size() > 1 ? true : false; + } + }; + + struct multi_geometry_type + { + template + struct result { typedef boost::tuple type; }; + + boost::tuple 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) + { + if (type != 0 && itr->type() != type) + { + collection = true; + break; + } + type = itr->type(); + } + return boost::tuple(type, collection); + } + }; + + + template + struct wkt_coordinate_policy : karma::real_policies + { + typedef boost::spirit::karma::real_policies base_type; + static int floatfield(T n) { return base_type::fmtflags::fixed; } + static unsigned precision(T n) { return 6 ;} + }; - coords = point_coord % lit(',') - ; - } - // rules - karma::rule wkt; - karma::rule point; - karma::rule linestring; - karma::rule polygon; - karma::rule coords; - karma::rule, geometry_type const& ()> coords2; - karma::rule point_coord; - karma::rule polygon_coord; - - // phoenix functions - phoenix::function _type; - phoenix::function _first; - // - karma::real_generator > coord_type; - -}; + template + struct wkt_generator : + karma::grammar + { + + 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 wkt; + karma::rule point; + karma::rule linestring; + karma::rule polygon; + + karma::rule coords; + karma::rule, geometry_type const& ()> coords2; + karma::rule point_coord; + karma::rule polygon_coord; + + // phoenix functions + phoenix::function _type; + phoenix::function _first; + // + karma::real_generator > coord_type; + + }; template -struct wkt_multi_generator : +struct wkt_multi_generator : karma::grammar >, geometry_container const& ()> { - + wkt_multi_generator() : wkt_multi_generator::base_type(wkt) { @@ -226,29 +226,29 @@ struct wkt_multi_generator : using boost::spirit::karma::_val; using boost::spirit::karma::_1; using boost::spirit::karma::_a; - + geometry_types.add (mapnik::Point,"Point") (mapnik::LineString,"LineString") (mapnik::Polygon,"Polygon") ; - - wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] - << lit("GeometryCollection(") << geometry << lit(")") - | eps(is_multi(_val)) << lit("Multi") << geometry_types[_1 = phoenix::at_c<0>(_a)] - << "(" << multi_geometry << ")" + + wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] + << lit("GeometryCollection(") << geometry << lit(")") + | eps(is_multi(_val)) << lit("Multi") << geometry_types[_1 = phoenix::at_c<0>(_a)] + << "(" << multi_geometry << ")" | geometry ; - - geometry = -(single_geometry % lit(',')) - ; - - single_geometry = geometry_types[_1 = _type(_val)] << path + + geometry = -(single_geometry % lit(',')) ; - - multi_geometry = -(path % lit(',')) - ; - + + single_geometry = geometry_types[_1 = _type(_val)] << path + ; + + multi_geometry = -(path % lit(',')) + ; + } // rules karma::rule >, geometry_container const& ()> wkt; @@ -260,7 +260,7 @@ struct wkt_multi_generator : phoenix::function is_multi; phoenix::function _multi_type; phoenix::function _type; - // + // karma::symbols geometry_types; }; diff --git a/include/mapnik/util/vertex_iterator.hpp b/include/mapnik/util/vertex_iterator.hpp index 1fb5bc64c..5a734ddbf 100644 --- a/include/mapnik/util/vertex_iterator.hpp +++ b/include/mapnik/util/vertex_iterator.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,53 +35,53 @@ namespace mapnik { namespace util { -template -class vertex_iterator - : public boost::iterator_facade< vertex_iterator, - typename boost::tuple const, - boost::forward_traversal_tag - > -{ - -public: - typedef typename boost::tuple value_type; - typedef vertex_vector container_type; - - vertex_iterator() - : v_(SEG_END,0,0) - {} - - explicit vertex_iterator(container_type const& vertices) - : vertices_(&vertices), - pos_(0) + template + class vertex_iterator + : public boost::iterator_facade< vertex_iterator, + typename boost::tuple const, + boost::forward_traversal_tag + > { - increment(); - } - -private: - friend class boost::iterator_core_access; - 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_; -}; - -}} + public: + typedef typename boost::tuple value_type; + typedef vertex_vector container_type; + + vertex_iterator() + : v_(SEG_END,0,0) + {} + + explicit vertex_iterator(container_type const& vertices) + : vertices_(&vertices), + pos_(0) + { + increment(); + } + + private: + friend class boost::iterator_core_access; + + 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 diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index b6acd5e58..d7d342477 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -42,7 +42,7 @@ namespace mapnik #ifdef MAPNIK_THREADSAFE using boost::mutex; #endif - + template class CreateUsingNew { @@ -76,13 +76,13 @@ private: }; public: - + static T* create() { static MaxAlign staticMemory; return new(&staticMemory) T; } -#ifdef __SUNPRO_CC +#ifdef __SUNPRO_CC // Sun C++ Compiler doesn't handle `volatile` keyword same as GCC. static void destroy(T* obj) #else @@ -92,7 +92,7 @@ public: obj->~T(); } }; - + template class CreatePolicy=CreateStatic> class singleton { @@ -113,7 +113,7 @@ template ::destroy(pInstance_); @@ -123,7 +123,7 @@ template class CreatePolicy> mutex singleton::mutex_; #endif - + template class CreatePolicy> T* singleton::pInstance_=0; template class CreatePolicy> bool singleton::destroyed_=false; + template class CreatePolicy> bool singleton::destroyed_=false; } diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index f6ac076d0..d657d974c 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -51,14 +51,14 @@ namespace mapnik { inline void to_utf8(UnicodeString const& input, std::string & target) { if (input.length() == 0) return; - + const int BUF_SIZE = 256; char buf [BUF_SIZE]; int len; - + UErrorCode err = U_ZERO_ERROR; u_strToUTF8(buf, BUF_SIZE, &len, input.getBuffer(), input.length(), &err); - if (err == U_BUFFER_OVERFLOW_ERROR || err == U_STRING_NOT_TERMINATED_WARNING ) + if (err == U_BUFFER_OVERFLOW_ERROR || err == U_STRING_NOT_TERMINATED_WARNING ) { boost::scoped_array buf_ptr(new char [len+1]); err = U_ZERO_ERROR; @@ -70,11 +70,11 @@ inline void to_utf8(UnicodeString const& input, std::string & target) target.assign(buf, len); } } - + struct value_null {}; - + typedef boost::variant value_base; - + namespace impl { struct equals : public boost::static_visitor @@ -84,24 +84,24 @@ struct equals { return false; } - + template bool operator() (T lhs, T rhs) const { return lhs == rhs; } - + bool operator() (int lhs, double rhs) const { return lhs == rhs; } - + bool operator() (double lhs, int rhs) const { return (lhs == rhs)? true : false ; } - - bool operator() (UnicodeString const& lhs, + + bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const { return (lhs == rhs) ? true: false; @@ -110,10 +110,10 @@ struct equals bool operator() (value_null, value_null) const { // this changed from false to true - https://github.com/mapnik/mapnik/issues/794 - return true; + return true; } }; - + struct not_equals : public boost::static_visitor { @@ -122,24 +122,24 @@ struct not_equals { return true; } - + template bool operator() (T lhs, T rhs) const { return lhs != rhs; } - + bool operator() (int lhs, double rhs) const { return lhs != rhs; } - + bool operator() (double lhs, int rhs) const { return lhs != rhs; } - - bool operator() (UnicodeString const& lhs, + + bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const { return (lhs != rhs)? true : false; @@ -174,23 +174,23 @@ struct greater_than { return false; } - + template bool operator()(T lhs, T rhs) const { return lhs > rhs; } - + bool operator() (int lhs, double rhs) const { return lhs > rhs; } - + bool operator() (double lhs, int rhs) const { return lhs > rhs; } - + bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const { return (lhs > rhs) ? true : false ; @@ -201,32 +201,32 @@ struct greater_than return false; } }; - + struct greater_or_equal : public boost::static_visitor -{ +{ template bool operator()(const T &, const U &) const { return false; } - + template bool operator() (T lhs, T rhs) const { return lhs >= rhs; } - + bool operator() (int lhs, double rhs) const { return lhs >= rhs; } - + bool operator() (double lhs, int rhs) const { return lhs >= rhs; } - + bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const { return ( lhs >= rhs ) ? true : false ; @@ -237,33 +237,33 @@ struct greater_or_equal return false; } }; - + struct less_than : public boost::static_visitor -{ +{ template bool operator()(const T &, const U &) const { return false; } - + template bool operator()(T lhs, T rhs) const { return lhs < rhs; } - + bool operator() (int lhs, double rhs) const { return lhs < rhs; } - + bool operator() (double lhs, int rhs) const { return lhs < rhs; } - - bool operator()(UnicodeString const& lhs, + + bool operator()(UnicodeString const& lhs, UnicodeString const& rhs ) const { return (lhs < rhs) ? true : false ; @@ -277,30 +277,30 @@ struct less_than struct less_or_equal : public boost::static_visitor -{ +{ template bool operator()(const T &, const U &) const { return false; } - + template bool operator()(T lhs, T rhs) const { return lhs <= rhs; } - + bool operator() (int lhs, double rhs) const { return lhs <= rhs; } - + bool operator() (double lhs, int rhs) const { return lhs <= rhs; } - - bool operator()(UnicodeString const& lhs, + + bool operator()(UnicodeString const& lhs, UnicodeString const& rhs ) const { return (lhs <= rhs) ? true : false ; @@ -311,29 +311,29 @@ struct less_or_equal return false; } }; - + template struct add : public boost::static_visitor -{ +{ typedef V value_type; - + template value_type operator() (T lhs, T rhs) const { return lhs + rhs ; } - - value_type operator() (UnicodeString const& lhs , + + value_type operator() (UnicodeString const& lhs , UnicodeString const& rhs ) const { return lhs + rhs; } - + value_type operator() (double lhs, int rhs) const { return lhs + rhs; } - + value_type operator() (int lhs, double rhs) const { return lhs + rhs; @@ -354,7 +354,7 @@ struct add : public boost::static_visitor out << lhs; return UnicodeString(out.str().c_str()) + rhs; } - + template value_type operator() (T1 const& lhs, T2 const&) const { @@ -364,7 +364,7 @@ struct add : public boost::static_visitor template struct sub : public boost::static_visitor -{ +{ typedef V value_type; template value_type operator() (T1 const& lhs, T2 const&) const @@ -383,21 +383,21 @@ struct sub : public boost::static_visitor { return lhs; } - + value_type operator() (double lhs, int rhs) const { return lhs - rhs; } - + value_type operator() (int lhs, double rhs) const { return lhs - rhs; } }; - + template struct mult : public boost::static_visitor -{ +{ typedef V value_type; template value_type operator() (T1 const& lhs , T2 const& ) const @@ -409,18 +409,18 @@ struct mult : public boost::static_visitor { return lhs * rhs; } - + value_type operator() (UnicodeString const& lhs, UnicodeString const& ) const { return lhs; - } - + } + value_type operator() (double lhs, int rhs) const { return lhs * rhs; } - + value_type operator() (int lhs, double rhs) const { return lhs * rhs; @@ -429,38 +429,38 @@ struct mult : public boost::static_visitor template struct div: public boost::static_visitor -{ +{ typedef V value_type; template value_type operator() (T1 const& lhs, T2 const&) const { return lhs; } - + template value_type operator() (T lhs, T rhs) const { return lhs / rhs; } - + value_type operator() (bool lhs, bool rhs ) const { boost::ignore_unused_variable_warning(lhs); boost::ignore_unused_variable_warning(rhs); return false; } - + value_type operator() (UnicodeString const& lhs, UnicodeString const&) const { return lhs; } - + value_type operator() (double lhs, int rhs) const { return lhs / rhs; } - + value_type operator() (int lhs, double rhs) const { return lhs / rhs; @@ -469,26 +469,26 @@ struct div: public boost::static_visitor template struct mod: public boost::static_visitor -{ +{ typedef V value_type; template value_type operator() (T1 const& lhs, T2 const&) const { return lhs; } - + template value_type operator() (T lhs, T rhs) const { return lhs % rhs; } - + value_type operator() (UnicodeString const& lhs, UnicodeString const&) const { return lhs; } - + value_type operator() (bool lhs, bool rhs) const { @@ -496,36 +496,36 @@ struct mod: public boost::static_visitor boost::ignore_unused_variable_warning(rhs); return false; } - + value_type operator() (double lhs, int rhs) const { return std::fmod(lhs, rhs); } - + value_type operator() (int lhs, double rhs) const { return std::fmod(lhs, rhs); } - + value_type operator() (double lhs, double rhs) const { return std::fmod(lhs, rhs); } }; - + struct to_bool : public boost::static_visitor { bool operator() (bool val) const { return val; } - + bool operator() (UnicodeString const& ustr) const { boost::ignore_unused_variable_warning(ustr); return true; } - + bool operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); @@ -541,7 +541,7 @@ struct to_bool : public boost::static_visitor struct to_string : public boost::static_visitor { - + template std::string operator() (T val) const { @@ -549,21 +549,21 @@ struct to_string : public boost::static_visitor ss << val; return ss.str(); } - // specializations + // specializations std::string operator() (UnicodeString const& val) const { std::string utf8; to_utf8(val,utf8); return utf8; } - + std::string operator() (double val) const { std::stringstream ss; ss << std::setprecision(16) << val; return ss.str(); } - + std::string operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); @@ -573,7 +573,7 @@ struct to_string : public boost::static_visitor struct to_unicode : public boost::static_visitor { - + template UnicodeString operator() (T val) const { @@ -582,7 +582,7 @@ struct to_unicode : public boost::static_visitor return UnicodeString(out.str().c_str()); } - // specializations + // specializations UnicodeString const& operator() (UnicodeString const& val) const { return val; @@ -594,14 +594,14 @@ struct to_unicode : public boost::static_visitor out << std::setprecision(16) << val; return UnicodeString(out.str().c_str()); } - + UnicodeString operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); return UnicodeString(""); } }; - + struct to_expression_string : public boost::static_visitor { std::string operator() (UnicodeString const& val) const @@ -609,8 +609,8 @@ struct to_expression_string : public boost::static_visitor std::string utf8; to_utf8(val,utf8); return "'" + utf8 + "'"; - } - + } + std::string operator() (double val) const { std::stringstream ss; @@ -628,7 +628,7 @@ struct to_expression_string : public boost::static_visitor boost::ignore_unused_variable_warning(val); return "null"; } - + template std::string operator() (T val) const { @@ -653,14 +653,14 @@ struct to_double : public boost::static_visitor double operator() (std::string const& val) const { return boost::lexical_cast(val); - } + } double operator() (UnicodeString const& val) const { std::string utf8; to_utf8(val,utf8); return boost::lexical_cast(utf8); - } - + } + double operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); @@ -683,14 +683,14 @@ struct to_int : public boost::static_visitor int operator() (std::string const& val) const { return boost::lexical_cast(val); - } + } int operator() (UnicodeString const& val) const { std::string utf8; to_utf8(val,utf8); return boost::lexical_cast(utf8); - } - + } + int operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); @@ -708,11 +708,11 @@ class value friend const value operator*(value const&,value const&); friend const value operator/(value const&,value const&); friend const value operator%(value const&,value const&); - + public: value () : base_(value_null()) {} - + template value(T _val_) : base_(_val_) {} @@ -725,7 +725,7 @@ public: { return boost::apply_visitor(impl::not_equals(),base_,other.base_); } - + bool operator>(value const& other) const { return boost::apply_visitor(impl::greater_than(),base_,other.base_); @@ -745,7 +745,7 @@ public: { return boost::apply_visitor(impl::less_or_equal(),base_,other.base_); } - + value_base const& base() const { return base_; @@ -765,7 +765,7 @@ public: { return boost::apply_visitor(impl::to_string(),base_); } - + UnicodeString to_unicode() const { return boost::apply_visitor(impl::to_unicode(),base_); @@ -782,7 +782,7 @@ public: } }; - + inline const value operator+(value const& p1,value const& p2) { @@ -814,12 +814,12 @@ inline const value operator%(value const& p1,value const& p2) } template -inline std::basic_ostream& +inline std::basic_ostream& operator << (std::basic_ostream& out, value const& v) { out << v.to_string(); - return out; + return out; } } diff --git a/include/mapnik/value_error.hpp b/include/mapnik/value_error.hpp index 22a692946..7239dd450 100644 --- a/include/mapnik/value_error.hpp +++ b/include/mapnik/value_error.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -41,7 +41,7 @@ public: virtual const char * what() const throw() { - return what_.c_str(); + return what_.c_str(); } void append_context(const std::string & ctx) const diff --git a/include/mapnik/version.hpp b/include/mapnik/version.hpp index dd69d20bd..b79c0f666 100644 --- a/include/mapnik/version.hpp +++ b/include/mapnik/version.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/vertex.hpp b/include/mapnik/vertex.hpp index 4e2ba3753..a41484cff 100644 --- a/include/mapnik/vertex.hpp +++ b/include/mapnik/vertex.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -25,7 +25,7 @@ #include -namespace mapnik +namespace mapnik { enum CommandType { @@ -34,20 +34,20 @@ enum CommandType { SEG_LINETO=2, SEG_CLOSE =3 }; - + template struct vertex { typedef T coord_type; }; - + template -struct vertex +struct vertex { typedef T coord_type; coord_type x; coord_type y; unsigned cmd; - vertex() + vertex() : x(0),y(0),cmd(SEG_END) {} vertex(coord_type x,coord_type y,unsigned cmd) : x(x),y(y),cmd(cmd) {} @@ -57,7 +57,7 @@ struct vertex : x(coord_type(rhs.x)), y(coord_type(rhs.y)), cmd(rhs.cmd) {} - + template vertex operator=(const vertex& rhs) { if ((void*)this == (void*)&rhs) @@ -68,12 +68,12 @@ struct vertex y=coord_type(rhs.y); cmd=rhs.cmd; return *this; - } + } }; - + typedef vertex vertex2d; typedef vertex vertex2i; - + template inline std::basic_ostream& operator << (std::basic_ostream& out, @@ -103,7 +103,7 @@ operator << (std::basic_ostream& out, s<<"vertex3("< -struct Shift +struct Shift { typedef T0 value_type; typedef T1 return_type; @@ -65,27 +65,27 @@ struct Shift typedef Shift NO_SHIFT; typedef Shift SHIFT0; typedef Shift SHIFT8; - - + + template struct view_transform; - + template -struct view_transform +struct view_transform { - + }; - + template -struct view_transform +struct view_transform { - + }; template struct view_transform,box2d,Trans> { - + }; } diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp index 9e95e1eb7..1ad237402 100644 --- a/include/mapnik/vertex_vector.hpp +++ b/include/mapnik/vertex_vector.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -20,9 +20,9 @@ * *****************************************************************************/ // Credits: -// I gratefully acknowledge the inspiring work of Maxim Shemanarev (McSeem), -// author of Anti-Grain Geometry (http://www.antigrain.com). I have used -// the datastructure from AGG as a template for my own. +// I gratefully acknowledge the inspiring work of Maxim Shemanarev (McSeem), +// author of Anti-Grain Geometry (http://www.antigrain.com). I have used +// the datastructure from AGG as a template for my own. #ifndef MAPNIK_VERTEX_VECTOR_HPP #define MAPNIK_VERTEX_VECTOR_HPP @@ -34,7 +34,7 @@ #include #include -#include // required for memcpy with linux/g++ +#include // required for memcpy with linux/g++ namespace mapnik { @@ -44,7 +44,7 @@ class vertex_vector : private boost::noncopyable { typedef T coord_type; typedef vertex vertex_type; - + enum block_e { block_shift = 8, block_size = 1< value_type; - - vertex_vector() + + vertex_vector() : num_blocks_(0), max_blocks_(0), vertices_(0), @@ -83,11 +83,11 @@ public: ::operator delete(vertices_); } } - unsigned size() const + unsigned size() const { return pos_; } - + void push_back (coord_type x,coord_type y,unsigned command) { unsigned block = pos_ >> block_shift; @@ -97,7 +97,7 @@ public: } coord_type* vertex = vertices_[block] + ((pos_ & block_mask) << 1); unsigned char* cmd= commands_[block] + (pos_ & block_mask); - + *cmd = static_cast(command); *vertex++ = x; *vertex = y; @@ -112,18 +112,18 @@ public: *y = (*vertex); return commands_[block] [pos & block_mask]; } - + void set_capacity(size_t) { //do nothing } - + private: void allocate_block(unsigned block) { if (block >= max_blocks_) { - coord_type** new_vertices = + coord_type** new_vertices = static_cast(::operator new (sizeof(coord_type*)*((max_blocks_ + grow_by) * 2))); unsigned char** new_commands = (unsigned char**)(new_vertices + max_blocks_ + grow_by); if (vertices_) @@ -138,7 +138,7 @@ private: } vertices_[block] = static_cast (::operator new(sizeof(coord_type)*(block_size * 2 + block_size / (sizeof(coord_type))))); - + commands_[block] = (unsigned char*)(vertices_[block] + block_size*2); ++num_blocks_; } diff --git a/include/mapnik/warp.hpp b/include/mapnik/warp.hpp index 4fc30877d..035df63c0 100644 --- a/include/mapnik/warp.hpp +++ b/include/mapnik/warp.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp index 55df4d102..a7284bb30 100644 --- a/include/mapnik/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -36,12 +36,12 @@ namespace mapnik /*! * From wikipedia.com: * - * Well-known text (WKT) is a text markup language for representing vector - * geometry objects on a map, spatial reference systems of spatial objects + * Well-known text (WKT) is a text markup language for representing vector + * geometry objects on a map, spatial reference systems of spatial objects * and transformations between spatial reference systems. A binary equivalent, - * known as well-known binary (WKB) is used to transfer and store the same - * information on databases, such as PostGIS. The formats are regulated by - * the Open Geospatial Consortium (OGC) and described in their Simple Feature + * known as well-known binary (WKB) is used to transfer and store the same + * information on databases, such as PostGIS. The formats are regulated by + * the Open Geospatial Consortium (OGC) and described in their Simple Feature * Access and Coordinate Transformation Service specifications. */ enum wkbFormat diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index cfdb2ba00..0ed4c1868 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,7 +30,7 @@ // stl #include -namespace mapnik { +namespace mapnik { MAPNIK_DECL bool from_wkt(std::string const& wkt, boost::ptr_vector & paths); diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 1c7bc4b30..cd5967b28 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -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 - struct result + struct push_vertex { - typedef void type; + template + struct result + { + typedef void type; + }; + + template + void operator() (T0 c, T1 path, T2 x, T3 y) const + { + BOOST_ASSERT( path!=0 ); + path->push_vertex(x,y,c); + } }; - - template - void operator() (T0 c, T1 path, T2 x, T3 y) const - { - BOOST_ASSERT( path!=0 ); - path->push_vertex(x,y,c); - } -}; -struct cleanup -{ - template - struct result + struct cleanup { - typedef void type; + template + struct result + { + typedef void type; + }; + + template + void operator() (T0 & path) const + { + if (path) delete path,path=0; + } }; - - template - void operator() (T0 & path) const - { - if (path) delete path,path=0; - } -}; -template -struct wkt_grammar : qi::grammar() , 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 - ; - - // ::= point - point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] - >> ( point_text(_a) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; - - // ::= | - point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) - | empty_set - ; - - // ::= linestring - linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] - >> (linestring_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; - - // ::= | { }* - linestring_text = points(_r1) | empty_set - ; - - // ::= polygon - polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] - >> ( polygon_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; - - // ::= | { }* - polygon_text = (lit('(') >> linestring_text(_r1) % lit(',') >> lit(')')) | empty_set; - - - // ::= multipoint - multipoint_tagged_text = no_case[lit("MULTIPOINT")] - >> multipoint_text - ; - - // ::= | { }* - multipoint_text = (lit('(') - >> ((eps[_a = new_(Point)] - >> (point_text(_a) | empty_set) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) % lit(',')) - >> lit(')')) | empty_set - ; - - // ::= multilinestring - multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] - >> multilinestring_text ; - - // ::= | { }* - multilinestring_text = (lit('(') - >> ((eps[_a = new_(LineString)] - >> ( points(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false])) - % lit(',')) - >> lit(')')) | empty_set; - - // ::= multipolygon - multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] - >> multipolygon_text ; - - // ::= | { }* - - multipolygon_text = (lit('(') - >> ((eps[_a = new_(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)]; - - // - empty_set = no_case[lit("EMPTY")]; + template + struct wkt_grammar : qi::grammar() , 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 + ; - // start - qi::rule(),ascii::space_type> geometry_tagged_text; - - qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; - qi::rule(),ascii::space_type> multipoint_tagged_text; - qi::rule(),ascii::space_type> multilinestring_tagged_text; - qi::rule(),ascii::space_type> multipolygon_tagged_text; - // - qi::rule point_text; - qi::rule linestring_text; - qi::rule polygon_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; - // - qi::rule point; - qi::rule,void(geometry_type*),ascii::space_type> points; - qi::rule empty_set; - boost::phoenix::function push_vertex_; - boost::phoenix::function cleanup_; -}; + // ::= point + point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] + >> ( point_text(_a) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; + + // ::= | + point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) + | empty_set + ; + + // ::= linestring + linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] + >> (linestring_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; + + // ::= | { }* + linestring_text = points(_r1) | empty_set + ; + + // ::= polygon + polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] + >> ( polygon_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; + + // ::= | { }* + polygon_text = (lit('(') >> linestring_text(_r1) % lit(',') >> lit(')')) | empty_set; + + + // ::= multipoint + multipoint_tagged_text = no_case[lit("MULTIPOINT")] + >> multipoint_text + ; + + // ::= | { }* + multipoint_text = (lit('(') + >> ((eps[_a = new_(Point)] + >> (point_text(_a) | empty_set) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) % lit(',')) + >> lit(')')) | empty_set + ; + + // ::= multilinestring + multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] + >> multilinestring_text ; + + // ::= | { }* + multilinestring_text = (lit('(') + >> ((eps[_a = new_(LineString)] + >> ( points(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false])) + % lit(',')) + >> lit(')')) | empty_set; + + // ::= multipolygon + multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] + >> multipolygon_text ; + + // ::= | { }* + + multipolygon_text = (lit('(') + >> ((eps[_a = new_(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)]; + + // + empty_set = no_case[lit("EMPTY")]; + + } + + // start + qi::rule(),ascii::space_type> geometry_tagged_text; + + qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; + qi::rule(),ascii::space_type> multipoint_tagged_text; + qi::rule(),ascii::space_type> multilinestring_tagged_text; + qi::rule(),ascii::space_type> multipolygon_tagged_text; + // + qi::rule point_text; + qi::rule linestring_text; + qi::rule polygon_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; + // + qi::rule point; + qi::rule,void(geometry_type*),ascii::space_type> points; + qi::rule empty_set; + boost::phoenix::function push_vertex_; + boost::phoenix::function cleanup_; + }; template @@ -201,14 +201,14 @@ struct wkt_collection_grammar : qi::grammar> (lit("(") >> wkt % lit(",") >> lit(")")); } - + qi::rule(),ascii::space_type> start; wkt_grammar wkt; }; @@ -221,7 +221,7 @@ struct wkt_stream_grammar : qi::grammar(),ascii::space_type> start; wkt_collection_grammar wkt_collection; }; diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index c76cadc87..d081e1b32 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -39,7 +39,7 @@ #include "agg_renderer_scanline.h" #include "agg_conv_stroke.h" -namespace mapnik +namespace mapnik { template @@ -66,7 +66,7 @@ void agg_renderer::process(building_symbolizer const& sym, ras_ptr->reset(); ras_ptr->gamma(agg::gamma_power()); - + double height = 0.0; expression_ptr height_expr = sym.height(); if (height_expr) @@ -74,7 +74,7 @@ void agg_renderer::process(building_symbolizer const& sym, value_type result = boost::apply_visitor(evaluate(*feature), *height_expr); height = result.to_double() * scale_factor_; } - + for (unsigned i=0;inum_geometries();++i) { geometry_type const& geom = feature->get_geometry(i); @@ -102,7 +102,7 @@ void agg_renderer::process(building_symbolizer const& sym, frame->line_to(x,y); face_segments.push_back(segment_t(x0,y0,x,y)); } - + x0 = x; y0 = y; } @@ -142,7 +142,7 @@ void agg_renderer::process(building_symbolizer const& sym, roof->line_to(x,y+height); } } - + path_type path(t_,*frame,prj_trans); agg::conv_stroke stroke(path); ras_ptr->add_path(stroke); diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 75360a01d..eef72e002 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -58,7 +58,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4); agg::pixfmt_rgba32_plain pixf(buf); - + std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); boost::optional mark = marker_cache::instance()->find(filename,true); @@ -73,7 +73,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, boost::optional pat = (*mark)->get_bitmap_data(); if (!pat) return; - + renderer_base ren_base(pixf); agg::pattern_filter_bilinear_rgba8 filter; pattern_source source(*(*pat)); diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index f0523b054..76d0e3668 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -59,10 +59,10 @@ void agg_renderer::process(line_symbolizer const& sym, unsigned g=col.green(); unsigned b=col.blue(); unsigned a=col.alpha(); - + agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4); agg::pixfmt_rgba32_plain pixf(buf); - + if (sym.get_rasterizer() == RASTERIZER_FAST) { typedef agg::renderer_outline_aa renderer_type; @@ -78,7 +78,7 @@ void agg_renderer::process(line_symbolizer const& sym, rasterizer_type ras(ren); ras.line_join(agg::outline_miter_accurate_join); ras.round_cap(true); - + for (unsigned i=0;inum_geometries();++i) { geometry_type const& geom = feature->get_geometry(i); @@ -94,31 +94,31 @@ void agg_renderer::process(line_symbolizer const& sym, typedef agg::renderer_scanline_aa_solid renderer; agg::scanline_p8 sl; - + ren_base renb(pixf); renderer ren(renb); 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(); for (unsigned i=0;inum_geometries();++i) { @@ -126,7 +126,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (geom.num_points() > 1) { path_type path(t_,geom,prj_trans); - + if (stroke_.has_dash()) { agg::conv_dash dash(path); @@ -135,12 +135,12 @@ void agg_renderer::process(line_symbolizer const& sym, dash_array::const_iterator end = d.end(); for (;itr != end;++itr) { - dash.add_dash(itr->first * scale_factor_, + dash.add_dash(itr->first * scale_factor_, itr->second * scale_factor_); } - + agg::conv_stroke > stroke(dash); - + line_join_e join=stroke_.get_line_join(); if ( join == MITER_JOIN) stroke.generator().line_join(agg::miter_join); @@ -150,7 +150,7 @@ void agg_renderer::process(line_symbolizer const& sym, stroke.generator().line_join(agg::round_join); else stroke.generator().line_join(agg::bevel_join); - + line_cap_e cap=stroke_.get_line_cap(); if (cap == BUTT_CAP) stroke.generator().line_cap(agg::butt_cap); @@ -158,11 +158,11 @@ void agg_renderer::process(line_symbolizer const& sym, stroke.generator().line_cap(agg::square_cap); else stroke.generator().line_cap(agg::round_cap); - + stroke.generator().miter_limit(4.0); stroke.generator().width(stroke_.get_width() * scale_factor_); ras_ptr->add_path(stroke); - + } else { @@ -176,7 +176,7 @@ void agg_renderer::process(line_symbolizer const& sym, stroke.generator().line_join(agg::round_join); else stroke.generator().line_join(agg::bevel_join); - + line_cap_e cap=stroke_.get_line_cap(); if (cap == BUTT_CAP) stroke.generator().line_cap(agg::butt_cap); @@ -184,7 +184,7 @@ void agg_renderer::process(line_symbolizer const& sym, stroke.generator().line_cap(agg::square_cap); else stroke.generator().line_cap(agg::round_cap); - + stroke.generator().miter_limit(4.0); stroke.generator().width(stroke_.get_width() * scale_factor_); ras_ptr->add_path(stroke); @@ -193,7 +193,7 @@ void agg_renderer::process(line_symbolizer const& sym, } } ren.color(agg::rgba8(r, g, b, int(a*stroke_.get_opacity()))); - agg::render_scanlines(*ras_ptr, sl, ren); + agg::render_scanlines(*ras_ptr, sl, ren); } } @@ -203,4 +203,4 @@ template void agg_renderer::process(line_symbolizer const&, proj_transform const&); } - + diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index b69b70639..44a9064f3 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -54,7 +54,7 @@ void agg_renderer::process(markers_symbolizer const& sym, typedef agg::pixfmt_rgba32_plain pixfmt; typedef agg::renderer_base renderer_base; typedef agg::renderer_scanline_aa_solid renderer_solid; - + ras_ptr->reset(); ras_ptr->gamma(agg::gamma_power()); agg::scanline_u8 sl; @@ -71,7 +71,7 @@ void agg_renderer::process(markers_symbolizer const& sym, marker_placement_e placement_method = sym.get_marker_placement(); marker_type_e marker_type = sym.get_marker_type(); metawriter_with_properties writer = sym.get_metawriter(); - + if (!filename.empty()) { boost::optional mark = mapnik::marker_cache::instance()->find(filename, true); @@ -88,8 +88,8 @@ void agg_renderer::process(markers_symbolizer const& sym, double x2 = bbox.maxx(); double y2 = bbox.maxy(); int w = (*mark)->width(); - int h = (*mark)->height(); - + int h = (*mark)->height(); + agg::trans_affine recenter = agg::trans_affine_translation(-0.5*(x1+x2),-0.5*(y1+y2)); tr.transform(&x1,&y1); tr.transform(&x2,&y2); @@ -97,10 +97,10 @@ void agg_renderer::process(markers_symbolizer const& sym, using namespace mapnik::svg; vertex_stl_adapter stl_storage((*marker)->source()); svg_path_adapter svg_path(stl_storage); - svg_renderer, - renderer_solid, - agg::pixfmt_rgba32_plain > svg_renderer(svg_path,(*marker)->attributes()); + svg_renderer, + renderer_solid, + agg::pixfmt_rgba32_plain > svg_renderer(svg_path,(*marker)->attributes()); for (unsigned i=0; inum_geometries(); ++i) { @@ -115,13 +115,13 @@ void agg_renderer::process(markers_symbolizer const& sym, prj_trans.backward(x,y,z); t_.forward(&x,&y); extent.re_center(x,y); - + if (sym.get_allow_overlap() || detector_->has_placement(extent)) { - + render_marker(floor(x - 0.5 * w),floor(y - 0.5 * h) ,**mark,tr, sym.get_opacity()); - + // TODO - impl this for markers? //if (!sym.get_ignore_placement()) // detector_->insert(label_ext); @@ -132,12 +132,12 @@ void agg_renderer::process(markers_symbolizer const& sym, else { path_type path(t_,geom,prj_trans); - markers_placement placement(path, extent, *detector_, - sym.get_spacing() * scale_factor_, - sym.get_max_error(), - sym.get_allow_overlap()); + markers_placement placement(path, extent, *detector_, + sym.get_spacing() * scale_factor_, + sym.get_max_error(), + sym.get_allow_overlap()); double x, y, angle; - + while (placement.get_point(&x, &y, &angle)) { agg::trans_affine matrix = recenter * tr *agg::trans_affine_rotation(angle) * agg::trans_affine_translation(x, y); @@ -166,7 +166,7 @@ void agg_renderer::process(markers_symbolizer const& sym, unsigned s_a=col.alpha(); double w = sym.get_width(); double h = sym.get_height(); - + arrow arrow_; box2d extent; @@ -183,7 +183,7 @@ void agg_renderer::process(markers_symbolizer const& sym, tr.transform(&x1,&y1); tr.transform(&x2,&y2); extent.init(x1,y1,x2,y2); - //std::clog << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; + //std::clog << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; } else { @@ -194,10 +194,10 @@ void agg_renderer::process(markers_symbolizer const& sym, tr.transform(&x1,&y1); tr.transform(&x2,&y2); extent.init(x1,y1,x2,y2); - //std::clog << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; + //std::clog << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; } - + double x; double y; double z=0; @@ -227,7 +227,7 @@ void agg_renderer::process(markers_symbolizer const& sym, // TODO - fill with packed scanlines? agg::scanline_p8 // and agg::renderer_outline_aa agg::render_scanlines(*ras_ptr, sl, ren); - + // outline if (strk_width) { @@ -235,7 +235,7 @@ void agg_renderer::process(markers_symbolizer const& sym, agg::conv_stroke outline(marker); outline.generator().width(strk_width * scale_factor_); ras_ptr->add_path(outline); - + ren.color(agg::rgba8(s_r, s_g, s_b, int(s_a*stroke_.get_opacity()))); agg::render_scanlines(*ras_ptr, sl_line, ren); } @@ -245,17 +245,17 @@ void agg_renderer::process(markers_symbolizer const& sym, } else { - + if (marker_type == ARROW) marker.concat_path(arrow_); path_type path(t_,geom,prj_trans); - markers_placement placement(path, extent, *detector_, - sym.get_spacing() * scale_factor_, - sym.get_max_error(), - sym.get_allow_overlap()); + markers_placement placement(path, extent, *detector_, + sym.get_spacing() * scale_factor_, + sym.get_max_error(), + sym.get_allow_overlap()); double x_t, y_t, angle; - + while (placement.get_point(&x_t, &y_t, &angle)) { agg::trans_affine matrix; @@ -278,7 +278,7 @@ void agg_renderer::process(markers_symbolizer const& sym, } - // TODO + // TODO if (writer.first) //writer.first->add_box(label_ext, feature, t_, writer.second); std::clog << "### Warning metawriter not yet supported for LINE placement\n"; diff --git a/src/agg/process_point_symbolizer.cpp b/src/agg/process_point_symbolizer.cpp index 7dee3054d..3e4f38b99 100644 --- a/src/agg/process_point_symbolizer.cpp +++ b/src/agg/process_point_symbolizer.cpp @@ -49,7 +49,7 @@ void agg_renderer::process(point_symbolizer const& sym, proj_transform const& prj_trans) { std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature); - + boost::optional marker; if ( !filename.empty() ) { @@ -63,7 +63,7 @@ void agg_renderer::process(point_symbolizer const& sym, if (marker) { int w = (*marker)->width(); - int h = (*marker)->height(); + int h = (*marker)->height(); agg::trans_affine tr; boost::array const& m = sym.get_transform(); tr.load_from(&m[0]); @@ -82,7 +82,7 @@ void agg_renderer::process(point_symbolizer const& sym, box2d label_ext (px0, py0, px1, py1); label_ext.expand_to_include(px2, py2); label_ext.expand_to_include(px3, py3); - + for (unsigned i=0; inum_geometries(); ++i) { geometry_type const& geom = feature->get_geometry(i); @@ -97,11 +97,11 @@ void agg_renderer::process(point_symbolizer const& sym, prj_trans.backward(x,y,z); t_.forward(&x,&y); label_ext.re_center(x,y); - + if (sym.get_allow_overlap() || detector_->has_placement(label_ext)) { - + render_marker(floor(x - 0.5 * w),floor(y - 0.5 * h) ,**marker,tr, sym.get_opacity()); if (!sym.get_ignore_placement()) @@ -119,4 +119,4 @@ template void agg_renderer::process(point_symbolizer const&, proj_transform const&); } - + diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index d87f086c2..5867b3fae 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -68,28 +68,28 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4); agg::pixfmt_rgba32_plain pixf(buf); ren_base renb(pixf); - + agg::scanline_u8 sl; 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); @@ -110,12 +110,12 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, std::clog << "### Warning only images (not '" << filename << "') are supported in the polygon_pattern_symbolizer\n"; return; } - + boost::optional pat = (*marker)->get_bitmap_data(); if (!pat) return; - + unsigned w=(*pat)->width(); unsigned h=(*pat)->height(); agg::row_accessor pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4); @@ -123,13 +123,13 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, agg::pixfmt_alpha_blend_rgba, agg::pixel32_type> pixf_pattern(pattern_rbuf); img_source_type img_src(pixf_pattern); - + unsigned num_geometries = feature->num_geometries(); pattern_alignment_e align = sym.get_alignment(); unsigned offset_x=0; unsigned offset_y=0; - + if (align == LOCAL_ALIGNMENT) { double x0=0,y0=0; @@ -139,9 +139,9 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, path.vertex(&x0,&y0); } offset_x = unsigned(width_-x0); - offset_y = unsigned(height_-y0); + offset_y = unsigned(height_-y0); } - + span_gen_type sg(img_src, offset_x, offset_y); renderer_type rp(renb,sa, sg); metawriter_with_properties writer = sym.get_metawriter(); @@ -164,4 +164,4 @@ template void agg_renderer::process(polygon_pattern_symbolizer const&, proj_transform const&); } - + diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index aed9f9e8b..89e389442 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -65,23 +65,23 @@ void agg_renderer::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(); @@ -105,4 +105,4 @@ template void agg_renderer::process(polygon_symbolizer const&, proj_transform const&); } - + diff --git a/src/agg/process_raster_symbolizer.cpp b/src/agg/process_raster_symbolizer.cpp index 3086ed43c..ffcefaa41 100644 --- a/src/agg/process_raster_symbolizer.cpp +++ b/src/agg/process_raster_symbolizer.cpp @@ -50,7 +50,7 @@ void agg_renderer::process(raster_symbolizer const& sym, raster_colorizer_ptr colorizer = sym.get_colorizer(); if (colorizer) colorizer->colorize(source,*feature); - + box2d target_ext = box2d(source->ext_); prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS); @@ -63,7 +63,7 @@ void agg_renderer::process(raster_symbolizer const& sym, int raster_height = end_y - start_y; double err_offs_x = ext.minx() - start_x; double err_offs_y = ext.miny() - start_y; - + if (raster_width > 0 && raster_height > 0) { double scale_factor = ext.width() / source->data_.width(); @@ -75,7 +75,7 @@ void agg_renderer::process(raster_symbolizer const& sym, sym.calculate_filter_factor(), scale_factor, sym.get_scaling()); - + if (sym.get_mode() == "normal"){ if (sym.get_opacity() == 1.0) { pixmap_.set_rectangle_alpha(start_x,start_y,target.data_); diff --git a/src/agg/process_shield_symbolizer.cpp b/src/agg/process_shield_symbolizer.cpp index 63eb27a41..6dad62d7b 100644 --- a/src/agg/process_shield_symbolizer.cpp +++ b/src/agg/process_shield_symbolizer.cpp @@ -42,11 +42,11 @@ void agg_renderer::process(shield_symbolizer const& sym, proj_transform const& prj_trans) { shield_symbolizer_helper, - 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 ren(pixmap_, font_manager_, *(font_manager_.get_stroker())); diff --git a/src/agg/process_text_symbolizer.cpp b/src/agg/process_text_symbolizer.cpp index a8fa1a44e..b31c87723 100644 --- a/src/agg/process_text_symbolizer.cpp +++ b/src/agg/process_text_symbolizer.cpp @@ -34,11 +34,11 @@ void agg_renderer::process(text_symbolizer const& sym, proj_transform const& prj_trans) { text_symbolizer_helper, - 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 ren(pixmap_, font_manager_, *(font_manager_.get_stroker())); @@ -59,4 +59,4 @@ template void agg_renderer::process(text_symbolizer const&, proj_transform const&); } - + diff --git a/src/arrow.cpp b/src/arrow.cpp index 593452e4b..acb85307d 100644 --- a/src/arrow.cpp +++ b/src/arrow.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -28,8 +28,8 @@ namespace mapnik { -arrow::arrow() - : pos_(0) +arrow::arrow() + : pos_(0) { x_[0] = -7.0; y_[0] = 1.0; cmd_[0] = agg::path_cmd_move_to; x_[1] = 1.0; y_[1] = 1.0; cmd_[1] = agg::path_cmd_line_to; @@ -46,7 +46,7 @@ void arrow::rewind(unsigned ) { pos_ = 0; } - + unsigned arrow::vertex(double* x, double* y) { if(pos_ < 7 ) @@ -57,7 +57,7 @@ unsigned arrow::vertex(double* x, double* y) } return agg::path_cmd_stop; } - + box2d arrow::extent() const { return box2d(-7,-3,7,3); diff --git a/src/box2d.cpp b/src/box2d.cpp index 16fe3148b..c6061dc06 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -58,8 +58,8 @@ box2d::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 #if !defined(__SUNPRO_CC) @@ -319,10 +319,10 @@ inline #endif void box2d::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()); } @@ -339,10 +339,10 @@ bool box2d::from_string(const std::string& s) unsigned i = 0; double d[4]; - for (boost::tokenizer >::iterator beg = tok.begin(); + for (boost::tokenizer >::iterator beg = tok.begin(); beg != tok.end(); ++beg) { - try + try { d[i] = boost::lexical_cast(boost::trim_copy(*beg)); } @@ -350,13 +350,13 @@ bool box2d::from_string(const std::string& s) { break; } - - if (i == 3) + + if (i == 3) { success = true; break; } - + ++i; } @@ -364,7 +364,7 @@ bool box2d::from_string(const std::string& s) { init(d[0], d[1], d[2], d[3]); } - + return success; } @@ -384,8 +384,8 @@ box2d& box2d::operator+=(box2d const& other) return *this; } - -template + +template box2d& box2d::operator*=(T t) { coord c = center(); @@ -397,8 +397,8 @@ box2d& box2d::operator*=(T t) maxy_ = c.y + sy; return *this; } - -template + +template box2d& box2d::operator/=(T t) { coord c = center(); @@ -411,7 +411,7 @@ box2d& box2d::operator/=(T t) return *this; } -template +template T box2d::operator[] (int index) const { switch(index) @@ -436,7 +436,7 @@ T box2d::operator[] (int index) const throw std::out_of_range("index out of range, max value is 3, min value is -4 "); } } - + template class box2d; template class box2d; } diff --git a/src/building_symbolizer.cpp b/src/building_symbolizer.cpp index 44baf2701..de6b1456e 100644 --- a/src/building_symbolizer.cpp +++ b/src/building_symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -28,7 +28,7 @@ namespace mapnik { -building_symbolizer::building_symbolizer() +building_symbolizer::building_symbolizer() : symbolizer_base(), fill_(color(128,128,128)), opacity_(1.0) diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index ae6b375db..ef4219a3b 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -93,7 +93,7 @@ public: ~cairo_pattern(void) { } - + void set_matrix(Cairo::Matrix const& matrix) { pattern_->set_matrix(matrix); @@ -102,15 +102,15 @@ public: void set_origin(double x, double y) { Cairo::Matrix matrix; - + pattern_->get_matrix(matrix); - + matrix.x0 = -x; matrix.y0 = -y; - + pattern_->set_matrix(matrix); } - + void set_extend(Cairo::Extend extend) { pattern_->set_extend(extend); @@ -593,7 +593,7 @@ public: faces->set_character_sizes(text_size); glyph_ptr glyph = faces->get_glyph(c); - + if (glyph) { Cairo::Matrix matrix; @@ -661,613 +661,613 @@ void cairo_renderer_base::start_map_processing(Map const& map) std::clog << "start map processing bbox=" << map.get_current_extent() << "\n"; #else -void cairo_renderer_base::start_map_processing(Map const& /*map*/) -{ + void cairo_renderer_base::start_map_processing(Map const& /*map*/) + { #endif #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0) - box2d bounds = t_.forward(t_.extent()); - context_->rectangle(bounds.minx(), bounds.miny(), bounds.maxx(), bounds.maxy()); - context_->clip(); + box2d bounds = t_.forward(t_.extent()); + context_->rectangle(bounds.minx(), bounds.miny(), bounds.maxx(), bounds.maxy()); + context_->clip(); #endif - boost::optional bg = m_.background(); - if (bg) - { - cairo_context context(context_); - context.set_color(*bg); - context.paint(); - } -} - -template <> -void cairo_renderer::end_map_processing(Map const& ) -{ -#ifdef MAPNIK_DEBUG - std::clog << "end map processing\n"; -#endif -} - -template <> -void cairo_renderer::end_map_processing(Map const& ) -{ -#ifdef MAPNIK_DEBUG - std::clog << "end map processing\n"; -#endif - context_->show_page(); -} - -void cairo_renderer_base::start_layer_processing(layer const& lay) -{ -#ifdef MAPNIK_DEBUG - std::clog << "start layer processing : " << lay.name() << "\n"; - std::clog << "datasource = " << lay.datasource().get() << "\n"; -#endif - if (lay.clear_label_cache()) - { - detector_.clear(); - } -} - -void cairo_renderer_base::end_layer_processing(layer const&) -{ -#ifdef MAPNIK_DEBUG - std::clog << "end layer processing\n"; -#endif -} - -void cairo_renderer_base::process(polygon_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - typedef coord_transform2 path_type; - - cairo_context context(context_); - - context.set_color(sym.get_fill(), sym.get_opacity()); - - for (unsigned i = 0; i < feature->num_geometries(); ++i) - { - geometry_type const& geom = feature->get_geometry(i); - - if (geom.num_points() > 2) - { - path_type path(t_, geom, prj_trans); - - context.add_path(path); - context.fill(); - } - } -} - -void cairo_renderer_base::process(building_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - typedef coord_transform2 path_type; - typedef coord_transform3 path_type_roof; - - cairo_context context(context_); - - color const& fill = sym.get_fill(); - double height = 0.0; - expression_ptr height_expr = sym.height(); - if (height_expr) - { - value_type result = boost::apply_visitor(evaluate(*feature), *height_expr); - height = 0.7071 * result.to_double(); - } - - for (unsigned i = 0; i < feature->num_geometries(); ++i) - { - geometry_type const& geom = feature->get_geometry(i); - - if (geom.num_points() > 2) - { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); - std::deque face_segments; - double x0(0); - double y0(0); - - geom.rewind(0); - unsigned cm = geom.vertex(&x0, &y0); - - for (unsigned j = 1; j < geom.num_points(); ++j) - { - double x=0; - double y=0; - - cm = geom.vertex(&x,&y); - - if (cm == SEG_MOVETO) - { - frame->move_to(x,y); - } - else if (cm == SEG_LINETO) - { - frame->line_to(x,y); - } - - if (j != 0) - { - face_segments.push_back(segment_t(x0, y0, x, y)); - } - - x0 = x; - y0 = y; - } - - std::sort(face_segments.begin(), face_segments.end(), y_order); - std::deque::const_iterator itr = face_segments.begin(); - for (; itr != face_segments.end(); ++itr) - { - boost::scoped_ptr faces(new geometry_type(Polygon)); - - faces->move_to(itr->get<0>(), itr->get<1>()); - faces->line_to(itr->get<2>(), itr->get<3>()); - faces->line_to(itr->get<2>(), itr->get<3>() + height); - faces->line_to(itr->get<0>(), itr->get<1>() + height); - - path_type faces_path(t_, *faces, prj_trans); - context.set_color(int(fill.red() * 0.8), int(fill.green() * 0.8), - int(fill.blue() * 0.8), fill.alpha() * sym.get_opacity() / 255.0); - context.add_path(faces_path); - context.fill(); - - frame->move_to(itr->get<0>(), itr->get<1>()); - frame->line_to(itr->get<0>(), itr->get<1>() + height); - - } - - geom.rewind(0); - for (unsigned j = 0; j < geom.num_points(); ++j) - { - double x, y; - unsigned cm = geom.vertex(&x, &y); - - if (cm == SEG_MOVETO) - { - frame->move_to(x, y + height); - roof->move_to(x, y + height); - } - else if (cm == SEG_LINETO) - { - frame->line_to(x, y + height); - roof->line_to(x, y + height); - } - } - - path_type path(t_, *frame, prj_trans); - context.set_color(128, 128, 128, sym.get_opacity()); - context.add_path(path); - context.stroke(); - - path_type roof_path(t_, *roof, prj_trans); - context.set_color(sym.get_fill(), sym.get_opacity()); - context.add_path(roof_path); - context.fill(); - } - } -} - -void cairo_renderer_base::process(line_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - typedef coord_transform2 path_type; - - cairo_context context(context_); - mapnik::stroke const& stroke_ = sym.get_stroke(); - - context.set_color(stroke_.get_color(), stroke_.get_opacity()); - - for (unsigned i = 0; i < feature->num_geometries(); ++i) - { - geometry_type const& geom = feature->get_geometry(i); - - if (geom.num_points() > 1) + boost::optional bg = m_.background(); + if (bg) { cairo_context context(context_); - path_type path(t_, geom, prj_trans); - - if (stroke_.has_dash()) - { - context.set_dash(stroke_.get_dash_array()); - } - - context.set_line_join(stroke_.get_line_join()); - context.set_line_cap(stroke_.get_line_cap()); - context.set_miter_limit(4.0); - context.set_line_width(stroke_.get_width()); - context.add_path(path); - context.stroke(); + context.set_color(*bg); + context.paint(); } } -} -void cairo_renderer_base::render_marker(const int x, const int y, marker &marker, const agg::trans_affine & tr, double opacity) - -{ - cairo_context context(context_); - if (marker.is_vector()) + template <> + void cairo_renderer::end_map_processing(Map const& ) { - box2d bbox; - bbox = (*marker.get_vector_data())->bounding_box(); +#ifdef MAPNIK_DEBUG + std::clog << "end map processing\n"; +#endif + } - coord c = bbox.center(); - // center the svg marker on '0,0' - agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); - // apply symbol transformation to get to map space - mtx *= tr; - // render the marker at the center of the marker box - mtx.translate(x+0.5 * marker.width(), y+0.5 * marker.height()); + template <> + void cairo_renderer::end_map_processing(Map const& ) + { +#ifdef MAPNIK_DEBUG + std::clog << "end map processing\n"; +#endif + context_->show_page(); + } - typedef coord_transform2 path_type; - mapnik::path_ptr vmarker = *marker.get_vector_data(); - - agg::pod_bvector const & attributes_ = vmarker->attributes(); - for(unsigned i = 0; i < attributes_.size(); ++i) + void cairo_renderer_base::start_layer_processing(layer const& lay) + { +#ifdef MAPNIK_DEBUG + std::clog << "start layer processing : " << lay.name() << "\n"; + std::clog << "datasource = " << lay.datasource().get() << "\n"; +#endif + if (lay.clear_label_cache()) { - mapnik::svg::path_attributes const& attr = attributes_[i]; - if (!attr.visibility_flag) - continue; - - context.save(); - - agg::trans_affine transform = attr.transform; - transform *= mtx; - - if (transform.is_valid() && !transform.is_identity()) - { - double m[6]; - transform.store_to(m); - context.transform(Cairo::Matrix(m[0],m[1],m[2],m[3],m[4],m[5])); - } - - vertex_stl_adapter stl_storage(vmarker->source()); - svg_path_adapter svg_path(stl_storage); - - if (attr.fill_flag || attr.fill_gradient.get_gradient_type() != NO_GRADIENT) - { - context.add_agg_path(svg_path,attr.index); - if (attr.even_odd_flag) - { - context.set_fill_rule(Cairo::FILL_RULE_EVEN_ODD); - } - else - { - context.set_fill_rule(Cairo::FILL_RULE_WINDING); - } - if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT) - { - cairo_gradient g(attr.fill_gradient,attr.opacity*opacity); - - context.set_gradient(g,bbox); - context.fill(); - } - else if(attr.fill_flag) - { - context.set_color(attr.fill_color.r,attr.fill_color.g,attr.fill_color.b,attr.opacity*opacity); - context.fill(); - } - } - - - if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT || attr.stroke_flag) - { - context.add_agg_path(svg_path,attr.index); - if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT) - { - context.set_line_width(attr.stroke_width); - context.set_line_cap(line_cap_enum(attr.line_cap)); - context.set_line_join(line_join_enum(attr.line_join)); - context.set_miter_limit(attr.miter_limit); - cairo_gradient g(attr.stroke_gradient,attr.opacity*opacity); - context.set_gradient(g,bbox); - context.stroke(); - } - else if(attr.stroke_flag) - { - context.set_color(attr.stroke_color.r,attr.stroke_color.g,attr.stroke_color.b,attr.opacity*opacity); - context.set_line_width(attr.stroke_width); - context.set_line_cap(line_cap_enum(attr.line_cap)); - context.set_line_join(line_join_enum(attr.line_join)); - context.set_miter_limit(attr.miter_limit); - context.stroke(); - } - } - - context.restore(); + detector_.clear(); } } - else if (marker.is_bitmap()) - { - context.add_image(x, y, **marker.get_bitmap_data(), opacity); - } -} -void cairo_renderer_base::process(point_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); - - boost::optional marker; - if ( !filename.empty() ) + void cairo_renderer_base::end_layer_processing(layer const&) { - marker = marker_cache::instance()->find(filename, true); - } - else - { - marker.reset(boost::make_shared()); +#ifdef MAPNIK_DEBUG + std::clog << "end layer processing\n"; +#endif } - if (marker) + void cairo_renderer_base::process(polygon_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) { + typedef coord_transform2 path_type; + + cairo_context context(context_); + + context.set_color(sym.get_fill(), sym.get_opacity()); + for (unsigned i = 0; i < feature->num_geometries(); ++i) { geometry_type const& geom = feature->get_geometry(i); - double x; - double y; - double z = 0; - if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT) - geom.label_position(&x, &y); - else - geom.label_interior_position(&x, &y); - - prj_trans.backward(x, y, z); - t_.forward(&x, &y); - - int w = (*marker)->width(); - int h = (*marker)->height(); - - int px = int(floor(x - 0.5 * w)); - int py = int(floor(y - 0.5 * h)); - box2d label_ext (px, py, px + w, py + h); - if (sym.get_allow_overlap() || - detector_.has_placement(label_ext)) + if (geom.num_points() > 2) { - agg::trans_affine mtx; - boost::array const& m = sym.get_transform(); - mtx.load_from(&m[0]); + path_type path(t_, geom, prj_trans); - render_marker(px,py,**marker, mtx, sym.get_opacity()); + context.add_path(path); + context.fill(); + } + } + } - if (!sym.get_ignore_placement()) - detector_.insert(label_ext); - metawriter_with_properties writer = sym.get_metawriter(); - if (writer.first) + void cairo_renderer_base::process(building_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) + { + typedef coord_transform2 path_type; + typedef coord_transform3 path_type_roof; + + cairo_context context(context_); + + color const& fill = sym.get_fill(); + double height = 0.0; + expression_ptr height_expr = sym.height(); + if (height_expr) + { + value_type result = boost::apply_visitor(evaluate(*feature), *height_expr); + height = 0.7071 * result.to_double(); + } + + for (unsigned i = 0; i < feature->num_geometries(); ++i) + { + geometry_type const& geom = feature->get_geometry(i); + + if (geom.num_points() > 2) + { + boost::scoped_ptr frame(new geometry_type(LineString)); + boost::scoped_ptr roof(new geometry_type(Polygon)); + std::deque face_segments; + double x0(0); + double y0(0); + + geom.rewind(0); + unsigned cm = geom.vertex(&x0, &y0); + + for (unsigned j = 1; j < geom.num_points(); ++j) { - writer.first->add_box(label_ext, *feature, t_, writer.second); + double x=0; + double y=0; + + cm = geom.vertex(&x,&y); + + if (cm == SEG_MOVETO) + { + frame->move_to(x,y); + } + else if (cm == SEG_LINETO) + { + frame->line_to(x,y); + } + + if (j != 0) + { + face_segments.push_back(segment_t(x0, y0, x, y)); + } + + x0 = x; + y0 = y; + } + + std::sort(face_segments.begin(), face_segments.end(), y_order); + std::deque::const_iterator itr = face_segments.begin(); + for (; itr != face_segments.end(); ++itr) + { + boost::scoped_ptr faces(new geometry_type(Polygon)); + + faces->move_to(itr->get<0>(), itr->get<1>()); + faces->line_to(itr->get<2>(), itr->get<3>()); + faces->line_to(itr->get<2>(), itr->get<3>() + height); + faces->line_to(itr->get<0>(), itr->get<1>() + height); + + path_type faces_path(t_, *faces, prj_trans); + context.set_color(int(fill.red() * 0.8), int(fill.green() * 0.8), + int(fill.blue() * 0.8), fill.alpha() * sym.get_opacity() / 255.0); + context.add_path(faces_path); + context.fill(); + + frame->move_to(itr->get<0>(), itr->get<1>()); + frame->line_to(itr->get<0>(), itr->get<1>() + height); + + } + + geom.rewind(0); + for (unsigned j = 0; j < geom.num_points(); ++j) + { + double x, y; + unsigned cm = geom.vertex(&x, &y); + + if (cm == SEG_MOVETO) + { + frame->move_to(x, y + height); + roof->move_to(x, y + height); + } + else if (cm == SEG_LINETO) + { + frame->line_to(x, y + height); + roof->line_to(x, y + height); + } + } + + path_type path(t_, *frame, prj_trans); + context.set_color(128, 128, 128, sym.get_opacity()); + context.add_path(path); + context.stroke(); + + path_type roof_path(t_, *roof, prj_trans); + context.set_color(sym.get_fill(), sym.get_opacity()); + context.add_path(roof_path); + context.fill(); + } + } + } + + void cairo_renderer_base::process(line_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) + { + typedef coord_transform2 path_type; + + cairo_context context(context_); + mapnik::stroke const& stroke_ = sym.get_stroke(); + + context.set_color(stroke_.get_color(), stroke_.get_opacity()); + + for (unsigned i = 0; i < feature->num_geometries(); ++i) + { + geometry_type const& geom = feature->get_geometry(i); + + if (geom.num_points() > 1) + { + cairo_context context(context_); + path_type path(t_, geom, prj_trans); + + if (stroke_.has_dash()) + { + context.set_dash(stroke_.get_dash_array()); + } + + context.set_line_join(stroke_.get_line_join()); + context.set_line_cap(stroke_.get_line_cap()); + context.set_miter_limit(4.0); + context.set_line_width(stroke_.get_width()); + context.add_path(path); + context.stroke(); + } + } + } + + void cairo_renderer_base::render_marker(const int x, const int y, marker &marker, const agg::trans_affine & tr, double opacity) + + { + cairo_context context(context_); + if (marker.is_vector()) + { + box2d bbox; + bbox = (*marker.get_vector_data())->bounding_box(); + + coord c = bbox.center(); + // center the svg marker on '0,0' + agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); + // apply symbol transformation to get to map space + mtx *= tr; + // render the marker at the center of the marker box + mtx.translate(x+0.5 * marker.width(), y+0.5 * marker.height()); + + typedef coord_transform2 path_type; + mapnik::path_ptr vmarker = *marker.get_vector_data(); + + agg::pod_bvector const & attributes_ = vmarker->attributes(); + for(unsigned i = 0; i < attributes_.size(); ++i) + { + mapnik::svg::path_attributes const& attr = attributes_[i]; + if (!attr.visibility_flag) + continue; + + context.save(); + + agg::trans_affine transform = attr.transform; + transform *= mtx; + + if (transform.is_valid() && !transform.is_identity()) + { + double m[6]; + transform.store_to(m); + context.transform(Cairo::Matrix(m[0],m[1],m[2],m[3],m[4],m[5])); + } + + vertex_stl_adapter stl_storage(vmarker->source()); + svg_path_adapter svg_path(stl_storage); + + if (attr.fill_flag || attr.fill_gradient.get_gradient_type() != NO_GRADIENT) + { + context.add_agg_path(svg_path,attr.index); + if (attr.even_odd_flag) + { + context.set_fill_rule(Cairo::FILL_RULE_EVEN_ODD); + } + else + { + context.set_fill_rule(Cairo::FILL_RULE_WINDING); + } + if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT) + { + cairo_gradient g(attr.fill_gradient,attr.opacity*opacity); + + context.set_gradient(g,bbox); + context.fill(); + } + else if(attr.fill_flag) + { + context.set_color(attr.fill_color.r,attr.fill_color.g,attr.fill_color.b,attr.opacity*opacity); + context.fill(); + } + } + + + if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT || attr.stroke_flag) + { + context.add_agg_path(svg_path,attr.index); + if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT) + { + context.set_line_width(attr.stroke_width); + context.set_line_cap(line_cap_enum(attr.line_cap)); + context.set_line_join(line_join_enum(attr.line_join)); + context.set_miter_limit(attr.miter_limit); + cairo_gradient g(attr.stroke_gradient,attr.opacity*opacity); + context.set_gradient(g,bbox); + context.stroke(); + } + else if(attr.stroke_flag) + { + context.set_color(attr.stroke_color.r,attr.stroke_color.g,attr.stroke_color.b,attr.opacity*opacity); + context.set_line_width(attr.stroke_width); + context.set_line_cap(line_cap_enum(attr.line_cap)); + context.set_line_join(line_join_enum(attr.line_join)); + context.set_miter_limit(attr.miter_limit); + context.stroke(); + } + } + + context.restore(); + } + } + else if (marker.is_bitmap()) + { + context.add_image(x, y, **marker.get_bitmap_data(), opacity); + } + } + + void cairo_renderer_base::process(point_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) + { + std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); + + boost::optional marker; + if ( !filename.empty() ) + { + marker = marker_cache::instance()->find(filename, true); + } + else + { + marker.reset(boost::make_shared()); + } + + if (marker) + { + for (unsigned i = 0; i < feature->num_geometries(); ++i) + { + geometry_type const& geom = feature->get_geometry(i); + double x; + double y; + double z = 0; + + if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT) + geom.label_position(&x, &y); + else + geom.label_interior_position(&x, &y); + + prj_trans.backward(x, y, z); + t_.forward(&x, &y); + + int w = (*marker)->width(); + int h = (*marker)->height(); + + int px = int(floor(x - 0.5 * w)); + int py = int(floor(y - 0.5 * h)); + box2d label_ext (px, py, px + w, py + h); + if (sym.get_allow_overlap() || + detector_.has_placement(label_ext)) + { + agg::trans_affine mtx; + boost::array const& m = sym.get_transform(); + mtx.load_from(&m[0]); + + render_marker(px,py,**marker, mtx, sym.get_opacity()); + + if (!sym.get_ignore_placement()) + detector_.insert(label_ext); + metawriter_with_properties writer = sym.get_metawriter(); + if (writer.first) + { + writer.first->add_box(label_ext, *feature, t_, writer.second); + } } } } } -} -void cairo_renderer_base::process(shield_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - shield_symbolizer_helper, + void cairo_renderer_base::process(shield_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) + { + shield_symbolizer_helper, label_collision_detector4> helper( sym, *feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_); - cairo_context context(context_); + cairo_context context(context_); - text_placement_info_ptr placement; - while ((placement = helper.get_placement())) { - for (unsigned int ii = 0; ii < placement->placements.size(); ++ii) - { - std::pair marker_pos = helper.get_marker_position(placement->placements[ii]); - render_marker(marker_pos.first, marker_pos.second, - helper.get_marker(), helper.get_transform(), - sym.get_opacity()); - context.add_text(placement->placements[ii], face_manager_, font_manager_); - } - } -} - -void cairo_renderer_base::process(line_pattern_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - typedef coord_transform2 path_type; - - std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); - boost::optional marker = mapnik::marker_cache::instance()->find(filename,true); - if (!marker && !(*marker)->is_bitmap()) return; - - unsigned width((*marker)->width()); - unsigned height((*marker)->height()); - - cairo_context context(context_); - cairo_pattern pattern(**((*marker)->get_bitmap_data())); - - pattern.set_extend(Cairo::EXTEND_REPEAT); - pattern.set_filter(Cairo::FILTER_BILINEAR); - context.set_line_width(height); - - for (unsigned i = 0; i < feature->num_geometries(); ++i) - { - geometry_type const& geom = feature->get_geometry(i); - - if (geom.num_points() > 1) - { - path_type path(t_, geom, prj_trans); - double length(0); - double x0(0), y0(0); - double x, y; - - for (unsigned cm = path.vertex(&x, &y); cm != SEG_END; cm = path.vertex(&x, &y)) + text_placement_info_ptr placement; + while ((placement = helper.get_placement())) { + for (unsigned int ii = 0; ii < placement->placements.size(); ++ii) { - if (cm == SEG_MOVETO) - { - length = 0.0; - } - else if (cm == SEG_LINETO) - { - double dx = x - x0; - double dy = y - y0; - double angle = atan2(dy, dx); - double offset = fmod(length, width); - - Cairo::Matrix matrix; - cairo_matrix_init_identity(&matrix); - cairo_matrix_translate(&matrix,x0,y0); - cairo_matrix_rotate(&matrix,angle); - cairo_matrix_translate(&matrix,-offset,0.5*height); - cairo_matrix_invert(&matrix); - - pattern.set_matrix(matrix); - - context.set_pattern(pattern); - - context.move_to(x0, y0); - context.line_to(x, y); - context.stroke(); - - length = length + hypot(x - x0, y - y0); - } - - x0 = x; - y0 = y; + std::pair marker_pos = helper.get_marker_position(placement->placements[ii]); + render_marker(marker_pos.first, marker_pos.second, + helper.get_marker(), helper.get_transform(), + sym.get_opacity()); + context.add_text(placement->placements[ii], face_manager_, font_manager_); } } } -} -void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - typedef coord_transform2 path_type; - - cairo_context context(context_); - std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); - boost::optional marker = mapnik::marker_cache::instance()->find(filename,true); - if (!marker && !(*marker)->is_bitmap()) return; - - cairo_pattern pattern(**((*marker)->get_bitmap_data())); - - pattern.set_extend(Cairo::EXTEND_REPEAT); - - context.set_pattern(pattern); - - for (unsigned i = 0; i < feature->num_geometries(); ++i) + void cairo_renderer_base::process(line_pattern_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) { - geometry_type const& geom = feature->get_geometry(i); + typedef coord_transform2 path_type; - if (geom.num_points() > 2) + std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); + boost::optional marker = mapnik::marker_cache::instance()->find(filename,true); + if (!marker && !(*marker)->is_bitmap()) return; + + unsigned width((*marker)->width()); + unsigned height((*marker)->height()); + + cairo_context context(context_); + cairo_pattern pattern(**((*marker)->get_bitmap_data())); + + pattern.set_extend(Cairo::EXTEND_REPEAT); + pattern.set_filter(Cairo::FILTER_BILINEAR); + context.set_line_width(height); + + for (unsigned i = 0; i < feature->num_geometries(); ++i) { - path_type path(t_, geom, prj_trans); + geometry_type const& geom = feature->get_geometry(i); - context.add_path(path); + if (geom.num_points() > 1) + { + path_type path(t_, geom, prj_trans); + double length(0); + double x0(0), y0(0); + double x, y; + + for (unsigned cm = path.vertex(&x, &y); cm != SEG_END; cm = path.vertex(&x, &y)) + { + if (cm == SEG_MOVETO) + { + length = 0.0; + } + else if (cm == SEG_LINETO) + { + double dx = x - x0; + double dy = y - y0; + double angle = atan2(dy, dx); + double offset = fmod(length, width); + + Cairo::Matrix matrix; + cairo_matrix_init_identity(&matrix); + cairo_matrix_translate(&matrix,x0,y0); + cairo_matrix_rotate(&matrix,angle); + cairo_matrix_translate(&matrix,-offset,0.5*height); + cairo_matrix_invert(&matrix); + + pattern.set_matrix(matrix); + + context.set_pattern(pattern); + + context.move_to(x0, y0); + context.line_to(x, y); + context.stroke(); + + length = length + hypot(x - x0, y - y0); + } + + x0 = x; + y0 = y; + } + } + } + } + + void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) + { + typedef coord_transform2 path_type; + + cairo_context context(context_); + std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); + boost::optional marker = mapnik::marker_cache::instance()->find(filename,true); + if (!marker && !(*marker)->is_bitmap()) return; + + cairo_pattern pattern(**((*marker)->get_bitmap_data())); + + pattern.set_extend(Cairo::EXTEND_REPEAT); + + context.set_pattern(pattern); + + for (unsigned i = 0; i < feature->num_geometries(); ++i) + { + geometry_type const& geom = feature->get_geometry(i); + + if (geom.num_points() > 2) + { + path_type path(t_, geom, prj_trans); + + context.add_path(path); + context.fill(); + } + } + } + + void cairo_renderer_base::process(raster_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) + { + raster_ptr const& source = feature->get_raster(); + if (source) + { + // If there's a colorizer defined, use it to color the raster in-place + raster_colorizer_ptr colorizer = sym.get_colorizer(); + if (colorizer) + colorizer->colorize(source,*feature); + + box2d target_ext = box2d(source->ext_); + prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS); + + box2d ext=t_.forward(target_ext); + int start_x = (int)ext.minx(); + int start_y = (int)ext.miny(); + int end_x = (int)ceil(ext.maxx()); + int end_y = (int)ceil(ext.maxy()); + int raster_width = end_x - start_x; + int raster_height = end_y - start_y; + double err_offs_x = ext.minx() - start_x; + double err_offs_y = ext.miny() - start_y; + + if (raster_width > 0 && raster_height > 0) + { + double scale_factor = ext.width() / source->data_.width(); + image_data_32 target_data(raster_width,raster_height); + raster target(target_ext, target_data); + + reproject_raster(target, *source, prj_trans, err_offs_x, err_offs_y, + sym.get_mesh_size(), + sym.calculate_filter_factor(), + scale_factor, + sym.get_scaling()); + + cairo_context context(context_); + //TODO -- support for advanced image merging + context.add_image(start_x, start_y, target.data_, sym.get_opacity()); + } + } + } + +// TODO - this is woefully behind the AGG version. + void cairo_renderer_base::process(markers_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) + { + typedef coord_transform2 path_type; + arrow arrow_; + cairo_context context(context_); + + color const& fill_ = sym.get_fill(); + context.set_color(fill_.red(), fill_.green(), fill_.blue(), fill_.alpha()); + + for (unsigned i = 0; i < feature->num_geometries(); ++i) + { + geometry_type const& geom = feature->get_geometry(i); + + if (geom.num_points() > 1) + { + path_type path(t_, geom, prj_trans); + + markers_placement placement(path, arrow_.extent(), detector_, sym.get_spacing(), sym.get_max_error(), sym.get_allow_overlap()); + + double x, y, angle; + while (placement.get_point(&x, &y, &angle)) { + Cairo::Matrix matrix = Cairo::rotation_matrix(angle) * Cairo::translation_matrix(x,y) ; + context.set_matrix(matrix); + context.add_path(arrow_); + } + } context.fill(); } } -} -void cairo_renderer_base::process(raster_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - raster_ptr const& source = feature->get_raster(); - if (source) + void cairo_renderer_base::process(text_symbolizer const& sym, + mapnik::feature_ptr const& feature, + proj_transform const& prj_trans) { - // If there's a colorizer defined, use it to color the raster in-place - raster_colorizer_ptr colorizer = sym.get_colorizer(); - if (colorizer) - colorizer->colorize(source,*feature); - - box2d target_ext = box2d(source->ext_); - prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS); + text_symbolizer_helper, label_collision_detector4> helper(sym, *feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_); - box2d ext=t_.forward(target_ext); - int start_x = (int)ext.minx(); - int start_y = (int)ext.miny(); - int end_x = (int)ceil(ext.maxx()); - int end_y = (int)ceil(ext.maxy()); - int raster_width = end_x - start_x; - int raster_height = end_y - start_y; - double err_offs_x = ext.minx() - start_x; - double err_offs_y = ext.miny() - start_y; - - if (raster_width > 0 && raster_height > 0) - { - double scale_factor = ext.width() / source->data_.width(); - image_data_32 target_data(raster_width,raster_height); - raster target(target_ext, target_data); - - reproject_raster(target, *source, prj_trans, err_offs_x, err_offs_y, - sym.get_mesh_size(), - sym.calculate_filter_factor(), - scale_factor, - sym.get_scaling()); - - cairo_context context(context_); - //TODO -- support for advanced image merging - context.add_image(start_x, start_y, target.data_, sym.get_opacity()); - } - } -} - -// TODO - this is woefully behind the AGG version. -void cairo_renderer_base::process(markers_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - typedef coord_transform2 path_type; - arrow arrow_; - cairo_context context(context_); - - color const& fill_ = sym.get_fill(); - context.set_color(fill_.red(), fill_.green(), fill_.blue(), fill_.alpha()); - - for (unsigned i = 0; i < feature->num_geometries(); ++i) - { - geometry_type const& geom = feature->get_geometry(i); - - if (geom.num_points() > 1) - { - path_type path(t_, geom, prj_trans); - - markers_placement placement(path, arrow_.extent(), detector_, sym.get_spacing(), sym.get_max_error(), sym.get_allow_overlap()); - - double x, y, angle; - while (placement.get_point(&x, &y, &angle)) { - Cairo::Matrix matrix = Cairo::rotation_matrix(angle) * Cairo::translation_matrix(x,y) ; - context.set_matrix(matrix); - context.add_path(arrow_); + cairo_context context(context_); + text_placement_info_ptr placement; + while ((placement = helper.get_placement())) { + for (unsigned int ii = 0; ii < placement->placements.size(); ++ii) + { + context.add_text(placement->placements[ii], face_manager_, font_manager_); } } - context.fill(); } -} -void cairo_renderer_base::process(text_symbolizer const& sym, - mapnik::feature_ptr const& feature, - proj_transform const& prj_trans) -{ - text_symbolizer_helper, label_collision_detector4> helper(sym, *feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_); - - cairo_context context(context_); - text_placement_info_ptr placement; - while ((placement = helper.get_placement())) { - for (unsigned int ii = 0; ii < placement->placements.size(); ++ii) - { - context.add_text(placement->placements[ii], face_manager_, font_manager_); - } - } -} - -template class cairo_renderer; -template class cairo_renderer; + template class cairo_renderer; + template class cairo_renderer; } #endif diff --git a/src/color.cpp b/src/color.cpp index dde0575c5..c70e01f5e 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -38,20 +38,20 @@ color::color( std::string const& css_string) blue_(0), alpha_(0xff) { - color_factory::init_from_string(*this,css_string); + color_factory::init_from_string(*this,css_string); } std::string color::to_string() const { std::stringstream ss; - if (alpha_ == 255) + if (alpha_ == 255) { ss << "rgb(" << red() << "," << green() << "," << blue() << ")"; - } - else + } + else { ss << "rgba(" << red() << "," @@ -66,16 +66,16 @@ std::string color::to_hex_string() const { if (alpha_ == 255 ) { - return (boost::format("#%1$02x%2$02x%3$02x") - % red() - % green() + return (boost::format("#%1$02x%2$02x%3$02x") + % red() + % green() % blue() ).str(); } else { - return (boost::format("#%1$02x%2$02x%3$02x%4$02x") - % red() - % green() + return (boost::format("#%1$02x%2$02x%3$02x%4$02x") + % red() + % green() % blue() % alpha()).str(); } diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index dd1721c31..72af26a7c 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -41,12 +41,12 @@ namespace mapnik { - + bool is_input_plugin (std::string const& filename) { return boost::algorithm::ends_with(filename,std::string(".input")); } - + datasource_cache::datasource_cache() { @@ -61,8 +61,8 @@ datasource_cache::~datasource_cache() std::map > datasource_cache::plugins_; bool datasource_cache::registered_=false; std::vector datasource_cache::plugin_directories_; - -datasource_ptr datasource_cache::create(const parameters& params, bool bind) + +datasource_ptr datasource_cache::create(const parameters& params, bool bind) { boost::optional type = params.get("type"); if ( ! type) @@ -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(lt_dlsym(itr->second->handle(), "create")); if ( ! create_datasource) @@ -135,9 +135,9 @@ std::vector datasource_cache::plugin_names () } return names; } - + void datasource_cache::register_datasources(const std::string& str) -{ +{ #ifdef MAPNIK_THREADSAFE mutex::scoped_lock lock(mapnik::singleton::mutex_); @@ -146,58 +146,58 @@ void datasource_cache::register_datasources(const std::string& str) // TODO - only push unique paths plugin_directories_.push_back(str); boost::filesystem::directory_iterator end_itr; - + if (exists(path) && is_directory(path)) { for (boost::filesystem::directory_iterator itr(path);itr!=end_itr;++itr ) { -#if (BOOST_FILESYSTEM_VERSION == 3) +#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())) -#endif - { - try + if (!is_directory( *itr ) && is_input_plugin(itr->path().leaf())) +#endif { -#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(lt_dlsym(module, "datasource_name")); - if (ds_name && insert(ds_name(),module)) - { -#ifdef MAPNIK_DEBUG - std::clog << "Datasource loader: registered: " << ds_name() << std::endl; -#endif - registered_=true; - } - else if (!ds_name) +#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) { - std::clog << "Problem loading plugin library '" << itr->path().string() << "' (plugin is lacking compatible interface)" << std::endl; + // http://www.mr-edd.co.uk/blog/supressing_gcc_warnings +#ifdef __GNUC__ + __extension__ +#endif + datasource_name* ds_name = + reinterpret_cast(lt_dlsym(module, "datasource_name")); + if (ds_name && insert(ds_name(),module)) + { +#ifdef MAPNIK_DEBUG + std::clog << "Datasource loader: registered: " << ds_name() << std::endl; +#endif + registered_=true; + } + else if (!ds_name) + { + std::clog << "Problem loading plugin library '" << itr->path().string() << "' (plugin is lacking compatible interface)" << std::endl; + } + } + 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 } } - 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 (...) {} - } } } } diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index 0087e030d..dec79bdfc 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -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 background = map_in.background(); - if (background) - { - map_out.set_background(*background); - } - // background_image - boost::optional background_image = map_in.background_image(); - if (background_image) - { - map_out.set_background_image(*background_image); - } - // maximum extent - boost::optional > 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 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 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.addLayer(lyr_out); - } - typedef std::map 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.set_background(*background); + } + // background_image + boost::optional background_image = map_in.background_image(); + if (background_image) + { + map_out.set_background_image(*background_image); + } + // maximum extent + boost::optional > 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 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 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); + } + + } + + }} diff --git a/src/distance.cpp b/src/distance.cpp index 683c69230..c338d92be 100644 --- a/src/distance.cpp +++ b/src/distance.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -27,7 +27,7 @@ #include namespace mapnik { - + using std::atan2; using std::cos; using std::pow; @@ -36,23 +36,23 @@ using std::sqrt; static const double deg2rad = 0.0174532925199432958; static const double R = 6372795.0; // average great-circle radius of the earth - -double great_circle_distance::operator() (coord2d const& pt0, + +double great_circle_distance::operator() (coord2d const& pt0, coord2d const& pt1) const { double lon0 = pt0.x * deg2rad; double lat0 = pt0.y * deg2rad; double lon1 = pt1.x * deg2rad; double lat1 = pt1.y * deg2rad; - + double dlat = lat1 - lat0; double dlon = lon1 - lon0; - + double sin_dlat = sin(0.5 * dlat); double sin_dlon = sin(0.5 * dlon); - + double a = pow(sin_dlat,2.0) + cos(lat0)*cos(lat1)*pow(sin_dlon,2.0); double c = 2 * atan2(sqrt(a),sqrt(1 - a)); - return R * c; + return R * c; } } diff --git a/src/expression_string.cpp b/src/expression_string.cpp index 78932bdf0..3919811a3 100644 --- a/src/expression_string.cpp +++ b/src/expression_string.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,27 +35,27 @@ struct expression_string : boost::static_visitor { explicit expression_string(std::string & str) : str_(str) {} - + void operator() (value_type const& x) const - { - str_ += x.to_expression_string() ; + { + str_ += x.to_expression_string() ; } - + void operator() (attribute const& attr) const { str_ += "["; str_ += attr.name(); str_ += "]"; } - - template + + template void operator() (binary_node const& x) const { if (x.type() != tags::mult::str() && x.type() != tags::div::str()) { str_ += "("; } - + boost::apply_visitor(expression_string(str_),x.left); str_ += x.type(); boost::apply_visitor(expression_string(str_),x.right); @@ -70,10 +70,10 @@ struct expression_string : boost::static_visitor { str_ += Tag::str(); str_ += "("; - boost::apply_visitor(expression_string(str_),x.expr); + boost::apply_visitor(expression_string(str_),x.expr); str_ += ")"; } - + void operator() (regex_match_node const & x) const { boost::apply_visitor(expression_string(str_),x.expr); @@ -88,7 +88,7 @@ struct expression_string : boost::static_visitor #endif str_ +="')"; } - + void operator() (regex_replace_node const & x) const { boost::apply_visitor(expression_string(str_),x.expr); diff --git a/src/feature_kv_iterator.cpp b/src/feature_kv_iterator.cpp index 00af9a54c..56c9acd51 100644 --- a/src/feature_kv_iterator.cpp +++ b/src/feature_kv_iterator.cpp @@ -29,18 +29,18 @@ namespace mapnik { feature_kv_iterator::feature_kv_iterator (feature_impl const& f, bool begin) : f_(f), itr_( begin ? f_.ctx_->begin() : f_.ctx_->end()) {} - - + + void feature_kv_iterator::increment() -{ +{ ++itr_; } bool feature_kv_iterator::equal( feature_kv_iterator const& other) const { - return ( itr_ == other.itr_); + return ( itr_ == other.itr_); } - + feature_kv_iterator::value_type const& feature_kv_iterator::dereference() const { boost::get<0>(kv_) = itr_->first; diff --git a/src/feature_style_processor.cpp b/src/feature_style_processor.cpp index b7c1d4ca1..9d8e81a20 100644 --- a/src/feature_style_processor.cpp +++ b/src/feature_style_processor.cpp @@ -127,7 +127,7 @@ void feature_style_processor::apply() } p.end_map_processing(m_); - + #if defined(RENDERING_STATS) t.stop(); std::clog << "//-- rendering timer stopped...\n\n"; @@ -214,7 +214,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces #if defined(RENDERING_STATS) if (!prj_trans.equal()) - std::clog << "notice: reprojecting layer: '" << lay.name() << "' from/to:\n\t'" + std::clog << "notice: reprojecting layer: '" << lay.name() << "' from/to:\n\t'" << lay.srs() << "'\n\t'" << m_.srs() << "'\n"; #endif @@ -233,7 +233,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces if (prj_trans.forward(map_ext, PROJ_ENVELOPE_POINTS) && map_ext.intersects(layer_ext)) { layer_ext.clip(map_ext); - } + } // if no intersection and projections are also equal, early return else if (prj_trans.equal()) { @@ -260,7 +260,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces #endif return; } - + box2d query_ext = m_.get_current_extent(); box2d unbuffered_extent = m_.get_current_extent(); prj_trans.forward(query_ext, PROJ_ENVELOPE_POINTS); @@ -551,15 +551,15 @@ void feature_style_processor::render_style( // done with style std::ostringstream s; - if (feature_count > 0) + if (feature_count > 0) { double perc_processed = ((double)feature_processed_count/(double)feature_count)*100.0; - s << "percent rendered: " << perc_processed << "% - " << feature_processed_count + s << "percent rendered: " << perc_processed << "% - " << feature_processed_count << " rendered for " << feature_count << " queried for "; s << std::setw(15 - (int)s.tellp()) << " layer '" << lay.name() << "' and style '" << style_name << "'\n"; - } - else + } + else { s << "" << std::setw(15) << "- no features returned from query for layer '" << lay.name() << "' and style '" << style_name << "'\n"; } diff --git a/src/feature_type_style.cpp b/src/feature_type_style.cpp index 6dc0fe86b..637ff166e 100644 --- a/src/feature_type_style.cpp +++ b/src/feature_type_style.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -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,13 +46,13 @@ 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)); } } } - + feature_type_style& feature_type_style::operator=(feature_type_style const& rhs) { if (this == &rhs) return *this; @@ -60,13 +60,13 @@ feature_type_style& feature_type_style::operator=(feature_type_style const& rhs) scale_denom_validity_ = -1; return *this; } - + void feature_type_style::add_rule(rule const& rule) { rules_.push_back(rule); scale_denom_validity_ = -1; -} - +} + rules const& feature_type_style::get_rules() const { return rules_; @@ -76,7 +76,7 @@ rules &feature_type_style::get_rules_nonconst() { return rules_; } - + void feature_type_style::set_filter_mode(filter_mode_e mode) { filter_mode_ = mode; diff --git a/src/filter_factory.cpp b/src/filter_factory.cpp index 6726cb3f2..05f99239a 100644 --- a/src/filter_factory.cpp +++ b/src/filter_factory.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -38,11 +38,11 @@ public: static expression_ptr compile(std::string const& str,transcoder const& tr) { expression_ptr expr(new expr_node(true)); - + std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); mapnik::expression_grammar g(tr); - + bool r = boost::spirit::qi::phrase_parse(itr,end,g, boost::spirit::standard_wide::space,*expr); if (r && itr==end) { @@ -50,7 +50,7 @@ public: } else { - throw config_error( "Failed to parse expression: \"" + str + "\"" ); + throw config_error( "Failed to parse expression: \"" + str + "\"" ); } } }; diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 5e58fa89c..fe90f96a9 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -35,7 +35,7 @@ #include #include #include -#include +#include namespace mapnik { @@ -47,10 +47,10 @@ freetype_engine::freetype_engine() throw std::runtime_error("can not load FreeType2 library"); } } - + freetype_engine::~freetype_engine() -{ - FT_Done_FreeType(library_); +{ + FT_Done_FreeType(library_); } bool freetype_engine::is_font_file(std::string const& file_name) @@ -79,7 +79,7 @@ bool freetype_engine::register_font(std::string const& file_name) { throw std::runtime_error("Failed to initialize FreeType2 library"); } - + FT_Face face = 0; // some font files have multiple fonts in a file // the count is in the 'root' face library[0] @@ -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()); } } @@ -116,30 +116,30 @@ bool freetype_engine::register_font(std::string const& file_name) bool freetype_engine::register_fonts(std::string const& dir, bool recurse) { boost::filesystem::path path(dir); - + if (!boost::filesystem::exists(path)) return false; if (!boost::filesystem::is_directory(path)) - return mapnik::freetype_engine::register_font(dir); - + return mapnik::freetype_engine::register_font(dir); + boost::filesystem::directory_iterator end_itr; for (boost::filesystem::directory_iterator itr(dir); itr != end_itr; ++itr) { if (boost::filesystem::is_directory(*itr) && recurse) { -#if (BOOST_FILESYSTEM_VERSION == 3) +#if (BOOST_FILESYSTEM_VERSION == 3) if (!register_fonts(itr->path().string(), true)) return false; #else // v2 if (!register_fonts(itr->string(), true)) return false; #endif } - else + else { -#if (BOOST_FILESYSTEM_VERSION == 3) +#if (BOOST_FILESYSTEM_VERSION == 3) mapnik::freetype_engine::register_font(itr->path().string()); #else // v2 - mapnik::freetype_engine::register_font(itr->string()); + mapnik::freetype_engine::register_font(itr->string()); #endif } } @@ -171,12 +171,12 @@ face_ptr freetype_engine::create_face(std::string const& family_name) if (itr != name2file_.end()) { FT_Face face; - FT_Error error = FT_New_Face (library_, - itr->second.second.c_str(), - itr->second.first, + FT_Error error = FT_New_Face (library_, + itr->second.second.c_str(), + itr->second.first, &face); if (!error) - { + { return face_ptr (new font_face(face)); } } @@ -186,7 +186,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name) stroker_ptr freetype_engine::create_stroker() { FT_Stroker s; - FT_Error error = FT_Stroker_New(library_, &s); + FT_Error error = FT_Stroker_New(library_, &s); if (!error) { return stroker_ptr(new stroker(s)); @@ -254,14 +254,14 @@ void font_face_set::get_string_info(string_info & info, UnicodeString const& ust UBiDi *bidi = ubidi_openSized(length, 0, &err); ubidi_setPara(bidi, ustr.getBuffer(), length, UBIDI_DEFAULT_LTR, 0, &err); - ubidi_writeReordered(bidi, reordered.getBuffer(length), + ubidi_writeReordered(bidi, reordered.getBuffer(length), length, UBIDI_DO_MIRRORING, &err); reordered.releaseBuffer(length); u_shapeArabic(reordered.getBuffer(), length, shaped.getBuffer(length), length, - U_SHAPE_LETTERS_SHAPE | U_SHAPE_LENGTH_FIXED_SPACES_NEAR | + U_SHAPE_LETTERS_SHAPE | U_SHAPE_LENGTH_FIXED_SPACES_NEAR | U_SHAPE_TEXT_DIRECTION_VISUAL_LTR, &err); shaped.releaseBuffer(length); @@ -390,30 +390,30 @@ void text_renderer::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::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); diff --git a/src/font_set.cpp b/src/font_set.cpp index df24f4c37..074d9c5bb 100644 --- a/src/font_set.cpp +++ b/src/font_set.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -39,7 +39,7 @@ font_set::font_set(std::string const& name) font_set::font_set(font_set const& rhs) : name_(rhs.name_), face_names_(rhs.face_names_) {} - + font_set& font_set::operator=(font_set const& other) { if (this == &other) @@ -48,10 +48,10 @@ font_set& font_set::operator=(font_set const& other) face_names_ = other.face_names_; return *this; -} +} font_set::~font_set() {} - + unsigned font_set::size() const { return face_names_.size(); @@ -66,7 +66,7 @@ std::string const& font_set::get_name() const { return name_; } - + std::vector const& font_set::get_face_names() const { return face_names_; diff --git a/src/gamma_method.cpp b/src/gamma_method.cpp index c3e81b6bb..b564a5a4b 100644 --- a/src/gamma_method.cpp +++ b/src/gamma_method.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/src/gradient.cpp b/src/gradient.cpp index 8e9c7278c..3d4771c0f 100644 --- a/src/gradient.cpp +++ b/src/gradient.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -36,15 +36,15 @@ static const char * gradient_strings[] = { 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::gradient() +: gradient_type_(NO_GRADIENT), + stops_(), + x1_(0), + y1_(0), + x2_(0), + y2_(0), + r_(0), + units_(OBJECT_BOUNDING_BOX) { } @@ -67,12 +67,12 @@ gradient & gradient::operator=(const gradient& rhs) return *this; } -void gradient::set_gradient_type(gradient_e grad) +void gradient::set_gradient_type(gradient_e grad) { gradient_type_=grad; } -gradient_e gradient::get_gradient_type() const +gradient_e gradient::get_gradient_type() const { return gradient_type_; } @@ -100,7 +100,7 @@ void gradient::add_stop(double offset,mapnik::color const& c) stops_.push_back(mapnik::stop_pair(offset,c)); } -bool gradient::has_stop() const +bool gradient::has_stop() const { return ! stops_.empty(); } diff --git a/src/graphics.cpp b/src/graphics.cpp index 90099da1b..4b276562a 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -82,7 +82,7 @@ image_32::image_32(Cairo::RefPtr rhs) else x = x * 255 / a; \ if (x > 255) x = 255; \ } while(0) - + DE_ALPHA(r); DE_ALPHA(g); DE_ALPHA(b); @@ -108,7 +108,7 @@ void image_32::set_grayscale_to_alpha() unsigned r = rgba & 0xff; unsigned g = (rgba >> 8 ) & 0xff; unsigned b = (rgba >> 16) & 0xff; - + // magic numbers for grayscale unsigned a = (int)((r * .3) + (g * .59) + (b * .11)); @@ -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; - - row_to[x] = (a1) | (b << 8) | (g << 16) | (r << 24) ; + 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) ; #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 + } } } -} } diff --git a/src/grid/grid_renderer.cpp b/src/grid/grid_renderer.cpp index 541f21825..d1d12a0a8 100644 --- a/src/grid/grid_renderer.cpp +++ b/src/grid/grid_renderer.cpp @@ -127,13 +127,13 @@ void grid_renderer::render_marker(mapnik::feature_ptr const& feature, unsigne typedef agg::renderer_base ren_base; typedef agg::renderer_scanline_bin_solid renderer; agg::scanline_bin sl; - + grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_); mapnik::pixfmt_gray16 pixf(buf); - + ren_base renb(pixf); renderer ren(renb); - + ras_ptr->reset(); box2d const& bbox = (*marker.get_vector_data())->bounding_box(); @@ -149,27 +149,27 @@ void grid_renderer::render_marker(mapnik::feature_ptr const& feature, unsigne vertex_stl_adapter stl_storage((*marker.get_vector_data())->source()); svg_path_adapter svg_path(stl_storage); svg_renderer, - renderer, - mapnik::pixfmt_gray16> svg_renderer(svg_path, - (*marker.get_vector_data())->attributes()); + agg::pod_bvector, + 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); - + } else { image_data_32 const& data = **marker.get_bitmap_data(); if (step == 1 && scale_factor_ == 1.0) { - pixmap_.set_rectangle(feature->id(), data, x, y); + pixmap_.set_rectangle(feature->id(), data, x, y); } else { double ratio = (1.0/step); image_data_32 target(ratio * data.width(), ratio * data.height()); mapnik::scale_image_agg(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); } } diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp index 78a12171d..606a00faa 100644 --- a/src/grid/process_building_symbolizer.cpp +++ b/src/grid/process_building_symbolizer.cpp @@ -39,13 +39,13 @@ #include "agg_scanline_bin.h" #include "agg_conv_stroke.h" -namespace mapnik +namespace mapnik { template void grid_renderer::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 path_type; typedef agg::renderer_base ren_base; @@ -67,7 +67,7 @@ void grid_renderer::process(building_symbolizer const& sym, value_type result = boost::apply_visitor(evaluate(*feature), *height_expr); height = result.to_double() * scale_factor_; } - + for (unsigned i=0;inum_geometries();++i) { geometry_type const& geom = feature->get_geometry(i); @@ -93,7 +93,7 @@ void grid_renderer::process(building_symbolizer const& sym, frame->line_to(x,y); face_segments.push_back(segment_t(x0,y0,x,y)); } - + x0 = x; y0 = y; } @@ -150,7 +150,7 @@ void grid_renderer::process(building_symbolizer const& sym, } template void grid_renderer::process(building_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index 021c218c9..0487d8f96 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -43,8 +43,8 @@ namespace mapnik { template void grid_renderer::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 path_type; typedef agg::renderer_base ren_base; @@ -86,8 +86,8 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, template void grid_renderer::process(line_pattern_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } - + diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index ddc10515b..ba0ab2f8a 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -43,8 +43,8 @@ namespace mapnik { template void grid_renderer::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 path_type; typedef agg::renderer_base ren_base; @@ -76,7 +76,7 @@ void grid_renderer::process(line_symbolizer const& sym, dash_array::const_iterator end = d.end(); for (;itr != end;++itr) { - dash.add_dash(itr->first * scale_factor_, + dash.add_dash(itr->first * scale_factor_, itr->second * scale_factor_); } @@ -102,7 +102,7 @@ void grid_renderer::process(line_symbolizer const& sym, stroke.generator().miter_limit(4.0); stroke.generator().width(stroke_.get_width() * scale_factor_); - + ras_ptr->add_path(stroke); } @@ -145,8 +145,8 @@ void grid_renderer::process(line_symbolizer const& sym, template void grid_renderer::process(line_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } - + diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 8dbc4aa2f..0c01f1849 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -53,8 +53,8 @@ namespace mapnik { template void grid_renderer::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 path_type; typedef agg::renderer_base ren_base; @@ -88,7 +88,7 @@ void grid_renderer::process(markers_symbolizer const& sym, double y1 = bbox.miny(); double x2 = bbox.maxx(); double y2 = bbox.maxy(); - + agg::trans_affine recenter = agg::trans_affine_translation(-0.5*(x1+x2),-0.5*(y1+y2)); tr.transform(&x1,&y1); tr.transform(&x2,&y2); @@ -96,10 +96,10 @@ void grid_renderer::process(markers_symbolizer const& sym, using namespace mapnik::svg; vertex_stl_adapter stl_storage((*marker)->source()); svg_path_adapter svg_path(stl_storage); - svg_renderer, - renderer, - mapnik::pixfmt_gray16 > svg_renderer(svg_path,(*marker)->attributes()); + svg_renderer, + renderer, + mapnik::pixfmt_gray16 > svg_renderer(svg_path,(*marker)->attributes()); bool placed = false; for (unsigned i=0; inum_geometries(); ++i) @@ -109,15 +109,15 @@ void grid_renderer::process(markers_symbolizer const& sym, { std::clog << "### Warning svg markers not supported yet for points within markers_symbolizer\n"; continue; - } - + } + path_type path(t_,geom,prj_trans); - markers_placement placement(path, extent, detector_, - sym.get_spacing() * scale_factor_, - sym.get_max_error(), - sym.get_allow_overlap()); + markers_placement placement(path, extent, detector_, + sym.get_spacing() * scale_factor_, + sym.get_max_error(), + sym.get_allow_overlap()); double x, y, angle; - + while (placement.get_point(&x, &y, &angle)) { placed = true; @@ -133,7 +133,7 @@ void grid_renderer::process(markers_symbolizer const& sym, { stroke const& stroke_ = sym.get_stroke(); double strk_width = stroke_.get_width(); - + double w; double h; unsigned int res = pixmap_.get_resolution(); @@ -146,7 +146,7 @@ void grid_renderer::process(markers_symbolizer const& sym, w = sym.get_width()/res; h = sym.get_height()/res; } - + arrow arrow_; box2d extent; @@ -174,7 +174,7 @@ void grid_renderer::process(markers_symbolizer const& sym, tr.transform(&x2,&y2); extent.init(x1,y1,x2,y2); } - + double x; double y; double z=0; @@ -198,7 +198,7 @@ void grid_renderer::process(markers_symbolizer const& sym, agg::path_storage marker; marker.concat_path(c); ras_ptr->add_path(marker); - + // outline if (strk_width) { @@ -212,18 +212,18 @@ void grid_renderer::process(markers_symbolizer const& sym, } else { - + agg::path_storage marker; if (marker_type == ARROW) marker.concat_path(arrow_); path_type path(t_,geom,prj_trans); - markers_placement placement(path, extent, detector_, - sym.get_spacing() * scale_factor_, - sym.get_max_error(), - sym.get_allow_overlap()); + markers_placement placement(path, extent, detector_, + sym.get_spacing() * scale_factor_, + sym.get_max_error(), + sym.get_allow_overlap()); double x_t, y_t, angle; - + while (placement.get_point(&x_t, &y_t, &angle)) { agg::trans_affine matrix; @@ -267,6 +267,6 @@ void grid_renderer::process(markers_symbolizer const& sym, } template void grid_renderer::process(markers_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } diff --git a/src/grid/process_point_symbolizer.cpp b/src/grid/process_point_symbolizer.cpp index 72773f004..20b439072 100644 --- a/src/grid/process_point_symbolizer.cpp +++ b/src/grid/process_point_symbolizer.cpp @@ -39,11 +39,11 @@ namespace mapnik { template void grid_renderer::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); - + boost::optional marker; if ( !filename.empty() ) { @@ -94,8 +94,8 @@ void grid_renderer::process(point_symbolizer const& sym, } template void grid_renderer::process(point_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } - + diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index ca9b09e7b..89aae4590 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -42,8 +42,8 @@ namespace mapnik { template void grid_renderer::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 path_type; typedef agg::renderer_base ren_base; @@ -67,7 +67,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, ras_ptr->add_path(path); } } - + // render id ren.color(mapnik::gray16(feature->id())); agg::render_scanlines(*ras_ptr, sl, ren); @@ -78,8 +78,8 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, template void grid_renderer::process(polygon_pattern_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } - + diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index ebd2f39fa..bb5e1aa0a 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -42,8 +42,8 @@ namespace mapnik { template void grid_renderer::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 path_type; typedef agg::renderer_base ren_base; @@ -66,7 +66,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, ras_ptr->add_path(path); } } - + // render id ren.color(mapnik::gray16(feature->id())); agg::render_scanlines(*ras_ptr, sl, ren); @@ -77,8 +77,8 @@ void grid_renderer::process(polygon_symbolizer const& sym, template void grid_renderer::process(polygon_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } - + diff --git a/src/grid/process_raster_symbolizer.cpp b/src/grid/process_raster_symbolizer.cpp index 02e82e595..d1414ad2b 100644 --- a/src/grid/process_raster_symbolizer.cpp +++ b/src/grid/process_raster_symbolizer.cpp @@ -29,14 +29,14 @@ namespace mapnik { template void grid_renderer::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::process(raster_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } diff --git a/src/grid/process_shield_symbolizer.cpp b/src/grid/process_shield_symbolizer.cpp index eab40fbcb..ad6544577 100644 --- a/src/grid/process_shield_symbolizer.cpp +++ b/src/grid/process_shield_symbolizer.cpp @@ -41,15 +41,15 @@ namespace mapnik { template void grid_renderer::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, - 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::process(shield_symbolizer const& sym, } template void grid_renderer::process(shield_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } diff --git a/src/grid/process_text_symbolizer.cpp b/src/grid/process_text_symbolizer.cpp index e9def442d..3278933f4 100644 --- a/src/grid/process_text_symbolizer.cpp +++ b/src/grid/process_text_symbolizer.cpp @@ -29,15 +29,15 @@ namespace mapnik { template void grid_renderer::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, - 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 ren(pixmap_, font_manager_, *(font_manager_.get_stroker())); @@ -58,8 +58,8 @@ void grid_renderer::process(text_symbolizer const& sym, } template void grid_renderer::process(text_symbolizer const&, - mapnik::feature_ptr const&, - proj_transform const&); + mapnik::feature_ptr const&, + proj_transform const&); } - + diff --git a/src/image_reader.cpp b/src/image_reader.cpp index 75f98d881..c0426be6a 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -26,22 +26,22 @@ #include namespace mapnik -{ -typedef factory ImageReaderFactory; - - + + bool register_image_reader(const std::string& type,image_reader* (* fun)(const std::string&)) { return ImageReaderFactory::instance()->register_product(type,fun); } - -image_reader* get_image_reader(const std::string& filename,const std::string& type) + +image_reader* get_image_reader(const std::string& filename,const std::string& type) { return ImageReaderFactory::instance()->create_object(type,filename); } -image_reader* get_image_reader(const std::string& filename) +image_reader* get_image_reader(const std::string& filename) { boost::optional type = type_from_filename(filename); if (type) diff --git a/src/image_util.cpp b/src/image_util.cpp index b2205e13a..574990feb 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -75,7 +75,7 @@ extern "C" namespace mapnik -{ +{ template std::string save_to_string(T const& image, @@ -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") { @@ -158,7 +158,7 @@ void handle_png_options(std::string const& type, } else if (boost::algorithm::istarts_with(t,std::string("c="))) { - try + try { if (*colors < 0) throw ImageWriterException("invalid color parameter: unavailable for true color images"); @@ -173,7 +173,7 @@ void handle_png_options(std::string const& type, } else if (boost::algorithm::istarts_with(t, std::string("t="))) { - try + try { if (*colors < 0) throw ImageWriterException("invalid trans_mode parameter: unavailable for true color images"); @@ -188,7 +188,7 @@ void handle_png_options(std::string const& type, } else if (boost::algorithm::istarts_with(t, std::string("g="))) { - try + try { if (*colors < 0) throw ImageWriterException("invalid gamma parameter: unavailable for true color images"); @@ -207,12 +207,12 @@ void handle_png_options(std::string const& type, { *compression = boost::lexical_cast(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); @@ -287,7 +287,7 @@ void save_to_stream(T const& image, } #endif else throw ImageWriterException("unknown file type: " + type); - } + } else throw ImageWriterException("Could not write to empty stream" ); } @@ -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); @@ -332,7 +332,7 @@ void save_to_stream(T const& image, else if (boost::algorithm::istarts_with(type, std::string("jpeg"))) { int quality = 85; - try + try { if(type.substr(4).length() != 0) { @@ -340,8 +340,8 @@ void save_to_stream(T const& image, if(quality<0 || quality>100) throw ImageWriterException("invalid jpeg quality: " + type.substr(4) + " out of bounds"); } - save_as_jpeg(stream, quality, image); - } + save_as_jpeg(stream, quality, image); + } catch(boost::bad_lexical_cast &) { throw ImageWriterException("invalid jpeg quality: " + type.substr(4) + " not a number"); @@ -349,7 +349,7 @@ void save_to_stream(T const& image, } #endif else throw ImageWriterException("unknown file type: " + type); - } + } else throw ImageWriterException("Could not write to empty stream" ); } @@ -404,24 +404,24 @@ void save_to_cairo_file(mapnik::Map const& map, surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,width,height); else if (type == "RGB24") surface = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24,width,height); - else - throw ImageWriterException("unknown file type: " + type); + else + throw ImageWriterException("unknown file type: " + type); Cairo::RefPtr context = Cairo::Context::create(surface); - + // TODO - expose as user option /* - if (type == "ARGB32" || type == "RGB24") - { - context->set_antialias(Cairo::ANTIALIAS_NONE); + if (type == "ARGB32" || type == "RGB24") + { + context->set_antialias(Cairo::ANTIALIAS_NONE); } */ - - + + mapnik::cairo_renderer ren(map, context); ren.apply(); - - if (type == "ARGB32" || type == "RGB24") - { + + if (type == "ARGB32" || type == "RGB24") + { surface->write_to_png(filename); } surface->finish(); @@ -464,14 +464,14 @@ template void save_to_file > (image_view > (image_view const&, std::string const&); - + template void save_to_file > (image_view const&, std::string const&, rgba_palette const& palette); - + template std::string save_to_string > (image_view const&, std::string const&); - + template std::string save_to_string > (image_view const&, std::string const&, rgba_palette const& palette); @@ -691,26 +691,26 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin { typedef agg::pixfmt_rgba32_plain pixfmt; typedef agg::renderer_base renderer_base; - + // define some stuff we'll use soon agg::rasterizer_scanline_aa<> ras; agg::scanline_u8 sl; agg::span_allocator sa; agg::image_filter_lut filter; - + // initialize source AGG buffer agg::rendering_buffer rbuf_src((unsigned char*)source.getBytes(), source.width(), source.height(), source.width() * 4); pixfmt pixf_src(rbuf_src); - + typedef agg::image_accessor_clone img_src_type; img_src_type img_src(pixf_src); - + // initialise destination AGG buffer (with transparency) agg::rendering_buffer rbuf_dst((unsigned char*)target.getBytes(), target.width(), target.height(), target.width() * 4); pixfmt pixf_dst(rbuf_dst); renderer_base rb_dst(pixf_dst); rb_dst.clear(agg::rgba(0, 0, 0, 0)); - + // create a scaling matrix agg::trans_affine img_mtx; img_mtx /= agg::trans_affine_scaling(scale_factor * ratio, scale_factor * ratio); @@ -718,7 +718,7 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin // create a linear interpolator for our scaling matrix typedef agg::span_interpolator_linear<> interpolator_type; interpolator_type interpolator(img_mtx); - + // draw an anticlockwise polygon to render our image into double scaled_width = source.width() * scale_factor; double scaled_height = source.height() * scale_factor; @@ -727,48 +727,48 @@ void scale_image_agg (Image& target,const Image& source, scaling_method_e scalin ras.line_to_d(x_off_f + scaled_width, y_off_f); ras.line_to_d(x_off_f + scaled_width, y_off_f + scaled_height); ras.line_to_d(x_off_f, y_off_f + scaled_height); - + switch(scaling_method) { - case SCALING_NEAR: - { - typedef agg::span_image_filter_rgba_nn 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 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 span_gen_type; span_gen_type sg(img_src, interpolator, filter); diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index aac35b24c..0bea3d063 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -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(); - }; - - namespace - { - image_reader* createJpegReader(const std::string& file) - { - return new JpegReader(file); - } - const bool registered = register_image_reader("jpeg",createJpegReader); - } +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(); +}; - 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 out_row(new unsigned int[w]); - // TODO - handle x0 - for (unsigned i=0;i=y0 && i 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 out_row(new unsigned int[w]); + // TODO - handle x0 + for (unsigned i=0;i=y0 && i 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); +} } diff --git a/src/layer.cpp b/src/layer.cpp index 3d88e17e6..e0e32d475 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -34,7 +34,7 @@ namespace mapnik -{ +{ layer::layer(std::string const& name, std::string const& srs) : name_(name), srs_(srs), @@ -46,7 +46,7 @@ layer::layer(std::string const& name, std::string const& srs) cache_features_(false), group_by_(""), ds_() {} - + layer::layer(const layer& rhs) : name_(rhs.name_), srs_(rhs.srs_), @@ -59,7 +59,7 @@ layer::layer(const layer& rhs) group_by_(rhs.group_by_), styles_(rhs.styles_), ds_(rhs.ds_) {} - + layer& layer::operator=(const layer& rhs) { layer tmp(rhs); @@ -71,7 +71,7 @@ bool layer::operator==(layer const& other) const { return (this == &other); } - + void layer::swap(const layer& rhs) { name_=rhs.name_; @@ -88,12 +88,12 @@ void layer::swap(const layer& rhs) } layer::~layer() {} - + void layer::set_name( std::string const& name) { name_ = name; } - + std::string const& layer::name() const { return name_; @@ -103,22 +103,22 @@ void layer::set_srs(std::string const& srs) { srs_ = srs; } - + std::string const& layer::srs() const { return srs_; } - + void layer::add_style(std::string const& stylename) { styles_.push_back(stylename); } - + std::vector const& layer::styles() const { return styles_; } - + std::vector & layer::styles() { return styles_; @@ -173,23 +173,23 @@ datasource_ptr layer::datasource() const { return ds_; } - + void layer::set_datasource(datasource_ptr const& ds) { ds_ = ds; } - + box2d layer::envelope() const { if (ds_) return ds_->envelope(); return box2d(); } - + void layer::set_clear_label_cache(bool clear) { clear_label_cache_ = clear; } - + bool layer::clear_label_cache() const { return clear_label_cache_; diff --git a/src/libxml2_loader.cpp b/src/libxml2_loader.cpp index fedfbfd44..64a67f14a 100644 --- a/src/libxml2_loader.cpp +++ b/src/libxml2_loader.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -44,7 +44,7 @@ using namespace std; //#define DEFAULT_OPTIONS (XML_PARSE_NOENT | XML_PARSE_NOBLANKS | XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA) #define DEFAULT_OPTIONS (XML_PARSE_NOERROR | XML_PARSE_NOENT | XML_PARSE_NOBLANKS | XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA) -namespace mapnik +namespace mapnik { class libxml2_loader : boost::noncopyable { @@ -67,8 +67,8 @@ public: { if (ctx_) { - xmlFreeParserCtxt(ctx_); - } + xmlFreeParserCtxt(ctx_); + } } void load( const std::string & filename, ptree & pt ) @@ -89,7 +89,7 @@ public: if (error) { os << ": " << std::endl << error->message; - // remove CR + // remove CR std::string msg = os.str().substr(0, os.str().size() - 1); config_error ex( msg ); @@ -104,7 +104,7 @@ public: } /* - if ( ! ctx->valid ) + if ( ! ctx->valid ) { std::clog << "### ERROR: Failed to validate DTD." << std::endl; @@ -127,7 +127,7 @@ public: if ( ! boost::filesystem::exists( path ) ) { throw config_error(string("Could not locate base_path '") + base_path + "': file or directory does not exist"); - } + } } xmlDocPtr doc = xmlCtxtReadMemory(ctx_, buffer.data(), buffer.length(), base_path.c_str(), encoding_, options_); @@ -190,7 +190,7 @@ private: for (; cur_node; cur_node = cur_node->next ) { - switch (cur_node->type) + switch (cur_node->type) { case XML_ELEMENT_NODE: { diff --git a/src/line_pattern_symbolizer.cpp b/src/line_pattern_symbolizer.cpp index f03cc90ae..ffb1471c1 100644 --- a/src/line_pattern_symbolizer.cpp +++ b/src/line_pattern_symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -27,8 +27,8 @@ namespace mapnik { - -line_pattern_symbolizer::line_pattern_symbolizer(path_expression_ptr file) + +line_pattern_symbolizer::line_pattern_symbolizer(path_expression_ptr file) : symbolizer_with_image(file), symbolizer_base() {} line_pattern_symbolizer::line_pattern_symbolizer(line_pattern_symbolizer const& rhs) diff --git a/src/line_symbolizer.cpp b/src/line_symbolizer.cpp index ccece0f8a..052075433 100644 --- a/src/line_symbolizer.cpp +++ b/src/line_symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/src/load_map.cpp b/src/load_map.cpp index b6ddae541..39b144d0d 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -193,7 +193,7 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base << "maximum-extent," << "base"; ensure_attrs(map_node, "Map", s.str()); - + try { parameters extra_attr; @@ -219,27 +219,27 @@ 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 ); + map.set_base_path( base ); } optional bgcolor = get_opt_attr(map_node, "background-color"); - if (bgcolor) + if (bgcolor) { map.set_background( * bgcolor ); } - + optional image_filename = get_opt_attr(map_node, "background-image"); if (image_filename) - { + { map.set_background_image(ensure_relative_to_xml(image_filename)); } - + map.set_srs( get_attr(map_node, "srs", map.srs() )); optional buffer_size = get_opt_attr(map_node,"buffer-size"); @@ -275,7 +275,7 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base } optional min_version_string = get_opt_attr(map_node, "minimum-version"); - + if (min_version_string) { extra_attr["minimum-version"] = *min_version_string; @@ -284,10 +284,10 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base unsigned i = 0; bool success = false; int n[3]; - for (boost::tokenizer >::iterator beg=tokens.begin(); + for (boost::tokenizer >::iterator beg=tokens.begin(); beg!=tokens.end();++beg) { - try + try { n[i] = boost::lexical_cast(boost::trim_copy(*beg)); } @@ -296,7 +296,7 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base std::clog << *beg << " : " << ex.what() << "\n"; break; } - if (i==2) + if (i==2) { success = true; break; @@ -310,9 +310,9 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base { throw config_error(std::string("This map uses features only present in Mapnik version ") + *min_version_string + " and newer"); } - + } - + } map.set_extra_attributes(extra_attr); @@ -322,7 +322,7 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base ex.append_context("(in node Map)"); throw; } - + parse_map_include( map, map_node ); } catch (const boost::property_tree::ptree_bad_path &) @@ -330,7 +330,7 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base throw config_error("Not a map file. Node 'Map' not found."); } } - + void map_parser::parse_map_include( Map & map, ptree const & include ) { ptree::const_iterator itr = include.begin(); @@ -380,7 +380,7 @@ void map_parser::parse_map_include( Map & map, ptree const & include ) { std::string name = get_attr(param, "name"); std::string value = get_value( param, - "datasource parameter"); + "datasource parameter"); params[name] = value; } else if( paramIter->first != "" && @@ -423,11 +423,11 @@ void map_parser::parse_map_include( Map & map, ptree const & include ) params[name] = value; } } - + if (is_string) { std::string value = get_value( param, - "parameter"); + "parameter"); params[name] = value; } } @@ -447,7 +447,7 @@ void map_parser::parse_map_include( Map & map, ptree const & include ) v.first + "'"); } } - + map.init_metawriters(); } @@ -546,7 +546,7 @@ void map_parser::parse_fontset( Map & map, ptree const & fset ) } map.insert_fontset(name, fontset); - + // XXX Hack because map object isn't accessible by text_symbolizer // when it's parsed fontsets_.insert(pair(name, fontset)); @@ -606,7 +606,7 @@ void map_parser::parse_layer( Map & map, ptree const & lay ) { lyr.setActive( * status ); } - + optional minZoom = get_opt_attr(lay, "minzoom"); if (minZoom) { @@ -694,7 +694,7 @@ void map_parser::parse_layer( Map & map, ptree const & lay ) ensure_attrs(param, "Parameter", "name"); std::string name = get_attr(param, "name"); std::string value = get_value( param, - "datasource parameter"); + "datasource parameter"); params[name] = value; } else if( paramIter->first != "" && @@ -746,10 +746,10 @@ void map_parser::parse_layer( Map & map, ptree const & lay ) map.addLayer(lyr); - } - catch (const config_error & ex) + } + catch (const config_error & ex) { - if ( ! name.empty() ) + if ( ! name.empty() ) { ex.append_context(std::string("(encountered during parsing of layer '") + name + "' in map '" + filename_ + "')"); } @@ -890,7 +890,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym ) { std::stringstream s; s << "file,base,allow-overlap,ignore-placement,opacity,placement,transform,meta-writer,meta-output"; - + optional file = get_opt_attr(sym, "file"); optional base = get_opt_attr(sym, "base"); optional allow_overlap = @@ -899,7 +899,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym ) get_opt_attr(sym, "ignore-placement"); optional opacity = get_opt_attr(sym, "opacity"); - + optional transform_wkt = get_opt_attr(sym, "transform"); if (file) @@ -917,7 +917,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym ) } *file = ensure_relative_to_xml(file); - + point_symbolizer symbol(parse_path(*file)); if (allow_overlap) @@ -930,7 +930,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym ) } if (ignore_placement) { - symbol.set_ignore_placement( * ignore_placement ); + symbol.set_ignore_placement( * ignore_placement ); } point_placement_e placement = get_attr(sym, "placement", CENTROID_POINT_PLACEMENT); @@ -942,12 +942,12 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym ) if (!mapnik::svg::parse_transform((*transform_wkt).c_str(),tr)) { std::stringstream ss; - ss << "Could not parse transform from '" << transform_wkt + ss << "Could not parse transform from '" << transform_wkt << "', expected string like: 'matrix(1, 0, 0, 1, 0, 0)'"; if (strict_) throw config_error(ss.str()); // value_error here? else - std::clog << "### WARNING: " << ss << endl; + std::clog << "### WARNING: " << ss << endl; } boost::array matrix; tr.store_to(&matrix[0]); @@ -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); @@ -987,7 +987,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym ) } if (ignore_placement) { - symbol.set_ignore_placement( * ignore_placement ); + symbol.set_ignore_placement( * ignore_placement ); } point_placement_e placement = get_attr(sym, "placement", CENTROID_POINT_PLACEMENT); @@ -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,15 +1056,15 @@ 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 opacity = get_opt_attr(sym, "opacity"); if (opacity) symbol.set_opacity( *opacity ); - + if (transform_wkt) { agg::trans_affine tr; @@ -1076,13 +1076,13 @@ void map_parser::parse_markers_symbolizer( rule & rule, ptree const & sym ) if (strict_) throw config_error(ss.str()); // value_error here? else - std::clog << "### WARNING: " << ss << endl; + std::clog << "### WARNING: " << ss << endl; } boost::array matrix; tr.store_to(&matrix[0]); symbol.set_transform(matrix); } - + optional c = get_opt_attr(sym, "fill"); if (c) symbol.set_fill(*c); optional spacing = get_opt_attr(sym, "spacing"); @@ -1103,14 +1103,14 @@ void map_parser::parse_markers_symbolizer( rule & rule, ptree const & sym ) { symbol.set_width(*w); symbol.set_height(*w); - + } else if (h) { symbol.set_width(*h); symbol.set_height(*h); } - + stroke strk; parse_stroke(strk,sym); symbol.set_stroke(strk); @@ -1143,7 +1143,7 @@ void map_parser::parse_line_pattern_symbolizer( rule & rule, ptree const & sym ) { std::string file = get_attr(sym, "file"); optional base = get_opt_attr(sym, "base"); - + try { if( base ) @@ -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); @@ -1191,7 +1191,7 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule, { std::string file = get_attr(sym, "file"); optional base = get_opt_attr(sym, "base"); - + try { if( base ) @@ -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,18 +1247,18 @@ 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); @@ -1494,7 +1494,7 @@ void map_parser::parse_stroke(stroke & strk, ptree const & sym) // stroke-dasharray optional str = get_opt_attr(sym,"stroke-dasharray"); - if (str) + if (str) { tokenizer<> tok (*str); std::vector dash_array; @@ -1563,7 +1563,7 @@ void map_parser::parse_line_symbolizer( rule & rule, ptree const & sym ) } } - + void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym ) { ensure_attrs(sym, "PolygonSymbolizer", "fill,fill-opacity,gamma,gamma-method,meta-writer,meta-output"); @@ -1597,7 +1597,7 @@ void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym ) void map_parser::parse_building_symbolizer( rule & rule, ptree const & sym ) { ensure_attrs(sym, "PolygonSymbolizer", "fill,fill-opacity,height,meta-writer,meta-output"); - try + try { building_symbolizer building_sym; @@ -1689,7 +1689,7 @@ void map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, // mode colorizer_mode default_mode = get_attr(node, "default-mode", COLORIZER_LINEAR); - + if(default_mode == COLORIZER_INHERIT) { throw config_error("RasterColorizer mode must not be INHERIT. "); } @@ -1697,15 +1697,15 @@ void map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, // default colour optional default_color = get_opt_attr(node, "default-color"); - if (default_color) + if (default_color) { rc->set_default_color( *default_color ); } - + // epsilon optional eps = get_opt_attr(node, "epsilon"); - if (eps) + if (eps) { if(*eps < 0) { throw config_error("RasterColorizer epsilon must be > 0. "); @@ -1713,7 +1713,7 @@ void map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, rc->set_epsilon( *eps ); } - + ptree::const_iterator stopIter = node.begin(); ptree::const_iterator endStop = node.end(); float maximumValue = -std::numeric_limits::max(); @@ -1739,11 +1739,11 @@ void map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, // value is required, and it must be bigger than the previous optional value = get_opt_attr(stop, "value"); - + if(!value) { throw config_error("stop tag missing value"); } - + if(value < maximumValue) { throw config_error("stop tag values must be in ascending order"); } @@ -1759,7 +1759,7 @@ void map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, tmpStop.set_value(*value); if (label) tmpStop.set_label(*label); - + rc->add_stop(tmpStop); } else if (stop_tag.first != "" && @@ -1792,20 +1792,20 @@ std::string map_parser::ensure_relative_to_xml( boost::optional opt { boost::filesystem::path xml_path = filename_; boost::filesystem::path rel_path = *opt_path; - if ( !rel_path.has_root_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 - - #ifdef MAPNIK_DEBUG +#endif + +#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(); } } diff --git a/src/map.cpp b/src/map.cpp index e421998b8..fa81ecfe0 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -59,17 +59,17 @@ static const char * aspect_fix_mode_strings[] = { "ADJUST_CANVAS_HEIGHT", "" }; - + 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), height_(height), @@ -77,7 +77,7 @@ Map::Map(int width,int height, std::string const& srs) buffer_size_(0), aspectFixMode_(GROW_BBOX), base_path_("") {} - + Map::Map(const Map& rhs) : width_(rhs.width_), height_(rhs.height_), @@ -95,7 +95,7 @@ Map::Map(const Map& rhs) base_path_(rhs.base_path_), extra_attr_(rhs.extra_attr_), extra_params_(rhs.extra_params_) {} - + Map& Map::operator=(const Map& rhs) { if (this==&rhs) return *this; @@ -116,43 +116,43 @@ Map& Map::operator=(const Map& rhs) extra_params_=rhs.extra_params_; return *this; } - + std::map const& Map::styles() const { return styles_; } - + std::map & Map::styles() { return styles_; } - + Map::style_iterator Map::begin_styles() { return styles_.begin(); } - + Map::style_iterator Map::end_styles() { return styles_.end(); } - + Map::const_style_iterator Map::begin_styles() const { return styles_.begin(); } - + Map::const_style_iterator Map::end_styles() const { return styles_.end(); } - -bool Map::insert_style(std::string const& name,feature_type_style const& style) + +bool Map::insert_style(std::string const& name,feature_type_style const& style) { return styles_.insert(make_pair(name,style)).second; } - -void Map::remove_style(std::string const& name) + +void Map::remove_style(std::string const& name) { styles_.erase(name); } @@ -200,7 +200,7 @@ Map::const_metawriter_iterator Map::end_metawriters() const return metawriters_.end(); } -bool Map::insert_fontset(std::string const& name, font_set const& fontset) +bool Map::insert_fontset(std::string const& name, font_set const& fontset) { return fontsets_.insert(make_pair(name, fontset)).second; } @@ -228,7 +228,7 @@ size_t Map::layer_count() const { return layers_.size(); } - + void Map::addLayer(const layer& l) { layers_.push_back(l); @@ -238,14 +238,14 @@ void Map::removeLayer(size_t index) { layers_.erase(layers_.begin()+index); } - -void Map::remove_all() + +void Map::remove_all() { layers_.clear(); styles_.clear(); metawriters_.clear(); } - + const layer& Map::getLayer(size_t index) const { return layers_[index]; @@ -275,14 +275,14 @@ unsigned Map::height() const { return height_; } - + void Map::set_width(unsigned width) { if (width >= MIN_MAPSIZE && width <= MAX_MAPSIZE) { width_=width; fixAspectRatio(); - } + } } void Map::set_height(unsigned height) @@ -293,7 +293,7 @@ void Map::set_height(unsigned height) fixAspectRatio(); } } - + void Map::resize(unsigned width,unsigned height) { if (width >= MIN_MAPSIZE && width <= MAX_MAPSIZE && @@ -309,12 +309,12 @@ std::string const& Map::srs() const { return srs_; } - + void Map::set_srs(std::string const& srs) { srs_ = srs; } - + void Map::set_buffer_size( int buffer_size) { buffer_size_ = buffer_size; @@ -324,22 +324,22 @@ int Map::buffer_size() const { return buffer_size_; } - + boost::optional const& Map::background() const { return background_; } - + void Map::set_background(const color& c) { background_ = c; } - + boost::optional const& Map::background_image() const { return background_image_; } - + void Map::set_background_image(std::string const& image_filename) { background_image_ = image_filename; @@ -349,7 +349,7 @@ void Map::set_maximum_extent(box2d const& box) { maximum_extent_ = box; } - + boost::optional > const& Map::maximum_extent() const { return maximum_extent_; @@ -370,21 +370,21 @@ void Map::zoom(double factor) coord2d center = current_extent_.center(); double w = factor * current_extent_.width(); double h = factor * current_extent_.height(); - current_extent_ = box2d(center.x - 0.5 * w, - center.y - 0.5 * h, - center.x + 0.5 * w, - center.y + 0.5 * h); + current_extent_ = box2d(center.x - 0.5 * w, + center.y - 0.5 * h, + center.x + 0.5 * w, + center.y + 0.5 * h); fixAspectRatio(); } - -void Map::zoom_all() + +void Map::zoom_all() { if (maximum_extent_) { zoom_to_box(*maximum_extent_); } else { - try + try { if (!layers_.size() > 0) return; @@ -400,24 +400,24 @@ void Map::zoom_all() { std::string const& layer_srs = itr->srs(); projection proj1(layer_srs); - + proj_transform prj_trans(proj0,proj1); - + box2d layer_ext = itr->envelope(); // TODO - consider using more robust method: http://trac.mapnik.org/ticket/751 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; first = false; } - else + else { ext.expand_to_include(layer_ext); } @@ -439,7 +439,7 @@ void Map::zoom_all() catch (proj_init_error & ex) { std::clog << "proj_init_error:" << ex.what() << "\n"; - } + } } } @@ -455,7 +455,7 @@ void Map::fixAspectRatio() double ratio2 = current_extent_.width() / current_extent_.height(); if (ratio1 == ratio2) return; - switch(aspectFixMode_) + switch(aspectFixMode_) { case ADJUST_BBOX_HEIGHT: current_extent_.height(current_extent_.width() / ratio1); @@ -464,44 +464,44 @@ void Map::fixAspectRatio() current_extent_.width(current_extent_.height() * ratio1); break; case ADJUST_CANVAS_HEIGHT: - height_ = int (width_ / ratio2 + 0.5); + height_ = int (width_ / ratio2 + 0.5); break; case ADJUST_CANVAS_WIDTH: - width_ = int (height_ * ratio2 + 0.5); + width_ = int (height_ * ratio2 + 0.5); break; case GROW_BBOX: if (ratio2 > ratio1) current_extent_.height(current_extent_.width() / ratio1); - else + else current_extent_.width(current_extent_.height() * ratio1); - break; + break; case SHRINK_BBOX: if (ratio2 < ratio1) current_extent_.height(current_extent_.width() / ratio1); - else + else current_extent_.width(current_extent_.height() * ratio1); - break; + break; case GROW_CANVAS: if (ratio2 > ratio1) width_ = (int) (height_ * ratio2 + 0.5); else - height_ = int (width_ / ratio2 + 0.5); + height_ = int (width_ / ratio2 + 0.5); break; case SHRINK_CANVAS: if (ratio2 > ratio1) - height_ = int (width_ / ratio2 + 0.5); + height_ = int (width_ / ratio2 + 0.5); else width_ = (int) (height_ * ratio2 + 0.5); break; default: if (ratio2 > ratio1) current_extent_.height(current_extent_.width() / ratio1); - else + else current_extent_.width(current_extent_.height() * ratio1); - break; + break; } } - + const box2d& Map::get_current_extent() const { return current_extent_; @@ -515,7 +515,7 @@ box2d Map::get_buffered_extent() const ext.height(current_extent_.height() + extra); return ext; } - + void Map::pan(int x,int y) { int dx = x - int(0.5 * width_); @@ -541,22 +541,22 @@ double Map::scale() const return current_extent_.width(); } -double Map::scale_denominator() const +double Map::scale_denominator() const { projection map_proj(srs_); - return mapnik::scale_denominator( *this, map_proj.is_geographic()); + return mapnik::scale_denominator( *this, map_proj.is_geographic()); } CoordTransform Map::view_transform() const { return CoordTransform(width_,height_,current_extent_); } - + featureset_ptr Map::query_point(unsigned index, double x, double y) const { if ( index< layers_.size()) { - mapnik::layer const& layer = layers_[index]; + mapnik::layer const& layer = layers_[index]; try { double z = 0; @@ -564,12 +564,12 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const mapnik::projection source(layer.srs()); proj_transform prj_trans(source,dest); prj_trans.backward(x,y,z); - + double minx = current_extent_.minx(); double miny = current_extent_.miny(); double maxx = current_extent_.maxx(); double maxy = current_extent_.maxy(); - + prj_trans.backward(minx,miny,z); prj_trans.backward(maxx,maxy,z); double tol = (maxx - minx) / width_ * 3; @@ -578,9 +578,9 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const { #ifdef MAPNIK_DEBUG std::clog << " query at point tol = " << tol << " (" << x << "," << y << ")\n"; -#endif +#endif featureset_ptr fs = ds->features_at_point(mapnik::coord2d(x,y)); - if (fs) + if (fs) return featureset_ptr(new filter_featureset(fs,hit_test_filter(x,y,tol))); } } @@ -593,7 +593,7 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const } return featureset_ptr(); } - + featureset_ptr Map::query_map_point(unsigned index, double x, double y) const { if ( index< layers_.size()) @@ -601,7 +601,7 @@ featureset_ptr Map::query_map_point(unsigned index, double x, double y) const mapnik::layer const& layer = layers_[index]; CoordTransform tr = view_transform(); tr.backward(&x,&y); - + try { mapnik::projection dest(srs_); @@ -609,12 +609,12 @@ featureset_ptr Map::query_map_point(unsigned index, double x, double y) const proj_transform prj_trans(source,dest); double z = 0; prj_trans.backward(x,y,z); - + double minx = current_extent_.minx(); double miny = current_extent_.miny(); double maxx = current_extent_.maxx(); double maxy = current_extent_.maxy(); - + prj_trans.backward(minx,miny,z); prj_trans.backward(maxx,maxy,z); double tol = (maxx - minx) / width_ * 3; @@ -625,7 +625,7 @@ featureset_ptr Map::query_map_point(unsigned index, double x, double y) const std::clog << " query at point tol = " << tol << " (" << x << "," << y << ")\n"; #endif featureset_ptr fs = ds->features_at_point(mapnik::coord2d(x,y)); - if (fs) + if (fs) return featureset_ptr(new filter_featureset(fs,hit_test_filter(x,y,tol))); } } diff --git a/src/mapped_memory_cache.cpp b/src/mapped_memory_cache.cpp index 00a9abdae..c9ea8084b 100644 --- a/src/mapped_memory_cache.cpp +++ b/src/mapped_memory_cache.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -30,7 +30,7 @@ #include #include -namespace mapnik +namespace mapnik { boost::unordered_map mapped_memory_cache::cache_; @@ -56,7 +56,7 @@ boost::optional mapped_memory_cache::find(std::string const& result.reset(itr->second); return result; } - + boost::filesystem::path path(uri); if (exists(path)) { @@ -64,9 +64,9 @@ boost::optional mapped_memory_cache::find(std::string const& { file_mapping mapping(uri.c_str(),read_only); mapped_region_ptr region(new mapped_region(mapping,read_only)); - + result.reset(region); - + if (update_cache) { cache_.insert(std::make_pair(uri,*result)); @@ -79,9 +79,9 @@ boost::optional 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; } diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp index b3b14ea3b..f5139699a 100644 --- a/src/marker_cache.cpp +++ b/src/marker_cache.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -36,7 +36,7 @@ #include #include -namespace mapnik +namespace mapnik { boost::unordered_map marker_cache::cache_; diff --git a/src/markers_symbolizer.cpp b/src/markers_symbolizer.cpp index bd30cf47e..02afffdd4 100644 --- a/src/markers_symbolizer.cpp +++ b/src/markers_symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -44,24 +44,24 @@ 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_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), 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), - symbolizer_base(), - allow_overlap_(false), - fill_(color(0,0,255)), - spacing_(100.0), + fill_(color(0,0,255)), + spacing_(100.0), max_error_(0.2), width_(5.0), height_(5.0), @@ -69,24 +69,24 @@ markers_symbolizer::markers_symbolizer(path_expression_ptr filename) marker_p_(MARKER_LINE_PLACEMENT), marker_type_(ARROW) {} -markers_symbolizer::markers_symbolizer(markers_symbolizer const& rhs) - : symbolizer_with_image(rhs), +markers_symbolizer::markers_symbolizer(markers_symbolizer const& rhs) + : symbolizer_with_image(rhs), symbolizer_base(rhs), allow_overlap_(rhs.allow_overlap_), - fill_(rhs.fill_), - spacing_(rhs.spacing_), + fill_(rhs.fill_), + spacing_(rhs.spacing_), max_error_(rhs.max_error_), width_(rhs.width_), height_(rhs.height_), stroke_(rhs.stroke_), marker_p_(rhs.marker_p_), marker_type_(rhs.marker_type_) {} - + void markers_symbolizer::set_allow_overlap(bool overlap) { allow_overlap_ = overlap; } - + bool markers_symbolizer::get_allow_overlap() const { return allow_overlap_; @@ -96,7 +96,7 @@ void markers_symbolizer::set_spacing(double spacing) { spacing_ = spacing; } - + double markers_symbolizer::get_spacing() const { return spacing_; @@ -106,17 +106,17 @@ void markers_symbolizer::set_max_error(double max_error) { max_error_ = max_error; } - + double markers_symbolizer::get_max_error() const { return max_error_; } - + void markers_symbolizer::set_fill(color fill) { fill_ = fill; } - + color const& markers_symbolizer::get_fill() const { return fill_; @@ -146,7 +146,7 @@ stroke const& markers_symbolizer::get_stroke() const { return stroke_; } - + void markers_symbolizer::set_stroke(stroke const& stroke) { stroke_ = stroke; diff --git a/src/memory.cpp b/src/memory.cpp index 7869a0fe6..3ac60446f 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp index d5e42f892..1e2edb189 100644 --- a/src/memory_datasource.cpp +++ b/src/memory_datasource.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -29,18 +29,18 @@ #include namespace mapnik { - + struct accumulate_extent { accumulate_extent(box2d & ext) : ext_(ext),first_(true) {} - + void operator() (feature_ptr feat) { for (unsigned i=0;inum_geometries();++i) { geometry_type & geom = feat->get_geometry(i); - if ( first_ ) + if ( first_ ) { first_ = false; ext_ = geom.envelope(); @@ -51,29 +51,29 @@ struct accumulate_extent } } } - + box2d & ext_; bool first_; }; - + memory_datasource::memory_datasource() : datasource(parameters()), desc_("in-memory datasource","utf-8") {} memory_datasource::~memory_datasource() {} - + void memory_datasource::push(feature_ptr feature) { // TODO - collect attribute descriptors? //desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Integer)); features_.push_back(feature); } - + datasource::datasource_t memory_datasource::type() const { return datasource::Vector; } - + featureset_ptr memory_datasource::features(const query& q) const { return featureset_ptr(new memory_featureset(q.get_bbox(),*this)); @@ -88,13 +88,13 @@ featureset_ptr memory_datasource::features_at_point(coord2d const& pt) const #endif return featureset_ptr(new memory_featureset(box,*this)); } - + box2d memory_datasource::envelope() const { box2d ext; accumulate_extent func(ext); std::for_each(features_.begin(),features_.end(),func); - return ext; + return ext; } boost::optional memory_datasource::get_geometry_type() const @@ -102,12 +102,12 @@ boost::optional memory_datasource::get_geometry_type() c // TODO - detect this? return datasource::Collection; } - + layer_descriptor memory_datasource::get_descriptor() const { return desc_; } - + size_t memory_datasource::size() const { return features_.size(); diff --git a/src/metawriter.cpp b/src/metawriter.cpp index 02cd62e65..9cd784cbf 100644 --- a/src/metawriter.cpp +++ b/src/metawriter.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ - + // Mapnik #include #include @@ -104,24 +104,24 @@ 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) { if (feature.has_key(p)) { mapnik::value const& val = feature.get(p); - std::string str = val.to_string(); + std::string str = val.to_string(); if (str.size() == 0) continue; // ignore empty attributes - + //Property found std::string text = boost::replace_all_copy(boost::replace_all_copy(str, "\\", "\\\\"), "\"", "\\\""); if (i++) *f_ << ","; *f_ << "\n \"" << p << "\":\"" << text << "\""; } } - + *f_ << "\n} }"; } @@ -142,7 +142,7 @@ void metawriter_json_stream::write_properties(Feature const& feature, metawriter void metawriter_json_stream::add_box(box2d 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 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(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_; } } diff --git a/src/metawriter_factory.cpp b/src/metawriter_factory.cpp index fbb33afc3..d79201838 100644 --- a/src/metawriter_factory.cpp +++ b/src/metawriter_factory.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -38,54 +38,54 @@ namespace mapnik metawriter_ptr metawriter_create(const boost::property_tree::ptree &pt) { - metawriter_ptr writer; - string type = get_attr(pt, "type"); + metawriter_ptr writer; + string type = get_attr(pt, "type"); - optional properties = get_opt_attr(pt, "default-output"); - if (type == "json") { - string file = get_attr(pt, "file"); - metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file))); - optional output_empty = get_opt_attr(pt, "output-empty"); - if (output_empty) { - json->set_output_empty(*output_empty); + optional properties = get_opt_attr(pt, "default-output"); + if (type == "json") { + string file = get_attr(pt, "file"); + metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file))); + optional output_empty = get_opt_attr(pt, "output-empty"); + if (output_empty) { + json->set_output_empty(*output_empty); + } + + optional pixel_coordinates = get_opt_attr(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 pixel_coordinates = get_opt_attr(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 +void metawriter_save(const metawriter_ptr &metawriter, ptree &metawriter_node, bool explicit_defaults) { - - metawriter_json *json = dynamic_cast(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.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.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()); } - } - - metawriter_inmem *inmem = dynamic_cast(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()); - } } } // namespace mapnik diff --git a/src/metawriter_inmem.cpp b/src/metawriter_inmem.cpp index 12cec9573..161b1968f 100644 --- a/src/metawriter_inmem.cpp +++ b/src/metawriter_inmem.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ - + // Mapnik #include #include @@ -41,25 +41,25 @@ using mapnik::metawriter_properties; map intersect_properties(Feature const& feature, metawriter_properties const& properties) { map nprops; - BOOST_FOREACH(string p, properties) + BOOST_FOREACH(string p, properties) { - if (feature.has_key(p)) + if (feature.has_key(p)) nprops.insert(std::make_pair(p,feature.get(p))); } - + return nprops; }} // end anonymous namespace namespace mapnik { -metawriter_inmem::metawriter_inmem(metawriter_properties dflt_properties) +metawriter_inmem::metawriter_inmem(metawriter_properties dflt_properties) : metawriter(dflt_properties) { } metawriter_inmem::~metawriter_inmem() { } -void +void metawriter_inmem::add_box(box2d const& box, Feature const& feature, CoordTransform const& /*t*/, metawriter_properties const& properties) { @@ -83,7 +83,7 @@ metawriter_inmem::add_text(text_placement_info const& p, } } -void +void metawriter_inmem::add_polygon(path_type & path, Feature const& feature, CoordTransform const& t, @@ -91,7 +91,7 @@ metawriter_inmem::add_polygon(path_type & path, add_vertices(path, feature, t, properties); } -void +void metawriter_inmem::add_line(path_type & path, Feature const& feature, CoordTransform const& t, @@ -99,7 +99,7 @@ metawriter_inmem::add_line(path_type & path, add_vertices(path, feature, t, properties); } -void +void metawriter_inmem::add_vertices(path_type & path, Feature const& feature, CoordTransform const& /*t*/, @@ -112,16 +112,16 @@ metawriter_inmem::add_vertices(path_type & path, while ((cmd = path.vertex(&x, &y)) != SEG_END) { box.expand_to_include(x, y); } - + if ((box.width() >= 0.0) && (box.height() >= 0.0)) { meta_instance inst; inst.properties = intersect_properties(feature, properties); inst.box = box; instances_.push_back(inst); - } + } } -void +void metawriter_inmem::start(metawriter_property_map const& /*properties*/) { instances_.clear(); } @@ -131,12 +131,12 @@ metawriter_inmem::instances() const { return instances_; } -metawriter_inmem::meta_instance_list::const_iterator +metawriter_inmem::meta_instance_list::const_iterator metawriter_inmem::inst_begin() const { return instances_.begin(); } -metawriter_inmem::meta_instance_list::const_iterator +metawriter_inmem::meta_instance_list::const_iterator metawriter_inmem::inst_end() const { return instances_.end(); } diff --git a/src/palette.cpp b/src/palette.cpp index 0dccde3b7..f03ecec2e 100644 --- a/src/palette.cpp +++ b/src/palette.cpp @@ -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 diff --git a/src/parse_path.cpp b/src/parse_path.cpp index aa7e1f9fe..d538befa3 100644 --- a/src/parse_path.cpp +++ b/src/parse_path.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 695af6137..8862929da 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -112,7 +112,7 @@ placement_finder::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 @@ -260,7 +260,7 @@ void placement_finder::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; @@ -407,7 +407,7 @@ void placement_finder::find_point_placement(double label_x, double la double dy = x * sina + y*cosa; current_placement->add_node(c, dx, dy, rad, ci.format); - + // compute the Bounding Box for each character and test for: // overlap, minimum distance or edge avoidance - exit if condition occurs box2d e; @@ -428,30 +428,30 @@ void placement_finder::find_point_placement(double label_x, double la current_placement->starting_x + dx + ci.width, // Top Right current_placement->starting_y - dy - ci.ymax); } - + // if there is an overlap with existing envelopes, then exit - no placement if (!detector_.extent().intersects(e) || (!p.allow_overlap && !detector_.has_point_placement(e, pi.get_actual_minimum_distance()))) { return; } - // if avoid_edges test dimensions contains e + // if avoid_edges test dimensions contains e if (p.avoid_edges && !dimensions_.contains(e)) { return; } - + if (p.minimum_padding > 0) { double min_pad = pi.get_actual_minimum_padding(); box2d epad(e.minx()-min_pad, - e.miny()-min_pad, - e.maxx()+min_pad, - e.maxy()+min_pad); - if (!dimensions_.contains(epad)) + e.miny()-min_pad, + e.maxx()+min_pad, + e.maxy()+min_pad); + if (!dimensions_.contains(epad)) { return; } } - + c_envelopes.push(e); // add character's envelope to temp storage } @@ -901,13 +901,13 @@ bool placement_finder::test_placement(const std::auto_ptr break; } if (p.minimum_padding > 0) - { + { double min_pad = pi.get_actual_minimum_padding(); box2d epad(e.minx()-min_pad, e.miny()-min_pad, e.maxx()+min_pad, e.maxy()+min_pad); - if (!dimensions_.contains(epad)) + if (!dimensions_.contains(epad)) { status = false; break; @@ -915,7 +915,7 @@ bool placement_finder::test_placement(const std::auto_ptr } pi.envelopes.push(e); } - + current_placement->rewind(); return status; diff --git a/src/plugin.cpp b/src/plugin.cpp index e96d71b52..810a26d38 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 9e642a91b..5e82013a2 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -51,12 +51,12 @@ public: ~png_reader(); unsigned width() const; unsigned height() const; - void read(unsigned x,unsigned y,image_data_32& image); + void read(unsigned x,unsigned y,image_data_32& image); private: void init(); }; - -namespace + +namespace { image_reader* create_png_reader(const std::string& file) { @@ -65,7 +65,7 @@ image_reader* create_png_reader(const std::string& file) const bool registered = register_image_reader("png",create_png_reader); } -png_reader::png_reader(const std::string& fileName) +png_reader::png_reader(const std::string& fileName) : fileName_(fileName), width_(0), height_(0), @@ -89,7 +89,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_error(png_ptr, "Read Error"); } } - + void png_reader::init() { @@ -111,7 +111,7 @@ void png_reader::init() png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,0,0,0); - if (!png_ptr) + if (!png_ptr) { fclose(fp); throw image_reader_exception("failed to allocate png_ptr"); @@ -137,21 +137,21 @@ void png_reader::init() #ifdef MAPNIK_DEBUG std::clog<<"bit_depth="<=libpng 1.2.7 png_set_add_alpha(png_ptr,0xff,PNG_FILLER_AFTER); //rgba - + double gamma; if (png_get_gAMA(png_ptr, info_ptr, &gamma)) png_set_gamma(png_ptr, 2.2, gamma); @@ -205,10 +205,10 @@ void png_reader::read(unsigned x0, unsigned y0,image_data_32& image) for (unsigned i=0;i=y0 && i=y0 && i(&row[x0]),w); - } + } } //END png_read_end(png_ptr,0); diff --git a/src/point_symbolizer.cpp b/src/point_symbolizer.cpp index 221f922cd..b0331eaab 100644 --- a/src/point_symbolizer.cpp +++ b/src/point_symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -37,13 +37,13 @@ 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) {} - -point_symbolizer::point_symbolizer(path_expression_ptr file) +: 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), symbolizer_base(), overlap_(false), @@ -61,7 +61,7 @@ void point_symbolizer::set_allow_overlap(bool overlap) { overlap_ = overlap; } - + bool point_symbolizer::get_allow_overlap() const { return overlap_; @@ -81,7 +81,7 @@ void point_symbolizer::set_ignore_placement(bool ignore_placement) { ignore_placement_ = ignore_placement; } - + bool point_symbolizer::get_ignore_placement() const { return ignore_placement_; diff --git a/src/polygon_pattern_symbolizer.cpp b/src/polygon_pattern_symbolizer.cpp index 511354248..66248eb36 100644 --- a/src/polygon_pattern_symbolizer.cpp +++ b/src/polygon_pattern_symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -26,7 +26,7 @@ namespace mapnik { - + static const char * pattern_alignment_strings[] = { "local", // feature "global", // map @@ -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), diff --git a/src/polygon_symbolizer.cpp b/src/polygon_symbolizer.cpp index 5d7c3b81c..7009e586c 100644 --- a/src/polygon_symbolizer.cpp +++ b/src/polygon_symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -27,7 +27,7 @@ namespace mapnik { -polygon_symbolizer::polygon_symbolizer() +polygon_symbolizer::polygon_symbolizer() : symbolizer_base(), fill_(color(128,128,128)), opacity_(1.0), @@ -40,7 +40,7 @@ polygon_symbolizer::polygon_symbolizer(color const& fill) opacity_(1.0), gamma_(1.0), gamma_method_(GAMMA_POWER) {} - + color const& polygon_symbolizer::get_fill() const { return fill_; diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp index e835adf4c..c52dfd7c6 100644 --- a/src/proj_transform.cpp +++ b/src/proj_transform.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -25,7 +25,7 @@ // mapnik #include #include -#include +#include #include // proj4 @@ -42,8 +42,8 @@ static const float M_PIby360 = M_PI / 360; static const float MAXEXTENTby180 = MAXEXTENT/180; namespace mapnik { - -proj_transform::proj_transform(projection const& source, + +proj_transform::proj_transform(projection const& source, projection const& dest) : source_(source), dest_(dest) @@ -91,8 +91,8 @@ 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 & box) const return false; box.init(minx,miny,maxx,maxy); return true; -} +} bool proj_transform::backward (box2d & box) const { @@ -222,19 +222,19 @@ void envelope_points(std::vector< coord > & coords, box2d& env { double width = env.width(); double height = env.height(); - + int steps; - + if (points <= 4) { steps = 0; } else { steps = static_cast(ceil((points - 4) / 4.0)); } - + steps += 1; double xstep = width / steps; double ystep = height / steps; - + for (int i=0; i<=steps; i++) { coords.push_back(coord(env.minx() + i * xstep, env.miny())); coords.push_back(coord(env.minx() + i * xstep, env.maxy())); @@ -249,7 +249,7 @@ void envelope_points(std::vector< coord > & coords, box2d& env box2d calculate_bbox(std::vector > & points) { std::vector >::iterator it = points.begin(); std::vector >::iterator it_end = points.end(); - + box2d env(*it, *(++it)); for (; it!=it_end; ++it) { env.expand_to_include(*it); @@ -262,16 +262,16 @@ box2d calculate_bbox(std::vector > & points) { * in the face of proj4 out of bounds conditions. * Can result in 20 -> 10 r/s performance hit. * Alternative is to provide proper clipping box - * in the target srs by setting map 'maximum-extent' + * in the target srs by setting map 'maximum-extent' */ bool proj_transform::backward(box2d& env, int points) const { if (is_source_equal_dest_) return true; - + std::vector > coords; envelope_points(coords, env, points); - + double z; for (std::vector >::iterator it = coords.begin(); it!=coords.end(); ++it) { z = 0; @@ -281,7 +281,7 @@ bool proj_transform::backward(box2d& env, int points) const } box2d result = calculate_bbox(coords); - + env.re_center(result.center().x, result.center().y); env.height(result.height()); env.width(result.width()); @@ -293,10 +293,10 @@ bool proj_transform::forward(box2d& env, int points) const { if (is_source_equal_dest_) return true; - + std::vector > coords; envelope_points(coords, env, points); - + double z; for (std::vector >::iterator it = coords.begin(); it!=coords.end(); ++it) { z = 0; @@ -306,7 +306,7 @@ bool proj_transform::forward(box2d& env, int points) const } box2d result = calculate_bbox(coords); - + env.re_center(result.center().x, result.center().y); env.height(result.height()); env.width(result.width()); @@ -322,5 +322,5 @@ mapnik::projection const& proj_transform::dest() const { return dest_; } - + } diff --git a/src/projection.cpp b/src/projection.cpp index ca0344cba..5fc97e150 100644 --- a/src/projection.cpp +++ b/src/projection.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -37,51 +37,51 @@ namespace mapnik { #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 boost::mutex projection::mutex_; #endif - + projection::projection(std::string const& params) : params_(params) -{ - init(); // -} - -projection::projection(projection const& rhs) - : params_(rhs.params_) { init(); // } - -projection& projection::operator=(projection const& rhs) -{ + +projection::projection(projection const& rhs) + : params_(rhs.params_) +{ + init(); // +} + +projection& projection::operator=(projection const& rhs) +{ projection tmp(rhs); swap(tmp); return *this; } - -bool projection::operator==(const projection& other) const + +bool projection::operator==(const projection& other) const { return (params_ == other.params_); } - -bool projection::operator!=(const projection& other) const + +bool projection::operator!=(const projection& other) const { return !(*this == other); } - + bool projection::is_initialized() const { return proj_ ? true : false; } - + bool projection::is_geographic() const { return is_geographic_; } - + std::string const& projection::params() const { return params_; } - + void projection::forward(double & x, double &y ) const { #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 @@ -97,9 +97,9 @@ void projection::forward(double & x, double &y ) const { x *=RAD_TO_DEG; y *=RAD_TO_DEG; - } + } } - + void projection::inverse(double & x,double & y) const { #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 @@ -109,7 +109,7 @@ void projection::inverse(double & x,double & y) const { x *=DEG_TO_RAD; y *=DEG_TO_RAD; - } + } projUV p; p.u = x; p.v = y; @@ -117,8 +117,8 @@ void projection::inverse(double & x,double & y) const x = RAD_TO_DEG * p.u; y = RAD_TO_DEG * p.v; } - -projection::~projection() + +projection::~projection() { #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 mutex::scoped_lock lock(mutex_); @@ -128,7 +128,7 @@ projection::~projection() if (proj_ctx_) pj_ctx_free(proj_ctx_); #endif } - + void projection::init() { #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 @@ -153,7 +153,7 @@ std::string projection::expanded() const } return std::string(""); } - + void projection::swap (projection& rhs) { std::swap(params_,rhs.params_); diff --git a/src/raster_colorizer.cpp b/src/raster_colorizer.cpp index ea6682139..1eb5a69f6 100644 --- a/src/raster_colorizer.cpp +++ b/src/raster_colorizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -40,15 +40,15 @@ static const char *colorizer_mode_strings[] = { IMPLEMENT_ENUM( colorizer_mode, colorizer_mode_strings ) -colorizer_stop::colorizer_stop(float value, colorizer_mode mode, - color const& _color, +colorizer_stop::colorizer_stop(float value, colorizer_mode mode, + color const& _color, std::string const& label) : value_(value) , mode_(mode) , color_(_color) , label_(label) { - + } colorizer_stop::colorizer_stop(colorizer_stop const& stop) @@ -62,13 +62,13 @@ colorizer_stop::colorizer_stop(colorizer_stop const& stop) colorizer_stop::~colorizer_stop() { - + } bool colorizer_stop::operator==(colorizer_stop const& other) const { - return (value_ == other.value_) && + return (value_ == other.value_) && (color_ == other.color_) && (mode_ == other.mode_) && (label_ == other.label_); @@ -80,7 +80,7 @@ std::string colorizer_stop::to_string() const std::stringstream ss; ss << color_.to_string() << " " << value_ << " " << mode_.as_string(); return ss.str(); -} +} @@ -91,24 +91,24 @@ raster_colorizer::raster_colorizer(colorizer_mode mode, color const& _color) , default_color_(_color) , epsilon_(std::numeric_limits::epsilon()) { - + } raster_colorizer::~raster_colorizer() { } -bool raster_colorizer::add_stop(colorizer_stop const& stop) +bool raster_colorizer::add_stop(colorizer_stop const& stop) { //make sure stops are added in order of value - if(stops_.size()) + if(stops_.size()) { - if(stop.get_value() <= stops_.back().get_value()) + if(stop.get_value() <= stops_.back().get_value()) { return false; } } - + stops_.push_back(stop); return true; @@ -117,9 +117,9 @@ bool raster_colorizer::add_stop(colorizer_stop const& stop) void raster_colorizer::colorize(raster_ptr const& raster, Feature const& f) const { unsigned *imageData = raster->data_.getData(); - + int len = raster->data_.width() * raster->data_.height(); - + bool hasNoData = false; float noDataValue = 0; @@ -129,7 +129,7 @@ void raster_colorizer::colorize(raster_ptr const& raster, Feature const& f) cons hasNoData = true; noDataValue = static_cast(f.get("NODATA").to_double()); } - + for (int i=0; i(fraction * ((float)end - (float)start) + start); } -color raster_colorizer::get_color(float value) const +color raster_colorizer::get_color(float value) const { int stopCount = stops_.size(); - + //use default color if no stops - if(stopCount == 0) + if(stopCount == 0) { return default_color_; } - + //1 - Find the stop that the value is in int stopIdx = -1; bool foundStopIdx = false; - - for(int i=0; i= stopCount) - { + if(nextStopIdx >= stopCount) + { //there is no next stop nextStopIdx = stopCount - 1; } - + //3 - Work out the mode colorizer_mode stopMode; - if( stopIdx == -1 ) - { + if( stopIdx == -1 ) + { //before the first stop stopMode = default_mode_; } - else + else { stopMode = stops_[stopIdx].get_mode(); - if(stopMode == COLORIZER_INHERIT) + if(stopMode == COLORIZER_INHERIT) { stopMode = default_mode_; } } - + //4 - Calculate the colour color stopColor; color nextStopColor; float stopValue = 0; float nextStopValue = 0; color outputColor = get_default_color(); - if(stopIdx == -1) + if(stopIdx == -1) { stopColor = default_color_; nextStopColor = stops_[nextStopIdx].get_color(); stopValue = value; nextStopValue = stops_[nextStopIdx].get_value(); } - else + else { stopColor = stops_[stopIdx].get_color(); nextStopColor = stops_[nextStopIdx].get_color(); stopValue = stops_[stopIdx].get_value(); nextStopValue = stops_[nextStopIdx].get_value(); } - - switch(stopMode) + + switch(stopMode) { case COLORIZER_LINEAR: { //deal with this separately so we don't have to worry about div0 - if(nextStopValue == stopValue) + if(nextStopValue == stopValue) { outputColor = stopColor; } - else + else { float fraction = (value - stopValue) / (nextStopValue - stopValue); - + unsigned r = interpolate(stopColor.red(), nextStopColor.red(),fraction); unsigned g = interpolate(stopColor.green(), nextStopColor.green(),fraction); unsigned b = interpolate(stopColor.blue(), nextStopColor.blue(),fraction); unsigned a = interpolate(stopColor.alpha(), nextStopColor.alpha(),fraction); - + outputColor.set_red(r); outputColor.set_green(g); outputColor.set_blue(b); outputColor.set_alpha(a); } - + } break; case COLORIZER_DISCRETE: @@ -252,18 +252,18 @@ color raster_colorizer::get_color(float value) const case COLORIZER_EXACT: default: //approximately equal (within epsilon) - if(fabs(value - stopValue) < epsilon_) + if(fabs(value - stopValue) < epsilon_) { outputColor = stopColor; } - else + else { outputColor = default_color_; } break; } - - + + /* std::clog << "get_color: " << value << "\n"; std::clog << "\tstopIdx: " << stopIdx << "\n"; diff --git a/src/save_map.cpp b/src/save_map.cpp index 13912a52d..dd2881f64 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -91,7 +91,7 @@ public: set_attr( sym_node, "rasterizer", sym.get_rasterizer() ); } } - + void operator () ( const line_pattern_symbolizer & sym ) { ptree & sym_node = rule_.push_back( @@ -165,7 +165,7 @@ public: { set_attr( sym_node, "scaling", sym.get_scaling() ); } - + if ( sym.get_opacity() != dfl.get_opacity() || explicit_defaults_ ) { set_attr( sym_node, "opacity", sym.get_opacity() ); @@ -198,9 +198,9 @@ public: // repeating the default values here. // maybe add a real, explicit default-ctor? - + shield_symbolizer dfl; - + if (sym.get_unlock_image() != dfl.get_unlock_image() || explicit_defaults_) { set_attr(sym_node, "unlock-image", sym.get_unlock_image()); @@ -310,7 +310,7 @@ public: private: serialize_symbolizer(); - + void serialize_raster_colorizer(ptree & sym_node, raster_colorizer_ptr const& colorizer, bool explicit_defaults) @@ -334,7 +334,7 @@ private: } } - + void add_image_attributes(ptree & node, const symbolizer_with_image & sym) { std::string const& filename = path_processor_type::to_string( *sym.get_filename()); @@ -345,7 +345,7 @@ private: { set_attr( node, "opacity", sym.get_opacity() ); } - + std::string tr_str = sym.get_transform_string(); if (tr_str != "matrix(1, 0, 0, 1, 0, 0)" || explicit_defaults_ ) { @@ -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(p.get()); text_placements_list *list = dynamic_cast(p.get()); if (simple) { @@ -385,7 +385,7 @@ private: { stroke dfl = stroke(); - + if ( strk.get_color() != dfl.get_color() || explicit_defaults_ ) { set_attr( node, "stroke", strk.get_color() ); @@ -428,7 +428,7 @@ private: } set_attr( node, "stroke-dasharray", os.str() ); } - + } void add_metawriter_attributes(ptree &node, symbolizer_base const& sym) { @@ -454,7 +454,7 @@ void serialize_rule( ptree & style_node, const rule & r, bool explicit_defaults) { set_attr(rule_node, "name", r.get_name()); } - + if ( r.has_else_filter() ) { rule_node.push_back( ptree::value_type( @@ -471,7 +471,7 @@ void serialize_rule( ptree & style_node, const rule & r, bool explicit_defaults) expression_ptr const& expr = r.get_filter(); std::string filter = mapnik::to_expression_string(*expr); std::string default_filter = mapnik::to_expression_string(*dfl.get_filter()); - + if ( filter != default_filter) { rule_node.push_back( ptree::value_type( @@ -509,7 +509,7 @@ void serialize_style( ptree & map_node, Map::const_style_iterator style_it, bool ptree::value_type("Style", ptree()))->second; set_attr(style_node, "name", name); - + feature_type_style dfl; if (filter_mode != dfl.get_filter_mode() || explicit_defaults) { @@ -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(".type", "string" ); } - private: +private: boost::property_tree::ptree & node_; }; @@ -599,7 +599,7 @@ void serialize_parameters( ptree & map_node, mapnik::parameters const& params) if (params.size()) { ptree & params_node = map_node.push_back( ptree::value_type("Parameters", ptree()))->second; - + parameters::const_iterator it = params.begin(); parameters::const_iterator end = params.end(); for (; it != end; ++it) @@ -618,12 +618,12 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau { ptree & layer_node = map_node.push_back( ptree::value_type("Layer", ptree()))->second; - + if ( layer.name() != "" ) { set_attr( layer_node, "name", layer.name() ); } - + if ( layer.srs() != "" ) { set_attr( layer_node, "srs", layer.srs() ); @@ -633,9 +633,9 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau { set_attr/**/( layer_node, "status", layer.isActive() ); } - + if ( layer.clear_label_cache() || explicit_defaults ) - { + { set_attr/**/( layer_node, "clear-label-cache", layer.clear_label_cache() ); } @@ -655,7 +655,7 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau } if ( layer.cache_features() || explicit_defaults ) - { + { set_attr/**/( layer_node, "cache-features", layer.cache_features() ); } @@ -710,17 +710,17 @@ void serialize_map(ptree & pt, Map const & map, bool explicit_defaults) { set_attr( map_node, "background-image", *image_filename ); } - + unsigned buffer_size = map.buffer_size(); if ( buffer_size || explicit_defaults) { - set_attr( map_node, "buffer-size", buffer_size ); + set_attr( map_node, "buffer-size", buffer_size ); } std::string const& base_path = map.base_path(); if ( !base_path.empty() || explicit_defaults) { - set_attr( map_node, "base", base_path ); + set_attr( map_node, "base", base_path ); } optional > const& maximum_extent = map.maximum_extent(); @@ -730,7 +730,7 @@ void serialize_map(ptree & pt, Map const & map, bool explicit_defaults) s << std::setprecision(16) << maximum_extent->minx() << "," << maximum_extent->miny() << "," << maximum_extent->maxx() << "," << maximum_extent->maxy(); - set_attr( map_node, "maximum-extent", s.str() ); + set_attr( map_node, "maximum-extent", s.str() ); } { @@ -747,9 +747,9 @@ void serialize_map(ptree & pt, Map const & map, bool explicit_defaults) parameters::const_iterator p_end = extra_attr.end(); for (; p_it != p_end; ++p_it) { - set_attr( map_node, p_it->first, p_it->second ); + set_attr( map_node, p_it->first, p_it->second ); } - + serialize_parameters( map_node, map.get_extra_parameters()); Map::const_style_iterator it = map.styles().begin(); diff --git a/src/scale_denominator.cpp b/src/scale_denominator.cpp index f79a964a8..ea2e612d8 100644 --- a/src/scale_denominator.cpp +++ b/src/scale_denominator.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -28,14 +28,14 @@ #include namespace mapnik { - -static const double pi = 3.14159265359; + +static const double pi = 3.14159265359; static const double meters_per_degree = 6378137 * 2 * pi/ 360; - + double scale_denominator(Map const& map, bool geographic) { double denom = map.scale() / 0.00028; if (geographic) denom *= meters_per_degree; - return denom; + return denom; } } diff --git a/src/shield_symbolizer.cpp b/src/shield_symbolizer.cpp index c5a03a453..dd2354a9b 100644 --- a/src/shield_symbolizer.cpp +++ b/src/shield_symbolizer.cpp @@ -81,7 +81,7 @@ void shield_symbolizer::set_shield_displacement(double shield_dx,double shield_d { shield_displacement_ = std::make_pair(shield_dx, shield_dy); } - + position const& shield_symbolizer::get_shield_displacement() const { return shield_displacement_; diff --git a/src/stroke.cpp b/src/stroke.cpp index 95cb632f2..d9f16c16c 100644 --- a/src/stroke.cpp +++ b/src/stroke.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -46,16 +46,16 @@ 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) {} +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) {} stroke::stroke(color const& c, double width) : c_(c), @@ -76,7 +76,7 @@ stroke::stroke(stroke const& other) line_join_(other.line_join_), gamma_(other.gamma_), gamma_method_(other.gamma_method_), - dash_(other.dash_), + dash_(other.dash_), dash_offset_(other.dash_offset_) {} stroke & stroke::operator=(const stroke& rhs) @@ -86,7 +86,7 @@ stroke & stroke::operator=(const stroke& rhs) return *this; } -void stroke::set_color(const color& c) +void stroke::set_color(const color& c) { c_=c; } @@ -106,13 +106,13 @@ void stroke::set_width(double w) } void stroke::set_opacity(double opacity) -{ +{ if (opacity > 1.0) opacity_=1.0; else if (opacity < 0.0) opacity_=0.0; else opacity_=opacity; } -double stroke::get_opacity() const +double stroke::get_opacity() const { return opacity_; } @@ -122,17 +122,17 @@ void stroke::set_line_cap(line_cap_e line_cap) line_cap_=line_cap; } -line_cap_e stroke::get_line_cap() const +line_cap_e stroke::get_line_cap() const { return line_cap_; } -void stroke::set_line_join(line_join_e line_join) +void stroke::set_line_join(line_join_e line_join) { line_join_=line_join; } -line_join_e stroke::get_line_join() const +line_join_e stroke::get_line_join() const { return line_join_; } @@ -162,7 +162,7 @@ void stroke::add_dash(double dash, double gap) dash_.push_back(std::make_pair(dash,gap)); } -bool stroke::has_dash() const +bool stroke::has_dash() const { return ! dash_.empty(); } diff --git a/src/svg/process_building_symbolizer.cpp b/src/svg/process_building_symbolizer.cpp index da56146b6..80659b03e 100644 --- a/src/svg/process_building_symbolizer.cpp +++ b/src/svg/process_building_symbolizer.cpp @@ -26,15 +26,15 @@ namespace mapnik { - template - void svg_renderer::process(building_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(building_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(building_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(building_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_line_pattern_symbolizer.cpp b/src/svg/process_line_pattern_symbolizer.cpp index 8a2274284..e567753dd 100644 --- a/src/svg/process_line_pattern_symbolizer.cpp +++ b/src/svg/process_line_pattern_symbolizer.cpp @@ -26,15 +26,15 @@ namespace mapnik { - template - void svg_renderer::process(line_pattern_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(line_pattern_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(line_pattern_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(line_pattern_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_line_symbolizer.cpp b/src/svg/process_line_symbolizer.cpp index 825b08d0b..374f325fb 100644 --- a/src/svg/process_line_symbolizer.cpp +++ b/src/svg/process_line_symbolizer.cpp @@ -26,24 +26,24 @@ namespace mapnik { - /*! - * @brief Collect presentation attributes found in line symbolizer. - */ - template - void svg_renderer::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 >::process(line_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +/*! + * @brief Collect presentation attributes found in line symbolizer. + */ +template +void svg_renderer::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 >::process(line_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_markers_symbolizer.cpp b/src/svg/process_markers_symbolizer.cpp index a4bba39bd..8688418f0 100644 --- a/src/svg/process_markers_symbolizer.cpp +++ b/src/svg/process_markers_symbolizer.cpp @@ -26,15 +26,15 @@ namespace mapnik { - template - void svg_renderer::process(markers_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(markers_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(markers_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(markers_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_point_symbolizer.cpp b/src/svg/process_point_symbolizer.cpp index bc6ab1a9c..5632880ce 100644 --- a/src/svg/process_point_symbolizer.cpp +++ b/src/svg/process_point_symbolizer.cpp @@ -26,15 +26,15 @@ namespace mapnik { - template - void svg_renderer::process(point_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(point_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(point_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(point_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_polygon_pattern_symbolizer.cpp b/src/svg/process_polygon_pattern_symbolizer.cpp index b3639b193..fb3d009dc 100644 --- a/src/svg/process_polygon_pattern_symbolizer.cpp +++ b/src/svg/process_polygon_pattern_symbolizer.cpp @@ -26,15 +26,15 @@ namespace mapnik { - template - void svg_renderer::process(polygon_pattern_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(polygon_pattern_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(polygon_pattern_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(polygon_pattern_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_polygon_symbolizer.cpp b/src/svg/process_polygon_symbolizer.cpp index 0c787d407..a3a38cd97 100644 --- a/src/svg/process_polygon_symbolizer.cpp +++ b/src/svg/process_polygon_symbolizer.cpp @@ -26,19 +26,19 @@ namespace mapnik { - /*! - * @brief Collect presentation attributes found in polygon symbolizer. - */ - template - void svg_renderer::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 >::process(polygon_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +/*! + * @brief Collect presentation attributes found in polygon symbolizer. + */ +template +void svg_renderer::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 >::process(polygon_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_raster_symbolizer.cpp b/src/svg/process_raster_symbolizer.cpp index ee7e0ab27..3378be467 100644 --- a/src/svg/process_raster_symbolizer.cpp +++ b/src/svg/process_raster_symbolizer.cpp @@ -24,17 +24,17 @@ // mapnik #include -namespace mapnik +namespace mapnik { - template - void svg_renderer::process(raster_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(raster_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(raster_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(raster_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_shield_symbolizer.cpp b/src/svg/process_shield_symbolizer.cpp index 7b9ae0311..64e997d77 100644 --- a/src/svg/process_shield_symbolizer.cpp +++ b/src/svg/process_shield_symbolizer.cpp @@ -26,15 +26,15 @@ namespace mapnik { - template - void svg_renderer::process(shield_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(shield_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(shield_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(shield_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/process_symbolizers.cpp b/src/svg/process_symbolizers.cpp index afa582e52..06b80b2eb 100644 --- a/src/svg/process_symbolizers.cpp +++ b/src/svg/process_symbolizers.cpp @@ -24,7 +24,7 @@ // mapnik #include -namespace mapnik { +namespace mapnik { template bool svg_renderer::process(rule::symbolizers const& syms, diff --git a/src/svg/process_text_symbolizer.cpp b/src/svg/process_text_symbolizer.cpp index 5440b1b01..f227e6b58 100644 --- a/src/svg/process_text_symbolizer.cpp +++ b/src/svg/process_text_symbolizer.cpp @@ -24,17 +24,17 @@ // mapnik #include -namespace mapnik +namespace mapnik { - template - void svg_renderer::process(text_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans) - { - // nothing yet. - } - - template void svg_renderer >::process(text_symbolizer const& sym, - Feature const& feature, - proj_transform const& prj_trans); +template +void svg_renderer::process(text_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans) +{ + // nothing yet. +} + +template void svg_renderer >::process(text_symbolizer const& sym, + Feature const& feature, + proj_transform const& prj_trans); } diff --git a/src/svg/svg_generator.cpp b/src/svg/svg_generator.cpp index 8e626eeea..edb64b4df 100644 --- a/src/svg/svg_generator.cpp +++ b/src/svg/svg_generator.cpp @@ -32,8 +32,8 @@ namespace mapnik { namespace svg { using namespace boost::spirit; template - svg_generator::svg_generator(OutputIterator& output_iterator) - : output_iterator_(output_iterator) {} + svg_generator::svg_generator(OutputIterator& output_iterator) + : output_iterator_(output_iterator) {} template svg_generator::~svg_generator() {} @@ -66,16 +66,16 @@ namespace mapnik { namespace svg { } template - void svg_generator::generate_path(path_type const& path, path_output_attributes const& path_attributes) - { + void svg_generator::generate_path(path_type const& path, path_output_attributes const& path_attributes) + { path_data_grammar data_grammar(path); path_attributes_grammar attributes_grammar; path_dash_array_grammar dash_array_grammar; - + karma::generate(output_iterator_, lit("\n"), path_attributes); } template class svg_generator >; -}} + }} diff --git a/src/svg/svg_output_attributes.cpp b/src/svg/svg_output_attributes.cpp index eac93a891..230f8d499 100644 --- a/src/svg/svg_output_attributes.cpp +++ b/src/svg/svg_output_attributes.cpp @@ -54,44 +54,44 @@ namespace mapnik { namespace svg { { stroke_width_ = stroke_width; } - + void path_output_attributes::set_stroke_linecap(const line_cap_e stroke_linecap) { - switch(stroke_linecap) - { - case BUTT_CAP: - stroke_linecap_ = "butt"; - break; - case SQUARE_CAP: - stroke_linecap_ = "square"; - break; - case ROUND_CAP: - stroke_linecap_ = "round"; - break; - default: - stroke_linecap_ = "butt"; - } + switch(stroke_linecap) + { + case BUTT_CAP: + stroke_linecap_ = "butt"; + break; + case SQUARE_CAP: + stroke_linecap_ = "square"; + break; + case ROUND_CAP: + stroke_linecap_ = "round"; + break; + default: + stroke_linecap_ = "butt"; + } } void path_output_attributes::set_stroke_linejoin(const line_join_e stroke_linejoin) { - switch(stroke_linejoin) - { - case MITER_JOIN: - stroke_linejoin_ = "miter"; - break; - case MITER_REVERT_JOIN: - stroke_linejoin_ = "miter"; - break; - case ROUND_JOIN: - stroke_linejoin_ = "round"; - break; - case BEVEL_JOIN: - stroke_linejoin_ = "bevel"; - break; - default: - stroke_linejoin_ = "miter"; - } + switch(stroke_linejoin) + { + case MITER_JOIN: + stroke_linejoin_ = "miter"; + break; + case MITER_REVERT_JOIN: + stroke_linejoin_ = "miter"; + break; + case ROUND_JOIN: + stroke_linejoin_ = "round"; + break; + case BEVEL_JOIN: + stroke_linejoin_ = "bevel"; + break; + default: + stroke_linejoin_ = "miter"; + } } void path_output_attributes::set_stroke_dasharray(const dash_array stroke_dasharray) @@ -225,21 +225,21 @@ namespace mapnik { namespace svg { // rect_output_attributes - const double root_output_attributes::SVG_VERSION = 1.1; - const std::string root_output_attributes::SVG_NAMESPACE_URL = "http://www.w3.org/2000/svg"; + const double root_output_attributes::SVG_VERSION = 1.1; + const std::string root_output_attributes::SVG_NAMESPACE_URL = "http://www.w3.org/2000/svg"; root_output_attributes::root_output_attributes() - : width_(400), - height_(400), - svg_version_(SVG_VERSION), - svg_namespace_url_(SVG_NAMESPACE_URL) + : width_(400), + height_(400), + svg_version_(SVG_VERSION), + svg_namespace_url_(SVG_NAMESPACE_URL) {} root_output_attributes::root_output_attributes(const unsigned width, const unsigned height) - : width_(width), - height_(height), - svg_version_(SVG_VERSION), - svg_namespace_url_(SVG_NAMESPACE_URL) + : width_(width), + height_(height), + svg_version_(SVG_VERSION), + svg_namespace_url_(SVG_NAMESPACE_URL) {} void root_output_attributes::set_width(const unsigned width) @@ -289,4 +289,4 @@ namespace mapnik { namespace svg { svg_version_ = SVG_VERSION; svg_namespace_url_ = SVG_NAMESPACE_URL; } -}} + }} diff --git a/src/svg/svg_renderer.cpp b/src/svg/svg_renderer.cpp index 8834644c4..a68979caa 100644 --- a/src/svg/svg_renderer.cpp +++ b/src/svg/svg_renderer.cpp @@ -33,70 +33,70 @@ namespace mapnik { - template - svg_renderer::svg_renderer(Map const& m, T & output_iterator, unsigned offset_x, unsigned offset_y) : - feature_style_processor(m), - output_iterator_(output_iterator), - width_(m.width()), - height_(m.height()), - t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y), - generator_(output_iterator) - {} +template +svg_renderer::svg_renderer(Map const& m, T & output_iterator, unsigned offset_x, unsigned offset_y) : + feature_style_processor(m), + output_iterator_(output_iterator), + width_(m.width()), + height_(m.height()), + t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y), + generator_(output_iterator) +{} - template - svg_renderer::~svg_renderer() {} +template +svg_renderer::~svg_renderer() {} - template - void svg_renderer::start_map_processing(Map const& map) +template +void svg_renderer::start_map_processing(Map const& map) +{ +#ifdef MAPNIK_DEBUG + std::clog << "start map processing" << std::endl; +#endif + + // generate XML header. + generator_.generate_header(); + + // generate SVG root element opening tag. + // the root element defines the size of the image, + // which is taken from the map's dimensions. + svg::root_output_attributes root_attributes(width_, height_); + generator_.generate_opening_root(root_attributes); + + boost::optional const& bgcolor = map.background(); + if(bgcolor) { - #ifdef MAPNIK_DEBUG - std::clog << "start map processing" << std::endl; - #endif - - // generate XML header. - generator_.generate_header(); - - // generate SVG root element opening tag. - // the root element defines the size of the image, - // which is taken from the map's dimensions. - svg::root_output_attributes root_attributes(width_, height_); - generator_.generate_opening_root(root_attributes); - - boost::optional const& bgcolor = map.background(); - if(bgcolor) - { - // generate background color as a rectangle that spans the whole image. - svg::rect_output_attributes bg_attributes(0, 0, width_, height_, *bgcolor); - generator_.generate_rect(bg_attributes); - } + // generate background color as a rectangle that spans the whole image. + svg::rect_output_attributes bg_attributes(0, 0, width_, height_, *bgcolor); + generator_.generate_rect(bg_attributes); } - - template - void svg_renderer::end_map_processing(Map const& map) - { - // generate SVG root element closing tag. - generator_.generate_closing_root(); - - #ifdef MAPNIK_DEBUG - std::clog << "end map processing" << std::endl; - #endif - } - - template - void svg_renderer::start_layer_processing(layer const& lay) - { - #ifdef MAPNIK_DEBUG - std::clog << "start layer processing: " << lay.name() << std::endl; - #endif - } - - template - void svg_renderer::end_layer_processing(layer const& lay) - { - #ifdef MAPNIK_DEBUG - std::clog << "end layer processing: " << lay.name() << std::endl; - #endif - } - - template class svg_renderer >; +} + +template +void svg_renderer::end_map_processing(Map const& map) +{ + // generate SVG root element closing tag. + generator_.generate_closing_root(); + +#ifdef MAPNIK_DEBUG + std::clog << "end map processing" << std::endl; +#endif +} + +template +void svg_renderer::start_layer_processing(layer const& lay) +{ +#ifdef MAPNIK_DEBUG + std::clog << "start layer processing: " << lay.name() << std::endl; +#endif +} + +template +void svg_renderer::end_layer_processing(layer const& lay) +{ +#ifdef MAPNIK_DEBUG + std::clog << "end layer processing: " << lay.name() << std::endl; +#endif +} + +template class svg_renderer >; } diff --git a/src/svg_parser.cpp b/src/svg_parser.cpp index 73c693eb1..2107aa646 100644 --- a/src/svg_parser.cpp +++ b/src/svg_parser.cpp @@ -45,29 +45,29 @@ namespace mapnik { namespace svg { -typedef std::vector > color_lookup_type; + typedef std::vector > color_lookup_type; -namespace qi = boost::spirit::qi; + namespace qi = boost::spirit::qi; -typedef std::vector > pairs_type; + typedef std::vector > pairs_type; -template -struct key_value_sequence_ordered - : qi::grammar -{ - key_value_sequence_ordered() - : key_value_sequence_ordered::base_type(query) + template + struct key_value_sequence_ordered + : qi::grammar { - query = pair >> *( qi::lit(';') >> pair); - pair = key >> -(':' >> value); - key = qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9-"); - value = +(qi::char_ - qi::lit(';')); - } - - qi::rule query; - qi::rule(), SkipType> pair; - qi::rule key, value; -}; + key_value_sequence_ordered() + : key_value_sequence_ordered::base_type(query) + { + query = pair >> *( qi::lit(';') >> pair); + pair = key >> -(':' >> value); + key = qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9-"); + value = +(qi::char_ - qi::lit(';')); + } + + qi::rule query; + qi::rule(), SkipType> pair; + qi::rule key, value; + }; agg::rgba8 parse_color(const char* str) { @@ -76,7 +76,7 @@ agg::rgba8 parse_color(const char* str) { mapnik::color_factory::init_from_string(c,str); } - catch (mapnik::config_error & ex) + catch (mapnik::config_error & ex) { std::cerr << ex.what() << std::endl; } @@ -88,7 +88,7 @@ double parse_double(const char* str) using namespace boost::spirit::qi; double val = 0.0; parse(str, str+ strlen(str),double_,val); - return val; + return val; } /* @@ -124,26 +124,26 @@ bool parse_style (const char* str, pairs_type & v) return phrase_parse(str, str + strlen(str), kv_parser, skip_type(), v); } -svg_parser::svg_parser(svg_converter > & path) +svg_parser::svg_parser(svg_converter > & path) : path_(path), is_defs_(false) {} - + svg_parser::~svg_parser() {} void svg_parser::parse(std::string const& filename) { xmlTextReaderPtr reader = xmlNewTextReaderFilename(filename.c_str()); - if (reader != 0) + if (reader != 0) { int ret = xmlTextReaderRead(reader); - while (ret == 1) + while (ret == 1) { process_node(reader); ret = xmlTextReaderRead(reader); } xmlFreeTextReader(reader); - if (ret != 0) + if (ret != 0) { std::cerr << "Failed to parse " << filename << std::endl; } @@ -171,8 +171,8 @@ void svg_parser::process_node(xmlTextReaderPtr reader) void svg_parser::start_element(xmlTextReaderPtr reader) { const xmlChar *name; - name = xmlTextReaderConstName(reader); - + name = xmlTextReaderConstName(reader); + if (!is_defs_ && xmlStrEqual(name, BAD_CAST "g")) { path_.push_attr(); @@ -186,11 +186,11 @@ void svg_parser::start_element(xmlTextReaderPtr reader) else if ( !is_defs_ && xmlStrEqual(name, BAD_CAST "path")) { parse_path(reader); - } + } else if (!is_defs_ && xmlStrEqual(name, BAD_CAST "polygon") ) { parse_polygon(reader); - } + } else if (!is_defs_ && xmlStrEqual(name, BAD_CAST "polyline")) { parse_polyline(reader); @@ -198,11 +198,11 @@ void svg_parser::start_element(xmlTextReaderPtr reader) else if (!is_defs_ && xmlStrEqual(name, BAD_CAST "line")) { parse_line(reader); - } + } else if (!is_defs_ && xmlStrEqual(name, BAD_CAST "rect")) { parse_rect(reader); - } + } else if (!is_defs_ && xmlStrEqual(name, BAD_CAST "circle")) { parse_circle(reader); @@ -234,7 +234,7 @@ void svg_parser::start_element(xmlTextReaderPtr reader) void svg_parser::end_element(xmlTextReaderPtr reader) { const xmlChar *name; - name = xmlTextReaderConstName(reader); + name = xmlTextReaderConstName(reader); if (!is_defs_ && xmlStrEqual(name, BAD_CAST "g")) { path_.pop_attr(); @@ -285,7 +285,7 @@ void svg_parser::parse_attr(const xmlChar * name, const xmlChar * value ) } else if (xmlStrEqual(name, BAD_CAST "fill-opacity")) { - path_.fill_opacity(parse_double((const char*) value)); + path_.fill_opacity(parse_double((const char*) value)); } else if (xmlStrEqual(name, BAD_CAST "fill-rule")) { @@ -334,27 +334,27 @@ void svg_parser::parse_attr(const xmlChar * name, const xmlChar * value ) } else if(xmlStrEqual(name,BAD_CAST "stroke-linecap")) { - if(xmlStrEqual(value,BAD_CAST "butt")) + if(xmlStrEqual(value,BAD_CAST "butt")) path_.line_cap(agg::butt_cap); - else if(xmlStrEqual(value,BAD_CAST "round")) + else if(xmlStrEqual(value,BAD_CAST "round")) path_.line_cap(agg::round_cap); - else if(xmlStrEqual(value,BAD_CAST "square")) + else if(xmlStrEqual(value,BAD_CAST "square")) path_.line_cap(agg::square_cap); } else if(xmlStrEqual(name,BAD_CAST "stroke-linejoin")) { - if(xmlStrEqual(value,BAD_CAST "miter")) + if(xmlStrEqual(value,BAD_CAST "miter")) path_.line_join(agg::miter_join); - else if(xmlStrEqual(value,BAD_CAST "round")) + else if(xmlStrEqual(value,BAD_CAST "round")) path_.line_join(agg::round_join); - else if(xmlStrEqual(value,BAD_CAST "bevel")) + else if(xmlStrEqual(value,BAD_CAST "bevel")) path_.line_join(agg::bevel_join); } else if(xmlStrEqual(name,BAD_CAST "stroke-miterlimit")) { path_.miter_limit(parse_double((const char*)value)); } - + else if(xmlStrEqual(name, BAD_CAST "opacity")) { double opacity = parse_double((const char*)value); @@ -376,14 +376,14 @@ void svg_parser::parse_attr(xmlTextReaderPtr reader) value = xmlTextReaderConstValue(reader); if (xmlStrEqual(name, BAD_CAST "style")) { - typedef std::vector > cont_type; + typedef std::vector > cont_type; typedef cont_type::value_type value_type; cont_type vec; parse_style((const char*)value, vec); BOOST_FOREACH(value_type kv , vec ) { - parse_attr(BAD_CAST kv.first.c_str(),BAD_CAST kv.second.c_str()); - } + parse_attr(BAD_CAST kv.first.c_str(),BAD_CAST kv.second.c_str()); + } } else { @@ -396,11 +396,11 @@ void svg_parser::parse_path(xmlTextReaderPtr reader) const xmlChar *value; value = xmlTextReaderGetAttribute(reader, BAD_CAST "d"); - if (value) + if (value) { path_.begin_path(); parse_attr(reader); - + if (!mapnik::svg::parse_path((const char*) value, path_)) { std::runtime_error("can't parse PATH\n"); @@ -412,9 +412,9 @@ void svg_parser::parse_path(xmlTextReaderPtr reader) void svg_parser::parse_polygon(xmlTextReaderPtr reader) { const xmlChar *value; - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "points"); - if (value) + if (value) { path_.begin_path(); parse_attr(reader); @@ -430,9 +430,9 @@ void svg_parser::parse_polygon(xmlTextReaderPtr reader) void svg_parser::parse_polyline(xmlTextReaderPtr reader) { const xmlChar *value; - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "points"); - if (value) + if (value) { path_.begin_path(); parse_attr(reader); @@ -440,7 +440,7 @@ void svg_parser::parse_polyline(xmlTextReaderPtr reader) { throw std::runtime_error("Failed to parse \n"); } - + path_.end_path(); } } @@ -452,7 +452,7 @@ void svg_parser::parse_line(xmlTextReaderPtr reader) double y1 = 0.0; double x2 = 0.0; double y2 = 0.0; - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "x1"); if (value) x1 = parse_double((const char*)value); value = xmlTextReaderGetAttribute(reader, BAD_CAST "y1"); @@ -461,13 +461,13 @@ void svg_parser::parse_line(xmlTextReaderPtr reader) if (value) x2 = parse_double((const char*)value); value = xmlTextReaderGetAttribute(reader, BAD_CAST "y2"); if (value) y2 = parse_double((const char*)value); - - path_.begin_path(); + + path_.begin_path(); parse_attr(reader); path_.move_to(x1, y1); path_.line_to(x2, y2); path_.end_path(); - + } void svg_parser::parse_circle(xmlTextReaderPtr reader) @@ -483,16 +483,16 @@ void svg_parser::parse_circle(xmlTextReaderPtr reader) value = xmlTextReaderGetAttribute(reader, BAD_CAST "r"); if (value) r = parse_double((const char*)value); - path_.begin_path(); + path_.begin_path(); parse_attr(reader); - + if(r != 0.0) { if(r < 0.0) throw std::runtime_error("parse_circle: Invalid radius"); agg::ellipse c(cx, cy, r, r); path_.storage().concat_path(c); } - + path_.end_path(); } @@ -503,7 +503,7 @@ void svg_parser::parse_ellipse(xmlTextReaderPtr reader) double cy = 0.0; double rx = 0.0; double ry = 0.0; - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "cx"); if (value) cx = parse_double((const char*)value); value = xmlTextReaderGetAttribute(reader, BAD_CAST "cy"); @@ -512,10 +512,10 @@ void svg_parser::parse_ellipse(xmlTextReaderPtr reader) if (value) rx = parse_double((const char*)value); value = xmlTextReaderGetAttribute(reader, BAD_CAST "ry"); if (value) ry = parse_double((const char*)value); - - path_.begin_path(); + + path_.begin_path(); parse_attr(reader); - + if(rx != 0.0 && ry != 0.0) { if(rx < 0.0) throw std::runtime_error("parse_ellipse: Invalid rx"); @@ -523,7 +523,7 @@ void svg_parser::parse_ellipse(xmlTextReaderPtr reader) agg::ellipse c(cx, cy, rx, ry); path_.storage().concat_path(c); } - + path_.end_path(); } @@ -536,7 +536,7 @@ void svg_parser::parse_rect(xmlTextReaderPtr reader) double h = 0.0; double rx = 0.0; double ry = 0.0; - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "x"); if (value) x = parse_double((const char*)value); value = xmlTextReaderGetAttribute(reader, BAD_CAST "y"); @@ -545,42 +545,42 @@ void svg_parser::parse_rect(xmlTextReaderPtr reader) if (value) w = parse_double((const char*)value); value = xmlTextReaderGetAttribute(reader, BAD_CAST "height"); if (value) h = parse_double((const char*)value); - + bool rounded = true; value = xmlTextReaderGetAttribute(reader, BAD_CAST "rx"); - + if (value) rx = parse_double((const char*)value); else rounded = false; - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "ry"); if (value) { ry = parse_double((const char*)value); - if (!rounded) + if (!rounded) { rx = ry; rounded = true; } } - else if (rounded) + else if (rounded) { ry = rx; } - + if(w != 0.0 && h != 0.0) { if(w < 0.0) throw std::runtime_error("parse_rect: Invalid width"); if(h < 0.0) throw std::runtime_error("parse_rect: Invalid height"); if(rx < 0.0) throw std::runtime_error("parse_rect: Invalid rx"); if(ry < 0.0) throw std::runtime_error("parse_rect: Invalid ry"); - + path_.begin_path(); parse_attr(reader); - + if(rounded) { //path_.move_to(x + rx,y); - //path_.line_to(x + w - rx,y); + //path_.line_to(x + w - rx,y); //path_.arc_to (rx,ry,0,0,1,x + w, y + ry); //path_.line_to(x + w, y + h - ry); //path_.arc_to (rx,ry,0,0,1,x + w - rx, y + h); @@ -609,10 +609,10 @@ void svg_parser::parse_rect(xmlTextReaderPtr reader) /* * - */ + style="stop-color:#ffffff;stop-opacity:1;" + offset="1" + id="stop3763" /> +*/ void svg_parser::parse_gradient_stop(xmlTextReaderPtr reader) { const xmlChar *value; @@ -738,16 +738,16 @@ bool svg_parser::parse_common_gradient(xmlTextReaderPtr reader) /** * - */ + collect="always" + xlink:href="#linearGradient3759" + id="radialGradient3765" + cx="-1.2957155" + cy="-21.425594" + fx="-1.2957155" + fy="-21.425594" + r="5.1999998" + gradientUnits="userSpaceOnUse" /> +*/ void svg_parser::parse_radial_gradient(xmlTextReaderPtr reader) { if (!parse_common_gradient(reader)) diff --git a/src/svg_path_parser.cpp b/src/svg_path_parser.cpp index 18539f42f..47f9f3b61 100644 --- a/src/svg_path_parser.cpp +++ b/src/svg_path_parser.cpp @@ -32,20 +32,20 @@ // stl #include -namespace mapnik { namespace svg { +namespace mapnik { namespace svg { -template -bool parse_path(const char* wkt, PathType & p) -{ - using namespace boost::spirit; - typedef const char* iterator_type; - typedef ascii::space_type skip_type; - svg_path_grammar g(p); - iterator_type first = wkt; - iterator_type last = wkt + std::strlen(wkt); - return qi::phrase_parse(first, last, g, skip_type()); -} + template + bool parse_path(const char* wkt, PathType & p) + { + using namespace boost::spirit; + typedef const char* iterator_type; + typedef ascii::space_type skip_type; + svg_path_grammar g(p); + iterator_type first = wkt; + iterator_type last = wkt + std::strlen(wkt); + return qi::phrase_parse(first, last, g, skip_type()); + } -template bool parse_path(const char*, svg_converter_type&); + template bool parse_path(const char*, svg_converter_type&); -}} + }} diff --git a/src/svg_points_parser.cpp b/src/svg_points_parser.cpp index d7c6fdbb8..d8d2de48a 100644 --- a/src/svg_points_parser.cpp +++ b/src/svg_points_parser.cpp @@ -27,20 +27,20 @@ // stl #include -namespace mapnik { namespace svg { +namespace mapnik { namespace svg { -template -bool parse_points(const char* wkt, PathType & p) -{ - using namespace boost::spirit; - typedef const char* iterator_type; - typedef ascii::space_type skip_type; - svg_points_grammar g(p); - iterator_type first = wkt; - iterator_type last = wkt + std::strlen(wkt); - return qi::phrase_parse(first, last, g, skip_type()); -} + template + bool parse_points(const char* wkt, PathType & p) + { + using namespace boost::spirit; + typedef const char* iterator_type; + typedef ascii::space_type skip_type; + svg_points_grammar g(p); + iterator_type first = wkt; + iterator_type last = wkt + std::strlen(wkt); + return qi::phrase_parse(first, last, g, skip_type()); + } -template bool parse_points(const char*, svg_converter_type&); + template bool parse_points(const char*, svg_converter_type&); -}} + }} diff --git a/src/svg_transform_parser.cpp b/src/svg_transform_parser.cpp index ea3b9bb4d..983cc61e2 100644 --- a/src/svg_transform_parser.cpp +++ b/src/svg_transform_parser.cpp @@ -28,35 +28,35 @@ // stl #include -namespace mapnik { namespace svg { +namespace mapnik { namespace svg { -template -bool parse_transform(const char * wkt, TransformType & p) -{ - using namespace boost::spirit; - typedef const char * iterator_type; - typedef ascii::space_type skip_type; - svg_transform_grammar g(p); - iterator_type first = wkt; - iterator_type last = wkt + std::strlen(wkt); - return qi::phrase_parse(first, last, g, skip_type()); -} + template + bool parse_transform(const char * wkt, TransformType & p) + { + using namespace boost::spirit; + typedef const char * iterator_type; + typedef ascii::space_type skip_type; + svg_transform_grammar g(p); + iterator_type first = wkt; + iterator_type last = wkt + std::strlen(wkt); + return qi::phrase_parse(first, last, g, skip_type()); + } /* -template -bool parse_transform(std::string const& wkt, TransformType & p) -{ - using namespace boost::spirit; - typedef std::string::const_iterator iterator_type; - typedef ascii::space_type skip_type; - svg_transform_grammar g(p); - iterator_type first = wkt.begin(); - iterator_type last = wkt.end(); - return qi::phrase_parse(first, last, g, skip_type()); -} + template + bool parse_transform(std::string const& wkt, TransformType & p) + { + using namespace boost::spirit; + typedef std::string::const_iterator iterator_type; + typedef ascii::space_type skip_type; + svg_transform_grammar g(p); + iterator_type first = wkt.begin(); + iterator_type last = wkt.end(); + return qi::phrase_parse(first, last, g, skip_type()); + } */ -template MAPNIK_DECL bool parse_transform(const char*, agg::trans_affine&); + template MAPNIK_DECL bool parse_transform(const char*, agg::trans_affine&); //template bool parse_transform(std::string const& , agg::trans_affine&); -}} + }} diff --git a/src/symbolizer.cpp b/src/symbolizer.cpp index e954aa5a1..a9c1f0c7e 100644 --- a/src/symbolizer.cpp +++ b/src/symbolizer.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -34,7 +34,7 @@ void symbolizer_base::add_metawriter(std::string const& name, metawriter_propert } void symbolizer_base::add_metawriter(metawriter_ptr writer_ptr, metawriter_properties const& properties, - std::string const& name) + std::string const& name) { writer_ptr_ = writer_ptr; properties_ = properties; @@ -87,17 +87,17 @@ symbolizer_with_image::symbolizer_with_image( symbolizer_with_image const& rhs) : image_filename_(rhs.image_filename_), image_opacity_(rhs.image_opacity_), matrix_(rhs.matrix_) {} - + path_expression_ptr symbolizer_with_image::get_filename() const { return image_filename_; } -void symbolizer_with_image::set_filename(path_expression_ptr image_filename) +void symbolizer_with_image::set_filename(path_expression_ptr image_filename) { image_filename_ = image_filename; } - + void symbolizer_with_image::set_transform(transform_type const& matrix) { matrix_ = matrix; diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index b786cc793..694bac939 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -38,8 +38,8 @@ text_placement_info_ptr text_symbolizer_helper::get_lin //Found a placement geometries_to_process_.erase(current_object); if (writer_.first) writer_.first->add_text( - *placement_, font_manager_, - feature_, t_, writer_.second); + *placement_, font_manager_, + feature_, t_, writer_.second); return placement_; } //No placement for this geometry. Keep it in geometries_to_process_ for next try. @@ -70,8 +70,8 @@ text_placement_info_ptr text_symbolizer_helper::get_poi //Found a placement points_.erase(current_object); if (writer_.first) writer_.first->add_text( - *placement_, font_manager_, - feature_, t_, writer_.second); + *placement_, font_manager_, + feature_, t_, writer_.second); finder.update_detector(); return placement_; } @@ -104,14 +104,14 @@ void text_symbolizer_helper::initialize_geometries() // don't bother with empty geometries if (geom.num_points() == 0) continue; eGeomType type = geom.type(); - if (type == Polygon) + if (type == Polygon) { largest_box_only = true; if (sym_.get_minimum_path_length() > 0) { // TODO - find less costly method than fetching full envelope box2d gbox = t_.forward(geom.envelope(), prj_trans_); - + if (gbox.width() < sym_.get_minimum_path_length()) { continue; @@ -121,7 +121,7 @@ void text_symbolizer_helper::initialize_geometries() // TODO - calculate length here as well geometries_to_process_.push_back(const_cast(&geom)); } - + if (largest_box_only) { geometries_to_process_.sort(largest_bbox_first()); @@ -194,8 +194,8 @@ bool text_symbolizer_helper::next_placement() if (placement_->properties.orientation) { angle_ = boost::apply_visitor( - evaluate(feature_), - *(placement_->properties.orientation)).to_double(); + evaluate(feature_), + *(placement_->properties.orientation)).to_double(); } else { angle_ = 0.0; } @@ -287,13 +287,13 @@ text_placement_info_ptr shield_symbolizer_helper::get_l { position const& pos = placement_->properties.displacement; placement_->additional_boxes.push_back( - /*TODO: I'm not sure this is correct. It's what the old code did, but - I think transfroms can make the marker non-centered. - */ - box2d(-0.5 * marker_ext_.width() - pos.first, - -0.5 * marker_ext_.height() - pos.second, - 0.5 * marker_ext_.width() - pos.first, - 0.5 * marker_ext_.height() - pos.second)); + /*TODO: I'm not sure this is correct. It's what the old code did, but + I think transfroms can make the marker non-centered. + */ + box2d(-0.5 * marker_ext_.width() - pos.first, + -0.5 * marker_ext_.height() - pos.second, + 0.5 * marker_ext_.width() - pos.first, + 0.5 * marker_ext_.height() - pos.second)); return text_symbolizer_helper::get_line_placement(); } diff --git a/src/text_placements.cpp b/src/text_placements.cpp index d3703ce02..6333c8304 100644 --- a/src/text_placements.cpp +++ b/src/text_placements.cpp @@ -369,7 +369,7 @@ std::set text_placements::get_all_expressions() /************************************************************************/ text_placement_info::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_) : properties(parent->properties), scale_factor(scale_factor_), has_dimensions(has_dimensions_), @@ -390,7 +390,7 @@ text_placement_info_ptr text_placements_dummy::get_placement_info( double scale_factor, dimension_type dim, bool has_dimensions) const { return text_placement_info_ptr(new text_placement_info_dummy( - this, scale_factor, dim, has_dimensions)); + this, scale_factor, dim, has_dimensions)); } /************************************************************************/ @@ -458,20 +458,20 @@ text_placement_info_ptr text_placements_simple::get_placement_info( double scale_factor, dimension_type dim, bool has_dimensions) const { return text_placement_info_ptr(new text_placement_info_simple(this, - scale_factor, dim, has_dimensions)); + scale_factor, dim, has_dimensions)); } /** Position string: [POS][SIZE] - * [POS] is any combination of - * N, E, S, W, NE, SE, NW, SW, X (exact position) (separated by commas) - * [SIZE] is a list of font sizes, separated by commas. The first font size - * is always the one given in the TextSymbolizer's parameters. - * First all directions are tried, then font size is reduced - * and all directions are tried again. The process ends when a placement is - * found or the last fontsize is tried without success. - * Example: N,S,15,10,8 (tries placement above, then below and if - * that fails it tries the additional font sizes 15, 10 and 8. - */ + * [POS] is any combination of + * N, E, S, W, NE, SE, NW, SW, X (exact position) (separated by commas) + * [SIZE] is a list of font sizes, separated by commas. The first font size + * is always the one given in the TextSymbolizer's parameters. + * First all directions are tried, then font size is reduced + * and all directions are tried again. The process ends when a placement is + * found or the last fontsize is tried without success. + * Example: N,S,15,10,8 (tries placement above, then below and if + * that fails it tries the additional font sizes 15, 10 and 8. + */ void text_placements_simple::set_positions(std::string positions) { positions_ = positions; @@ -489,16 +489,16 @@ void text_placements_simple::set_positions(std::string positions) ("NW", NORTHWEST) ("SW", SOUTHWEST) ("X" , EXACT_POSITION) - ; + ; } } direction_name; std::string::iterator first = positions.begin(), last = positions.end(); qi::phrase_parse(first, last, - (direction_name[push_back(phoenix::ref(direction_), _1)] % ',') >> *(',' >> qi::float_[push_back(phoenix::ref(text_sizes_), _1)]), - space - ); + (direction_name[push_back(phoenix::ref(direction_), _1)] % ',') >> *(',' >> qi::float_[push_back(phoenix::ref(text_sizes_), _1)]), + space + ); if (first != last) { std::cerr << "WARNING: Could not parse text_placement_simple placement string ('" << positions << "').\n"; } @@ -558,7 +558,7 @@ text_placement_info_ptr text_placements_list::get_placement_info( double scale_factor, dimension_type dim, bool has_dimensions) const { return text_placement_info_ptr(new text_placement_info_list(this, - scale_factor, dim, has_dimensions)); + scale_factor, dim, has_dimensions)); } text_placements_list::text_placements_list() : text_placements(), list_(0) diff --git a/src/text_processing.cpp b/src/text_processing.cpp index b571e34d2..f3fd3527d 100644 --- a/src/text_processing.cpp +++ b/src/text_processing.cpp @@ -45,7 +45,7 @@ void node::to_xml(boost::property_tree::ptree &xml) const { //TODO: Should this throw a config_error? #ifdef MAPNIK_DEBUG - std::cerr << "Error: Trying to write unsupported node type to XML.\n"; + std::cerr << "Error: Trying to write unsupported node type to XML.\n"; #endif } @@ -141,7 +141,7 @@ std::vector const& list_node::get_children() const void text_node::to_xml(ptree &xml) const { ptree &new_node = xml.push_back(ptree::value_type( - "", ptree()))->second; + "", ptree()))->second; new_node.put_value(to_expression_string(*text_)); } diff --git a/src/text_symbolizer.cpp b/src/text_symbolizer.cpp index ed67c4c8e..4fd152991 100644 --- a/src/text_symbolizer.cpp +++ b/src/text_symbolizer.cpp @@ -87,8 +87,8 @@ IMPLEMENT_ENUM( text_transform_e, text_transform_strings ) text_symbolizer::text_symbolizer(text_placements_ptr placements) - : symbolizer_base(), - placement_options_(placements) +: symbolizer_base(), + placement_options_(placements) { } diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index 25a5d5724..c940bcb93 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -25,14 +25,14 @@ #include #include -extern "C" +extern "C" { -#include +#include } // stl #include -namespace mapnik +namespace mapnik { using std::min; @@ -75,7 +75,7 @@ image_reader* create_tiff_reader(const std::string& file) { return new tiff_reader(file); } - + const bool registered = register_image_reader("tiff",create_tiff_reader); } @@ -98,9 +98,9 @@ void tiff_reader::init() TIFFSetWarningHandler(0); TIFF* tif = load_if_exists(file_name_); if (!tif) throw image_reader_exception ("Can't load tiff file"); - + char msg[1024]; - + if (TIFFRGBAImageOK(tif,msg)) { TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width_); @@ -144,7 +144,7 @@ unsigned tiff_reader::height() const void tiff_reader::read(unsigned x,unsigned y,image_data_32& image) -{ +{ if (read_method_==stripped) { read_stripped(x,y,image); @@ -255,17 +255,17 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_32& image) TIFFClose(tif); } } - + TIFF* tiff_reader::load_if_exists(std::string const& filename) { TIFF * tif = 0; boost::filesystem::path path(file_name_); if (exists(path)) // && is_regular(path)) { -- not supported in boost-1.33.* - { + { // File path is a full file path and does exist tif = TIFFOpen(filename.c_str(), "rb"); } - + return tif; } } diff --git a/src/unicode.cpp b/src/unicode.cpp index 5665ded5d..5882adee3 100644 --- a/src/unicode.cpp +++ b/src/unicode.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -29,7 +29,7 @@ #ifdef MAPNIK_DEBUG #include -#endif +#endif namespace mapnik { @@ -46,8 +46,8 @@ transcoder::transcoder (std::string const& encoding) UnicodeString transcoder::transcode(const char* data, boost::int32_t length) const { UErrorCode err = U_ZERO_ERROR; - - UnicodeString ustr(data,length,conv_,err); + + UnicodeString ustr(data,length,conv_,err); if (ustr.isBogus()) { ustr.remove(); @@ -58,5 +58,5 @@ UnicodeString transcoder::transcode(const char* data, boost::int32_t length) con transcoder::~transcoder() { if (conv_) ucnv_close(conv_); -} +} } diff --git a/src/warp.cpp b/src/warp.cpp index b9768d1cc..e5532dd12 100644 --- a/src/warp.cpp +++ b/src/warp.cpp @@ -55,7 +55,7 @@ void reproject_raster(raster &target, raster const& source, std::string scaling_method_name) { if (prj_trans.equal()) { - + if (scaling_method_name == "bilinear8"){ scale_image_bilinear8(target.data_,source.data_, offset_x, offset_y); @@ -120,39 +120,39 @@ void reproject_raster(raster &target, raster const& source, scaling_method_name); switch(scaling_method) { - case SCALING_NEAR: break; - 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: break; + 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; } // Project mesh cells into target interpolating raster inside each one diff --git a/src/wkb.cpp b/src/wkb.cpp index 158311cc4..e17e4d9ef 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko @@ -49,7 +49,7 @@ private: wkbFormat format_; public: - + enum wkbGeometryType { wkbPoint=1, wkbLineString=2, @@ -112,10 +112,10 @@ public: needSwap_ = byteOrder_ ? wkbXDR : wkbNDR; #else needSwap_ = byteOrder_ ? wkbNDR : wkbXDR; -#endif +#endif } - - void read(boost::ptr_vector & paths) + + void read(boost::ptr_vector & paths) { int type = read_integer(); @@ -171,25 +171,25 @@ public: break; } } - + private: - - int read_integer() + + int read_integer() { boost::int32_t n; if (needSwap_) { read_int32_xdr(wkb_ + pos_, n); - } - else + } + else { read_int32_ndr(wkb_ + pos_, n); } pos_ += 4; - + return n; } - + double read_double() { double d; @@ -197,15 +197,15 @@ private: { read_double_xdr(wkb_ + pos_, d); } - else + else { read_double_ndr(wkb_ + pos_, d); } pos_ += 8; - + return d; } - + void read_coords(CoordinateArray& ar) { if (! needSwap_) @@ -217,7 +217,7 @@ private: pos_ += 16; // skip XY } } - else + else { for (unsigned i=0;imove_to(x, y); paths.push_back(pt); } - + void read_multipoint(boost::ptr_vector & paths) { int num_points = read_integer(); @@ -269,7 +269,7 @@ private: read_point(paths); } } - + void read_point_xyz(boost::ptr_vector & paths) { geometry_type* pt = new geometry_type(Point); @@ -304,7 +304,7 @@ private: } paths.push_back(line); } - + void read_multilinestring(boost::ptr_vector & paths) { int num_lines = read_integer(); @@ -314,7 +314,7 @@ private: read_linestring(paths); } } - + void read_linestring_xyz(boost::ptr_vector & paths) { geometry_type* line = new geometry_type(LineString); @@ -340,8 +340,8 @@ private: } } - - void read_polygon(boost::ptr_vector & paths) + + void read_polygon(boost::ptr_vector & paths) { geometry_type* poly = new geometry_type(Polygon); int num_rings = read_integer(); @@ -361,7 +361,7 @@ private: } paths.push_back(poly); } - + void read_multipolygon(boost::ptr_vector & paths) { int num_polys = read_integer(); @@ -371,7 +371,7 @@ private: read_polygon(paths); } } - + void read_polygon_xyz(boost::ptr_vector & paths) { geometry_type* poly = new geometry_type(Polygon); @@ -412,7 +412,7 @@ private: read(paths); } } - + #ifdef MAPNIK_DEBUG_WKB std::string wkb_geometry_type_string(int type) { @@ -446,10 +446,10 @@ private: void geometry_utils::from_wkb (boost::ptr_vector& paths, const char* wkb, unsigned size, - wkbFormat format) + wkbFormat format) { wkb_reader reader(wkb, size, format); return reader.read(paths); -} +} } diff --git a/src/wkt/wkt_factory.cpp b/src/wkt/wkt_factory.cpp index d3abf3b4a..17196af78 100644 --- a/src/wkt/wkt_factory.cpp +++ b/src/wkt/wkt_factory.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * + * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2011 Artem Pavlenko