diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index f89b4eb01..ced0a53ee 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -30,6 +30,8 @@ // mapnik #include +#include +#include #include #include #include diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 5ec4b93ac..b86a7e33d 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -72,6 +72,7 @@ void export_logger(); #include #include +#include #include #include #ifdef HAVE_CAIRO diff --git a/bindings/python/mapnik_shield_symbolizer.cpp b/bindings/python/mapnik_shield_symbolizer.cpp index 28ae7083e..8a08900bb 100644 --- a/bindings/python/mapnik_shield_symbolizer.cpp +++ b/bindings/python/mapnik_shield_symbolizer.cpp @@ -21,6 +21,13 @@ * *****************************************************************************/ +/* The functions in this file produce deprecation warnings. + * But as shield symbolizer doesn't fully support more than one + * placement from python yet these functions are actually the + * correct ones. + */ +#define NO_DEPRECATION_WARNINGS + // boost #include @@ -53,12 +60,13 @@ tuple get_shield_displacement(const shield_symbolizer& s) void set_shield_displacement(shield_symbolizer & s, boost::python::tuple arg) { - s.set_shield_displacement(extract(arg[0]),extract(arg[1])); + s.get_placement_options()->defaults.displacement.first = extract(arg[0]); + s.get_placement_options()->defaults.displacement.second = extract(arg[1]); } tuple get_text_displacement(const shield_symbolizer& t) { - position const& pos = t.get_displacement(); + position const& pos = t.get_placement_options()->defaults.displacement; return boost::python::make_tuple(pos.first, pos.second); } @@ -79,46 +87,6 @@ void set_filename(shield_symbolizer & t, std::string const& file_expr) } -struct shield_symbolizer_pickle_suite : boost::python::pickle_suite -{ - static boost::python::tuple - getinitargs(const shield_symbolizer& s) - { - std::string filename = path_processor_type::to_string(*s.get_filename()); - //(name, font name, font size, font color, image file, image type, width, height) - return boost::python::make_tuple( "TODO",//s.get_name(), - s.get_face_name(),s.get_text_size(),s.get_fill(),filename,guess_type(filename)); - - } - - static boost::python::tuple - getstate(const shield_symbolizer& s) - { - return boost::python::make_tuple(s.get_halo_fill(),s.get_halo_radius()); - } - - // TODO add lots more... - static void - setstate (shield_symbolizer& s, boost::python::tuple state) - { - using namespace boost::python; - /*if (len(state) != 1) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 1-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - }*/ - - s.set_halo_fill(extract(state[0])); - s.set_halo_radius(extract(state[1])); - - } - -}; - - void export_shield_symbolizer() { using namespace boost::python; @@ -126,7 +94,7 @@ void export_shield_symbolizer() init("TODO") + path_expression_ptr>() ) //.def_pickle(shield_symbolizer_pickle_suite()) .add_property("allow_overlap", diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index 87379c9fd..f0b99f714 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -26,6 +26,8 @@ #include // mapnik +#include +#include #include #include #include diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp index 2546bd09e..31e016ced 100644 --- a/demo/c++/rundemo.cpp +++ b/demo/c++/rundemo.cpp @@ -21,6 +21,9 @@ *****************************************************************************/ #include +#include +#include +#include #include #include #include diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 71401b8de..c82f57239 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -29,6 +29,7 @@ #include #include #include +#include // for all symbolizers // boost #include @@ -47,6 +48,7 @@ struct trans_affine; namespace mapnik { class marker; + struct rasterizer; template diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index 73d5e4f47..30741427c 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -31,7 +31,7 @@ #include #include #include -//#include +#include // for all symbolizers // cairo #include diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index 870965fa9..014c51299 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -63,162 +63,10 @@ typedef boost::spirit::ascii::space_type ascii_space_type; struct named_colors_ : qi::symbols { - named_colors_() - { - add - ("aliceblue", color(240, 248, 255)) - ("antiquewhite", color(250, 235, 215)) - ("aqua", color(0, 255, 255)) - ("aquamarine", color(127, 255, 212)) - ("azure", color(240, 255, 255)) - ("beige", color(245, 245, 220)) - ("bisque", color(255, 228, 196)) - ("black", color(0, 0, 0)) - ("blanchedalmond", color(255,235,205)) - ("blue", color(0, 0, 255)) - ("blueviolet", color(138, 43, 226)) - ("brown", color(165, 42, 42)) - ("burlywood", color(222, 184, 135)) - ("cadetblue", color(95, 158, 160)) - ("chartreuse", color(127, 255, 0)) - ("chocolate", color(210, 105, 30)) - ("coral", color(255, 127, 80)) - ("cornflowerblue", color(100, 149, 237)) - ("cornsilk", color(255, 248, 220)) - ("crimson", color(220, 20, 60)) - ("cyan", color(0, 255, 255)) - ("darkblue", color(0, 0, 139)) - ("darkcyan", color(0, 139, 139)) - ("darkgoldenrod", color(184, 134, 11)) - ("darkgray", color(169, 169, 169)) - ("darkgreen", color(0, 100, 0)) - ("darkgrey", color(169, 169, 169)) - ("darkkhaki", color(189, 183, 107)) - ("darkmagenta", color(139, 0, 139)) - ("darkolivegreen", color(85, 107, 47)) - ("darkorange", color(255, 140, 0)) - ("darkorchid", color(153, 50, 204)) - ("darkred", color(139, 0, 0)) - ("darksalmon", color(233, 150, 122)) - ("darkseagreen", color(143, 188, 143)) - ("darkslateblue", color(72, 61, 139)) - ("darkslategrey", color(47, 79, 79)) - ("darkturquoise", color(0, 206, 209)) - ("darkviolet", color(148, 0, 211)) - ("deeppink", color(255, 20, 147)) - ("deepskyblue", color(0, 191, 255)) - ("dimgray", color(105, 105, 105)) - ("dimgrey", color(105, 105, 105)) - ("dodgerblue", color(30, 144, 255)) - ("firebrick", color(178, 34, 34)) - ("floralwhite", color(255, 250, 240)) - ("forestgreen", color(34, 139, 34)) - ("fuchsia", color(255, 0, 255)) - ("gainsboro", color(220, 220, 220)) - ("ghostwhite", color(248, 248, 255)) - ("gold", color(255, 215, 0)) - ("goldenrod", color(218, 165, 32)) - ("gray", color(128, 128, 128)) - ("grey", color(128, 128, 128)) - ("green", color(0, 128, 0)) - ("greenyellow", color(173, 255, 47)) - ("honeydew", color(240, 255, 240)) - ("hotpink", color(255, 105, 180)) - ("indianred", color(205, 92, 92)) - ("indigo", color(75, 0, 130)) - ("ivory", color(255, 255, 240)) - ("khaki", color(240, 230, 140)) - ("lavender", color(230, 230, 250)) - ("lavenderblush", color(255, 240, 245)) - ("lawngreen", color(124, 252, 0)) - ("lemonchiffon", color(255, 250, 205)) - ("lightblue", color(173, 216, 230)) - ("lightcoral", color(240, 128, 128)) - ("lightcyan", color(224, 255, 255)) - ("lightgoldenrodyellow", color(250, 250, 210)) - ("lightgray", color(211, 211, 211)) - ("lightgreen", color(144, 238, 144)) - ("lightgrey", color(211, 211, 211)) - ("lightpink", color(255, 182, 193)) - ("lightsalmon", color(255, 160, 122)) - ("lightseagreen", color(32, 178, 170)) - ("lightskyblue", color(135, 206, 250)) - ("lightslategray", color(119, 136, 153)) - ("lightslategrey", color(119, 136, 153)) - ("lightsteelblue", color(176, 196, 222)) - ("lightyellow", color(255, 255, 224)) - ("lime", color(0, 255, 0)) - ("limegreen", color(50, 205, 50)) - ("linen", color(250, 240, 230)) - ("magenta", color(255, 0, 255)) - ("maroon", color(128, 0, 0)) - ("mediumaquamarine", color(102, 205, 170)) - ("mediumblue", color(0, 0, 205)) - ("mediumorchid", color(186, 85, 211)) - ("mediumpurple", color(147, 112, 219)) - ("mediumseagreen", color(60, 179, 113)) - ("mediumslateblue", color(123, 104, 238)) - ("mediumspringgreen", color(0, 250, 154)) - ("mediumturquoise", color(72, 209, 204)) - ("mediumvioletred", color(199, 21, 133)) - ("midnightblue", color(25, 25, 112)) - ("mintcream", color(245, 255, 250)) - ("mistyrose", color(255, 228, 225)) - ("moccasin", color(255, 228, 181)) - ("navajowhite", color(255, 222, 173)) - ("navy", color(0, 0, 128)) - ("oldlace", color(253, 245, 230)) - ("olive", color(128, 128, 0)) - ("olivedrab", color(107, 142, 35)) - ("orange", color(255, 165, 0)) - ("orangered", color(255, 69, 0)) - ("orchid", color(218, 112, 214)) - ("palegoldenrod", color(238, 232, 170)) - ("palegreen", color(152, 251, 152)) - ("paleturquoise", color(175, 238, 238)) - ("palevioletred", color(219, 112, 147)) - ("papayawhip", color(255, 239, 213)) - ("peachpuff", color(255, 218, 185)) - ("peru", color(205, 133, 63)) - ("pink", color(255, 192, 203)) - ("plum", color(221, 160, 221)) - ("powderblue", color(176, 224, 230)) - ("purple", color(128, 0, 128)) - ("red", color(255, 0, 0)) - ("rosybrown", color(188, 143, 143)) - ("royalblue", color(65, 105, 225)) - ("saddlebrown", color(139, 69, 19)) - ("salmon", color(250, 128, 114)) - ("sandybrown", color(244, 164, 96)) - ("seagreen", color(46, 139, 87)) - ("seashell", color(255, 245, 238)) - ("sienna", color(160, 82, 45)) - ("silver", color(192, 192, 192)) - ("skyblue", color(135, 206, 235)) - ("slateblue", color(106, 90, 205)) - ("slategray", color(112, 128, 144)) - ("slategrey", color(112, 128, 144)) - ("snow", color(255, 250, 250)) - ("springgreen", color(0, 255, 127)) - ("steelblue", color(70, 130, 180)) - ("tan", color(210, 180, 140)) - ("teal", color(0, 128, 128)) - ("thistle", color(216, 191, 216)) - ("tomato", color(255, 99, 71)) - ("turquoise", color(64, 224, 208)) - ("violet", color(238, 130, 238)) - ("wheat", color(245, 222, 179)) - ("white", color(255, 255, 255)) - ("whitesmoke", color(245, 245, 245)) - ("yellow", color(255, 255, 0)) - ("yellowgreen", color(154, 205, 50)) - ("transparent", color(0, 0, 0, 0)) - ; - } + named_colors_(); } ; // clipper helper - template inline int clip_int(int val) { @@ -256,19 +104,7 @@ struct alpha_conv_impl }; // http://www.w3.org/TR/css3-color/#hsl-color -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) - return m1 + (m2 - m1) * h * 6.0; - if (h * 2 < 1.0) - return m2; - if (h * 3 < 2.0) - return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0; - return m1; -} +inline double hue_to_rgb( double m1, double m2, double h); struct hsl_conv_impl { @@ -307,70 +143,7 @@ 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; - using qi::double_; - using qi::_1; - using qi::_a; - using qi::_b; - using qi::_c; - using ascii::no_case; - using phoenix::at_c; - - css_color %= rgba_color - | rgba_percent_color - | hsl_percent_color - | hex_color - | hex_color_small - | no_case[named]; - - 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(')') - ; - - 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<3>(_val) = alpha_converter(_1)]) - >> lit(')') - ; - - hsl_percent_color = lit("hsl") >> -lit('a') - >> 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)] - ; - } - + css_color_grammar(); qi::uint_parser< unsigned, 16, 2, 2 > hex2 ; qi::uint_parser< unsigned, 16, 1, 1 > hex1 ; qi::uint_parser< unsigned, 10, 1, 3 > dec3 ; diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp index d2f6ef4d2..31432aa33 100644 --- a/include/mapnik/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -39,7 +39,7 @@ namespace mapnik template bool clip_test(T p,T q,double& tmin,double& tmax) { - double r(0); + double r = 0; bool result=true; if (p<0.0) { @@ -96,8 +96,8 @@ inline bool point_inside_path(double x,double y,Iter start,Iter end) double x0=boost::get<0>(*start); double y0=boost::get<1>(*start); - double x1(0); - double y1(0); + double x1 = 0; + double y1 = 0; while (++start!=end) { if ( boost::get<2>(*start) == SEG_MOVETO) @@ -174,8 +174,8 @@ 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(0); - double y1(0); + double x1 = 0; + double y1 = 0; while (++start != end) { if ( boost::get<2>(*start) == SEG_MOVETO) @@ -224,10 +224,10 @@ struct filter_at_point template double path_length(PathType & path) { - double x0(0); - double y0(0); - double x1(0); - double y1(0); + double x0 = 0; + double y0 = 0; + double x1 = 0; + double y1 = 0; path.rewind(0); unsigned command = path.vertex(&x0,&y0); if (command == SEG_END) return 0; @@ -244,10 +244,10 @@ double path_length(PathType & path) template bool middle_point(PathType & path, double & x, double & y) { - double x0(0); - double y0(0); - double x1(0); - double y1(0); + double x0 = 0; + double y0 = 0; + double x1 = 0; + double y1 = 0; double mid_length = 0.5 * path_length(path); path.rewind(0); unsigned command = path.vertex(&x0,&y0); @@ -334,7 +334,7 @@ template bool hit_test(PathType & path, double x, double y, double tol) { bool inside=false; - double x0 = 0 ; + double x0 = 0; double y0 = 0; double x1 = 0; double y1 = 0; diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 20356dc84..31bfeb337 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -88,8 +88,8 @@ public: box2d envelope() const { box2d result; - double x(0); - double y(0); + double x = 0; + double y = 0; rewind(0); for (unsigned i=0;i #include #include -//#include +#include // for all symbolizers #include // boost diff --git a/include/mapnik/grid/grid_util.hpp b/include/mapnik/grid/grid_util.hpp index 517c4ccc1..b1b61c661 100644 --- a/include/mapnik/grid/grid_util.hpp +++ b/include/mapnik/grid/grid_util.hpp @@ -26,6 +26,9 @@ // mapnik #include +// boost +#include + namespace mapnik { /* @@ -45,15 +48,20 @@ static inline void scale_grid(mapnik::grid::data_type & target, if (source_width<1 || source_height<1 || target_width<1 || target_height<1) return; - int x=0,y=0,xs=0,ys=0; + int x = 0; + int y = 0; + int xs = 0; + int ys = 0; int tw2 = target_width/2; int th2 = target_height/2; int offs_x = rint((source_width-target_width-x_off_f*2*source_width)/2); int offs_y = rint((source_height-target_height-y_off_f*2*source_height)/2); - unsigned yprt(0); - unsigned yprt1(0); - unsigned xprt(0); - unsigned xprt1(0); + unsigned yprt = 0; + unsigned yprt1 = 0; + unsigned xprt = 0; + unsigned xprt1 = 0; + boost::ignore_unused_variable_warning(yprt1); + boost::ignore_unused_variable_warning(xprt1); //no scaling or subpixel offset if (target_height == source_height && target_width == source_width && offs_x == 0 && offs_y == 0){ diff --git a/include/mapnik/path_expression_grammar.hpp b/include/mapnik/path_expression_grammar.hpp index 9c11e29eb..f60f33feb 100644 --- a/include/mapnik/path_expression_grammar.hpp +++ b/include/mapnik/path_expression_grammar.hpp @@ -24,29 +24,15 @@ #define MAPNIK_PATH_EXPRESSIONS_GRAMMAR_HPP // mapnik -#include -#include -#include +#include // boost #include -#include // spirit2 #include #include -// fusion -#include - -// phoenix -#include -#include -#include -#include -#include -#include - // stl #include #include @@ -65,29 +51,7 @@ typedef boost::variant path_component; template struct path_expression_grammar : qi::grammar(), space_type> { - path_expression_grammar() - : path_expression_grammar::base_type(expr) - { - using boost::phoenix::construct; - using standard_wide::char_; - using qi::_1; - using qi::_val; - using qi::lit; - using qi::lexeme; - using phoenix::push_back; - - expr = - * ( - str [ push_back(_val, _1)] - | - ( '[' >> attr [ push_back(_val, construct( _1 )) ] >> ']') - ) - ; - - attr %= +(char_ - ']'); - str %= lexeme[+(char_ -'[')]; - } - + path_expression_grammar(); qi::rule() , space_type> expr; qi::rule attr; qi::rule str; diff --git a/include/mapnik/rule.hpp b/include/mapnik/rule.hpp index 6acb43cc9..104f763e7 100644 --- a/include/mapnik/rule.hpp +++ b/include/mapnik/rule.hpp @@ -23,7 +23,7 @@ #ifndef MAPNIK_RULE_HPP #define MAPNIK_RULE_HPP -// mapni +// mapnik #include #include #include diff --git a/include/mapnik/text_symbolizer.hpp b/include/mapnik/text_symbolizer.hpp index 05a9c2a39..1824f62fe 100644 --- a/include/mapnik/text_symbolizer.hpp +++ b/include/mapnik/text_symbolizer.hpp @@ -37,7 +37,7 @@ // stl #include -#if (1 && __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#if (!defined(NO_DEPRECATION_WARNINGS) && __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #define func_deprecated __attribute__ ((deprecated)) #else #define func_deprecated diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 46780e5fd..969b932d6 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -26,8 +26,6 @@ // mapnik #include #include -#include -#include // boost #include @@ -55,161 +53,88 @@ struct is_container namespace mapnik { namespace util { - namespace karma = boost::spirit::karma; - namespace phoenix = boost::phoenix; - - namespace { - - struct get_type - { - template - struct result { typedef int type; }; - - int operator() (geometry_type const& geom) const - { - return static_cast(geom.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.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); - } - }; +namespace karma = boost::spirit::karma; +namespace phoenix = boost::phoenix; +namespace { +struct get_type +{ 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 ;} - }; + struct result { typedef int type; }; + int operator() (geometry_type const& geom) const + { + return static_cast(geom.type()); } +}; - template - struct wkt_generator : - karma::grammar +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.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord)); + return coord; + } +}; - 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 - ; +struct multi_geometry_ +{ + template + struct result { typedef bool type; }; - point = &uint_(mapnik::Point)[_1 = _type(_val)] - << string[ phoenix::if_ (single) [_1 = "Point("] - .else_[_1 = "("]] - << point_coord [_1 = _first(_val)] << lit(')') - ; + bool operator() (geometry_container const& geom) const + { + return geom.size() > 1 ? true : false; + } +}; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] - << string[ phoenix::if_ (single) [_1 = "LineString("] - .else_[_1 = "("]] - << coords - << lit(')') - ; +struct multi_geometry_type +{ + template + struct result { typedef boost::tuple type; }; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] - << string[ phoenix::if_ (single) [_1 = "Polygon("] - .else_[_1 = "("]] - << coords2 - << lit("))") - ; + boost::tuple operator() (geometry_container const& geom) const; +}; - 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 - ; +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 ;} +}; - coords2 %= *polygon_coord(_a) - ; +} - coords = point_coord % lit(',') - ; +template +struct wkt_generator : + karma::grammar +{ + wkt_generator(bool single = false); + // rules + karma::rule wkt; + karma::rule point; + karma::rule linestring; + karma::rule polygon; - } - // 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; - - }; + 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 @@ -217,38 +142,7 @@ struct wkt_multi_generator : karma::grammar >, geometry_container const& ()> { - wkt_multi_generator() - : wkt_multi_generator::base_type(wkt) - { - using boost::spirit::karma::lit; - using boost::spirit::karma::eps; - 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 << ")" - | geometry - ; - - geometry = -(single_geometry % lit(',')) - ; - - single_geometry = geometry_types[_1 = _type(_val)] << path - ; - - multi_geometry = -(path % lit(',')) - ; - - } + wkt_multi_generator(); // rules karma::rule >, geometry_container const& ()> wkt; karma::rule geometry; diff --git a/plugins/input/csv/csv_datasource.hpp b/plugins/input/csv/csv_datasource.hpp index 22a99a2b8..056d2391d 100644 --- a/plugins/input/csv/csv_datasource.hpp +++ b/plugins/input/csv/csv_datasource.hpp @@ -25,9 +25,19 @@ // mapnik #include +#include +#include +#include +#include +#include +#include + +// boost +#include // stl #include +#include class csv_datasource : public mapnik::datasource { diff --git a/plugins/input/gdal/gdal_datasource.hpp b/plugins/input/gdal/gdal_datasource.hpp index 989b30135..15654fae9 100644 --- a/plugins/input/gdal/gdal_datasource.hpp +++ b/plugins/input/gdal/gdal_datasource.hpp @@ -25,9 +25,19 @@ // mapnik #include +#include +#include +#include +#include +#include +#include // boost -#include +#include + +// stl +#include +#include // gdal #include diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index 959b1d009..008194ff9 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -23,6 +23,7 @@ // mapnik #include #include +#include #include // boost diff --git a/plugins/input/gdal/gdal_featureset.hpp b/plugins/input/gdal/gdal_featureset.hpp index a9912e70e..fc3856574 100644 --- a/plugins/input/gdal/gdal_featureset.hpp +++ b/plugins/input/gdal/gdal_featureset.hpp @@ -31,6 +31,8 @@ #include #include +#include "gdal_datasource.hpp" + class GDALDataset; class GDALRasterBand; diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 3ce9140e8..58354b6f8 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -36,6 +36,7 @@ #include // mapnik #include +#include #include #include #include diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 231339cc0..9f9ce42d0 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -25,7 +25,16 @@ // mapnik #include +#include +#include +#include +#include +#include +#include + // boost +#include +#include #include #include #include @@ -33,6 +42,12 @@ #include #include +// stl +#include +#include +#include +#include + class geojson_datasource : public mapnik::datasource { public: diff --git a/plugins/input/geos/geos_datasource.hpp b/plugins/input/geos/geos_datasource.hpp index 752a89ffc..6127e9fbd 100644 --- a/plugins/input/geos/geos_datasource.hpp +++ b/plugins/input/geos/geos_datasource.hpp @@ -25,12 +25,21 @@ // mapnik #include +#include +#include #include +#include +#include #include // boost +#include #include +// stl +#include +#include + #include "geos_feature_ptr.hpp" class geos_datasource : public mapnik::datasource diff --git a/plugins/input/kismet/kismet_datasource.hpp b/plugins/input/kismet/kismet_datasource.hpp index 6e54d9c23..85504839b 100644 --- a/plugins/input/kismet/kismet_datasource.hpp +++ b/plugins/input/kismet/kismet_datasource.hpp @@ -23,21 +23,25 @@ #ifndef KISMET_DATASOURCE_HPP #define KISMET_DATASOURCE_HPP -// stl -#include - // mapnik #include +#include +#include #include +#include +#include #include -#include // boost +#include #include -#include #include -// sqlite +// stl +#include +#include +#include + #include "kismet_types.hpp" class kismet_datasource : public mapnik::datasource diff --git a/plugins/input/kismet/kismet_types.hpp b/plugins/input/kismet/kismet_types.hpp index c3393d74e..519577897 100644 --- a/plugins/input/kismet/kismet_types.hpp +++ b/plugins/input/kismet/kismet_types.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include // boost #include diff --git a/plugins/input/occi/occi_datasource.hpp b/plugins/input/occi/occi_datasource.hpp index bbc57970d..7e85de7b0 100644 --- a/plugins/input/occi/occi_datasource.hpp +++ b/plugins/input/occi/occi_datasource.hpp @@ -25,13 +25,21 @@ // mapnik #include -#include +#include +#include #include +#include +#include #include // boost +#include #include +// stl +#include +#include + // oci #include "occi_types.hpp" diff --git a/plugins/input/ogr/ogr_converter.hpp b/plugins/input/ogr/ogr_converter.hpp index 94b198d54..a52ab66ce 100644 --- a/plugins/input/ogr/ogr_converter.hpp +++ b/plugins/input/ogr/ogr_converter.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include // ogr #include diff --git a/plugins/input/ogr/ogr_datasource.hpp b/plugins/input/ogr/ogr_datasource.hpp index 1898397e0..67dc5799c 100644 --- a/plugins/input/ogr/ogr_datasource.hpp +++ b/plugins/input/ogr/ogr_datasource.hpp @@ -25,15 +25,23 @@ // mapnik #include +#include +#include #include +#include +#include #include // boost +#include #include +// stl +#include +#include + // ogr #include - #include "ogr_layer_ptr.hpp" class ogr_datasource : public mapnik::datasource diff --git a/plugins/input/osm/osm_datasource.hpp b/plugins/input/osm/osm_datasource.hpp index 1b99718ed..fc79faa88 100644 --- a/plugins/input/osm/osm_datasource.hpp +++ b/plugins/input/osm/osm_datasource.hpp @@ -25,7 +25,20 @@ // mapnik #include +#include +#include +#include #include +#include +#include + +// boost +#include +#include + +// stl +#include +#include #include "osm.h" diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index f484837c8..5cb786569 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -25,12 +25,22 @@ // mapnik #include +#include +#include +#include #include +#include #include // boost +#include +#include #include +// stl +#include +#include + #include "connection_manager.hpp" #include "resultset.hpp" #include "cursorresultset.hpp" diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index efbd38233..1c66c462e 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -26,6 +26,7 @@ // mapnik #include +#include #include #include diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp index 9b84380e5..c79afbbe6 100644 --- a/plugins/input/raster/raster_datasource.hpp +++ b/plugins/input/raster/raster_datasource.hpp @@ -24,9 +24,22 @@ #define RASTER_DATASOURCE_HPP // mapnik -#include -#include #include +#include +#include +#include +#include +#include +#include + +// boost +#include +#include + +// stl +#include +#include + class raster_datasource : public mapnik::datasource { diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index bd26a076f..b39bf237b 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -22,6 +22,7 @@ // mapnik #include +#include #include #include #include diff --git a/plugins/input/rasterlite/rasterlite_datasource.hpp b/plugins/input/rasterlite/rasterlite_datasource.hpp index 4971b2d1d..e2a8137d9 100644 --- a/plugins/input/rasterlite/rasterlite_datasource.hpp +++ b/plugins/input/rasterlite/rasterlite_datasource.hpp @@ -25,10 +25,21 @@ // mapnik #include +#include +#include +#include +#include +#include +#include // boost +#include #include +// stl +#include +#include + #include "rasterlite_include.hpp" class rasterlite_datasource : public mapnik::datasource diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index 522365dde..56ea052fc 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -25,11 +25,21 @@ // mapnik #include +#include +#include +#include #include +#include +#include // boost +#include #include +// stl +#include +#include + #include "shape_io.hpp" using mapnik::datasource; diff --git a/plugins/input/shape/shape_utils.cpp b/plugins/input/shape/shape_utils.cpp index 56cd7c8a2..a2685e67c 100644 --- a/plugins/input/shape/shape_utils.cpp +++ b/plugins/input/shape/shape_utils.cpp @@ -22,6 +22,7 @@ // mapnik #include +#include #include "shape_utils.hpp" // boost diff --git a/plugins/input/sqlite/sqlite_connection.hpp b/plugins/input/sqlite/sqlite_connection.hpp index 1a38062e2..b28c4c97e 100644 --- a/plugins/input/sqlite/sqlite_connection.hpp +++ b/plugins/input/sqlite/sqlite_connection.hpp @@ -28,6 +28,7 @@ // mapnik #include +#include #include #include diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index c1f840212..063ccaf75 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -25,18 +25,26 @@ // mapnik #include +#include +#include #include +#include +#include #include #include // boost +#include #include #include +// stl +#include +#include + // sqlite #include "sqlite_connection.hpp" - class sqlite_datasource : public mapnik::datasource { public: diff --git a/plugins/input/sqlite/sqlite_prepared.hpp b/plugins/input/sqlite/sqlite_prepared.hpp index c18591f04..f6bf45339 100644 --- a/plugins/input/sqlite/sqlite_prepared.hpp +++ b/plugins/input/sqlite/sqlite_prepared.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // boost diff --git a/plugins/input/sqlite/sqlite_resultset.hpp b/plugins/input/sqlite/sqlite_resultset.hpp index c1582f8ba..9c10eb0f3 100644 --- a/plugins/input/sqlite/sqlite_resultset.hpp +++ b/plugins/input/sqlite/sqlite_resultset.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include // stl #include diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index 891150506..fb81ce62b 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -29,6 +29,7 @@ // mapnik #include +#include #include #include diff --git a/plugins/input/templates/helloworld/hello_datasource.hpp b/plugins/input/templates/helloworld/hello_datasource.hpp index f2e172f56..b7e3dfbbc 100644 --- a/plugins/input/templates/helloworld/hello_datasource.hpp +++ b/plugins/input/templates/helloworld/hello_datasource.hpp @@ -3,6 +3,19 @@ // mapnik #include +#include +#include +#include +#include +#include +#include + +// boost +#include +#include + +// stl +#include class hello_datasource : public mapnik::datasource { diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index bff971757..92cda8973 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ // mapnik +#include +#include #include #include #include @@ -239,7 +241,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) { blend_from = true; mapnik::filter::filter_visitor visitor(*current_buffer_); - BOOST_FOREACH(mapnik::filter::filter_type filter_tag, st.image_filters()) + BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.image_filters()) { boost::apply_visitor(visitor, filter_tag); } @@ -256,7 +258,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) // apply any 'direct' image filters mapnik::filter::filter_visitor visitor(pixmap_); - BOOST_FOREACH(mapnik::filter::filter_type filter_tag, st.direct_image_filters()) + BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.direct_image_filters()) { boost::apply_visitor(visitor, filter_tag); } diff --git a/src/build.py b/src/build.py index 1ad71687b..2257132b5 100644 --- a/src/build.py +++ b/src/build.py @@ -25,11 +25,15 @@ import sys import glob from copy import copy from subprocess import Popen, PIPE +from colorizer import colorizer +col = colorizer() Import('env') lib_env = env.Clone() +col.colorize(lib_env) + def call(cmd, silent=True): stdin, stderr = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate() if not stderr: @@ -101,6 +105,7 @@ else: # unix, non-macos source = Split( """ color.cpp + css_color_grammar.cpp conversions.cpp image_compositing.cpp image_scaling.cpp @@ -133,6 +138,7 @@ source = Split( parse_path.cpp parse_transform.cpp palette.cpp + path_expression_grammar.cpp placement_finder.cpp plugin.cpp png_reader.cpp @@ -144,6 +150,7 @@ source = Split( text_symbolizer.cpp tiff_reader.cpp wkb.cpp + wkb_generator.cpp projection.cpp proj_transform.cpp distance.cpp diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index e8120444d..10b22cb1b 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -23,6 +23,8 @@ #if defined(HAVE_CAIRO) // mapnik +#include +#include #include #include #include @@ -52,7 +54,6 @@ #include // agg - #include "agg_conv_clip_polyline.h" #include "agg_conv_clip_polygon.h" #include "agg_conv_smooth_poly1.h" diff --git a/src/css_color_grammar.cpp b/src/css_color_grammar.cpp new file mode 100644 index 000000000..cf0d3f242 --- /dev/null +++ b/src/css_color_grammar.cpp @@ -0,0 +1,262 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#include + +namespace mapnik +{ + +named_colors_::named_colors_() +{ + add + ("aliceblue", color(240, 248, 255)) + ("antiquewhite", color(250, 235, 215)) + ("aqua", color(0, 255, 255)) + ("aquamarine", color(127, 255, 212)) + ("azure", color(240, 255, 255)) + ("beige", color(245, 245, 220)) + ("bisque", color(255, 228, 196)) + ("black", color(0, 0, 0)) + ("blanchedalmond", color(255,235,205)) + ("blue", color(0, 0, 255)) + ("blueviolet", color(138, 43, 226)) + ("brown", color(165, 42, 42)) + ("burlywood", color(222, 184, 135)) + ("cadetblue", color(95, 158, 160)) + ("chartreuse", color(127, 255, 0)) + ("chocolate", color(210, 105, 30)) + ("coral", color(255, 127, 80)) + ("cornflowerblue", color(100, 149, 237)) + ("cornsilk", color(255, 248, 220)) + ("crimson", color(220, 20, 60)) + ("cyan", color(0, 255, 255)) + ("darkblue", color(0, 0, 139)) + ("darkcyan", color(0, 139, 139)) + ("darkgoldenrod", color(184, 134, 11)) + ("darkgray", color(169, 169, 169)) + ("darkgreen", color(0, 100, 0)) + ("darkgrey", color(169, 169, 169)) + ("darkkhaki", color(189, 183, 107)) + ("darkmagenta", color(139, 0, 139)) + ("darkolivegreen", color(85, 107, 47)) + ("darkorange", color(255, 140, 0)) + ("darkorchid", color(153, 50, 204)) + ("darkred", color(139, 0, 0)) + ("darksalmon", color(233, 150, 122)) + ("darkseagreen", color(143, 188, 143)) + ("darkslateblue", color(72, 61, 139)) + ("darkslategrey", color(47, 79, 79)) + ("darkturquoise", color(0, 206, 209)) + ("darkviolet", color(148, 0, 211)) + ("deeppink", color(255, 20, 147)) + ("deepskyblue", color(0, 191, 255)) + ("dimgray", color(105, 105, 105)) + ("dimgrey", color(105, 105, 105)) + ("dodgerblue", color(30, 144, 255)) + ("firebrick", color(178, 34, 34)) + ("floralwhite", color(255, 250, 240)) + ("forestgreen", color(34, 139, 34)) + ("fuchsia", color(255, 0, 255)) + ("gainsboro", color(220, 220, 220)) + ("ghostwhite", color(248, 248, 255)) + ("gold", color(255, 215, 0)) + ("goldenrod", color(218, 165, 32)) + ("gray", color(128, 128, 128)) + ("grey", color(128, 128, 128)) + ("green", color(0, 128, 0)) + ("greenyellow", color(173, 255, 47)) + ("honeydew", color(240, 255, 240)) + ("hotpink", color(255, 105, 180)) + ("indianred", color(205, 92, 92)) + ("indigo", color(75, 0, 130)) + ("ivory", color(255, 255, 240)) + ("khaki", color(240, 230, 140)) + ("lavender", color(230, 230, 250)) + ("lavenderblush", color(255, 240, 245)) + ("lawngreen", color(124, 252, 0)) + ("lemonchiffon", color(255, 250, 205)) + ("lightblue", color(173, 216, 230)) + ("lightcoral", color(240, 128, 128)) + ("lightcyan", color(224, 255, 255)) + ("lightgoldenrodyellow", color(250, 250, 210)) + ("lightgray", color(211, 211, 211)) + ("lightgreen", color(144, 238, 144)) + ("lightgrey", color(211, 211, 211)) + ("lightpink", color(255, 182, 193)) + ("lightsalmon", color(255, 160, 122)) + ("lightseagreen", color(32, 178, 170)) + ("lightskyblue", color(135, 206, 250)) + ("lightslategray", color(119, 136, 153)) + ("lightslategrey", color(119, 136, 153)) + ("lightsteelblue", color(176, 196, 222)) + ("lightyellow", color(255, 255, 224)) + ("lime", color(0, 255, 0)) + ("limegreen", color(50, 205, 50)) + ("linen", color(250, 240, 230)) + ("magenta", color(255, 0, 255)) + ("maroon", color(128, 0, 0)) + ("mediumaquamarine", color(102, 205, 170)) + ("mediumblue", color(0, 0, 205)) + ("mediumorchid", color(186, 85, 211)) + ("mediumpurple", color(147, 112, 219)) + ("mediumseagreen", color(60, 179, 113)) + ("mediumslateblue", color(123, 104, 238)) + ("mediumspringgreen", color(0, 250, 154)) + ("mediumturquoise", color(72, 209, 204)) + ("mediumvioletred", color(199, 21, 133)) + ("midnightblue", color(25, 25, 112)) + ("mintcream", color(245, 255, 250)) + ("mistyrose", color(255, 228, 225)) + ("moccasin", color(255, 228, 181)) + ("navajowhite", color(255, 222, 173)) + ("navy", color(0, 0, 128)) + ("oldlace", color(253, 245, 230)) + ("olive", color(128, 128, 0)) + ("olivedrab", color(107, 142, 35)) + ("orange", color(255, 165, 0)) + ("orangered", color(255, 69, 0)) + ("orchid", color(218, 112, 214)) + ("palegoldenrod", color(238, 232, 170)) + ("palegreen", color(152, 251, 152)) + ("paleturquoise", color(175, 238, 238)) + ("palevioletred", color(219, 112, 147)) + ("papayawhip", color(255, 239, 213)) + ("peachpuff", color(255, 218, 185)) + ("peru", color(205, 133, 63)) + ("pink", color(255, 192, 203)) + ("plum", color(221, 160, 221)) + ("powderblue", color(176, 224, 230)) + ("purple", color(128, 0, 128)) + ("red", color(255, 0, 0)) + ("rosybrown", color(188, 143, 143)) + ("royalblue", color(65, 105, 225)) + ("saddlebrown", color(139, 69, 19)) + ("salmon", color(250, 128, 114)) + ("sandybrown", color(244, 164, 96)) + ("seagreen", color(46, 139, 87)) + ("seashell", color(255, 245, 238)) + ("sienna", color(160, 82, 45)) + ("silver", color(192, 192, 192)) + ("skyblue", color(135, 206, 235)) + ("slateblue", color(106, 90, 205)) + ("slategray", color(112, 128, 144)) + ("slategrey", color(112, 128, 144)) + ("snow", color(255, 250, 250)) + ("springgreen", color(0, 255, 127)) + ("steelblue", color(70, 130, 180)) + ("tan", color(210, 180, 140)) + ("teal", color(0, 128, 128)) + ("thistle", color(216, 191, 216)) + ("tomato", color(255, 99, 71)) + ("turquoise", color(64, 224, 208)) + ("violet", color(238, 130, 238)) + ("wheat", color(245, 222, 179)) + ("white", color(255, 255, 255)) + ("whitesmoke", color(245, 245, 245)) + ("yellow", color(255, 255, 0)) + ("yellowgreen", color(154, 205, 50)) + ("transparent", color(0, 0, 0, 0)) + ; +} + +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) + return m1 + (m2 - m1) * h * 6.0; + if (h * 2 < 1.0) + return m2; + if (h * 3 < 2.0) + return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0; + return m1; +} + +template +css_color_grammar::css_color_grammar() + : css_color_grammar::base_type(css_color) + +{ + using qi::lit; + using qi::_val; + using qi::double_; + using qi::_1; + using qi::_a; + using qi::_b; + using qi::_c; + using ascii::no_case; + using phoenix::at_c; + + css_color %= rgba_color + | rgba_percent_color + | hsl_percent_color + | hex_color + | hex_color_small + | no_case[named]; + + 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(')') + ; + + 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<3>(_val) = alpha_converter(_1)]) + >> lit(')') + ; + + hsl_percent_color = lit("hsl") >> -lit('a') + >> 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)] + ; +} + +template struct mapnik::css_color_grammar; + + +} \ No newline at end of file diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index 9c77db0ee..e14df4973 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ // mapnik +#include #include #include #include diff --git a/src/expression_node.cpp b/src/expression_node.cpp index 5c997044d..f5f9bad8b 100644 --- a/src/expression_node.cpp +++ b/src/expression_node.cpp @@ -37,7 +37,6 @@ regex_replace_node::regex_replace_node (expr_node const& a, UnicodeString const& format(f) {} #else -regex_match_node::pattern boost::regex; regex_match_node::regex_match_node (expr_node const& a, std::string const& str) : expr(a), diff --git a/src/feature_style_processor.cpp b/src/feature_style_processor.cpp index 31f955ad5..a8e0fc8cd 100644 --- a/src/feature_style_processor.cpp +++ b/src/feature_style_processor.cpp @@ -20,8 +20,10 @@ * *****************************************************************************/ -//mapnik +// mapnik #include +#include +#include #include #include #include @@ -36,7 +38,8 @@ // boost #include #include -//stl + +// stl #include #if defined(HAVE_CAIRO) diff --git a/src/grid/grid_renderer.cpp b/src/grid/grid_renderer.cpp index fdbe834dd..ab231e853 100644 --- a/src/grid/grid_renderer.cpp +++ b/src/grid/grid_renderer.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ // mapnik +#include +#include #include #include #include diff --git a/src/load_map.cpp b/src/load_map.cpp index 9a1183a89..b23545a90 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -22,9 +22,7 @@ // mapnik #include - #include - #include #include #include @@ -39,16 +37,12 @@ #include #include #include - #include #include #include #include - #include - #include - #include #include #include @@ -1064,7 +1058,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& node) if (parse_stroke(strk,node)) sym.set_stroke(strk); - marker_placement_e placement = node.get_attr("placement", MARKER_LINE_PLACEMENT); + marker_placement_e placement = node.get_attr("placement", MARKER_POINT_PLACEMENT); sym.set_marker_placement(placement); parse_symbolizer_base(sym, node); rule.append(sym); diff --git a/src/map.cpp b/src/map.cpp index 1b7f14905..7a9d1f14b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -20,7 +20,9 @@ * *****************************************************************************/ -//mapnik +// mapnik +#include +#include #include #include #include diff --git a/src/markers_symbolizer.cpp b/src/markers_symbolizer.cpp index 03554e03c..c494bf7fc 100644 --- a/src/markers_symbolizer.cpp +++ b/src/markers_symbolizer.cpp @@ -45,7 +45,10 @@ markers_symbolizer::markers_symbolizer() allow_overlap_(false), spacing_(100.0), max_error_(0.2), - marker_p_(MARKER_POINT_PLACEMENT) {} + marker_p_(MARKER_POINT_PLACEMENT) { + // override the default for clipping in symbolizer base + this->set_clip(false); + } markers_symbolizer::markers_symbolizer(path_expression_ptr const& filename) : symbolizer_with_image(filename), @@ -56,7 +59,10 @@ markers_symbolizer::markers_symbolizer(path_expression_ptr const& filename) allow_overlap_(false), spacing_(100.0), max_error_(0.2), - marker_p_(MARKER_POINT_PLACEMENT) {} + marker_p_(MARKER_POINT_PLACEMENT) { + // override the default for clipping in symbolizer base + this->set_clip(false); + } markers_symbolizer::markers_symbolizer(markers_symbolizer const& rhs) : symbolizer_with_image(rhs), diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp index 17d32e877..8bee607ac 100644 --- a/src/memory_datasource.cpp +++ b/src/memory_datasource.cpp @@ -22,6 +22,8 @@ // mapnik #include +#include +#include #include #include #include diff --git a/src/path_expression_grammar.cpp b/src/path_expression_grammar.cpp new file mode 100644 index 000000000..40185818b --- /dev/null +++ b/src/path_expression_grammar.cpp @@ -0,0 +1,62 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include +#include + +// boost +#include +#include +#include +#include + +namespace mapnik +{ + +template +path_expression_grammar::path_expression_grammar() + : path_expression_grammar::base_type(expr) +{ + using boost::phoenix::construct; + using standard_wide::char_; + using qi::_1; + using qi::_val; + using qi::lit; + using qi::lexeme; + using phoenix::push_back; + + expr = + * ( + str [ push_back(_val, _1)] + | + ( '[' >> attr [ push_back(_val, construct( _1 )) ] >> ']') + ) + ; + + attr %= +(char_ - ']'); + str %= lexeme[+(char_ -'[')]; +} + +template struct mapnik::path_expression_grammar; + +} diff --git a/src/save_map.cpp b/src/save_map.cpp index 0151ff2a7..232aba2a7 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ // mapnik +#include +#include #include #include #include @@ -201,9 +203,11 @@ public: { set_attr(sym_node, "unlock-image", sym.get_unlock_image()); } - if (sym.get_text_opacity() != dfl.get_text_opacity() || explicit_defaults_) + + if (sym.get_placement_options()->defaults.format.text_opacity != + dfl.get_placement_options()->defaults.format.text_opacity || explicit_defaults_) { - set_attr(sym_node, "text-opacity", sym.get_text_opacity()); + set_attr(sym_node, "text-opacity", sym.get_placement_options()->defaults.format.text_opacity); } position displacement = sym.get_shield_displacement(); if (displacement.first != dfl.get_shield_displacement().first || explicit_defaults_) diff --git a/src/wkb_generator.cpp b/src/wkb_generator.cpp new file mode 100644 index 000000000..68decfc9e --- /dev/null +++ b/src/wkb_generator.cpp @@ -0,0 +1,141 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#include +#include +#include + +namespace mapnik { namespace util { + +boost::tuple multi_geometry_type::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 +wkt_generator::wkt_generator(bool single) + : 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(',') + ; +} + +template +wkt_multi_generator::wkt_multi_generator() + : wkt_multi_generator::base_type(wkt) +{ + using boost::spirit::karma::lit; + using boost::spirit::karma::eps; + 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 << ")" + | geometry + ; + + geometry = -(single_geometry % lit(',')) + ; + + single_geometry = geometry_types[_1 = _type(_val)] << path + ; + + multi_geometry = -(path % lit(',')) + ; + +} + +template struct mapnik::util::wkt_generator >; +template struct mapnik::util::wkt_multi_generator >; + + +}} \ No newline at end of file diff --git a/utils/svg2png/svg2png.cpp b/utils/svg2png/svg2png.cpp index 228387893..2c9113b08 100644 --- a/utils/svg2png/svg2png.cpp +++ b/utils/svg2png/svg2png.cpp @@ -149,7 +149,6 @@ int main (int argc,char** argv) agg::scanline_u8 sl; double opacity = 1; - double scale_factor_ = .95; int w = marker.width(); int h = marker.height(); if (verbose) @@ -165,8 +164,6 @@ int main (int argc,char** argv) mapnik::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 *= agg::trans_affine_scaling(scale_factor_); // render the marker at the center of the marker box mtx.translate(0.5 * w, 0.5 * h);