remove redundant ExpressionFormat node

This commit is contained in:
artemp 2014-07-25 14:26:13 +01:00
parent 37245fdde1
commit 70059cc346
5 changed files with 0 additions and 209 deletions

View file

@ -32,7 +32,6 @@
#include <mapnik/text/formatting/text.hpp>
#include <mapnik/text/formatting/list.hpp>
#include <mapnik/text/formatting/format.hpp>
#include <mapnik/text/formatting/expression_format.hpp>
#include <mapnik/text/formatting/layout.hpp>
#include <mapnik/text/layout.hpp>
#include <mapnik/symbolizer.hpp>

View file

@ -1,66 +0,0 @@
/*****************************************************************************
*
* 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
*
*****************************************************************************/
#ifndef FORMATTING_EXPRESSION_HPP
#define FORMATTING_EXPRESSION_HPP
#include <mapnik/text/formatting/base.hpp>
#include <mapnik/expression.hpp>
// boost
#include <boost/property_tree/ptree_fwd.hpp>
namespace mapnik {
class feature_impl;
class xml_node;
struct char_properties;
namespace formatting {
class MAPNIK_DECL expression_format: public node
{
public:
void to_xml(boost::property_tree::ptree &xml) const;
static node_ptr from_xml(xml_node const& xml);
virtual void apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const;
virtual void add_expressions(expression_set &output) const;
void set_child(node_ptr child);
node_ptr get_child() const;
expression_ptr face_name;
expression_ptr text_size;
expression_ptr character_spacing;
expression_ptr line_spacing;
expression_ptr text_opacity;
expression_ptr wrap_char;
expression_ptr fill;
expression_ptr halo_fill;
expression_ptr halo_radius;
private:
node_ptr child_;
static expression_ptr get_expression(xml_node const& xml, std::string name);
};
} //ns formatting
} //ns mapnik
#endif // FORMATTING_EXPRESSION_HPP

View file

@ -213,7 +213,6 @@ source = Split(
text/symbolizer_helpers.cpp
text/text_properties.cpp
text/formatting/base.cpp
text/formatting/expression.cpp
text/formatting/list.cpp
text/formatting/text.cpp
text/formatting/format.cpp

View file

@ -1,139 +0,0 @@
/*****************************************************************************
*
* 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
*
*****************************************************************************/
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/text/formatting/expression_format.hpp>
#include <mapnik/ptree_helpers.hpp>
#include <mapnik/expression_string.hpp>
#include <mapnik/expression_evaluator.hpp>
#include <mapnik/text/text_properties.hpp>
#include <mapnik/color_factory.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/xml_node.hpp>
//boost
#include <boost/property_tree/ptree.hpp>
namespace mapnik {
namespace formatting {
using boost::property_tree::ptree;
void expression_format::to_xml(boost::property_tree::ptree &xml) const
{
ptree &new_node = xml.push_back(ptree::value_type("ExpressionFormat", ptree()))->second;
if (face_name) set_attr(new_node, "face-name", to_expression_string(*face_name));
if (text_size) set_attr(new_node, "size", to_expression_string(*text_size));
if (character_spacing) set_attr(new_node, "character-spacing", to_expression_string(*character_spacing));
if (line_spacing) set_attr(new_node, "line-spacing", to_expression_string(*line_spacing));
if (text_opacity) set_attr(new_node, "opacity", to_expression_string(*text_opacity));
if (wrap_char) set_attr(new_node, "wrap-character", to_expression_string(*wrap_char));
if (fill) set_attr(new_node, "fill", to_expression_string(*fill));
if (halo_fill) set_attr(new_node, "halo-fill", to_expression_string(*halo_fill));
if (halo_radius) set_attr(new_node, "halo-radius", to_expression_string(*halo_radius));
if (child_) child_->to_xml(new_node);
}
node_ptr expression_format::from_xml(xml_node const& xml)
{
expression_format *n = new expression_format();
node_ptr np(n);
node_ptr child = node::from_xml(xml);
n->set_child(child);
n->face_name = get_expression(xml, "face-name");
n->text_size = get_expression(xml, "size");
n->character_spacing = get_expression(xml, "character-spacing");
n->line_spacing = get_expression(xml, "line-spacing");
n->text_opacity = get_expression(xml, "opacity");
n->wrap_char = get_expression(xml, "wrap-character");
n->fill = get_expression(xml, "fill");
n->halo_fill = get_expression(xml, "halo-fill");
n->halo_radius = get_expression(xml, "halo-radius");
return np;
}
expression_ptr expression_format::get_expression(xml_node const& xml, std::string name)
{
boost::optional<expression_ptr> tmp = xml.get_opt_attr<expression_ptr>(name);
if (tmp) return *tmp;
return expression_ptr();
}
void expression_format::apply(char_properties_ptr p, feature_impl const& feature, attributes const& vars, text_layout &output) const
{
char_properties_ptr new_properties = std::make_shared<char_properties>(*p);
if (face_name) new_properties->face_name =
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *face_name).to_string();
if (text_size) new_properties->text_size =
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *text_size).to_double();
if (character_spacing) new_properties->character_spacing =
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *character_spacing).to_double();
if (line_spacing) new_properties->line_spacing =
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *line_spacing).to_double();
if (text_opacity) new_properties->text_opacity =
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *text_opacity).to_double();
if (wrap_char) new_properties->wrap_char =
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *character_spacing).to_unicode()[0];
if (fill) new_properties->fill = parse_color(
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *fill).to_string());
if (halo_fill) new_properties->halo_fill = parse_color(
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *halo_fill).to_string());
if (halo_radius) new_properties->halo_radius =
boost::apply_visitor(evaluate<feature_impl,value_type,attributes>(feature,vars), *halo_radius).to_double();
if (child_) {
child_->apply(new_properties, feature, vars, output);
} else {
MAPNIK_LOG_WARN(expression) << "Useless format: No text to format";
}
}
void expression_format::set_child(node_ptr child)
{
child_ = child;
}
node_ptr expression_format::get_child() const
{
return child_;
}
void expression_format::add_expressions(expression_set &output) const
{
if (child_) child_->add_expressions(output);
output.insert(face_name);
output.insert(text_size);
output.insert(character_spacing);
output.insert(line_spacing);
output.insert(text_opacity);
output.insert(wrap_char);
output.insert(fill);
output.insert(halo_fill);
output.insert(halo_radius);
}
} //ns formatting
} //ns mapnik

View file

@ -23,7 +23,6 @@
#include <mapnik/text/formatting/registry.hpp>
#include <mapnik/text/formatting/text.hpp>
#include <mapnik/text/formatting/format.hpp>
#include <mapnik/text/formatting/expression_format.hpp>
#include <mapnik/text/formatting/layout.hpp>
#include <mapnik/xml_node.hpp>
#include <mapnik/config_error.hpp>
@ -37,7 +36,6 @@ registry::registry()
{
register_name("<xmltext>", &text_node::from_xml);
register_name("Format", &format_node::from_xml);
register_name("ExpressionFormat", &expression_format::from_xml);
register_name("Layout", &layout_node::from_xml);
}