2010-06-01 15:31:08 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
//$Id$
|
|
|
|
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/agg_renderer.hpp>
|
2010-06-13 14:03:42 +02:00
|
|
|
#include <mapnik/agg_rasterizer.hpp>
|
2010-06-01 15:31:08 +02:00
|
|
|
#include <mapnik/image_util.hpp>
|
2010-07-06 02:37:05 +02:00
|
|
|
#include <mapnik/metawriter.hpp>
|
2011-01-26 02:18:40 +01:00
|
|
|
#include <mapnik/marker_cache.hpp>
|
2011-09-01 02:43:46 +02:00
|
|
|
#include <mapnik/expression_evaluator.hpp>
|
2010-06-01 15:31:08 +02:00
|
|
|
|
|
|
|
#include "agg_basics.h"
|
|
|
|
#include "agg_rendering_buffer.h"
|
|
|
|
#include "agg_pixfmt_rgba.h"
|
|
|
|
#include "agg_rasterizer_scanline_aa.h"
|
|
|
|
#include "agg_scanline_u.h"
|
|
|
|
|
|
|
|
// stl
|
|
|
|
#include <string>
|
|
|
|
|
2011-05-10 23:09:54 +02:00
|
|
|
// boost
|
|
|
|
#include <boost/make_shared.hpp>
|
|
|
|
|
2010-06-01 15:31:08 +02:00
|
|
|
namespace mapnik {
|
|
|
|
|
2011-01-26 02:18:40 +01:00
|
|
|
template <typename T>
|
|
|
|
void agg_renderer<T>::process(point_symbolizer const& sym,
|
|
|
|
Feature const& feature,
|
|
|
|
proj_transform const& prj_trans)
|
|
|
|
{
|
|
|
|
std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
|
|
|
|
|
|
|
|
boost::optional<mapnik::marker_ptr> marker;
|
|
|
|
if ( !filename.empty() )
|
|
|
|
{
|
2010-06-03 14:35:43 +02:00
|
|
|
marker = marker_cache::instance()->find(filename, true);
|
2011-01-26 02:18:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-10 23:09:54 +02:00
|
|
|
marker.reset(boost::make_shared<mapnik::marker>());
|
2011-01-26 02:18:40 +01:00
|
|
|
}
|
2010-06-08 12:16:22 +02:00
|
|
|
|
2011-01-26 02:18:40 +01:00
|
|
|
if (marker)
|
|
|
|
{
|
|
|
|
for (unsigned i=0; i<feature.num_geometries(); ++i)
|
2010-06-02 13:03:30 +02:00
|
|
|
{
|
2011-01-26 02:18:40 +01:00
|
|
|
geometry_type const& geom = feature.get_geometry(i);
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
double z=0;
|
2011-02-24 19:05:07 +01:00
|
|
|
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
|
2011-02-01 09:16:32 +01:00
|
|
|
geom.label_position(&x, &y);
|
|
|
|
else
|
|
|
|
geom.label_interior_position(&x, &y);
|
2011-01-26 02:18:40 +01:00
|
|
|
|
|
|
|
prj_trans.backward(x,y,z);
|
|
|
|
t_.forward(&x,&y);
|
|
|
|
|
|
|
|
int w = (*marker)->width();
|
|
|
|
int h = (*marker)->height();
|
|
|
|
|
|
|
|
int px = int(floor(x - 0.5 * w));
|
|
|
|
int py = int(floor(y - 0.5 * h));
|
|
|
|
box2d<double> label_ext (px, py, px + w, py + h);
|
|
|
|
if (sym.get_allow_overlap() ||
|
|
|
|
detector_.has_placement(label_ext))
|
2010-06-02 13:03:30 +02:00
|
|
|
{
|
|
|
|
agg::trans_affine tr;
|
|
|
|
boost::array<double,6> const& m = sym.get_transform();
|
|
|
|
tr.load_from(&m[0]);
|
2010-06-19 22:32:00 +02:00
|
|
|
|
2011-01-26 02:18:40 +01:00
|
|
|
render_marker(px,py,**marker,tr, sym.get_opacity());
|
|
|
|
|
|
|
|
if (!sym.get_ignore_placement())
|
|
|
|
detector_.insert(label_ext);
|
|
|
|
metawriter_with_properties writer = sym.get_metawriter();
|
|
|
|
if (writer.first) writer.first->add_box(label_ext, feature, t_, writer.second);
|
2010-06-02 13:03:30 +02:00
|
|
|
}
|
|
|
|
}
|
2010-06-01 15:31:08 +02:00
|
|
|
}
|
2011-01-26 02:18:40 +01:00
|
|
|
|
2010-06-01 15:31:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template void agg_renderer<image_32>::process(point_symbolizer const&,
|
2010-06-02 13:03:30 +02:00
|
|
|
Feature const&,
|
|
|
|
proj_transform const&);
|
2010-06-01 15:31:08 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|