2012-10-02 00:01:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2014-11-20 15:25:50 +01:00
|
|
|
* Copyright (C) 2014 Artem Pavlenko
|
2012-10-02 00:01: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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/rule.hpp>
|
2014-09-30 21:50:08 +02:00
|
|
|
#include <mapnik/expression_node.hpp>
|
2013-01-04 08:55:09 +01:00
|
|
|
|
2013-01-04 04:57:09 +01:00
|
|
|
// stl
|
|
|
|
#include <limits>
|
2014-07-26 01:15:18 +02:00
|
|
|
#include <memory>
|
2013-01-04 04:57:09 +01:00
|
|
|
|
2012-10-02 00:01:12 +02:00
|
|
|
namespace mapnik
|
|
|
|
{
|
|
|
|
|
|
|
|
rule::rule()
|
|
|
|
: name_(),
|
|
|
|
min_scale_(0),
|
|
|
|
max_scale_(std::numeric_limits<double>::infinity()),
|
|
|
|
syms_(),
|
2013-11-14 05:00:13 +01:00
|
|
|
filter_(std::make_shared<expr_node>(true)),
|
2012-10-02 00:01:12 +02:00
|
|
|
else_filter_(false),
|
|
|
|
also_filter_(false) {}
|
|
|
|
|
|
|
|
rule::rule(std::string const& name,
|
|
|
|
double min_scale_denominator,
|
|
|
|
double max_scale_denominator)
|
|
|
|
: name_(name),
|
|
|
|
min_scale_(min_scale_denominator),
|
|
|
|
max_scale_(max_scale_denominator),
|
|
|
|
syms_(),
|
2013-11-28 07:50:15 +01:00
|
|
|
filter_(std::make_shared<mapnik::expr_node>(true)),
|
2012-10-02 00:01:12 +02:00
|
|
|
else_filter_(false),
|
|
|
|
also_filter_(false) {}
|
|
|
|
|
2013-11-14 04:26:17 +01:00
|
|
|
rule::rule(rule const& rhs)
|
2012-10-02 00:01:12 +02:00
|
|
|
: name_(rhs.name_),
|
|
|
|
min_scale_(rhs.min_scale_),
|
|
|
|
max_scale_(rhs.max_scale_),
|
|
|
|
syms_(rhs.syms_),
|
2013-11-14 05:00:13 +01:00
|
|
|
filter_(std::make_shared<expr_node>(*rhs.filter_)),
|
2012-10-02 00:01:12 +02:00
|
|
|
else_filter_(rhs.else_filter_),
|
2014-05-27 13:34:35 +02:00
|
|
|
also_filter_(rhs.also_filter_) {}
|
2012-10-02 00:01:12 +02:00
|
|
|
|
2014-09-05 07:03:54 +02:00
|
|
|
rule::rule(rule && rhs)
|
|
|
|
: name_(std::move(rhs.name_)),
|
|
|
|
min_scale_(std::move(rhs.min_scale_)),
|
|
|
|
max_scale_(std::move(rhs.max_scale_)),
|
|
|
|
syms_(std::move(rhs.syms_)),
|
|
|
|
filter_(std::move(rhs.filter_)),
|
|
|
|
else_filter_(std::move(rhs.else_filter_)),
|
|
|
|
also_filter_(std::move(rhs.also_filter_)) {}
|
|
|
|
|
2013-11-28 07:50:15 +01:00
|
|
|
rule& rule::operator=(rule rhs)
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
2014-08-31 09:44:41 +02:00
|
|
|
using std::swap;
|
|
|
|
swap(this->name_, rhs.name_);
|
|
|
|
swap(this->min_scale_, rhs.min_scale_);
|
|
|
|
swap(this->max_scale_, rhs.max_scale_);
|
|
|
|
swap(this->syms_, rhs.syms_);
|
|
|
|
swap(this->filter_, rhs.filter_);
|
|
|
|
swap(this->else_filter_, rhs.else_filter_);
|
|
|
|
swap(this->also_filter_, rhs.also_filter_);
|
2012-10-02 00:01:12 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-05-27 13:34:35 +02:00
|
|
|
bool rule::operator==(rule const& rhs) const
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
2014-05-27 13:34:35 +02:00
|
|
|
return (name_ == rhs.name_) &&
|
|
|
|
(min_scale_ == rhs.min_scale_) &&
|
|
|
|
(max_scale_ == rhs.max_scale_) &&
|
|
|
|
(syms_ == rhs.syms_) &&
|
|
|
|
(filter_ == rhs.filter_) &&
|
|
|
|
(else_filter_ == rhs.else_filter_) &&
|
|
|
|
(also_filter_ == rhs.also_filter_);
|
2012-10-02 00:01:12 +02:00
|
|
|
}
|
|
|
|
|
2014-09-05 07:03:54 +02:00
|
|
|
|
2012-10-02 00:01:12 +02:00
|
|
|
void rule::set_max_scale(double scale)
|
|
|
|
{
|
|
|
|
max_scale_=scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
double rule::get_max_scale() const
|
|
|
|
{
|
|
|
|
return max_scale_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rule::set_min_scale(double scale)
|
|
|
|
{
|
|
|
|
min_scale_=scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
double rule::get_min_scale() const
|
|
|
|
{
|
|
|
|
return min_scale_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rule::set_name(std::string const& name)
|
|
|
|
{
|
|
|
|
name_=name;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string const& rule::get_name() const
|
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
2013-11-28 07:50:15 +01:00
|
|
|
void rule::append(symbolizer && sym)
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
2013-11-28 07:50:15 +01:00
|
|
|
syms_.push_back(std::move(sym));
|
2012-10-02 00:01:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void rule::remove_at(size_t index)
|
|
|
|
{
|
|
|
|
if (index < syms_.size())
|
|
|
|
{
|
|
|
|
syms_.erase(syms_.begin()+index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-10 19:50:56 +02:00
|
|
|
rule::symbolizers const& rule::get_symbolizers() const
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
|
|
|
return syms_;
|
|
|
|
}
|
|
|
|
|
2012-10-10 19:50:56 +02:00
|
|
|
rule::symbolizers::const_iterator rule::begin() const
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
|
|
|
return syms_.begin();
|
|
|
|
}
|
|
|
|
|
2012-10-10 19:50:56 +02:00
|
|
|
rule::symbolizers::const_iterator rule::end() const
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
|
|
|
return syms_.end();
|
|
|
|
}
|
|
|
|
|
2012-10-10 19:50:56 +02:00
|
|
|
rule::symbolizers::iterator rule::begin()
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
|
|
|
return syms_.begin();
|
|
|
|
}
|
|
|
|
|
2012-10-10 19:50:56 +02:00
|
|
|
rule::symbolizers::iterator rule::end()
|
2012-10-02 00:01:12 +02:00
|
|
|
{
|
|
|
|
return syms_.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void rule::set_filter(expression_ptr const& filter)
|
|
|
|
{
|
|
|
|
filter_=filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
expression_ptr const& rule::get_filter() const
|
|
|
|
{
|
|
|
|
return filter_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rule::set_else(bool else_filter)
|
|
|
|
{
|
|
|
|
else_filter_=else_filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rule::has_else_filter() const
|
|
|
|
{
|
|
|
|
return else_filter_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rule::set_also(bool also_filter)
|
|
|
|
{
|
|
|
|
also_filter_=also_filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rule::has_also_filter() const
|
|
|
|
{
|
|
|
|
return also_filter_;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|