2011-04-26 23:44:52 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 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/grid/grid_renderer.hpp>
|
2012-01-25 16:17:38 +01:00
|
|
|
#include <mapnik/symbolizer_helpers.hpp>
|
2011-04-26 23:44:52 +02:00
|
|
|
|
|
|
|
namespace mapnik {
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void grid_renderer<T>::process(text_symbolizer const& sym,
|
2012-02-02 02:53:35 +01:00
|
|
|
mapnik::feature_ptr const& feature,
|
|
|
|
proj_transform const& prj_trans)
|
2011-04-26 23:44:52 +02:00
|
|
|
{
|
2012-03-07 13:48:51 +01:00
|
|
|
box2d<double> query_extent;
|
2012-01-25 16:17:38 +01:00
|
|
|
text_symbolizer_helper<face_manager<freetype_engine>,
|
2012-02-02 02:53:35 +01:00
|
|
|
label_collision_detector4> helper(
|
|
|
|
sym, *feature, prj_trans,
|
|
|
|
width_, height_,
|
|
|
|
scale_factor_ * (1.0/pixmap_.get_resolution()),
|
2012-03-07 13:48:51 +01:00
|
|
|
t_, font_manager_, detector_,
|
|
|
|
query_extent);
|
2012-01-26 19:58:47 +01:00
|
|
|
bool placement_found = false;
|
2011-04-26 23:44:52 +02:00
|
|
|
|
2012-01-25 16:17:38 +01:00
|
|
|
text_renderer<T> ren(pixmap_, font_manager_, *(font_manager_.get_stroker()));
|
2012-01-26 19:58:47 +01:00
|
|
|
|
2012-03-03 20:15:24 +01:00
|
|
|
while (helper.next()) {
|
2012-01-29 04:57:56 +01:00
|
|
|
placement_found = true;
|
2012-03-03 20:15:24 +01:00
|
|
|
placements_type &placements = helper.placements();
|
|
|
|
for (unsigned int ii = 0; ii < placements.size(); ++ii)
|
2012-01-26 19:58:47 +01:00
|
|
|
{
|
2012-03-03 20:15:24 +01:00
|
|
|
ren.prepare_glyphs(&(placements[ii]));
|
|
|
|
ren.render_id(feature->id(), placements[ii].center, 2);
|
2012-01-26 19:58:47 +01:00
|
|
|
}
|
2011-04-26 23:44:52 +02:00
|
|
|
}
|
2012-01-26 19:58:47 +01:00
|
|
|
if (placement_found) pixmap_.add_feature(feature);
|
2012-01-25 16:17:38 +01:00
|
|
|
|
2011-04-26 23:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template void grid_renderer<grid>::process(text_symbolizer const&,
|
2012-02-02 02:53:35 +01:00
|
|
|
mapnik::feature_ptr const&,
|
|
|
|
proj_transform const&);
|
2011-04-26 23:44:52 +02:00
|
|
|
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|