Merge remote-tracking branch 'origin/master'

This commit is contained in:
Artem Pavlenko 2012-02-15 23:31:38 +00:00
commit ab56a63f2f
13 changed files with 319 additions and 90 deletions

View file

@ -0,0 +1,58 @@
/*****************************************************************************
*
* 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/formatting/base.hpp>
#include <mapnik/expression.hpp>
namespace mapnik {
namespace formatting {
class expression_format: public node {
public:
void to_xml(boost::property_tree::ptree &xml) const;
static node_ptr from_xml(boost::property_tree::ptree const& xml);
virtual void apply(char_properties const& p, Feature const& feature, processed_text &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_before;
expression_ptr wrap_char;
expression_ptr fill;
expression_ptr halo_fill;
expression_ptr halo_radius;
private:
node_ptr child_;
static expression_ptr get_expression(boost::property_tree::ptree const& xml, std::string name);
};
} //ns formatting
} //ns mapnik
#endif // FORMATTING_EXPRESSION_HPP

View file

@ -129,7 +129,7 @@ public:
virtual ~text_placements() {}
/** List of all properties used as the default for the subclasses. */
text_symbolizer_properties properties;
text_symbolizer_properties defaults;
};
/** Pointer to object of class text_placements */

View file

@ -162,7 +162,7 @@ struct text_symbolizer_properties
unsigned text_ratio;
unsigned wrap_width;
/** Default values for char_properties. */
char_properties default_format;
char_properties format;
private:
/** A tree of formatting::nodes which contain text and formatting information. */
formatting::node_ptr tree_;

View file

@ -165,6 +165,7 @@ source = Split(
warp.cpp
json/feature_collection_parser.cpp
markers_placement.cpp
formatting/expression.cpp
"""
)

View file

@ -0,0 +1,144 @@
/*****************************************************************************
*
* 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/formatting/expression.hpp>
#include <mapnik/ptree_helpers.hpp>
#include <mapnik/expression_string.hpp>
#include <mapnik/expression_evaluator.hpp>
#include <mapnik/text_properties.hpp>
#include <mapnik/feature.hpp>
// boost
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("Format", 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_before) set_attr(new_node, "wrap-before", to_expression_string(*wrap_before));
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(ptree 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, "opactity");
n->wrap_before = get_expression(xml, "wrap-before");
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(ptree const& xml, std::string name)
{
boost::optional<std::string> tmp = get_opt_attr<std::string>(xml, name);
if (tmp) return parse_expression(*tmp);
return expression_ptr();
}
void expression_format::apply(char_properties const& p, const Feature &feature, processed_text &output) const
{
char_properties new_properties = p;
if (face_name) new_properties.face_name =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *face_name).to_string();
if (text_size) new_properties.text_size =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *text_size).to_double();
if (character_spacing) new_properties.character_spacing =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *character_spacing).to_double();
if (line_spacing) new_properties.line_spacing =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *line_spacing).to_double();
if (text_opacity) new_properties.text_opacity =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *text_opacity).to_double();
if (wrap_before) new_properties.wrap_before =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *wrap_before).to_bool();
if (wrap_char) new_properties.wrap_char =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *character_spacing).to_unicode()[0];
// if (fill) new_properties.fill =
// boost::apply_visitor(evaluate<Feature,value_type>(feature), *fill).to_color();
// if (halo_fill) new_properties.halo_fill =
// boost::apply_visitor(evaluate<Feature,value_type>(feature), *halo_fill).to_color();
if (halo_radius) new_properties.halo_radius =
boost::apply_visitor(evaluate<Feature,value_type>(feature), *halo_radius).to_double();
if (child_) {
child_->apply(new_properties, feature, output);
} else {
#ifdef MAPNIK_DEBUG
std::cerr << "Warning: Useless format: No text to format\n";
#endif
}
}
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_before);
output.insert(wrap_char);
output.insert(fill);
output.insert(halo_fill);
output.insert(halo_radius);
}
} //ns formatting
} //ns mapnik

View file

@ -1281,10 +1281,10 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
placement_finder = text_placements_ptr(new text_placements_dummy());
}
placement_finder->properties.from_xml(sym, fontsets_);
placement_finder->defaults.from_xml(sym, fontsets_);
if (strict_ &&
!placement_finder->properties.default_format.fontset.size())
ensure_font_face(placement_finder->properties.default_format.face_name);
!placement_finder->defaults.format.fontset.size())
ensure_font_face(placement_finder->defaults.format.face_name);
if (list) {
ptree::const_iterator symIter = sym.begin();
ptree::const_iterator endSym = sym.end();
@ -1299,8 +1299,8 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
text_symbolizer_properties & p = list->add();
p.from_xml(symIter->second, fontsets_);
if (strict_ &&
!p.default_format.fontset.size())
ensure_font_face(p.default_format.face_name);
!p.format.fontset.size())
ensure_font_face(p.format.face_name);
}
}
@ -1354,10 +1354,10 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
placement_finder = text_placements_ptr(new text_placements_dummy());
}
placement_finder->properties.from_xml(sym, fontsets_);
placement_finder->defaults.from_xml(sym, fontsets_);
if (strict_ &&
!placement_finder->properties.default_format.fontset.size())
ensure_font_face(placement_finder->properties.default_format.face_name);
!placement_finder->defaults.format.fontset.size())
ensure_font_face(placement_finder->defaults.format.face_name);
if (list) {
ptree::const_iterator symIter = sym.begin();
ptree::const_iterator endSym = sym.end();
@ -1372,8 +1372,8 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
text_symbolizer_properties & p = list->add();
p.from_xml(symIter->second, fontsets_);
if (strict_&&
!placement_finder->properties.default_format.fontset.size())
ensure_font_face(p.default_format.face_name);
!p.format.fontset.size())
ensure_font_face(p.format.face_name);
}
}

View file

@ -357,7 +357,7 @@ private:
void add_font_attributes(ptree & node, const text_symbolizer & sym)
{
text_placements_ptr p = sym.get_placement_options();
p->properties.to_xml(node, explicit_defaults_);
p->defaults.to_xml(node, explicit_defaults_);
/* Known types:
- text_placements_dummy: no handling required
- text_placements_simple: positions string
@ -366,13 +366,14 @@ private:
text_placements_simple *simple = dynamic_cast<text_placements_simple *>(p.get());
text_placements_list *list = dynamic_cast<text_placements_list *>(p.get());
if (simple) {
set_attr(node, "placment-type", "simple");
set_attr(node, "placement-type", "simple");
set_attr(node, "placements", simple->get_positions());
}
if (list) {
set_attr(node, "placment-type", "list");
set_attr(node, "placement-type", "list");
unsigned i;
text_symbolizer_properties *dfl = &(list->properties);
//dfl = last properties passed as default so only attributes that change are actually written
text_symbolizer_properties *dfl = &(list->defaults);
for (i=0; i < list->size(); i++) {
ptree &placement_node = node.push_back(ptree::value_type("Placement", ptree()))->second;
list->get(i).to_xml(placement_node, explicit_defaults_, *dfl);

View file

@ -68,7 +68,7 @@ void text_symbolizer_properties::process(processed_text &output, Feature const&
{
output.clear();
if (tree_) {
tree_->apply(default_format, feature, output);
tree_->apply(format, feature, output);
} else {
#ifdef MAPNIK_DEBUG
std::cerr << "Warning: text_symbolizer_properties can't produce text: No formatting tree!\n";
@ -130,7 +130,7 @@ void text_symbolizer_properties::from_xml(boost::property_tree::ptree const &sym
set_old_style_expression(parse_expression(*name_, "utf8"));
}
default_format.from_xml(sym, fontsets);
format.from_xml(sym, fontsets);
formatting::node_ptr n(formatting::node::from_xml(sym));
if (n) set_format_tree(n);
}
@ -213,7 +213,7 @@ void text_symbolizer_properties::to_xml(boost::property_tree::ptree &node, bool
{
set_attr(node, "vertical-alignment", valign);
}
default_format.to_xml(node, explicit_defaults, dfl.default_format);
format.to_xml(node, explicit_defaults, dfl.format);
if (tree_) tree_->to_xml(node);
}
@ -352,13 +352,13 @@ void char_properties::to_xml(boost::property_tree::ptree &node, bool explicit_de
/************************************************************************/
text_placements::text_placements() : properties()
text_placements::text_placements() : defaults()
{
}
void text_placements::add_expressions(expression_set &output)
{
properties.add_expressions(output);
defaults.add_expressions(output);
}
@ -366,7 +366,7 @@ void text_placements::add_expressions(expression_set &output)
text_placement_info::text_placement_info(text_placements const* parent,
double scale_factor_, dimension_type dim, bool has_dimensions_)
: properties(parent->properties),
: properties(parent->defaults),
scale_factor(scale_factor_),
has_dimensions(has_dimensions_),
dimensions(dim),
@ -397,7 +397,7 @@ bool text_placement_info_simple::next()
if (state > 0)
{
if (state > parent_->text_sizes_.size()) return false;
properties.default_format.text_size = parent_->text_sizes_[state-1];
properties.format.text_size = parent_->text_sizes_[state-1];
}
if (!next_position_only()) {
state++;
@ -411,7 +411,7 @@ bool text_placement_info_simple::next()
bool text_placement_info_simple::next_position_only()
{
const position &pdisp = parent_->properties.displacement;
const position &pdisp = parent_->defaults.displacement;
position &displacement = properties.displacement;
if (position_state >= parent_->direction_.size()) return false;
directions_t dir = parent_->direction_[position_state];
@ -523,7 +523,7 @@ std::string text_placements_simple::get_positions()
bool text_placement_info_list::next()
{
if (state == 0) {
properties = parent_->properties;
properties = parent_->defaults;
} else {
if (state-1 >= parent_->list_.size()) return false;
properties = parent_->list_[state-1];
@ -538,7 +538,7 @@ text_symbolizer_properties & text_placements_list::add()
text_symbolizer_properties &last = list_.back();
list_.push_back(last); //Preinitialize with old values
} else {
list_.push_back(properties);
list_.push_back(defaults);
}
return list_.back();
}
@ -564,7 +564,7 @@ text_placements_list::text_placements_list() : text_placements(), list_(0)
void text_placements_list::add_expressions(expression_set &output)
{
properties.add_expressions(output);
defaults.add_expressions(output);
std::vector<text_symbolizer_properties>::const_iterator it;
for (it=list_.begin(); it != list_.end(); it++)

View file

@ -22,6 +22,7 @@
#include <mapnik/formatting/text.hpp>
#include <mapnik/formatting/list.hpp>
#include <mapnik/formatting/format.hpp>
#include <mapnik/formatting/expression.hpp>
#include <mapnik/processed_text.hpp>
#include <mapnik/color.hpp>
#include <mapnik/feature.hpp>
@ -62,6 +63,8 @@ node_ptr node::from_xml(boost::property_tree::ptree const& xml)
n = text_node::from_xml(itr->second);
} else if (itr->first == "Format") {
n = format_node::from_xml(itr->second);
} else if (itr->first == "ExpressionFormat") {
n = expression_format::from_xml(itr->second);
} else if (itr->first != "<xmlcomment>" && itr->first != "<xmlattr>" && itr->first != "Placement") {
throw config_error("Unknown item " + itr->first);
}

View file

@ -138,312 +138,312 @@ expression_ptr text_symbolizer::get_name() const
void text_symbolizer::set_name(expression_ptr name)
{
placement_options_->properties.set_old_style_expression(name);
placement_options_->defaults.set_old_style_expression(name);
}
expression_ptr text_symbolizer::get_orientation() const
{
return placement_options_->properties.orientation;
return placement_options_->defaults.orientation;
}
void text_symbolizer::set_orientation(expression_ptr orientation)
{
placement_options_->properties.orientation = orientation;
placement_options_->defaults.orientation = orientation;
}
std::string const& text_symbolizer::get_face_name() const
{
return placement_options_->properties.default_format.face_name;
return placement_options_->defaults.format.face_name;
}
void text_symbolizer::set_face_name(std::string face_name)
{
placement_options_->properties.default_format.face_name = face_name;
placement_options_->defaults.format.face_name = face_name;
}
void text_symbolizer::set_fontset(font_set const& fontset)
{
placement_options_->properties.default_format.fontset = fontset;
placement_options_->defaults.format.fontset = fontset;
}
font_set const& text_symbolizer::get_fontset() const
{
return placement_options_->properties.default_format.fontset;
return placement_options_->defaults.format.fontset;
}
unsigned text_symbolizer::get_text_ratio() const
{
return placement_options_->properties.text_ratio;
return placement_options_->defaults.text_ratio;
}
void text_symbolizer::set_text_ratio(unsigned ratio)
{
placement_options_->properties.text_ratio = ratio;
placement_options_->defaults.text_ratio = ratio;
}
unsigned text_symbolizer::get_wrap_width() const
{
return placement_options_->properties.wrap_width;
return placement_options_->defaults.wrap_width;
}
void text_symbolizer::set_wrap_width(unsigned width)
{
placement_options_->properties.wrap_width = width;
placement_options_->defaults.wrap_width = width;
}
bool text_symbolizer::get_wrap_before() const
{
return placement_options_->properties.default_format.wrap_before;
return placement_options_->defaults.format.wrap_before;
}
void text_symbolizer::set_wrap_before(bool wrap_before)
{
placement_options_->properties.default_format.wrap_before = wrap_before;
placement_options_->defaults.format.wrap_before = wrap_before;
}
unsigned char text_symbolizer::get_wrap_char() const
{
return placement_options_->properties.default_format.wrap_char;
return placement_options_->defaults.format.wrap_char;
}
std::string text_symbolizer::get_wrap_char_string() const
{
return std::string(1, placement_options_->properties.default_format.wrap_char);
return std::string(1, placement_options_->defaults.format.wrap_char);
}
void text_symbolizer::set_wrap_char(unsigned char character)
{
placement_options_->properties.default_format.wrap_char = character;
placement_options_->defaults.format.wrap_char = character;
}
void text_symbolizer::set_wrap_char_from_string(std::string const& character)
{
placement_options_->properties.default_format.wrap_char = (character)[0];
placement_options_->defaults.format.wrap_char = (character)[0];
}
text_transform_e text_symbolizer::get_text_transform() const
{
return placement_options_->properties.default_format.text_transform;
return placement_options_->defaults.format.text_transform;
}
void text_symbolizer::set_text_transform(text_transform_e convert)
{
placement_options_->properties.default_format.text_transform = convert;
placement_options_->defaults.format.text_transform = convert;
}
unsigned text_symbolizer::get_line_spacing() const
{
return placement_options_->properties.default_format.line_spacing;
return placement_options_->defaults.format.line_spacing;
}
void text_symbolizer::set_line_spacing(unsigned spacing)
{
placement_options_->properties.default_format.line_spacing = spacing;
placement_options_->defaults.format.line_spacing = spacing;
}
unsigned text_symbolizer::get_character_spacing() const
{
return placement_options_->properties.default_format.character_spacing;
return placement_options_->defaults.format.character_spacing;
}
void text_symbolizer::set_character_spacing(unsigned spacing)
{
placement_options_->properties.default_format.character_spacing = spacing;
placement_options_->defaults.format.character_spacing = spacing;
}
unsigned text_symbolizer::get_label_spacing() const
{
return placement_options_->properties.label_spacing;
return placement_options_->defaults.label_spacing;
}
void text_symbolizer::set_label_spacing(unsigned spacing)
{
placement_options_->properties.label_spacing = spacing;
placement_options_->defaults.label_spacing = spacing;
}
unsigned text_symbolizer::get_label_position_tolerance() const
{
return placement_options_->properties.label_position_tolerance;
return placement_options_->defaults.label_position_tolerance;
}
void text_symbolizer::set_label_position_tolerance(unsigned tolerance)
{
placement_options_->properties.label_position_tolerance = tolerance;
placement_options_->defaults.label_position_tolerance = tolerance;
}
bool text_symbolizer::get_force_odd_labels() const
{
return placement_options_->properties.force_odd_labels;
return placement_options_->defaults.force_odd_labels;
}
void text_symbolizer::set_force_odd_labels(bool force)
{
placement_options_->properties.force_odd_labels = force;
placement_options_->defaults.force_odd_labels = force;
}
double text_symbolizer::get_max_char_angle_delta() const
{
return placement_options_->properties.max_char_angle_delta;
return placement_options_->defaults.max_char_angle_delta;
}
void text_symbolizer::set_max_char_angle_delta(double angle)
{
placement_options_->properties.max_char_angle_delta = angle;
placement_options_->defaults.max_char_angle_delta = angle;
}
void text_symbolizer::set_text_size(float size)
{
placement_options_->properties.default_format.text_size = size;
placement_options_->defaults.format.text_size = size;
}
float text_symbolizer::get_text_size() const
{
return placement_options_->properties.default_format.text_size;
return placement_options_->defaults.format.text_size;
}
void text_symbolizer::set_fill(color const& fill)
{
placement_options_->properties.default_format.fill = fill;
placement_options_->defaults.format.fill = fill;
}
color const& text_symbolizer::get_fill() const
{
return placement_options_->properties.default_format.fill;
return placement_options_->defaults.format.fill;
}
void text_symbolizer::set_halo_fill(color const& fill)
{
placement_options_->properties.default_format.halo_fill = fill;
placement_options_->defaults.format.halo_fill = fill;
}
color const& text_symbolizer::get_halo_fill() const
{
return placement_options_->properties.default_format.halo_fill;
return placement_options_->defaults.format.halo_fill;
}
void text_symbolizer::set_halo_radius(double radius)
{
placement_options_->properties.default_format.halo_radius = radius;
placement_options_->defaults.format.halo_radius = radius;
}
double text_symbolizer::get_halo_radius() const
{
return placement_options_->properties.default_format.halo_radius;
return placement_options_->defaults.format.halo_radius;
}
void text_symbolizer::set_label_placement(label_placement_e label_p)
{
placement_options_->properties.label_placement = label_p;
placement_options_->defaults.label_placement = label_p;
}
label_placement_e text_symbolizer::get_label_placement() const
{
return placement_options_->properties.label_placement;
return placement_options_->defaults.label_placement;
}
void text_symbolizer::set_displacement(double x, double y)
{
placement_options_->properties.displacement = std::make_pair(x,y);
placement_options_->defaults.displacement = std::make_pair(x,y);
}
void text_symbolizer::set_displacement(position const& p)
{
placement_options_->properties.displacement = p;
placement_options_->defaults.displacement = p;
}
position const& text_symbolizer::get_displacement() const
{
return placement_options_->properties.displacement;
return placement_options_->defaults.displacement;
}
bool text_symbolizer::get_avoid_edges() const
{
return placement_options_->properties.avoid_edges;
return placement_options_->defaults.avoid_edges;
}
void text_symbolizer::set_avoid_edges(bool avoid)
{
placement_options_->properties.avoid_edges = avoid;
placement_options_->defaults.avoid_edges = avoid;
}
double text_symbolizer::get_minimum_distance() const
{
return placement_options_->properties.minimum_distance;
return placement_options_->defaults.minimum_distance;
}
void text_symbolizer::set_minimum_distance(double distance)
{
placement_options_->properties.minimum_distance = distance;
placement_options_->defaults.minimum_distance = distance;
}
double text_symbolizer::get_minimum_padding() const
{
return placement_options_->properties.minimum_padding;
return placement_options_->defaults.minimum_padding;
}
void text_symbolizer::set_minimum_padding(double distance)
{
placement_options_->properties.minimum_padding = distance;
placement_options_->defaults.minimum_padding = distance;
}
double text_symbolizer::get_minimum_path_length() const
{
return placement_options_->properties.minimum_path_length;
return placement_options_->defaults.minimum_path_length;
}
void text_symbolizer::set_minimum_path_length(double size)
{
placement_options_->properties.minimum_path_length = size;
placement_options_->defaults.minimum_path_length = size;
}
void text_symbolizer::set_allow_overlap(bool overlap)
{
placement_options_->properties.allow_overlap = overlap;
placement_options_->defaults.allow_overlap = overlap;
}
bool text_symbolizer::get_allow_overlap() const
{
return placement_options_->properties.allow_overlap;
return placement_options_->defaults.allow_overlap;
}
void text_symbolizer::set_text_opacity(double text_opacity)
{
placement_options_->properties.default_format.text_opacity = text_opacity;
placement_options_->defaults.format.text_opacity = text_opacity;
}
double text_symbolizer::get_text_opacity() const
{
return placement_options_->properties.default_format.text_opacity;
return placement_options_->defaults.format.text_opacity;
}
void text_symbolizer::set_vertical_alignment(vertical_alignment_e valign)
{
placement_options_->properties.valign = valign;
placement_options_->defaults.valign = valign;
}
vertical_alignment_e text_symbolizer::get_vertical_alignment() const
{
return placement_options_->properties.valign;
return placement_options_->defaults.valign;
}
void text_symbolizer::set_horizontal_alignment(horizontal_alignment_e halign)
{
placement_options_->properties.halign = halign;
placement_options_->defaults.halign = halign;
}
horizontal_alignment_e text_symbolizer::get_horizontal_alignment() const
{
return placement_options_->properties.halign;
return placement_options_->defaults.halign;
}
void text_symbolizer::set_justify_alignment(justify_alignment_e jalign)
{
placement_options_->properties.jalign = jalign;
placement_options_->defaults.jalign = jalign;
}
justify_alignment_e text_symbolizer::get_justify_alignment() const
{
return placement_options_->properties.jalign;
return placement_options_->defaults.jalign;
}
text_placements_ptr text_symbolizer::get_placement_options() const

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
<Layer name="layer" srs="+proj=latlong +datum=WGS84">
<StyleName>My Style</StyleName>
<Datasource>
<Parameter name="type">shape</Parameter>
<Parameter name="file">points.shp</Parameter>
</Datasource>
</Layer>
<Style name="My Style">
<Rule>
<PointSymbolizer/>
<TextSymbolizer face-name="DejaVu Sans Book" placement="point" dx="0" dy="5">
<ExpressionFormat size="[nr]">[name]</ExpressionFormat>
</TextSymbolizer>
</Rule>
</Style>
</Map>

View file

@ -13,7 +13,7 @@ filenames = ["list", "simple"]
filenames_one_width = ["simple-E", "simple-NE", "simple-NW", "simple-N",
"simple-SE", "simple-SW", "simple-S", "simple-W",
"formating-1", "formating-2", "formating-3", "formating-4",
"shieldsymbolizer-1"]
"shieldsymbolizer-1", "expressionformat"]
def render(filename, width):
print "Rendering style \"%s\" with width %d" % (filename, width)