2007-09-25 20:47:12 +02:00
|
|
|
/*****************************************************************************
|
2012-02-02 02:53:35 +01:00
|
|
|
*
|
2007-09-25 20:47:12 +02:00
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2011-10-23 15:04:25 +02:00
|
|
|
* Copyright (C) 2011 Artem Pavlenko
|
2007-09-25 20:47:12 +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
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
//mapnik
|
2007-09-25 20:47:12 +02:00
|
|
|
#include <mapnik/symbolizer.hpp>
|
2010-07-06 02:37:05 +02:00
|
|
|
#include <mapnik/map.hpp>
|
2012-06-07 17:06:45 +02:00
|
|
|
#include <mapnik/transform_processor.hpp>
|
2007-09-25 20:47:12 +02:00
|
|
|
|
|
|
|
namespace mapnik {
|
|
|
|
|
2012-05-27 23:50:09 +02:00
|
|
|
void evaluate_transform(agg::trans_affine& tr, Feature const& feature,
|
|
|
|
transform_list_ptr const& trans_expr)
|
|
|
|
{
|
|
|
|
if (trans_expr)
|
|
|
|
{
|
2012-09-26 15:24:26 +02:00
|
|
|
#ifdef MAPNIK_LOG
|
|
|
|
MAPNIK_LOG_DEBUG(transform) << "transform: evaluate "
|
|
|
|
<< transform_processor_type::to_string(*trans_expr);
|
|
|
|
#endif
|
2012-05-27 23:50:09 +02:00
|
|
|
transform_processor_type::evaluate(tr, feature, *trans_expr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-10 13:05:40 +02:00
|
|
|
// default ctor
|
|
|
|
symbolizer_base::symbolizer_base()
|
2012-08-15 10:47:03 +02:00
|
|
|
: comp_op_(src_over),
|
2012-05-10 13:05:40 +02:00
|
|
|
clip_(true),
|
2012-08-16 16:53:38 +02:00
|
|
|
simplify_algorithm_value_(radial_distance),
|
2012-08-14 17:04:57 +02:00
|
|
|
simplify_tolerance_value_(0.0),
|
2012-05-10 13:05:40 +02:00
|
|
|
smooth_value_(0.0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy ctor
|
|
|
|
symbolizer_base::symbolizer_base(symbolizer_base const& other)
|
|
|
|
: comp_op_(other.comp_op_),
|
|
|
|
affine_transform_(other.affine_transform_),
|
|
|
|
clip_(other.clip_),
|
2012-08-25 15:33:24 +02:00
|
|
|
simplify_algorithm_value_(other.simplify_algorithm_value_),
|
2012-08-14 17:04:57 +02:00
|
|
|
simplify_tolerance_value_(other.simplify_tolerance_value_),
|
2012-05-10 13:05:40 +02:00
|
|
|
smooth_value_(other.smooth_value_) {}
|
|
|
|
|
2012-04-05 16:59:11 +02:00
|
|
|
void symbolizer_base::set_comp_op(composite_mode_e comp_op)
|
|
|
|
{
|
|
|
|
comp_op_ = comp_op;
|
|
|
|
}
|
|
|
|
|
2012-05-10 13:05:40 +02:00
|
|
|
composite_mode_e symbolizer_base::comp_op() const
|
2012-04-05 16:59:11 +02:00
|
|
|
{
|
|
|
|
return comp_op_;
|
|
|
|
}
|
|
|
|
|
2012-04-18 10:42:19 +02:00
|
|
|
void symbolizer_base::set_transform(transform_type const& affine_transform)
|
|
|
|
{
|
|
|
|
affine_transform_ = affine_transform;
|
2012-05-27 23:50:09 +02:00
|
|
|
|
|
|
|
#ifdef MAPNIK_LOG
|
|
|
|
MAPNIK_LOG_DEBUG(load_map) << "map_parser: set_transform: "
|
|
|
|
<< (affine_transform_
|
|
|
|
? transform_processor_type::to_string(*affine_transform_)
|
|
|
|
: std::string("null"));
|
|
|
|
#endif
|
2012-04-18 10:42:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
transform_type const& symbolizer_base::get_transform() const
|
|
|
|
{
|
|
|
|
return affine_transform_;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string symbolizer_base::get_transform_string() const
|
|
|
|
{
|
2012-05-27 23:50:09 +02:00
|
|
|
if (affine_transform_)
|
2012-11-29 04:33:09 +01:00
|
|
|
{
|
2012-05-27 23:50:09 +02:00
|
|
|
return transform_processor_type::to_string(*affine_transform_);
|
2012-11-29 04:33:09 +01:00
|
|
|
}
|
2012-05-27 23:50:09 +02:00
|
|
|
else
|
2012-11-29 04:33:09 +01:00
|
|
|
{
|
2012-05-27 23:50:09 +02:00
|
|
|
return std::string();
|
2012-11-29 04:33:09 +01:00
|
|
|
}
|
2012-04-18 10:42:19 +02:00
|
|
|
}
|
|
|
|
|
2012-04-24 12:10:54 +02:00
|
|
|
void symbolizer_base::set_clip(bool clip)
|
|
|
|
{
|
|
|
|
clip_ = clip;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool symbolizer_base::clip() const
|
|
|
|
{
|
|
|
|
return clip_;
|
|
|
|
}
|
|
|
|
|
2012-08-16 16:53:38 +02:00
|
|
|
void symbolizer_base::set_simplify_algorithm(simplify_algorithm_e algo)
|
|
|
|
{
|
|
|
|
simplify_algorithm_value_ = algo;
|
|
|
|
}
|
|
|
|
|
|
|
|
simplify_algorithm_e symbolizer_base::simplify_algorithm() const
|
|
|
|
{
|
|
|
|
return simplify_algorithm_value_;
|
|
|
|
}
|
|
|
|
|
2012-08-14 17:04:57 +02:00
|
|
|
void symbolizer_base::set_simplify_tolerance(double simplify_tolerance)
|
|
|
|
{
|
|
|
|
simplify_tolerance_value_ = simplify_tolerance;
|
|
|
|
}
|
|
|
|
|
|
|
|
double symbolizer_base::simplify_tolerance() const
|
|
|
|
{
|
|
|
|
return simplify_tolerance_value_;
|
|
|
|
}
|
|
|
|
|
2012-05-07 17:08:16 +02:00
|
|
|
void symbolizer_base::set_smooth(double smooth)
|
|
|
|
{
|
|
|
|
smooth_value_ = smooth;
|
|
|
|
}
|
|
|
|
|
|
|
|
double symbolizer_base::smooth() const
|
|
|
|
{
|
|
|
|
return smooth_value_;
|
|
|
|
}
|
2012-04-24 12:10:54 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
2012-04-05 16:59:11 +02:00
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
symbolizer_with_image::symbolizer_with_image(path_expression_ptr file)
|
2010-06-15 15:43:27 +02:00
|
|
|
: image_filename_( file ),
|
2012-05-10 13:05:40 +02:00
|
|
|
image_opacity_(1.0f)
|
2010-06-03 14:35:02 +02:00
|
|
|
{
|
|
|
|
}
|
2007-09-25 20:47:12 +02:00
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
symbolizer_with_image::symbolizer_with_image( symbolizer_with_image const& rhs)
|
2010-06-03 14:35:02 +02:00
|
|
|
: image_filename_(rhs.image_filename_),
|
2012-05-01 17:47:33 +02:00
|
|
|
image_opacity_(rhs.image_opacity_),
|
|
|
|
image_transform_(rhs.image_transform_)
|
|
|
|
{
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2012-08-22 01:36:15 +02:00
|
|
|
path_expression_ptr const& symbolizer_with_image::get_filename() const
|
2009-12-16 21:02:06 +01:00
|
|
|
{
|
|
|
|
return image_filename_;
|
|
|
|
}
|
|
|
|
|
2012-08-22 01:36:15 +02:00
|
|
|
void symbolizer_with_image::set_filename(path_expression_ptr const& image_filename)
|
2009-12-16 21:02:06 +01:00
|
|
|
{
|
|
|
|
image_filename_ = image_filename;
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2010-06-15 14:27:50 +02:00
|
|
|
void symbolizer_with_image::set_opacity(float opacity)
|
|
|
|
{
|
2012-01-20 22:45:47 +01:00
|
|
|
image_opacity_ = opacity;
|
2010-06-15 14:27:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
float symbolizer_with_image::get_opacity() const
|
|
|
|
{
|
2012-01-20 22:45:47 +01:00
|
|
|
return image_opacity_;
|
2010-06-15 14:27:50 +02:00
|
|
|
}
|
|
|
|
|
2012-05-10 13:05:40 +02:00
|
|
|
void symbolizer_with_image::set_image_transform(transform_type const& tr)
|
2012-05-01 17:47:33 +02:00
|
|
|
{
|
|
|
|
image_transform_ = tr;
|
2012-05-27 23:50:09 +02:00
|
|
|
|
|
|
|
#ifdef MAPNIK_LOG
|
|
|
|
MAPNIK_LOG_DEBUG(load_map) << "map_parser: set_image_transform: "
|
|
|
|
<< (image_transform_
|
|
|
|
? transform_processor_type::to_string(*image_transform_)
|
|
|
|
: std::string("null"));
|
|
|
|
#endif
|
2012-05-01 17:47:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
transform_type const& symbolizer_with_image::get_image_transform() const
|
|
|
|
{
|
|
|
|
return image_transform_;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string symbolizer_with_image::get_image_transform_string() const
|
|
|
|
{
|
2012-05-27 23:50:09 +02:00
|
|
|
if (image_transform_)
|
2012-11-29 04:33:09 +01:00
|
|
|
{
|
2012-05-27 23:50:09 +02:00
|
|
|
return transform_processor_type::to_string(*image_transform_);
|
2012-11-29 04:33:09 +01:00
|
|
|
}
|
2012-05-27 23:50:09 +02:00
|
|
|
else
|
2012-11-29 04:33:09 +01:00
|
|
|
{
|
2012-05-27 23:50:09 +02:00
|
|
|
return std::string();
|
2012-11-29 04:33:09 +01:00
|
|
|
}
|
2012-05-01 17:47:33 +02:00
|
|
|
}
|
|
|
|
|
2007-09-25 20:47:12 +02:00
|
|
|
} // end of namespace mapnik
|