mapnik/src/text_symbolizer.cpp

467 lines
11 KiB
C++
Raw Normal View History

2006-03-31 12:32:02 +02:00
/*****************************************************************************
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
*
2006-03-31 12:32:02 +02:00
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
*
2006-03-31 12:32:02 +02:00
* 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
2006-03-31 12:32:02 +02:00
* 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
*
2006-03-31 12:32:02 +02:00
*****************************************************************************/
//mapnik
2012-04-08 02:20:56 +02:00
#include <mapnik/debug.hpp>
#include <mapnik/text_symbolizer.hpp>
2012-02-12 02:47:26 +01:00
#include <mapnik/enumeration.hpp>
2007-10-08 19:42:41 +02:00
// boost
#include <boost/scoped_ptr.hpp>
2012-02-12 02:47:26 +01:00
namespace mapnik
{
static const char * label_placement_strings[] = {
"point",
"line",
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
"vertex",
"interior",
""
};
IMPLEMENT_ENUM( label_placement_e, label_placement_strings )
static const char * vertical_alignment_strings[] = {
"top",
"middle",
"bottom",
"auto",
""
};
IMPLEMENT_ENUM( vertical_alignment_e, vertical_alignment_strings )
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
static const char * horizontal_alignment_strings[] = {
"left",
"middle",
"right",
"auto",
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
""
};
IMPLEMENT_ENUM( horizontal_alignment_e, horizontal_alignment_strings )
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
static const char * justify_alignment_strings[] = {
"left",
"center",
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
"right",
"auto",
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
""
};
IMPLEMENT_ENUM( justify_alignment_e, justify_alignment_strings )
Patch from David Eastcott : 1. Modified Text Symbolizer a) corrected line fragment centering (for 2nd and subsequent lines, when line breaks occur). b) adjusted vertical alignment calculation so that: i) middle -> has the center of the text line(s) at the point origin ii) bottom -> has the text line(s) below the point origin iii) top -> has the text line(s) above the point origin c) added new text_symbolizer attribute: 'wrap_before', value range: true/false, default == false allows line breaks at first wrap_char before wrap_width as an alternative to the original which was to create the line break at the first wrap_char after wrap_width d) added new text_symbolizer attribute: 'horizontal_alignment', value range: left/middle/right, default == middle i) left -> has all text line(s) to left of the point origin ii) middle -> has all text line(s) centered on the the point origin iii) right -> has all text line(s) to the right of the point origin NOTE: dx, dy position adjustments are applied after alignments and before Justify. e) added new text_symbolizer attribute: 'justify_alignment', value range: left/middle/right, default == middle i) left -> after alignments, has all text line(s) are left justified (left to right reading) ii) middle -> after alignments, has all text line(s) center justified iii) right -> after alignments, has all text line(s) right justified (right to left reading) f) added new text_symbolizer attribute: 'opacity', value range: 0.0 thru 1.0; 1.0 == fully opaque g) modified positioning to compensate for both line_spacing and character_spacing, to ensure proper centering of the text envelope. Also ensure that centering occurs correctly even if no wrapping occurs. Line spacing is uniform and consistent and compensates for errors between text_size and the actual size (ci.height is inconsistent, depending on case and character); fixes issue with multi-line text where some lines have a slight gap and others are compressed together. 2. Modified shield_symbolizer a) added the attributes: i) allow_overlap ii) vertical_alignment iii) horizontal_alignment iv) justify_alignment v) wrap_width vi) wrap_character vii) wrap_before viii) text_convert ix) line_spacing x) character_spacing xi) opacity b) added new shield_symbolizer attribute: 'unlock_image', value range: true/false, default == false i) false == image and text placement behaviour same as before ii) true == image placement independant of text, image is always centered at geometry point, text placed per attributes, dx/dy only affect text. Allows user to create point markers with text, but both the text and image rendering collision detection are done as a pair (they come and go together - solves problem if using point_symbolizer and text_symbolizers where one or the other are omitted due to overlaps, but not both) c) extended choices for the attribute 'placement' to include vertex; effect is limited to the shield_symbolizer Allows an attempted placement at every vertex available, gives additional shield placement volume when using line geometry d) ensured that the text placement was not updating the detector unless a shield image was actually placed. e) added new shield_symbolizer attribute: 'no_text', value range: true/false, default = false When set true, the text for the feature is ignored ('space' subsituted) so that pure graphic symbols can be used and no text is rendered over top of them.
2009-10-19 15:52:53 +02:00
static const char * text_transform_strings[] = {
"none",
"uppercase",
"lowercase",
"capitalize",
""
};
IMPLEMENT_ENUM( text_transform_e, text_transform_strings )
text_symbolizer::text_symbolizer(text_placements_ptr placements)
2012-02-02 02:53:35 +01:00
: symbolizer_base(),
placement_options_(placements)
{
}
text_symbolizer::text_symbolizer(expression_ptr name, std::string const& face_name,
float size, color const& fill,
text_placements_ptr placements)
2010-08-10 14:19:19 +02:00
: symbolizer_base(),
placement_options_(placements)
{
set_name(name);
set_face_name(face_name);
set_text_size(size);
set_fill(fill);
}
2009-12-16 21:02:06 +01:00
text_symbolizer::text_symbolizer(expression_ptr name, float size, color const& fill,
text_placements_ptr placements)
2010-08-10 14:19:19 +02:00
: symbolizer_base(),
placement_options_(placements)
{
set_name(name);
set_text_size(size);
set_fill(fill);
}
2009-12-16 21:02:06 +01:00
text_symbolizer::text_symbolizer(text_symbolizer const& rhs)
2010-08-10 14:19:19 +02:00
: symbolizer_base(rhs),
placement_options_(rhs.placement_options_) /*TODO: Copy options! */
{
}
2009-12-16 21:02:06 +01:00
text_symbolizer& text_symbolizer::operator=(text_symbolizer const& other)
{
if (this == &other)
2010-06-02 13:03:30 +02:00
return *this;
placement_options_ = other.placement_options_; /*TODO: Copy options? */
2012-04-08 02:20:56 +02:00
#ifdef MAPNIK_LOG
mapnik::log() << "text_symbolizer: TODO - Metawriter (text_symbolizer::operator=)";
#endif
2009-12-16 21:02:06 +01:00
return *this;
}
2010-02-03 19:36:01 +01:00
expression_ptr text_symbolizer::get_name() const
2009-12-16 21:02:06 +01:00
{
return expression_ptr();
2009-12-16 21:02:06 +01:00
}
2010-02-03 19:36:01 +01:00
void text_symbolizer::set_name(expression_ptr name)
2009-12-16 21:02:06 +01:00
{
placement_options_->defaults.set_old_style_expression(name);
2009-12-16 21:02:06 +01:00
}
expression_ptr text_symbolizer::get_orientation() const
{
return placement_options_->defaults.orientation;
}
void text_symbolizer::set_orientation(expression_ptr orientation)
{
placement_options_->defaults.orientation = orientation;
}
2009-12-16 21:02:06 +01:00
std::string const& text_symbolizer::get_face_name() const
{
return placement_options_->defaults.format.face_name;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_face_name(std::string face_name)
{
placement_options_->defaults.format.face_name = face_name;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_fontset(font_set const& fontset)
{
placement_options_->defaults.format.fontset = fontset;
2009-12-16 21:02:06 +01:00
}
font_set const& text_symbolizer::get_fontset() const
{
return placement_options_->defaults.format.fontset;
2009-12-16 21:02:06 +01:00
}
unsigned text_symbolizer::get_text_ratio() const
{
return placement_options_->defaults.text_ratio;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_text_ratio(unsigned ratio)
{
placement_options_->defaults.text_ratio = ratio;
2009-12-16 21:02:06 +01:00
}
unsigned text_symbolizer::get_wrap_width() const
{
return placement_options_->defaults.wrap_width;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_wrap_width(unsigned width)
{
placement_options_->defaults.wrap_width = width;
2009-12-16 21:02:06 +01:00
}
bool text_symbolizer::get_wrap_before() const
{
return placement_options_->defaults.format.wrap_before;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_wrap_before(bool wrap_before)
{
placement_options_->defaults.format.wrap_before = wrap_before;
2009-12-16 21:02:06 +01:00
}
unsigned char text_symbolizer::get_wrap_char() const
{
return placement_options_->defaults.format.wrap_char;
2009-12-16 21:02:06 +01:00
}
std::string text_symbolizer::get_wrap_char_string() const
{
return std::string(1, placement_options_->defaults.format.wrap_char);
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_wrap_char(unsigned char character)
{
placement_options_->defaults.format.wrap_char = character;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_wrap_char_from_string(std::string const& character)
{
placement_options_->defaults.format.wrap_char = (character)[0];
2009-12-16 21:02:06 +01:00
}
text_transform_e text_symbolizer::get_text_transform() const
2009-12-16 21:02:06 +01:00
{
return placement_options_->defaults.format.text_transform;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_text_transform(text_transform_e convert)
2009-12-16 21:02:06 +01:00
{
placement_options_->defaults.format.text_transform = convert;
2009-12-16 21:02:06 +01:00
}
unsigned text_symbolizer::get_line_spacing() const
{
return placement_options_->defaults.format.line_spacing;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_line_spacing(unsigned spacing)
{
placement_options_->defaults.format.line_spacing = spacing;
2009-12-16 21:02:06 +01:00
}
unsigned text_symbolizer::get_character_spacing() const
{
return placement_options_->defaults.format.character_spacing;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_character_spacing(unsigned spacing)
{
placement_options_->defaults.format.character_spacing = spacing;
2009-12-16 21:02:06 +01:00
}
unsigned text_symbolizer::get_label_spacing() const
{
return placement_options_->defaults.label_spacing;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_label_spacing(unsigned spacing)
{
placement_options_->defaults.label_spacing = spacing;
2009-12-16 21:02:06 +01:00
}
unsigned text_symbolizer::get_label_position_tolerance() const
{
return placement_options_->defaults.label_position_tolerance;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_label_position_tolerance(unsigned tolerance)
{
placement_options_->defaults.label_position_tolerance = tolerance;
2009-12-16 21:02:06 +01:00
}
bool text_symbolizer::get_force_odd_labels() const
{
return placement_options_->defaults.force_odd_labels;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_force_odd_labels(bool force)
{
placement_options_->defaults.force_odd_labels = force;
2009-12-16 21:02:06 +01:00
}
double text_symbolizer::get_max_char_angle_delta() const
{
return placement_options_->defaults.max_char_angle_delta;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_max_char_angle_delta(double angle)
{
placement_options_->defaults.max_char_angle_delta = angle;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_text_size(float size)
2009-12-16 21:02:06 +01:00
{
placement_options_->defaults.format.text_size = size;
2009-12-16 21:02:06 +01:00
}
float text_symbolizer::get_text_size() const
2009-12-16 21:02:06 +01:00
{
return placement_options_->defaults.format.text_size;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_fill(color const& fill)
{
placement_options_->defaults.format.fill = fill;
2009-12-16 21:02:06 +01:00
}
color const& text_symbolizer::get_fill() const
{
return placement_options_->defaults.format.fill;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_halo_fill(color const& fill)
{
placement_options_->defaults.format.halo_fill = fill;
2009-12-16 21:02:06 +01:00
}
color const& text_symbolizer::get_halo_fill() const
{
return placement_options_->defaults.format.halo_fill;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_halo_radius(double radius)
2009-12-16 21:02:06 +01:00
{
placement_options_->defaults.format.halo_radius = radius;
2009-12-16 21:02:06 +01:00
}
double text_symbolizer::get_halo_radius() const
2009-12-16 21:02:06 +01:00
{
return placement_options_->defaults.format.halo_radius;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_label_placement(label_placement_e label_p)
{
placement_options_->defaults.label_placement = label_p;
2009-12-16 21:02:06 +01:00
}
label_placement_e text_symbolizer::get_label_placement() const
{
return placement_options_->defaults.label_placement;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_displacement(double x, double y)
2009-12-16 21:02:06 +01:00
{
placement_options_->defaults.displacement = std::make_pair(x,y);
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_displacement(position const& p)
{
placement_options_->defaults.displacement = p;
}
2009-12-16 21:02:06 +01:00
position const& text_symbolizer::get_displacement() const
{
return placement_options_->defaults.displacement;
2009-12-16 21:02:06 +01:00
}
bool text_symbolizer::get_avoid_edges() const
{
return placement_options_->defaults.avoid_edges;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_avoid_edges(bool avoid)
{
placement_options_->defaults.avoid_edges = avoid;
2009-12-16 21:02:06 +01:00
}
double text_symbolizer::get_minimum_distance() const
{
return placement_options_->defaults.minimum_distance;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_minimum_distance(double distance)
{
placement_options_->defaults.minimum_distance = distance;
2009-12-16 21:02:06 +01:00
}
double text_symbolizer::get_minimum_padding() const
{
return placement_options_->defaults.minimum_padding;
}
void text_symbolizer::set_minimum_padding(double distance)
{
placement_options_->defaults.minimum_padding = distance;
}
double text_symbolizer::get_minimum_path_length() const
{
return placement_options_->defaults.minimum_path_length;
}
void text_symbolizer::set_minimum_path_length(double size)
{
placement_options_->defaults.minimum_path_length = size;
}
2009-12-16 21:02:06 +01:00
void text_symbolizer::set_allow_overlap(bool overlap)
{
placement_options_->defaults.allow_overlap = overlap;
2009-12-16 21:02:06 +01:00
}
bool text_symbolizer::get_allow_overlap() const
{
return placement_options_->defaults.allow_overlap;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_text_opacity(double text_opacity)
2009-12-16 21:02:06 +01:00
{
placement_options_->defaults.format.text_opacity = text_opacity;
2009-12-16 21:02:06 +01:00
}
double text_symbolizer::get_text_opacity() const
2009-12-16 21:02:06 +01:00
{
return placement_options_->defaults.format.text_opacity;
2009-12-16 21:02:06 +01:00
}
2011-05-30 00:33:41 +02:00
void text_symbolizer::set_vertical_alignment(vertical_alignment_e valign)
{
placement_options_->defaults.valign = valign;
2011-05-30 00:33:41 +02:00
}
vertical_alignment_e text_symbolizer::get_vertical_alignment() const
{
return placement_options_->defaults.valign;
2011-05-30 00:33:41 +02:00
}
2009-12-16 21:02:06 +01:00
void text_symbolizer::set_horizontal_alignment(horizontal_alignment_e halign)
{
placement_options_->defaults.halign = halign;
2009-12-16 21:02:06 +01:00
}
horizontal_alignment_e text_symbolizer::get_horizontal_alignment() const
{
return placement_options_->defaults.halign;
2009-12-16 21:02:06 +01:00
}
void text_symbolizer::set_justify_alignment(justify_alignment_e jalign)
{
placement_options_->defaults.jalign = jalign;
2009-12-16 21:02:06 +01:00
}
justify_alignment_e text_symbolizer::get_justify_alignment() const
{
return placement_options_->defaults.jalign;
2009-12-16 21:02:06 +01:00
}
text_placements_ptr text_symbolizer::get_placement_options() const
{
return placement_options_;
}
void text_symbolizer::set_placement_options(text_placements_ptr placement_options)
{
placement_options_ = placement_options;
}
}