diff --git a/Makefile b/Makefile index de9564ebb..be26fc0a2 100755 --- a/Makefile +++ b/Makefile @@ -26,6 +26,8 @@ clean: @if test -e ".sconf_temp/"; then rm -r ".sconf_temp/"; fi @find ./ -name "*.pyc" -exec rm {} \; @find ./ -name "*.os" -exec rm {} \; + @find ./ -name "*.dylib" -exec rm {} \; + @find ./ -name "*.so" -exec rm {} \; @find ./ -name "*.o" -exec rm {} \; @find ./ -name "*.pyc" -exec rm {} \; @if test -e "bindings/python/mapnik/paths.py"; then rm "bindings/python/mapnik/paths.py"; fi diff --git a/benchmark/test_expression_parse.cpp b/benchmark/test_expression_parse.cpp index 4c911f821..4f109aa74 100644 --- a/benchmark/test_expression_parse.cpp +++ b/benchmark/test_expression_parse.cpp @@ -30,40 +30,11 @@ public: } }; -class test2 : public benchmark::test_case -{ - std::string expr_; -public: - test2(mapnik::parameters const& params) - : test_case(params), - expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))") {} - bool validate() const - { - mapnik::expression_grammar expr_grammar;; - mapnik::expression_ptr expr = mapnik::parse_expression(expr_,expr_grammar); - std::string result = mapnik::to_expression_string(*expr); - bool ret = (result == expr_); - if (!ret) - { - std::clog << result << " != " << expr_ << "\n"; - } - return ret; - } - void operator()() const - { - mapnik::expression_grammar expr_grammar; - for (std::size_t i=0;idata(),actual, "png8:m=h"); + mapnik::save_to_file(im_->data(),actual, "png8:m=h:z=1"); return benchmark::compare_images(actual,expected); } void operator()() const @@ -28,7 +28,7 @@ public: std::string out; for (std::size_t i=0;idata(),"png8:m=h"); + out = mapnik::save_to_string(im_->data(),"png8:m=h:z=1"); } } }; diff --git a/benchmark/test_to_bool.cpp b/benchmark/test_to_bool.cpp index 62b9d13a0..92f073156 100644 --- a/benchmark/test_to_bool.cpp +++ b/benchmark/test_to_bool.cpp @@ -26,31 +26,4 @@ public: } }; -class test2 : public benchmark::test_case -{ - std::string value_; -public: - test2(mapnik::parameters const& params) - : test_case(params), - value_("1.23456789") {} - bool validate() const - { - double result = 0; - mapnik::util::string2double(value_.data(),value_.data()+value_.size(),result); - if (result != 1.23456789) return false; - result = 0; - mapnik::util::string2double(value_,result); - return (result == 1.23456789); - } - void operator()() const - { - for (std::size_t i=0;ibool") -BENCHMARK(test2,"string->double") +BENCHMARK(test,"string->bool") diff --git a/benchmark/test_to_double.cpp b/benchmark/test_to_double.cpp new file mode 100644 index 000000000..1605dcd06 --- /dev/null +++ b/benchmark/test_to_double.cpp @@ -0,0 +1,31 @@ +#include "bench_framework.hpp" +#include + +class test : public benchmark::test_case +{ + std::string value_; +public: + test(mapnik::parameters const& params) + : test_case(params), + value_("1.23456789") {} + bool validate() const + { + double result = 0; + if (!mapnik::util::string2double(value_.data(),value_.data()+value_.size(),result)) return false; + if (result != 1.23456789) return false; + result = 0; + if (!mapnik::util::string2double(value_,result)) return false; + if (result != 1.23456789) return false; + return true; + } + void operator()() const + { + for (std::size_t i=0;idouble") diff --git a/benchmark/test_to_int.cpp b/benchmark/test_to_int.cpp new file mode 100644 index 000000000..195d0336b --- /dev/null +++ b/benchmark/test_to_int.cpp @@ -0,0 +1,31 @@ +#include "bench_framework.hpp" +#include + +class test : public benchmark::test_case +{ + std::string value_; +public: + test(mapnik::parameters const& params) + : test_case(params), + value_("123456789") {} + bool validate() const + { + mapnik::value_integer result = 0; + if (!mapnik::util::string2int(value_.data(),value_.data()+value_.size(),result)) return false; + if (result != 123456789) return false; + result = 0; + if (!mapnik::util::string2int(value_,result)) return false; + if (result != 123456789) return false; + return true; + } + void operator()() const + { + for (std::size_t i=0;iint") diff --git a/include/mapnik/expression.hpp b/include/mapnik/expression.hpp index 9f8009b89..65c129d09 100644 --- a/include/mapnik/expression.hpp +++ b/include/mapnik/expression.hpp @@ -38,13 +38,10 @@ namespace mapnik { // fwd declare to reduce compile time -template struct expression_grammar; typedef std::shared_ptr expression_ptr; typedef std::set expression_set; - MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt, std::string const& encoding = "UTF8"); -MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt, mapnik::expression_grammar const& g); } #endif // MAPNIK_EXPRESSION_HPP diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 85fce2e5d..f47a39b79 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -127,7 +127,7 @@ struct expression_grammar : qi::grammar { typedef qi::rule rule_type; - explicit expression_grammar(); + explicit expression_grammar(std::string const& encoding = "utf-8"); qi::real_parser > strict_double; typename integer_parser::type int__; diff --git a/include/mapnik/expression_grammar_impl.hpp b/include/mapnik/expression_grammar_impl.hpp index a46f444cf..f43003960 100644 --- a/include/mapnik/expression_grammar_impl.hpp +++ b/include/mapnik/expression_grammar_impl.hpp @@ -64,9 +64,9 @@ expr_node regex_replace_impl::operator() (T0 & node, T1 const& pattern, T2 const } template -expression_grammar::expression_grammar() +expression_grammar::expression_grammar(std::string const& encoding) : expression_grammar::base_type(expr), - tr_("utf-8"), + tr_(encoding), unicode_(unicode_impl(tr_)), regex_match_(regex_match_impl(tr_)), regex_replace_(regex_replace_impl(tr_)) diff --git a/include/mapnik/parse_path.hpp b/include/mapnik/parse_path.hpp index f3d65c5e5..7d91a34c6 100644 --- a/include/mapnik/parse_path.hpp +++ b/include/mapnik/parse_path.hpp @@ -34,12 +34,9 @@ namespace mapnik { // fwd declare to reduce compile time -template struct path_expression_grammar; class feature_impl; MAPNIK_DECL path_expression_ptr parse_path(std::string const & str); -MAPNIK_DECL path_expression_ptr parse_path(std::string const & str, - path_expression_grammar const& g); struct MAPNIK_DECL path_processor { diff --git a/include/mapnik/parse_transform.hpp b/include/mapnik/parse_transform.hpp index 8e9edebf7..79c462ef8 100644 --- a/include/mapnik/parse_transform.hpp +++ b/include/mapnik/parse_transform.hpp @@ -29,22 +29,8 @@ namespace mapnik { -template struct transform_expression_grammar; - -typedef transform_expression_grammar - transform_expression_grammar_string; - -MAPNIK_DECL transform_list_ptr parse_transform(std::string const& str); - MAPNIK_DECL transform_list_ptr parse_transform(std::string const& str, - std::string const& encoding); - -MAPNIK_DECL bool parse_transform(transform_list& list, - std::string const& str); - -MAPNIK_DECL bool parse_transform(transform_list& list, - std::string const& str, - transform_expression_grammar_string const& g); + std::string const& encoding="utf-8"); } // namespace mapnik diff --git a/include/mapnik/text/placements_list.hpp b/include/mapnik/text/placements_list.hpp index 4f436c682..0b5e356fb 100644 --- a/include/mapnik/text/placements_list.hpp +++ b/include/mapnik/text/placements_list.hpp @@ -42,8 +42,8 @@ struct glyph_info; struct glyph_position { - glyph_position(glyph_info const& glyph, pixel_position const& pos, rotation const& rot) - : glyph(&glyph), pos(pos), rot(rot) { } + glyph_position(glyph_info const& _glyph, pixel_position const& _pos, rotation const& _rot) + : glyph(&_glyph), pos(_pos), rot(_rot) { } glyph_info const* glyph; pixel_position pos; rotation rot; @@ -52,8 +52,8 @@ struct glyph_position struct marker_info { marker_info() : marker(), transform() {} - marker_info(marker_ptr marker, agg::trans_affine const& transform) : - marker(marker), transform(transform) {} + marker_info(marker_ptr _marker, agg::trans_affine const& _transform) : + marker(_marker), transform(_transform) {} marker_ptr marker; agg::trans_affine transform; }; diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index f16b81395..70afb69c1 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -24,6 +24,7 @@ #define MAPNIK_GEOMETRY_TO_WKB_HPP // mapnik +#include #include #include @@ -141,7 +142,7 @@ wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order) { assert(g.size() == 1); std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point - wkb_buffer_ptr wkb(new wkb_buffer(size)); + wkb_buffer_ptr wkb = std::make_unique(size); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); int type = static_cast(mapnik::geometry_type::types::Point); @@ -161,7 +162,7 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde unsigned num_points = g.size(); assert(num_points > 1); std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints - wkb_buffer_ptr wkb(new wkb_buffer(size)); + wkb_buffer_ptr wkb = std::make_unique(size); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); int type = static_cast(mapnik::geometry_type::types::LineString); @@ -209,7 +210,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) } } unsigned num_rings = rings.size(); - wkb_buffer_ptr wkb(new wkb_buffer(size)); + wkb_buffer_ptr wkb = std::make_unique(size); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); int type = static_cast(mapnik::geometry_type::types::Polygon); @@ -281,7 +282,7 @@ wkb_buffer_ptr to_wkb(geometry_container const& paths, wkbByteOrder byte_order ) wkb_cont.push_back(std::move(wkb)); } - wkb_buffer_ptr multi_wkb( new wkb_buffer(multi_size)); + wkb_buffer_ptr multi_wkb = std::make_unique(multi_size); wkb_stream ss(multi_wkb->buffer(), multi_wkb->size()); ss.write(reinterpret_cast(&byte_order),1); multi_type = collection ? 7 : multi_type + 3; diff --git a/include/mapnik/xml_attribute_cast.hpp b/include/mapnik/xml_attribute_cast.hpp index 227456195..702cfa23e 100644 --- a/include/mapnik/xml_attribute_cast.hpp +++ b/include/mapnik/xml_attribute_cast.hpp @@ -188,7 +188,7 @@ struct do_xml_attribute_cast else { mapnik::expression_ptr expr = parse_expression(source); - tree.expr_cache_.insert(std::move(std::make_pair(source,expr))); + tree.expr_cache_.insert(std::make_pair(source,expr)); return expr; } } diff --git a/src/color_factory.cpp b/src/color_factory.cpp index 28945a20c..773c15515 100644 --- a/src/color_factory.cpp +++ b/src/color_factory.cpp @@ -46,7 +46,7 @@ color parse_color(std::string const& str, c); if (result && (first == last)) { - return std::move(c); + return c; } else { diff --git a/src/expression.cpp b/src/expression.cpp index 3067b3251..191685909 100644 --- a/src/expression.cpp +++ b/src/expression.cpp @@ -36,12 +36,6 @@ namespace mapnik expression_ptr parse_expression(std::string const& str, std::string const& encoding) { static const expression_grammar g; - return parse_expression(str, g); -} - -expression_ptr parse_expression(std::string const& str, - mapnik::expression_grammar const& g) -{ boost::spirit::standard_wide::space_type space; auto node = std::make_shared(); std::string::const_iterator itr = str.begin(); diff --git a/src/load_map.cpp b/src/load_map.cpp index 0bf1f1dc1..5edacaf7c 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -293,14 +293,13 @@ void map_parser::parse_map(Map & map, xml_node const& pt, std::string const& bas unsigned i = 0; bool success = false; int n[3]; - for (boost::tokenizer >::iterator beg = tokens.begin(); - beg != tokens.end(); ++beg) + for (auto const& beg : tokens) { - std::string item = mapnik::util::trim_copy(*beg); + std::string item = mapnik::util::trim_copy(beg); if (!mapnik::util::string2int(item,n[i])) { throw config_error(std::string("Invalid version string encountered: '") - + *beg + "' in '" + *min_version_string + "'"); + + beg + "' in '" + *min_version_string + "'"); } if (i==2) { @@ -340,89 +339,75 @@ void map_parser::parse_map_include(Map & map, xml_node const& include) { try { - xml_node::const_iterator itr = include.begin(); - xml_node::const_iterator end = include.end(); - - for (; itr != end; ++itr) + for (auto const& n : include) { - if (itr->is_text()) continue; - if (itr->is("Include")) + if (n.is_text()) continue; + if (n.is("Include")) { - parse_map_include(map, *itr); + parse_map_include(map, n); } - else if (itr->is("Style")) + else if (n.is("Style")) { - parse_style(map, *itr); + parse_style(map, n); } - else if (itr->is("Layer")) + else if (n.is("Layer")) { - parse_layer(map, *itr); + parse_layer(map, n); } - else if (itr->is("FontSet")) + else if (n.is("FontSet")) { - parse_fontset(map, *itr); + parse_fontset(map, n); } - else if (itr->is("FileSource")) + else if (n.is("FileSource")) { - std::string name = itr->get_attr("name"); - std::string value = itr->get_text(); - file_sources_[std::move(name)] = std::move(value); + file_sources_[n.get_attr("name")] = n.get_text(); } - else if (itr->is("Datasource")) + else if (n.is("Datasource")) { - std::string name = itr->get_attr("name", std::string("Unnamed")); + std::string name = n.get_attr("name", std::string("Unnamed")); parameters params; - xml_node::const_iterator paramIter = itr->begin(); - xml_node::const_iterator endParam = itr->end(); - for (; paramIter != endParam; ++paramIter) + for (auto const& p: n) { - if (paramIter->is("Parameter")) + if (p.is("Parameter")) { - std::string param_name = paramIter->get_attr("name"); - std::string value = paramIter->get_text(); - params[std::move(param_name)] = std::move(value); + params[p.get_attr("name")] = p.get_text(); } } - datasource_templates_[name] = std::move(params); + datasource_templates_[std::move(name)] = std::move(params); } - else if (itr->is("Parameters")) + else if (n.is("Parameters")) { parameters & params = map.get_extra_parameters(); - xml_node::const_iterator paramIter = itr->begin(); - xml_node::const_iterator endParam = itr->end(); - for (; paramIter != endParam; ++paramIter) + for (auto const& p: n) { - if (paramIter->is("Parameter")) + if (p.is("Parameter")) { - std::string name = paramIter->get_attr("name"); bool is_string = true; - boost::optional type = paramIter->get_opt_attr("type"); + boost::optional type = p.get_opt_attr("type"); if (type) { if (*type == "int") { is_string = false; - mapnik::value_integer value = paramIter->get_value(); - params[std::move(name)] = std::move(value); + params[p.get_attr("name")] = p.get_value(); } else if (*type == "float") { is_string = false; - double value = paramIter->get_value(); - params[std::move(name)] = std::move(value); + params[p.get_attr("name")] = p.get_value(); } } - if (is_string) { - std::string value = paramIter->get_text(); - params[std::move(name)] = std::move(value); + params[p.get_attr("name")] = p.get_text(); } } } } } - } catch (config_error const& ex) { + } + catch (config_error const& ex) + { ex.append_context(include); throw; } @@ -509,15 +494,12 @@ void map_parser::parse_fontset(Map & map, xml_node const& fset) { name = fset.get_attr("name"); font_set fontset(name); - xml_node::const_iterator itr = fset.begin(); - xml_node::const_iterator end = fset.end(); - bool success = false; - for (; itr != end; ++itr) + for (auto const& n: fset) { - if (itr->is("Font")) + if (n.is("Font")) { - if (parse_font(fontset, *itr)) + if (parse_font(fontset, n)) { success = true; } @@ -534,7 +516,7 @@ void map_parser::parse_fontset(Map & map, xml_node const& fset) // XXX Hack because map object isn't accessible by text_symbolizer // when it's parsed - fontsets_.insert(std::move(std::make_pair(name, fontset))); + fontsets_.insert(std::make_pair(name, fontset)); } catch (config_error const& ex) { @@ -662,15 +644,12 @@ void map_parser::parse_layer(Map & map, xml_node const& node) } } - xml_node::const_iterator child = node.begin(); - xml_node::const_iterator end = node.end(); - - for(; child != end; ++child) + for (auto const& child: node) { - if (child->is("StyleName")) + if (child.is("StyleName")) { - std::string style_name = child->get_text(); + std::string style_name = child.get_text(); if (style_name.empty()) { std::string ss("StyleName is empty in Layer: '"); @@ -689,14 +668,14 @@ void map_parser::parse_layer(Map & map, xml_node const& node) lyr.add_style(style_name); } } - else if (child->is("Datasource")) + else if (child.is("Datasource")) { parameters params; - optional base = child->get_opt_attr("base"); + optional base = child.get_opt_attr("base"); if(base) { std::map::const_iterator base_itr = datasource_templates_.find(*base); - if (base_itr!=datasource_templates_.end()) + if (base_itr != datasource_templates_.end()) { params = base_itr->second; } @@ -707,26 +686,24 @@ void map_parser::parse_layer(Map & map, xml_node const& node) } } - xml_node::const_iterator paramIter = child->begin(); - xml_node::const_iterator endParam = child->end(); - for (; paramIter != endParam; ++paramIter) + for (auto const& n : child) { - if (paramIter->is("Parameter")) + if (n.is("Parameter")) { - std::string param_name = paramIter->get_attr("name"); - std::string value = paramIter->get_text(); - params[param_name] = value; + params[n.get_attr("name")] = n.get_text(); } } boost::optional base_param = params.get("base"); boost::optional file_param = params.get("file"); - if (base_param){ + if (base_param) + { params["base"] = ensure_relative_to_xml(base_param); } - else if (file_param){ + else if (file_param) + { params["file"] = ensure_relative_to_xml(file_param); } @@ -908,14 +885,7 @@ void map_parser::parse_symbolizer_base(symbolizer_base &sym, xml_node const &pt) optional geometry_transform_wkt = pt.get_opt_attr("geometry-transform"); if (geometry_transform_wkt) { - mapnik::transform_list_ptr tl = std::make_shared(); - if (!mapnik::parse_transform(*tl, *geometry_transform_wkt)) - { - std::string ss("Could not parse transform from '"); - ss += *geometry_transform_wkt + "', expected transform attribute"; - throw config_error(ss); - } - put(sym, keys::geometry_transform, tl); + put(sym, keys::geometry_transform, mapnik::parse_transform(*geometry_transform_wkt)); } // clip @@ -976,12 +946,7 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym) if (image_transform_wkt) { - mapnik::transform_list_ptr tl = std::make_shared(); - if (!mapnik::parse_transform(*tl, *image_transform_wkt)) - { - throw mapnik::config_error("Failed to parse transform: '" + *image_transform_wkt + "'"); - } - put(symbol, keys::image_transform, tl); + put(symbol, keys::image_transform, mapnik::parse_transform(*image_transform_wkt)); } } parse_symbolizer_base(symbol, sym); @@ -1053,12 +1018,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym) optional image_transform_wkt = sym.get_opt_attr("transform"); if (image_transform_wkt) { - mapnik::transform_list_ptr tl = std::make_shared(); - if (!mapnik::parse_transform(*tl, *image_transform_wkt)) - { - throw mapnik::config_error("Failed to parse transform: '" + *image_transform_wkt + "'"); - } - put(symbol, keys::image_transform, tl); + put(symbol, keys::image_transform, mapnik::parse_transform(*image_transform_wkt)); } optional c = sym.get_opt_attr("fill"); @@ -1154,7 +1114,7 @@ void map_parser::parse_polygon_pattern_symbolizer(rule & rule, if(base) { - std::map::iterator itr = file_sources_.find(*base); + std::map::const_iterator itr = file_sources_.find(*base); if (itr!=file_sources_.end()) { file = itr->second + "/" + file; @@ -1221,12 +1181,7 @@ void map_parser::parse_text_symbolizer(rule & rule, xml_node const& sym) optional halo_transform_wkt = sym.get_opt_attr("halo-transform"); if (halo_transform_wkt) { - mapnik::transform_list_ptr tl = std::make_shared(); - if (!mapnik::parse_transform(*tl, *halo_transform_wkt)) - { - throw mapnik::config_error("Failed to parse halo-transform: '" + *halo_transform_wkt + "'"); - } - put(text_symbol, keys::halo_transform, tl); + put(text_symbol, keys::halo_transform, mapnik::parse_transform(*halo_transform_wkt)); } rule.append(std::move(text_symbol)); @@ -1244,7 +1199,8 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym) { text_placements_ptr placement_finder; optional placement_type = sym.get_opt_attr("placement-type"); - if (placement_type) { + if (placement_type) + { placement_finder = placements::registry::instance().from_xml(*placement_type, sym, fontsets_); } else { placement_finder = std::make_shared(); @@ -1261,12 +1217,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym) optional image_transform_wkt = sym.get_opt_attr("transform"); if (image_transform_wkt) { - mapnik::transform_list_ptr tl = std::make_shared(); - if (!mapnik::parse_transform(*tl, *image_transform_wkt)) - { - throw mapnik::config_error("Failed to parse transform: '" + *image_transform_wkt + "'"); - } - put(shield_symbol, keys::image_transform, tl); + put(shield_symbol, keys::image_transform, mapnik::parse_transform(*image_transform_wkt)); } // shield displacement @@ -1632,7 +1583,8 @@ bool map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, colorizer_mode default_mode = node.get_attr("default-mode", COLORIZER_LINEAR); - if(default_mode == COLORIZER_INHERIT) { + if(default_mode == COLORIZER_INHERIT) + { throw config_error("RasterColorizer mode must not be INHERIT. "); } rc->set_default_mode(default_mode); @@ -1649,47 +1601,44 @@ bool map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, optional eps = node.get_opt_attr("epsilon"); if (eps) { - if(*eps < 0) { + if(*eps < 0) + { throw config_error("RasterColorizer epsilon must be > 0. "); } rc->set_epsilon(*eps); } - - xml_node::const_iterator stopIter = node.begin(); - xml_node::const_iterator endStop = node.end(); float maximumValue = -std::numeric_limits::max(); - - for(; stopIter != endStop; ++stopIter) + for (auto const& n : node) { - if (stopIter->is("stop")) + if (n.is("stop")) { found_stops = true; // colour is optional. - optional stopcolor = stopIter->get_opt_attr("color"); - if (!stopcolor) { + optional stopcolor = n.get_opt_attr("color"); + if (!stopcolor) + { *stopcolor = *default_color; } // mode default to INHERIT - colorizer_mode mode = - stopIter->get_attr("mode", COLORIZER_INHERIT); + colorizer_mode mode = n.get_attr("mode", COLORIZER_INHERIT); // value is required, and it must be bigger than the previous - optional value = - stopIter->get_opt_attr("value"); + optional value = n.get_opt_attr("value"); - if(!value) { + if(!value) + { throw config_error("stop tag missing value"); } - if(value < maximumValue) { + if(value < maximumValue) + { throw config_error("stop tag values must be in ascending order"); } maximumValue = *value; - optional label = - stopIter->get_opt_attr("label"); + optional label = n.get_opt_attr("label"); //append the stop colorizer_stop tmpStop; @@ -1697,7 +1646,9 @@ bool map_parser::parse_raster_colorizer(raster_colorizer_ptr const& rc, tmpStop.set_mode(mode); tmpStop.set_value(*value); if (label) + { tmpStop.set_label(*label); + } rc->add_stop(tmpStop); } diff --git a/src/map.cpp b/src/map.cpp index c11314d2e..95a020b20 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -140,12 +140,12 @@ Map::const_style_iterator Map::end_styles() const // TODO(dane) - only kept for python bindings, can we avoid needing? bool Map::insert_style(std::string const& name,feature_type_style const& style) { - return styles_.insert(std::move(make_pair(name,style))).second; + return styles_.insert(make_pair(name,style)).second; } bool Map::insert_style(std::string const& name,feature_type_style && style) { - return styles_.insert(std::move(make_pair(name,std::move(style)))).second; + return styles_.insert(make_pair(name, std::move(style))).second; } void Map::remove_style(std::string const& name) @@ -168,7 +168,7 @@ bool Map::insert_fontset(std::string const& name, font_set const& fontset) { throw mapnik::config_error("Fontset name must match the name used to reference it on the map"); } - return fontsets_.insert(std::move(make_pair(name, fontset))).second; + return fontsets_.insert(make_pair(name, fontset)).second; } bool Map::insert_fontset(std::string const& name, font_set && fontset) @@ -177,7 +177,7 @@ bool Map::insert_fontset(std::string const& name, font_set && fontset) { throw mapnik::config_error("Fontset name must match the name used to reference it on the map"); } - return fontsets_.insert(std::move(make_pair(name, std::move(fontset)))).second; + return fontsets_.insert(make_pair(name, std::move(fontset))).second; } boost::optional Map::find_fontset(std::string const& name) const diff --git a/src/parse_path.cpp b/src/parse_path.cpp index 7de8c2b3b..9e2ce39f0 100644 --- a/src/parse_path.cpp +++ b/src/parse_path.cpp @@ -31,30 +31,22 @@ // boost #include - // stl #include - namespace mapnik { path_expression_ptr parse_path(std::string const& str) { static const path_expression_grammar g; - return parse_path(str,g); -} - -path_expression_ptr parse_path(std::string const& str, - path_expression_grammar const& g) -{ - path_expression path; + auto path = std::make_shared(); boost::spirit::standard_wide::space_type space; std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); - bool r = qi::phrase_parse(itr, end, g, space, path); - if (r && itr == end) + bool r = qi::phrase_parse(itr, end, g, space, *path); + if (r && itr == end) { - return std::make_shared(path); //path; + return path; } else { diff --git a/src/parse_transform.cpp b/src/parse_transform.cpp index 0cc5e8af9..df377b279 100644 --- a/src/parse_transform.cpp +++ b/src/parse_transform.cpp @@ -23,48 +23,29 @@ #include #include #include -#include +// stl +#include +#include namespace mapnik { -transform_list_ptr parse_transform(std::string const& str) -{ - return parse_transform(str, "utf-8"); -} - transform_list_ptr parse_transform(std::string const& str, std::string const& encoding) { + static const transform_expression_grammar g; transform_list_ptr tl = std::make_shared(); - static const transform_expression_grammar_string gte; - if (!parse_transform(*tl, str, gte)) - { - tl.reset(); - } - return tl; -} - -bool parse_transform(transform_list& tl, - std::string const& str) -{ - static const transform_expression_grammar_string gte; - return parse_transform(tl, str, gte); -} - -bool parse_transform(transform_list& transform, - std::string const& str, - transform_expression_grammar_string const& g) -{ std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); - bool r = qi::phrase_parse(itr, end, g, space_type(), transform); - - #ifdef MAPNIK_LOG - MAPNIK_LOG_DEBUG(load_map) << "map_parser: Parsed transform [ " - << transform_processor_type::to_string(transform) << " ]"; - #endif - - return (r && itr==end); + bool r = qi::phrase_parse(itr, end, g, space_type(), *tl); + if (r && itr == end) + { + return tl; + } + else + { + throw std::runtime_error("Failed to parse transform: \"" + str + "\""); + } } + } // namespace mapnik diff --git a/src/wkb.cpp b/src/wkb.cpp index 039a31f40..c6b187e1f 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -576,19 +576,33 @@ private: switch (type) { case wkbPoint: s << "Point"; break; - case wkbLineString: s << "LineString"; break; - case wkbPolygon: s << "Polygon"; break; - case wkbMultiPoint: s << "MultiPoint"; break; - case wkbMultiLineString: s << "MultiLineString"; break; - case wkbMultiPolygon: s << "MultiPolygon"; break; - case wkbGeometryCollection: s << "GeometryCollection"; break; case wkbPointZ: s << "PointZ"; break; - case wkbLineStringZ: s << "LineStringZ"; break; - case wkbPolygonZ: s << "PolygonZ"; break; + case wkbPointM: s << "PointM"; break; + case wkbPointZM: s << "PointZM"; break; + case wkbMultiPoint: s << "MultiPoint"; break; case wkbMultiPointZ: s << "MultiPointZ"; break; + case wkbMultiPointM: s << "MultiPointM"; break; + case wkbMultiPointZM: s << "MultiPointZM"; break; + case wkbLineString: s << "LineString"; break; + case wkbLineStringZ: s << "LineStringZ"; break; + case wkbLineStringM: s << "LineStringM"; break; + case wkbLineStringZM: s << "LineStringZM"; break; + case wkbMultiLineString: s << "MultiLineString"; break; case wkbMultiLineStringZ: s << "MultiLineStringZ"; break; + case wkbMultiLineStringM: s << "MultiLineStringM"; break; + case wkbMultiLineStringZM: s << "MultiLineStringZM"; break; + case wkbPolygon: s << "Polygon"; break; + case wkbPolygonZ: s << "PolygonZ"; break; + case wkbPolygonM: s << "PolygonM"; break; + case wkbPolygonZM: s << "PolygonZM"; break; + case wkbMultiPolygon: s << "MultiPolygon"; break; case wkbMultiPolygonZ: s << "MultiPolygonZ"; break; + case wkbMultiPolygonM: s << "MultiPolygonM"; break; + case wkbMultiPolygonZM: s << "MultiPolygonZM"; break; + case wkbGeometryCollection: s << "GeometryCollection"; break; case wkbGeometryCollectionZ: s << "GeometryCollectionZ"; break; + case wkbGeometryCollectionM: s << "GeometryCollectionM"; break; + case wkbGeometryCollectionZM: s << "GeometryCollectionZM"; break; default: s << "wkbUnknown(" << type << ")"; break; } diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp index 34bc273d3..e01ca5a75 100644 --- a/src/xml_tree.cpp +++ b/src/xml_tree.cpp @@ -228,7 +228,7 @@ xml_node &xml_node::add_child(std::string && name, unsigned line, bool is_text) void xml_node::add_attribute(const char * name, const char * value) { - attributes_.insert(std::move(std::make_pair(name,std::move(xml_attribute(value))))); + attributes_.insert(std::make_pair(name,xml_attribute(value))); } xml_node::attribute_map const& xml_node::get_attributes() const diff --git a/tests/data/broken_maps/css_value_broken.xml b/tests/data/broken_maps/css_value_broken.xml index 251d2ee8a..2926b15f7 100644 --- a/tests/data/broken_maps/css_value_broken.xml +++ b/tests/data/broken_maps/css_value_broken.xml @@ -2,7 +2,7 @@ \ No newline at end of file diff --git a/tests/python_tests/geometry_io_test.py b/tests/python_tests/geometry_io_test.py index 0368b190f..1feaa6ae6 100644 --- a/tests/python_tests/geometry_io_test.py +++ b/tests/python_tests/geometry_io_test.py @@ -68,17 +68,6 @@ wkbs = [ [ 0, "LINESTRING EMPTY", '010200000000000000'], [ 0, "MULTILINESTRING EMPTY", '010500000000000000'], [ 0, "Polygon EMPTY", '010300000000000000'], - [ 0, "MULTIPOLYGON EMPTY", '010600000000000000'], - [ 0, "TRIANGLE EMPTY", '011100000000000000'], - - [ 0, "CircularString EMPTY", '010800000000000000'], - [ 0, "CurvePolygon EMPTY", '010A00000000000000'], - [ 0, "CompoundCurve EMPTY", '010900000000000000'], - [ 0, "MultiCurve EMPTY", '010B00000000000000'], - - [ 0, "MultiSurface EMPTY", '010C00000000000000'], - [ 0, "PolyhedralSurface EMPTY", '010F00000000000000'], - [ 0, "TIN EMPTY", '011000000000000000'], [ 0, "GEOMETRYCOLLECTION EMPTY", '010700000000000000'], [ 2, "GEOMETRYCOLLECTION(MULTILINESTRING((10 10,20 20,10 40),(40 40,30 30,40 20,30 10)),LINESTRING EMPTY)", '010700000002000000010500000002000000010200000003000000000000000000244000000000000024400000000000003440000000000000344000000000000024400000000000004440010200000004000000000000000000444000000000000044400000000000003e400000000000003e40000000000000444000000000000034400000000000003e400000000000002440010200000000000000' ], @@ -88,10 +77,22 @@ wkbs = [ [ 1, "GEOMETRYCOLLECTION(POINT EMPTY,MULTIPOINT(0 0))", '010700000002000000010400000000000000010400000001000000010100000000000000000000000000000000000000'], [ 0, "LINESTRING EMPTY", '010200000000000000' ], [ 1, "Point(0 0)", '010100000000000000000000000000000000000000' ], - # a few bogus inputs - [ 0, "", '' ], - [ 0, "00", '01' ], - [ 0, "0000", '0104' ], + # unsupported types + [ 0, "MULTIPOLYGON EMPTY", '010600000000000000'], + [ 0, "TRIANGLE EMPTY", '011100000000000000'], + [ 0, "CircularString EMPTY", '010800000000000000'], + [ 0, "CurvePolygon EMPTY", '010A00000000000000'], + [ 0, "CompoundCurve EMPTY", '010900000000000000'], + [ 0, "MultiCurve EMPTY", '010B00000000000000'], + [ 0, "MultiSurface EMPTY", '010C00000000000000'], + [ 0, "PolyhedralSurface EMPTY", '010F00000000000000'], + [ 0, "TIN EMPTY", '011000000000000000'], + # TODO - a few bogus inputs + # enable if we start range checking to avoid crashing on invalid input? + # https://github.com/mapnik/mapnik/issues/2236 + #[ 0, "", '' ], + #[ 0, "00", '01' ], + #[ 0, "0000", '0104' ], ] def test_path_geo_interface():