diff --git a/include/mapnik/params.hpp b/include/mapnik/params.hpp index a38fa54e7..535cacb38 100644 --- a/include/mapnik/params.hpp +++ b/include/mapnik/params.hpp @@ -51,6 +51,10 @@ struct value_holder : value_holder_base value_holder() : value_holder_base() {} + // C-string -> std::string + value_holder(char const* str) + : value_holder(std::string(str)) {} + // perfect forwarding template value_holder(T && obj) diff --git a/include/mapnik/symbolizer_base.hpp b/include/mapnik/symbolizer_base.hpp index fc88c579c..f07cf3d2a 100644 --- a/include/mapnik/symbolizer_base.hpp +++ b/include/mapnik/symbolizer_base.hpp @@ -101,7 +101,7 @@ struct strict_value : value_base_type strict_value() = default; strict_value(const char* val) - : value_base_type(val) {} + : value_base_type(std::string(val)) {} template strict_value(T const& obj) diff --git a/include/mapnik/xml_attribute_cast.hpp b/include/mapnik/xml_attribute_cast.hpp index fb3b7ebdc..cafa7e79a 100644 --- a/include/mapnik/xml_attribute_cast.hpp +++ b/include/mapnik/xml_attribute_cast.hpp @@ -55,7 +55,7 @@ struct do_xml_attribute_cast { static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& /*source*/) { - std::string err_msg("No conversion from std::string to"); + std::string err_msg("No conversion from std::string to "); err_msg += std::string(typeid(T).name()); throw std::runtime_error(err_msg); } @@ -74,6 +74,19 @@ struct do_xml_attribute_cast } }; +// specialization for mapnik::value_bool +template <> +struct do_xml_attribute_cast +{ + static inline boost::optional xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source) + { + bool result; + if (mapnik::util::string2bool(source, result)) + return boost::optional(result); + return boost::optional(); + } +}; + // specialization for int template <> struct do_xml_attribute_cast diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 8aef44414..2653e5757 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -479,7 +479,7 @@ postgis_datasource::postgis_datasource(parameters const& params) // Finally, add unique metadata to layer descriptor mapnik::parameters & extra_params = desc_.get_extra_parameters(); // explicitly make copies of values due to https://github.com/mapnik/mapnik/issues/2651 - extra_params["srid"] = srid_; + extra_params["srid"] = mapnik::value_integer(srid_); if (!key_field_.empty()) { extra_params["key_field"] = key_field_; diff --git a/src/load_map.cpp b/src/load_map.cpp index f21708274..fcb04c003 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -200,7 +200,7 @@ void map_parser::parse_map(Map & map, xml_node const& node, std::string const& b { map.set_background(*bgcolor); } - + optional image_filename = map_node.get_opt_attr("background-image"); if (image_filename) { @@ -891,7 +891,7 @@ void map_parser::parse_symbolizer_base(symbolizer_base &sym, xml_node const& nod { set_symbolizer_property(sym, keys::simplify_tolerance, node); set_symbolizer_property(sym, keys::smooth, node); - set_symbolizer_property(sym, keys::clip, node); + set_symbolizer_property(sym, keys::clip, node); set_symbolizer_property(sym, keys::comp_op, node); set_symbolizer_property(sym, keys::geometry_transform, node); set_symbolizer_property(sym, keys::simplify_algorithm, node); @@ -907,8 +907,8 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & node) point_symbolizer sym; parse_symbolizer_base(sym, node); set_symbolizer_property(sym, keys::opacity, node); - set_symbolizer_property(sym, keys::allow_overlap, node); - set_symbolizer_property(sym, keys::ignore_placement, node); + set_symbolizer_property(sym, keys::allow_overlap, node); + set_symbolizer_property(sym, keys::ignore_placement, node); set_symbolizer_property(sym, keys::point_placement_type, node); set_symbolizer_property(sym, keys::image_transform, node); if (file && !file->empty()) @@ -1011,9 +1011,9 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& node) set_symbolizer_property(sym, keys::offset, node); set_symbolizer_property(sym, keys::width, node); set_symbolizer_property(sym, keys::height, node); - set_symbolizer_property(sym, keys::allow_overlap, node); - set_symbolizer_property(sym, keys::avoid_edges, node); - set_symbolizer_property(sym, keys::ignore_placement, node); + set_symbolizer_property(sym, keys::allow_overlap, node); + set_symbolizer_property(sym, keys::avoid_edges, node); + set_symbolizer_property(sym, keys::ignore_placement, node); set_symbolizer_property(sym, keys::fill, node); set_symbolizer_property(sym, keys::image_transform, node); set_symbolizer_property(sym, keys::markers_placement_type, node); @@ -1172,7 +1172,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& node) set_symbolizer_property(sym, keys::shield_dx, node); set_symbolizer_property(sym, keys::shield_dy, node); set_symbolizer_property(sym, keys::opacity, node); - set_symbolizer_property(sym, keys::unlock_image, node); + set_symbolizer_property(sym, keys::unlock_image, node); std::string file = node.get_attr("file"); if (file.empty()) @@ -1343,7 +1343,7 @@ void map_parser::parse_raster_symbolizer(rule & rule, xml_node const & node) // premultiplied status of image optional premultiplied = node.get_opt_attr("premultiplied"); - if (premultiplied) put(raster_sym, keys::premultiplied, *premultiplied); + if (premultiplied) put(raster_sym, keys::premultiplied, bool(*premultiplied)); bool found_colorizer = false; for ( auto const& css : node) diff --git a/src/text/formatting/layout.cpp b/src/text/formatting/layout.cpp index ef908c569..9a5ca10aa 100644 --- a/src/text/formatting/layout.cpp +++ b/src/text/formatting/layout.cpp @@ -75,9 +75,9 @@ node_ptr layout_node::from_xml(xml_node const& xml, fontset_map const& fontsets) if (xml.has_attribute("text-ratio")) set_property_from_xml(n->text_ratio, "text-ratio", xml); if (xml.has_attribute("wrap-width")) set_property_from_xml(n->wrap_width, "wrap-width", xml); if (xml.has_attribute("wrap-character")) set_property_from_xml(n->wrap_char, "wrap-character", xml); - if (xml.has_attribute("wrap-before")) set_property_from_xml(n->wrap_before, "wrap-before", xml); - if (xml.has_attribute("repeat-wrap-character")) set_property_from_xml(n->repeat_wrap_char, "repeat-wrap-character", xml); - if (xml.has_attribute("rotate-displacement")) set_property_from_xml(n->rotate_displacement, "rotate-displacement", xml); + if (xml.has_attribute("wrap-before")) set_property_from_xml(n->wrap_before, "wrap-before", xml); + if (xml.has_attribute("repeat-wrap-character")) set_property_from_xml(n->repeat_wrap_char, "repeat-wrap-character", xml); + if (xml.has_attribute("rotate-displacement")) set_property_from_xml(n->rotate_displacement, "rotate-displacement", xml); if (xml.has_attribute("orientation")) set_property_from_xml(n->orientation, "orientation", xml); if (xml.has_attribute("horizontal-alignment")) set_property_from_xml(n->halign, "horizontal-alignment", xml); if (xml.has_attribute("vertical-alignment")) set_property_from_xml(n->valign, "vertical-alignment", xml); diff --git a/src/text/text_properties.cpp b/src/text/text_properties.cpp index ef5b9af10..73210d109 100644 --- a/src/text/text_properties.cpp +++ b/src/text/text_properties.cpp @@ -103,9 +103,9 @@ void text_symbolizer_properties::text_properties_from_xml(xml_node const& node) set_property_from_xml(expressions.label_position_tolerance, "label-position-tolerance", node); set_property_from_xml(expressions.minimum_padding, "minimum-padding", node); set_property_from_xml(expressions.minimum_path_length, "minimum-path-length", node); - set_property_from_xml(expressions.avoid_edges, "avoid-edges", node); - set_property_from_xml(expressions.allow_overlap, "allow-overlap", node); - set_property_from_xml(expressions.largest_bbox_only, "largest-bbox-only", node); + set_property_from_xml(expressions.avoid_edges, "avoid-edges", node); + set_property_from_xml(expressions.allow_overlap, "allow-overlap", node); + set_property_from_xml(expressions.largest_bbox_only, "largest-bbox-only", node); set_property_from_xml(expressions.max_char_angle_delta, "max-char-angle-delta", node); set_property_from_xml(expressions.upright, "upright", node); } @@ -215,9 +215,9 @@ void text_layout_properties::from_xml(xml_node const &node, fontset_map const& f set_property_from_xml(text_ratio, "text-ratio", node); set_property_from_xml(wrap_width, "wrap-width", node); set_property_from_xml(wrap_char, "wrap-character", node); - set_property_from_xml(wrap_before, "wrap-before", node); - set_property_from_xml(repeat_wrap_char, "repeat-wrap-character", node); - set_property_from_xml(rotate_displacement, "rotate-displacement", node); + set_property_from_xml(wrap_before, "wrap-before", node); + set_property_from_xml(repeat_wrap_char, "repeat-wrap-character", node); + set_property_from_xml(rotate_displacement, "rotate-displacement", node); set_property_from_xml(orientation, "orientation", node); set_property_from_xml(valign, "vertical-alignment", node); set_property_from_xml(halign, "horizontal-alignment", node); diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp index b14b8e4e0..2e2a7df8e 100644 --- a/src/xml_tree.cpp +++ b/src/xml_tree.cpp @@ -69,6 +69,7 @@ DEFINE_NAME_TRAIT( double, "double") DEFINE_NAME_TRAIT( float, "float") DEFINE_NAME_TRAIT( unsigned, "unsigned") DEFINE_NAME_TRAIT( int, "int") +DEFINE_NAME_TRAIT( bool, "bool") DEFINE_NAME_TRAIT( boolean_type, "boolean_type") #ifdef BIGINT DEFINE_NAME_TRAIT( mapnik::value_integer, "long long" ) @@ -411,6 +412,7 @@ std::string xml_node::line_to_string() const #define compile_get_value(T) template T xml_node::get_value() const compile_get_opt_attr(boolean_type); +compile_get_opt_attr(mapnik::value_bool); compile_get_opt_attr(std::string); compile_get_opt_attr(int); compile_get_opt_attr(unsigned); diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index e339a8f58..9de886732 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -352,23 +352,23 @@ void pgsql2sqlite(Connection conn, break; } case 23: - output_rec.push_back(sqlite::value_type(int4net(buf))); + output_rec.emplace_back(int4net(buf)); break; case 21: - output_rec.push_back(sqlite::value_type(int2net(buf))); + output_rec.emplace_back(int(int2net(buf))); break; case 700: { float val; float4net(val,buf); - output_rec.push_back(sqlite::value_type(val)); + output_rec.emplace_back(double(val)); break; } case 701: { double val; float8net(val,buf); - output_rec.push_back(sqlite::value_type(val)); + output_rec.emplace_back(val); break; } case 1700: @@ -377,7 +377,7 @@ void pgsql2sqlite(Connection conn, double val; if (mapnik::util::string2double(str,val)) { - output_rec.push_back(sqlite::value_type(val)); + output_rec.emplace_back(val); } break; }