2010-06-06 14:10:36 +02:00
|
|
|
/*****************************************************************************
|
2012-02-02 02:53:35 +01:00
|
|
|
*
|
2010-06-06 14:10:36 +02:00
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2011-10-23 15:04:25 +02:00
|
|
|
* Copyright (C) 2011 Artem Pavlenko
|
2010-06-06 14:10:36 +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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2012-04-08 02:45:01 +02:00
|
|
|
// mapnik
|
2010-06-06 14:10:36 +02:00
|
|
|
#include <mapnik/markers_symbolizer.hpp>
|
|
|
|
|
2012-06-29 04:54:25 +02:00
|
|
|
// boost
|
|
|
|
#include <boost/make_shared.hpp>
|
|
|
|
|
2010-06-06 14:10:36 +02:00
|
|
|
namespace mapnik {
|
|
|
|
|
2010-08-19 19:33:01 +02:00
|
|
|
static const char * marker_placement_strings[] = {
|
|
|
|
"point",
|
|
|
|
"line",
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2011-04-01 08:24:57 +02:00
|
|
|
IMPLEMENT_ENUM( marker_placement_e, marker_placement_strings )
|
2010-08-19 19:33:01 +02:00
|
|
|
|
2010-06-06 14:10:36 +02:00
|
|
|
markers_symbolizer::markers_symbolizer()
|
2012-07-11 07:38:53 +02:00
|
|
|
: symbolizer_with_image(parse_path("shape://ellipse")),
|
2012-04-08 03:56:32 +02:00
|
|
|
symbolizer_base(),
|
2012-07-09 11:18:41 +02:00
|
|
|
width_(),
|
|
|
|
height_(),
|
2012-04-08 03:56:32 +02:00
|
|
|
ignore_placement_(false),
|
|
|
|
allow_overlap_(false),
|
|
|
|
spacing_(100.0),
|
|
|
|
max_error_(0.2),
|
2012-07-25 04:56:08 +02:00
|
|
|
marker_p_(MARKER_POINT_PLACEMENT) {
|
|
|
|
// override the default for clipping in symbolizer base
|
|
|
|
this->set_clip(false);
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
markers_symbolizer::markers_symbolizer(path_expression_ptr const& filename)
|
2012-02-02 02:53:35 +01:00
|
|
|
: symbolizer_with_image(filename),
|
2010-08-10 14:43:21 +02:00
|
|
|
symbolizer_base(),
|
2012-07-09 11:18:41 +02:00
|
|
|
width_(),
|
|
|
|
height_(),
|
2012-03-18 22:35:02 +01:00
|
|
|
ignore_placement_(false),
|
2012-04-08 03:56:32 +02:00
|
|
|
allow_overlap_(false),
|
2012-02-02 02:53:35 +01:00
|
|
|
spacing_(100.0),
|
2010-08-19 19:33:01 +02:00
|
|
|
max_error_(0.2),
|
2012-07-25 04:56:08 +02:00
|
|
|
marker_p_(MARKER_POINT_PLACEMENT) {
|
|
|
|
// override the default for clipping in symbolizer base
|
|
|
|
this->set_clip(false);
|
|
|
|
}
|
2010-06-06 14:10:36 +02:00
|
|
|
|
2012-02-02 02:53:35 +01:00
|
|
|
markers_symbolizer::markers_symbolizer(markers_symbolizer const& rhs)
|
|
|
|
: symbolizer_with_image(rhs),
|
2010-08-10 14:43:21 +02:00
|
|
|
symbolizer_base(rhs),
|
2012-07-09 11:18:41 +02:00
|
|
|
width_(rhs.width_),
|
|
|
|
height_(rhs.height_),
|
2012-03-18 22:35:02 +01:00
|
|
|
ignore_placement_(rhs.ignore_placement_),
|
2012-04-08 03:56:32 +02:00
|
|
|
allow_overlap_(rhs.allow_overlap_),
|
2012-02-02 02:53:35 +01:00
|
|
|
spacing_(rhs.spacing_),
|
2010-08-19 19:33:01 +02:00
|
|
|
max_error_(rhs.max_error_),
|
2012-07-05 18:11:52 +02:00
|
|
|
fill_(rhs.fill_),
|
2012-07-31 03:31:21 +02:00
|
|
|
fill_opacity_(rhs.fill_opacity_),
|
|
|
|
opacity_(rhs.opacity_),
|
2010-08-19 19:33:01 +02:00
|
|
|
stroke_(rhs.stroke_),
|
2012-07-04 15:50:11 +02:00
|
|
|
marker_p_(rhs.marker_p_) {}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2012-03-18 22:35:02 +01:00
|
|
|
void markers_symbolizer::set_ignore_placement(bool ignore_placement)
|
|
|
|
{
|
|
|
|
ignore_placement_ = ignore_placement;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool markers_symbolizer::get_ignore_placement() const
|
|
|
|
{
|
|
|
|
return ignore_placement_;
|
|
|
|
}
|
|
|
|
|
2010-06-06 14:10:36 +02:00
|
|
|
void markers_symbolizer::set_allow_overlap(bool overlap)
|
|
|
|
{
|
|
|
|
allow_overlap_ = overlap;
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2010-06-06 14:10:36 +02:00
|
|
|
bool markers_symbolizer::get_allow_overlap() const
|
|
|
|
{
|
|
|
|
return allow_overlap_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void markers_symbolizer::set_spacing(double spacing)
|
|
|
|
{
|
|
|
|
spacing_ = spacing;
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2010-08-19 19:33:01 +02:00
|
|
|
double markers_symbolizer::get_spacing() const
|
2010-06-06 14:10:36 +02:00
|
|
|
{
|
|
|
|
return spacing_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void markers_symbolizer::set_max_error(double max_error)
|
|
|
|
{
|
|
|
|
max_error_ = max_error;
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2010-08-19 19:33:01 +02:00
|
|
|
double markers_symbolizer::get_max_error() const
|
2010-06-06 14:10:36 +02:00
|
|
|
{
|
|
|
|
return max_error_;
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2012-07-31 03:31:21 +02:00
|
|
|
void markers_symbolizer::set_opacity(float opacity)
|
|
|
|
{
|
|
|
|
opacity_ = opacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::optional<float> markers_symbolizer::get_opacity() const
|
|
|
|
{
|
|
|
|
return opacity_;
|
|
|
|
}
|
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
void markers_symbolizer::set_fill(color const& fill)
|
2010-06-06 14:10:36 +02:00
|
|
|
{
|
|
|
|
fill_ = fill;
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
boost::optional<color> markers_symbolizer::get_fill() const
|
2010-06-06 14:10:36 +02:00
|
|
|
{
|
|
|
|
return fill_;
|
|
|
|
}
|
|
|
|
|
2012-07-31 03:31:21 +02:00
|
|
|
void markers_symbolizer::set_fill_opacity(float opacity)
|
|
|
|
{
|
|
|
|
fill_opacity_ = opacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::optional<float> markers_symbolizer::get_fill_opacity() const
|
|
|
|
{
|
|
|
|
return fill_opacity_;
|
|
|
|
}
|
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
void markers_symbolizer::set_width(expression_ptr const& width)
|
2010-08-19 19:33:01 +02:00
|
|
|
{
|
|
|
|
width_ = width;
|
|
|
|
}
|
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
expression_ptr const& markers_symbolizer::get_width() const
|
2010-08-19 19:33:01 +02:00
|
|
|
{
|
|
|
|
return width_;
|
|
|
|
}
|
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
void markers_symbolizer::set_height(expression_ptr const& height)
|
2010-08-19 19:33:01 +02:00
|
|
|
{
|
|
|
|
height_ = height;
|
|
|
|
}
|
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
expression_ptr const& markers_symbolizer::get_height() const
|
2010-08-19 19:33:01 +02:00
|
|
|
{
|
|
|
|
return height_;
|
|
|
|
}
|
|
|
|
|
2012-07-05 18:11:52 +02:00
|
|
|
boost::optional<stroke> markers_symbolizer::get_stroke() const
|
2010-08-19 19:33:01 +02:00
|
|
|
{
|
|
|
|
return stroke_;
|
|
|
|
}
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2010-08-19 19:33:01 +02:00
|
|
|
void markers_symbolizer::set_stroke(stroke const& stroke)
|
|
|
|
{
|
|
|
|
stroke_ = stroke;
|
|
|
|
}
|
|
|
|
|
|
|
|
void markers_symbolizer::set_marker_placement(marker_placement_e marker_p)
|
|
|
|
{
|
|
|
|
marker_p_ = marker_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
marker_placement_e markers_symbolizer::get_marker_placement() const
|
|
|
|
{
|
|
|
|
return marker_p_;
|
|
|
|
}
|
|
|
|
|
2010-06-06 14:10:36 +02:00
|
|
|
}
|