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)
|
|
|
|
*
|
2006-02-07 15:41:41 +01:00
|
|
|
* Copyright (C) 2006 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.
|
2006-02-07 15:41:41 +01:00
|
|
|
*
|
2006-03-31 12:32:02 +02:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2006-02-07 15:41:41 +01:00
|
|
|
* 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.
|
2006-02-07 15:41:41 +01:00
|
|
|
*
|
2006-03-31 12:32:02 +02:00
|
|
|
* 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-02-07 15:41:41 +01:00
|
|
|
//$Id$
|
|
|
|
|
2007-10-08 19:42:41 +02:00
|
|
|
// mapnik
|
|
|
|
#include <mapnik/agg_renderer.hpp>
|
2010-06-13 14:03:42 +02:00
|
|
|
#include <mapnik/agg_rasterizer.hpp>
|
2011-01-26 02:18:40 +01:00
|
|
|
#include <mapnik/marker_cache.hpp>
|
2007-10-08 19:42:41 +02:00
|
|
|
#include <mapnik/unicode.hpp>
|
|
|
|
#include <mapnik/placement_finder.hpp>
|
2008-01-23 22:56:04 +01:00
|
|
|
#include <mapnik/config_error.hpp>
|
2008-06-29 12:58:48 +02:00
|
|
|
#include <mapnik/font_set.hpp>
|
2010-06-18 17:39:32 +02:00
|
|
|
#include <mapnik/parse_path.hpp>
|
2010-05-27 12:20:03 +02:00
|
|
|
#include <mapnik/text_path.hpp>
|
2011-01-26 10:19:00 +01:00
|
|
|
#include <mapnik/svg/svg_converter.hpp>
|
|
|
|
#include <mapnik/svg/svg_renderer.hpp>
|
|
|
|
#include <mapnik/svg/svg_path_adapter.hpp>
|
|
|
|
|
2007-10-08 19:42:41 +02:00
|
|
|
|
2006-10-04 13:22:18 +02:00
|
|
|
// agg
|
2008-06-29 12:58:29 +02:00
|
|
|
#define AGG_RENDERING_BUFFER row_ptr_cache<int8u>
|
2008-02-05 14:58:47 +01:00
|
|
|
#include "agg_rendering_buffer.h"
|
|
|
|
#include "agg_pixfmt_rgba.h"
|
|
|
|
#include "agg_rasterizer_scanline_aa.h"
|
2006-02-07 15:41:41 +01:00
|
|
|
#include "agg_basics.h"
|
|
|
|
#include "agg_scanline_p.h"
|
|
|
|
#include "agg_scanline_u.h"
|
|
|
|
#include "agg_renderer_scanline.h"
|
|
|
|
#include "agg_path_storage.h"
|
|
|
|
#include "agg_span_allocator.h"
|
|
|
|
#include "agg_span_pattern_rgba.h"
|
|
|
|
#include "agg_image_accessors.h"
|
|
|
|
#include "agg_conv_stroke.h"
|
|
|
|
#include "agg_conv_dash.h"
|
|
|
|
#include "agg_conv_contour.h"
|
2007-11-02 13:50:15 +01:00
|
|
|
#include "agg_conv_clip_polyline.h"
|
2006-02-07 15:41:41 +01:00
|
|
|
#include "agg_vcgen_stroke.h"
|
|
|
|
#include "agg_conv_adaptor_vcgen.h"
|
|
|
|
#include "agg_conv_smooth_poly1.h"
|
|
|
|
#include "agg_conv_marker.h"
|
|
|
|
#include "agg_vcgen_markers_term.h"
|
|
|
|
#include "agg_renderer_outline_aa.h"
|
|
|
|
#include "agg_rasterizer_outline_aa.h"
|
|
|
|
#include "agg_rasterizer_outline.h"
|
|
|
|
#include "agg_renderer_outline_image.h"
|
|
|
|
#include "agg_span_allocator.h"
|
|
|
|
#include "agg_span_pattern_rgba.h"
|
|
|
|
#include "agg_renderer_scanline.h"
|
|
|
|
#include "agg_pattern_filters_rgba.h"
|
|
|
|
#include "agg_renderer_outline_image.h"
|
2007-10-05 13:27:00 +02:00
|
|
|
#include "agg_vpgen_clip_polyline.h"
|
2007-11-02 13:50:15 +01:00
|
|
|
#include "agg_arrowhead.h"
|
2007-10-05 13:27:00 +02:00
|
|
|
|
2011-01-26 10:19:00 +01:00
|
|
|
|
2007-10-08 19:42:41 +02:00
|
|
|
// boost
|
|
|
|
#include <boost/utility.hpp>
|
2010-06-24 17:57:25 +02:00
|
|
|
|
2007-10-08 19:42:41 +02:00
|
|
|
|
|
|
|
// stl
|
2008-02-05 14:58:47 +01:00
|
|
|
#ifdef MAPNIK_DEBUG
|
2007-10-08 19:42:41 +02:00
|
|
|
#include <iostream>
|
2008-02-05 14:58:47 +01:00
|
|
|
#endif
|
2006-10-17 16:12:53 +02:00
|
|
|
|
2010-03-12 00:19:12 +01:00
|
|
|
#include <cmath>
|
|
|
|
|
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
|
|
|
namespace mapnik
|
2006-02-07 15:41:41 +01:00
|
|
|
{
|
2009-12-16 21:02:06 +01:00
|
|
|
class pattern_source : private boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
pattern_source(image_data_32 const& pattern)
|
2010-06-02 13:03:30 +02:00
|
|
|
: pattern_(pattern) {}
|
2009-12-16 21:02:06 +01:00
|
|
|
|
|
|
|
unsigned int width() const
|
|
|
|
{
|
2010-06-02 13:03:30 +02:00
|
|
|
return pattern_.width();
|
2009-12-16 21:02:06 +01:00
|
|
|
}
|
|
|
|
unsigned int height() const
|
|
|
|
{
|
2010-06-02 13:03:30 +02:00
|
|
|
return pattern_.height();
|
2009-12-16 21:02:06 +01:00
|
|
|
}
|
|
|
|
agg::rgba8 pixel(int x, int y) const
|
|
|
|
{
|
2010-06-02 13:03:30 +02:00
|
|
|
unsigned c = pattern_(x,y);
|
|
|
|
return agg::rgba8(c & 0xff,
|
|
|
|
(c >> 8) & 0xff,
|
|
|
|
(c >> 16) & 0xff,
|
|
|
|
(c >> 24) & 0xff);
|
2009-12-16 21:02:06 +01:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
image_data_32 const& pattern_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2010-06-10 16:12:20 +02:00
|
|
|
agg_renderer<T>::agg_renderer(Map const& m, T & pixmap, double scale_factor, unsigned offset_x, unsigned offset_y)
|
2010-06-14 12:29:29 +02:00
|
|
|
: feature_style_processor<agg_renderer>(m, scale_factor),
|
2009-12-16 21:02:06 +01:00
|
|
|
pixmap_(pixmap),
|
|
|
|
width_(pixmap_.width()),
|
|
|
|
height_(pixmap_.height()),
|
2010-06-10 16:12:20 +02:00
|
|
|
scale_factor_(scale_factor),
|
2010-06-25 17:23:35 +02:00
|
|
|
t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y),
|
2009-12-16 21:02:06 +01:00
|
|
|
font_engine_(),
|
|
|
|
font_manager_(font_engine_),
|
2010-06-25 17:23:35 +02:00
|
|
|
detector_(box2d<double>(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size())),
|
2009-12-16 21:02:06 +01:00
|
|
|
ras_ptr(new rasterizer)
|
|
|
|
{
|
2010-07-19 13:10:03 +02:00
|
|
|
boost::optional<color> const& bg = m.background();
|
2009-12-16 21:02:06 +01:00
|
|
|
if (bg) pixmap_.set_background(*bg);
|
2010-07-19 13:10:03 +02:00
|
|
|
|
|
|
|
boost::optional<std::string> const& image_filename = m.background_image();
|
|
|
|
if (image_filename)
|
|
|
|
{
|
2011-01-26 02:18:40 +01:00
|
|
|
boost::optional<mapnik::marker_ptr> bg_marker = mapnik::marker_cache::instance()->find(*image_filename,true);
|
|
|
|
if (bg_marker && (*bg_marker)->is_bitmap())
|
2010-07-19 13:10:03 +02:00
|
|
|
{
|
2011-01-26 02:18:40 +01:00
|
|
|
mapnik::image_ptr bg_image = *(*bg_marker)->get_bitmap_data();
|
|
|
|
int w = bg_image->width();
|
|
|
|
int h = bg_image->height();
|
2010-07-19 13:10:03 +02:00
|
|
|
if ( w > 0 && h > 0)
|
|
|
|
{
|
2010-07-19 13:10:20 +02:00
|
|
|
// repeat background-image both vertically and horizontally
|
2010-07-19 13:10:03 +02:00
|
|
|
unsigned x_steps = unsigned(std::ceil(width_/double(w)));
|
|
|
|
unsigned y_steps = unsigned(std::ceil(height_/double(h)));
|
|
|
|
for (unsigned x=0;x<x_steps;++x)
|
|
|
|
{
|
|
|
|
for (unsigned y=0;y<y_steps;++y)
|
|
|
|
{
|
2011-01-26 02:18:40 +01:00
|
|
|
pixmap_.set_rectangle_alpha2(*bg_image, x*w, y*h, 1.0f);
|
2010-07-19 13:10:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-19 18:13:33 +01:00
|
|
|
#ifdef MAPNIK_DEBUG
|
2009-12-16 21:02:06 +01:00
|
|
|
std::clog << "scale=" << m.scale() << "\n";
|
2006-11-19 18:13:33 +01:00
|
|
|
#endif
|
2009-12-16 21:02:06 +01: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
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
template <typename T>
|
|
|
|
agg_renderer<T>::~agg_renderer() {}
|
2008-02-05 14:58:47 +01:00
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
template <typename T>
|
2011-04-04 06:35:28 +02:00
|
|
|
#ifdef MAPNIK_DEBUG
|
2009-12-16 21:02:06 +01:00
|
|
|
void agg_renderer<T>::start_map_processing(Map const& map)
|
|
|
|
{
|
|
|
|
std::clog << "start map processing bbox="
|
2010-06-25 17:23:35 +02:00
|
|
|
<< map.get_current_extent() << "\n";
|
2011-04-04 06:35:28 +02:00
|
|
|
#else
|
|
|
|
void agg_renderer<T>::start_map_processing(Map const& /*map*/)
|
|
|
|
{
|
2006-11-19 18:13:33 +01:00
|
|
|
#endif
|
2009-12-16 21:02:06 +01:00
|
|
|
ras_ptr->clip_box(0,0,width_,height_);
|
|
|
|
}
|
2006-02-21 20:55:24 +01:00
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
template <typename T>
|
|
|
|
void agg_renderer<T>::end_map_processing(Map const& )
|
|
|
|
{
|
2006-11-19 18:13:33 +01:00
|
|
|
#ifdef MAPNIK_DEBUG
|
2009-12-16 21:02:06 +01:00
|
|
|
std::clog << "end map processing\n";
|
2006-11-19 18:13:33 +01:00
|
|
|
#endif
|
2009-12-16 21:02:06 +01: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
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
template <typename T>
|
|
|
|
void agg_renderer<T>::start_layer_processing(layer const& lay)
|
|
|
|
{
|
2006-11-19 18:13:33 +01:00
|
|
|
#ifdef MAPNIK_DEBUG
|
2009-12-16 21:02:06 +01:00
|
|
|
std::clog << "start layer processing : " << lay.name() << "\n";
|
|
|
|
std::clog << "datasource = " << lay.datasource().get() << "\n";
|
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
|
|
|
#endif
|
2009-12-16 21:02:06 +01:00
|
|
|
if (lay.clear_label_cache())
|
|
|
|
{
|
2010-06-02 13:03:30 +02:00
|
|
|
detector_.clear();
|
2009-12-16 21:02:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void agg_renderer<T>::end_layer_processing(layer const&)
|
|
|
|
{
|
2006-11-19 18:13:33 +01:00
|
|
|
#ifdef MAPNIK_DEBUG
|
2009-12-16 21:02:06 +01:00
|
|
|
std::clog << "end layer processing\n";
|
2006-11-19 18:13:33 +01:00
|
|
|
#endif
|
2009-12-16 21:02:06 +01:00
|
|
|
}
|
|
|
|
|
2011-01-26 10:19:00 +01:00
|
|
|
template <typename T>
|
|
|
|
void agg_renderer<T>::render_marker(const int x, const int y, marker &marker, const agg::trans_affine & tr, double opacity)
|
|
|
|
{
|
|
|
|
if (marker.is_vector())
|
|
|
|
{
|
|
|
|
typedef agg::pixfmt_rgba32_plain pixfmt;
|
|
|
|
typedef agg::renderer_base<pixfmt> renderer_base;
|
2011-05-17 08:19:41 +02:00
|
|
|
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
|
2011-01-26 10:19:00 +01:00
|
|
|
|
|
|
|
ras_ptr->reset();
|
|
|
|
ras_ptr->gamma(agg::gamma_linear());
|
|
|
|
agg::scanline_u8 sl;
|
|
|
|
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4);
|
|
|
|
pixfmt pixf(buf);
|
|
|
|
renderer_base renb(pixf);
|
|
|
|
|
|
|
|
box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box();
|
2011-01-31 10:56:31 +01:00
|
|
|
coord<double,2> c = bbox.center();
|
|
|
|
// center the svg marker on '0,0'
|
|
|
|
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
|
|
|
|
// apply symbol transformation to get to map space
|
|
|
|
mtx *= tr;
|
|
|
|
mtx *= agg::trans_affine_scaling(scale_factor_);
|
|
|
|
// render the marker at the center of the marker box
|
|
|
|
mtx.translate(x+0.5 * marker.width(), y+0.5 * marker.height());
|
2011-01-26 10:19:00 +01:00
|
|
|
|
|
|
|
vertex_stl_adapter<svg_path_storage> stl_storage((*marker.get_vector_data())->source());
|
|
|
|
svg_path_adapter svg_path(stl_storage);
|
|
|
|
svg_renderer<svg_path_adapter,
|
2011-05-17 08:19:41 +02:00
|
|
|
agg::pod_bvector<path_attributes>,
|
|
|
|
renderer_solid,
|
|
|
|
agg::pixfmt_rgba32_plain> svg_renderer(svg_path,
|
2011-01-26 10:19:00 +01:00
|
|
|
(*marker.get_vector_data())->attributes());
|
|
|
|
|
|
|
|
svg_renderer.render(*ras_ptr, sl, renb, mtx, opacity, bbox);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pixmap_.set_rectangle_alpha2(**marker.get_bitmap_data(), x, y, opacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
template class agg_renderer<image_32>;
|
2006-02-07 15:41:41 +01:00
|
|
|
}
|