/
symbolizer.cpp
176 lines (148 loc) · 4.46 KB
/
symbolizer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*****************************************************************************
*
* 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/symbolizer.hpp>
#include <mapnik/map.hpp>
#include <mapnik/transform_processor.hpp>
namespace mapnik {
void evaluate_transform(agg::trans_affine& tr, Feature const& feature,
transform_list_ptr const& trans_expr)
{
#ifdef MAPNIK_LOG
MAPNIK_LOG_DEBUG(transform) << "transform: evaluate "
<< (trans_expr
? transform_processor_type::to_string(*trans_expr)
: std::string("null"));
#endif
if (trans_expr)
{
transform_processor_type::evaluate(tr, feature, *trans_expr);
}
}
// default ctor
symbolizer_base::symbolizer_base()
: comp_op_(src_over),
clip_(true),
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_),
smooth_value_(other.smooth_value_) {}
void symbolizer_base::set_comp_op(composite_mode_e comp_op)
{
comp_op_ = comp_op;
}
composite_mode_e symbolizer_base::comp_op() const
{
return comp_op_;
}
void symbolizer_base::set_transform(transform_type const& affine_transform)
{
affine_transform_ = affine_transform;
#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
}
transform_type const& symbolizer_base::get_transform() const
{
return affine_transform_;
}
std::string symbolizer_base::get_transform_string() const
{
if (affine_transform_)
return transform_processor_type::to_string(*affine_transform_);
else
return std::string();
}
void symbolizer_base::set_clip(bool clip)
{
clip_ = clip;
}
bool symbolizer_base::clip() const
{
return clip_;
}
void symbolizer_base::set_smooth(double smooth)
{
smooth_value_ = smooth;
}
double symbolizer_base::smooth() const
{
return smooth_value_;
}
///////////////////////////////////////////////////////////////////////////////////////
symbolizer_with_image::symbolizer_with_image(path_expression_ptr file)
: image_filename_( file ),
image_opacity_(1.0f)
{
}
symbolizer_with_image::symbolizer_with_image( symbolizer_with_image const& rhs)
: image_filename_(rhs.image_filename_),
image_opacity_(rhs.image_opacity_),
image_transform_(rhs.image_transform_)
{
}
path_expression_ptr const& symbolizer_with_image::get_filename() const
{
return image_filename_;
}
void symbolizer_with_image::set_filename(path_expression_ptr const& image_filename)
{
image_filename_ = image_filename;
}
void symbolizer_with_image::set_opacity(float opacity)
{
image_opacity_ = opacity;
}
float symbolizer_with_image::get_opacity() const
{
return image_opacity_;
}
void symbolizer_with_image::set_image_transform(transform_type const& tr)
{
image_transform_ = tr;
#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
}
transform_type const& symbolizer_with_image::get_image_transform() const
{
return image_transform_;
}
std::string symbolizer_with_image::get_image_transform_string() const
{
if (image_transform_)
return transform_processor_type::to_string(*image_transform_);
else
return std::string();
}
} // end of namespace mapnik