Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8598202f8f
17 changed files with 152 additions and 85 deletions
24
SConstruct
24
SConstruct
|
@ -33,6 +33,8 @@ except:
|
|||
HAS_DISTUTILS = False
|
||||
|
||||
|
||||
py3 = None
|
||||
|
||||
# local file to hold custom user configuration variables
|
||||
# Todo check timestamp, reload if changed?
|
||||
SCONS_LOCAL_CONFIG = 'config.py'
|
||||
|
@ -302,7 +304,7 @@ opts.AddVariables(
|
|||
('BOOST_TOOLKIT','Specify boost toolkit, e.g., gcc41.','',False),
|
||||
('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False),
|
||||
('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False),
|
||||
('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")',''),
|
||||
('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")','boost_python'),
|
||||
|
||||
# Variables for required dependencies
|
||||
('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'),
|
||||
|
@ -1326,12 +1328,21 @@ if not preconfigured:
|
|||
color_print(4,'Not building with cairo support, pass CAIRO=True to enable')
|
||||
|
||||
if 'python' in env['BINDINGS']:
|
||||
# checklibwithheader does not work for boost_python since we can't feed it
|
||||
# multiple header files, so we fall back on a simple check for boost_python headers
|
||||
|
||||
py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
|
||||
|
||||
if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python':
|
||||
env['BOOST_PYTHON_LIB'] = 'boost_python3'
|
||||
|
||||
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'):
|
||||
color_print(1,'Could not find required header files for boost python')
|
||||
env['MISSING_DEPS'].append('boost python')
|
||||
|
||||
if not conf.CheckLibWithHeader(libs=[env['BOOST_PYTHON_LIB']], header='boost/python/detail/config.hpp', language='C++'):
|
||||
color_print(1, 'Could not find library "%s" for boost python bindings' % env['BOOST_PYTHON_LIB'])
|
||||
env['MISSING_DEPS'].append('boost python')
|
||||
|
||||
|
||||
if env['CAIRO']:
|
||||
if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'):
|
||||
env['HAS_PYCAIRO'] = True
|
||||
|
@ -1469,8 +1480,6 @@ if not preconfigured:
|
|||
color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON'])
|
||||
Exit(1)
|
||||
|
||||
py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
|
||||
|
||||
if py3:
|
||||
sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON']
|
||||
else:
|
||||
|
@ -1535,11 +1544,6 @@ if not preconfigured:
|
|||
color_print(1,"Python version 2.2 or greater required")
|
||||
Exit(1)
|
||||
|
||||
if env['BOOST_PYTHON_LIB']:
|
||||
if not conf.CheckLibWithHeader(libs=[env['BOOST_PYTHON_LIB']], header='boost/python/detail/config.hpp', language='C++'):
|
||||
color_print(1, 'Could not find library %s for boost python' % env['BOOST_PYTHON_LIB'])
|
||||
Exit(1)
|
||||
|
||||
color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION'])
|
||||
color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX']))
|
||||
color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION']))
|
||||
|
|
|
@ -43,15 +43,7 @@ prefix = env['PREFIX']
|
|||
target_path = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik')
|
||||
target_path_deprecated = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik2')
|
||||
|
||||
libraries = ['mapnik']
|
||||
|
||||
if env['BOOST_PYTHON_LIB']:
|
||||
libraries.append(env['BOOST_PYTHON_LIB'])
|
||||
else:
|
||||
if is_py3():
|
||||
libraries.append('boost_python3%s' % env['BOOST_APPEND'])
|
||||
else:
|
||||
libraries.append('boost_python%s' % env['BOOST_APPEND'])
|
||||
libraries = ['mapnik',env['BOOST_PYTHON_LIB']]
|
||||
|
||||
# TODO - do solaris/fedora need direct linking too?
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
|
|
|
@ -150,12 +150,13 @@ void render_layer2(const mapnik::Map& map,
|
|||
|
||||
void render3(const mapnik::Map& map,
|
||||
PycairoSurface* surface,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0)
|
||||
{
|
||||
python_unblock_auto_block b;
|
||||
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
|
||||
mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
|
||||
mapnik::cairo_renderer<Cairo::Surface> ren(map,s,scale_factor,offset_x,offset_y);
|
||||
ren.apply();
|
||||
}
|
||||
|
||||
|
@ -169,12 +170,13 @@ void render4(const mapnik::Map& map, PycairoSurface* surface)
|
|||
|
||||
void render5(const mapnik::Map& map,
|
||||
PycairoContext* context,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0)
|
||||
{
|
||||
python_unblock_auto_block b;
|
||||
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
|
||||
mapnik::cairo_renderer<Cairo::Context> ren(map,c,offset_x, offset_y);
|
||||
mapnik::cairo_renderer<Cairo::Context> ren(map,c,scale_factor,offset_x, offset_y);
|
||||
ren.apply();
|
||||
}
|
||||
|
||||
|
@ -207,7 +209,7 @@ void render_to_file1(const mapnik::Map& map,
|
|||
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
|
||||
{
|
||||
#if defined(HAVE_CAIRO)
|
||||
mapnik::save_to_cairo_file(map,filename,format);
|
||||
mapnik::save_to_cairo_file(map,filename,format,1.0);
|
||||
#else
|
||||
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
|
||||
#endif
|
||||
|
@ -226,7 +228,7 @@ void render_to_file2(const mapnik::Map& map,const std::string& filename)
|
|||
if (format == "pdf" || format == "svg" || format =="ps")
|
||||
{
|
||||
#if defined(HAVE_CAIRO)
|
||||
mapnik::save_to_cairo_file(map,filename,format);
|
||||
mapnik::save_to_cairo_file(map,filename,format,1.0);
|
||||
#else
|
||||
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
|
||||
#endif
|
||||
|
@ -248,7 +250,7 @@ void render_to_file3(const mapnik::Map& map,
|
|||
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
|
||||
{
|
||||
#if defined(HAVE_CAIRO)
|
||||
mapnik::save_to_cairo_file(map,filename,format);
|
||||
mapnik::save_to_cairo_file(map,filename,format,scale_factor);
|
||||
#else
|
||||
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
|
||||
#endif
|
||||
|
|
|
@ -570,7 +570,7 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
Cairo::RefPtr<Cairo::ImageSurface> image_surface =
|
||||
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, map.width(),map.height());
|
||||
|
||||
mapnik::cairo_renderer<Cairo::Surface> png_render(map, image_surface);
|
||||
mapnik::cairo_renderer<Cairo::Surface> png_render(map, image_surface, scaling_factor);
|
||||
png_render.apply();
|
||||
|
||||
image_32 buf(image_surface);
|
||||
|
|
|
@ -72,7 +72,7 @@ private:
|
|||
class MAPNIK_DECL cairo_renderer_base : private boost::noncopyable
|
||||
{
|
||||
protected:
|
||||
cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, unsigned offset_x=0, unsigned offset_y=0);
|
||||
cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
public:
|
||||
~cairo_renderer_base();
|
||||
void start_map_processing(Map const& map);
|
||||
|
@ -127,6 +127,9 @@ protected:
|
|||
|
||||
Map const& m_;
|
||||
Cairo::RefPtr<Cairo::Context> context_;
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
double scale_factor_;
|
||||
CoordTransform t_;
|
||||
boost::shared_ptr<freetype_engine> font_engine_;
|
||||
face_manager<freetype_engine> font_manager_;
|
||||
|
@ -141,7 +144,7 @@ class MAPNIK_DECL cairo_renderer : public feature_style_processor<cairo_renderer
|
|||
{
|
||||
public:
|
||||
typedef cairo_renderer_base processor_impl_type;
|
||||
cairo_renderer(Map const& m, Cairo::RefPtr<T> const& surface, unsigned offset_x=0, unsigned offset_y=0);
|
||||
cairo_renderer(Map const& m, Cairo::RefPtr<T> const& surface, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
void end_map_processing(Map const& map);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ enum composite_mode_e
|
|||
};
|
||||
|
||||
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
|
||||
MAPNIK_DECL boost::optional<std::string> comp_op_to_string(composite_mode_e comp_op);
|
||||
|
||||
template <typename T1, typename T2>
|
||||
MAPNIK_DECL void composite(T1 & dst, T2 & src,
|
||||
|
|
|
@ -60,7 +60,8 @@ public:
|
|||
#if defined(HAVE_CAIRO)
|
||||
MAPNIK_DECL void save_to_cairo_file(mapnik::Map const& map,
|
||||
std::string const& filename,
|
||||
std::string const& type);
|
||||
std::string const& type,
|
||||
double scale_factor);
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -25,9 +25,11 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/raster_colorizer.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/image_compositing.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -54,11 +56,25 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
|
|||
|
||||
std::string const& get_mode() const
|
||||
{
|
||||
MAPNIK_LOG_ERROR(raster_symbolizer) << "getting 'mode' is deprecated and will be removed in Mapnik 3.x, use 'comp-op' with Mapnik >= 2.1.x";
|
||||
return mode_;
|
||||
}
|
||||
void set_mode(std::string const& mode)
|
||||
{
|
||||
MAPNIK_LOG_ERROR(raster_symbolizer) << "setting 'mode' is deprecated and will be removed in Mapnik 3.x, use 'comp-op' with Mapnik >= 2.1.x";
|
||||
mode_ = mode;
|
||||
if (mode == "normal")
|
||||
{
|
||||
this->set_comp_op(src_over);
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::optional<composite_mode_e> comp_op = comp_op_from_string(mode);
|
||||
if (comp_op)
|
||||
this->set_comp_op(*comp_op);
|
||||
else
|
||||
MAPNIK_LOG_ERROR(raster_symbolizer) << "could not convert mode into comp-op";
|
||||
}
|
||||
}
|
||||
std::string const& get_scaling() const
|
||||
{
|
||||
|
|
|
@ -42,9 +42,10 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
|
|||
shield_symbolizer_helper<face_manager<freetype_engine>,
|
||||
label_collision_detector4> helper(
|
||||
sym, feature, prj_trans,
|
||||
detector_->extent().width(), detector_->extent().height(),
|
||||
width_, height_,
|
||||
scale_factor_,
|
||||
t_, font_manager_, *detector_, query_extent_);
|
||||
t_, font_manager_, *detector_,
|
||||
query_extent_);
|
||||
|
||||
text_renderer<T> ren(*current_buffer_,
|
||||
font_manager_,
|
||||
|
|
|
@ -35,9 +35,10 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
|
|||
text_symbolizer_helper<face_manager<freetype_engine>,
|
||||
label_collision_detector4> helper(
|
||||
sym, feature, prj_trans,
|
||||
detector_->extent().width(), detector_->extent().height(),
|
||||
width_,height_,
|
||||
scale_factor_,
|
||||
t_, font_manager_, *detector_, query_extent_);
|
||||
t_, font_manager_, *detector_,
|
||||
query_extent_);
|
||||
|
||||
text_renderer<T> ren(*current_buffer_,
|
||||
font_manager_,
|
||||
|
|
|
@ -737,9 +737,16 @@ private:
|
|||
Cairo::RefPtr<Cairo::Context> context_;
|
||||
};
|
||||
|
||||
cairo_renderer_base::cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, unsigned offset_x, unsigned offset_y)
|
||||
cairo_renderer_base::cairo_renderer_base(Map const& m,
|
||||
Cairo::RefPtr<Cairo::Context> const& context,
|
||||
double scale_factor,
|
||||
unsigned offset_x,
|
||||
unsigned offset_y)
|
||||
: m_(m),
|
||||
context_(context),
|
||||
width_(m.width()),
|
||||
height_(m.height()),
|
||||
scale_factor_(scale_factor),
|
||||
t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y),
|
||||
font_engine_(boost::make_shared<freetype_engine>()),
|
||||
font_manager_(*font_engine_),
|
||||
|
@ -750,16 +757,16 @@ cairo_renderer_base::cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Cont
|
|||
}
|
||||
|
||||
template <>
|
||||
cairo_renderer<Cairo::Context>::cairo_renderer(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, unsigned offset_x, unsigned offset_y)
|
||||
cairo_renderer<Cairo::Context>::cairo_renderer(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, double scale_factor, unsigned offset_x, unsigned offset_y)
|
||||
: feature_style_processor<cairo_renderer>(m),
|
||||
cairo_renderer_base(m,context,offset_x,offset_y)
|
||||
cairo_renderer_base(m,context,scale_factor,offset_x,offset_y)
|
||||
{
|
||||
}
|
||||
|
||||
template <>
|
||||
cairo_renderer<Cairo::Surface>::cairo_renderer(Map const& m, Cairo::RefPtr<Cairo::Surface> const& surface, unsigned offset_x, unsigned offset_y)
|
||||
cairo_renderer<Cairo::Surface>::cairo_renderer(Map const& m, Cairo::RefPtr<Cairo::Surface> const& surface, double scale_factor, unsigned offset_x, unsigned offset_y)
|
||||
: feature_style_processor<cairo_renderer>(m),
|
||||
cairo_renderer_base(m,Cairo::Context::create(surface),offset_x,offset_y)
|
||||
cairo_renderer_base(m,Cairo::Context::create(surface),scale_factor,offset_x,offset_y)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1185,11 +1192,11 @@ void cairo_renderer_base::process(shield_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
shield_symbolizer_helper<face_manager<freetype_engine>,
|
||||
label_collision_detector4> helper(
|
||||
sym, feature, prj_trans,
|
||||
detector_.extent().width(), detector_.extent().height(),
|
||||
1.0 /*scale_factor*/,
|
||||
t_, font_manager_, detector_, query_extent_);
|
||||
label_collision_detector4> helper(
|
||||
sym, feature, prj_trans,
|
||||
width_, height_,
|
||||
1.0 /*scale_factor*/,
|
||||
t_, font_manager_, detector_, query_extent_);
|
||||
cairo_context context(context_);
|
||||
context.set_operator(sym.comp_op());
|
||||
|
||||
|
@ -1462,8 +1469,12 @@ void cairo_renderer_base::process(text_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
text_symbolizer_helper<face_manager<freetype_engine>, label_collision_detector4> helper(sym, feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_, query_extent_);
|
||||
|
||||
text_symbolizer_helper<face_manager<freetype_engine>,
|
||||
label_collision_detector4> helper(
|
||||
sym, feature, prj_trans,
|
||||
width_, height_,
|
||||
1.0 /*scale_factor*/,
|
||||
t_, font_manager_, detector_, query_extent_);
|
||||
cairo_context context(context_);
|
||||
context.set_operator(sym.comp_op());
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ void grid_renderer<T>::process(shield_symbolizer const& sym,
|
|||
sym, feature, prj_trans,
|
||||
width_, height_,
|
||||
scale_factor_,
|
||||
t_, font_manager_, detector_, query_extent);
|
||||
|
||||
t_, font_manager_, detector_,
|
||||
query_extent);
|
||||
bool placement_found = false;
|
||||
|
||||
text_renderer<T> ren(pixmap_,
|
||||
|
|
|
@ -35,7 +35,7 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
|
|||
text_symbolizer_helper<face_manager<freetype_engine>,
|
||||
label_collision_detector4> helper(
|
||||
sym, feature, prj_trans,
|
||||
detector_.extent().width(), detector_.extent().height(),
|
||||
width_, height_,
|
||||
scale_factor_ * (1.0/pixmap_.get_resolution()),
|
||||
t_, font_manager_, detector_,
|
||||
query_extent);
|
||||
|
|
|
@ -88,6 +88,17 @@ boost::optional<composite_mode_e> comp_op_from_string(std::string const& name)
|
|||
return mode;
|
||||
}
|
||||
|
||||
boost::optional<std::string> comp_op_to_string(composite_mode_e comp_op)
|
||||
{
|
||||
boost::optional<std::string> mode;
|
||||
comp_op_lookup_type::left_const_iterator left_iter = comp_lookup.left.find(comp_op);
|
||||
if (left_iter != comp_lookup.left.end())
|
||||
{
|
||||
mode.reset(left_iter->second);
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void composite(T1 & dst, T2 & src, composite_mode_e mode,
|
||||
float opacity,
|
||||
|
|
|
@ -352,18 +352,19 @@ void save_to_file(T const& image, std::string const& filename, rgba_palette cons
|
|||
|
||||
#if defined(HAVE_CAIRO)
|
||||
// TODO - move to separate cairo_io.hpp
|
||||
void save_to_cairo_file(mapnik::Map const& map, std::string const& filename)
|
||||
void save_to_cairo_file(mapnik::Map const& map, std::string const& filename, double scale_factor)
|
||||
{
|
||||
boost::optional<std::string> type = type_from_filename(filename);
|
||||
if (type)
|
||||
{
|
||||
save_to_cairo_file(map,filename,*type);
|
||||
save_to_cairo_file(map,filename,*type,scale_factor);
|
||||
}
|
||||
}
|
||||
|
||||
void save_to_cairo_file(mapnik::Map const& map,
|
||||
std::string const& filename,
|
||||
std::string const& type)
|
||||
std::string const& type,
|
||||
double scale_factor)
|
||||
{
|
||||
std::ofstream file (filename.c_str(), std::ios::out|std::ios::trunc|std::ios::binary);
|
||||
if (file)
|
||||
|
@ -417,7 +418,7 @@ void save_to_cairo_file(mapnik::Map const& map,
|
|||
*/
|
||||
|
||||
|
||||
mapnik::cairo_renderer<Cairo::Context> ren(map, context);
|
||||
mapnik::cairo_renderer<Cairo::Context> ren(map, context, scale_factor);
|
||||
ren.apply();
|
||||
|
||||
if (type == "ARGB32" || type == "RGB24")
|
||||
|
|
|
@ -851,7 +851,7 @@ void map_parser::parse_symbolizer_base(symbolizer_base &sym, xml_node const &pt)
|
|||
if (strict_)
|
||||
throw config_error(ss.str()); // value_error here?
|
||||
else
|
||||
std::clog << "### WARNING: " << ss.str() << endl;
|
||||
MAPNIK_LOG_WARN(load_map) << "### WARNING: " << ss;
|
||||
}
|
||||
sym.set_transform(tl);
|
||||
}
|
||||
|
@ -1263,8 +1263,6 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
|
|||
shield_symbol.set_unlock_image(* unlock_image);
|
||||
}
|
||||
|
||||
parse_symbolizer_base(shield_symbol, sym);
|
||||
|
||||
std::string file = sym.get_attr<std::string>("file");
|
||||
if (file.empty())
|
||||
{
|
||||
|
@ -1289,6 +1287,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
|
|||
throw mapnik::config_error("Failed to parse path_expression '" + file + "'");
|
||||
}
|
||||
shield_symbol.set_filename(expr);
|
||||
parse_symbolizer_base(shield_symbol, sym);
|
||||
rule.append(shield_symbol);
|
||||
}
|
||||
catch (const config_error & ex)
|
||||
|
@ -1392,7 +1391,6 @@ void map_parser::parse_line_symbolizer(rule & rule, xml_node const & sym)
|
|||
line_rasterizer_e rasterizer = sym.get_attr<line_rasterizer_e>("rasterizer", RASTERIZER_FULL);
|
||||
symbol.set_rasterizer(rasterizer);
|
||||
|
||||
// meta-writer
|
||||
parse_symbolizer_base(symbol, sym);
|
||||
rule.append(symbol);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/save_map.hpp>
|
||||
#include <mapnik/map.hpp>
|
||||
#include <mapnik/ptree_helpers.hpp>
|
||||
|
@ -30,6 +31,7 @@
|
|||
#include <mapnik/text_placements/simple.hpp>
|
||||
#include <mapnik/text_placements/list.hpp>
|
||||
#include <mapnik/text_placements/dummy.hpp>
|
||||
#include <mapnik/image_compositing.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
@ -73,7 +75,7 @@ public:
|
|||
{
|
||||
set_attr( sym_node, "placement", sym.get_point_placement() );
|
||||
}
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( line_symbolizer const& sym )
|
||||
|
@ -83,13 +85,13 @@ public:
|
|||
|
||||
const stroke & strk = sym.get_stroke();
|
||||
add_stroke_attributes(sym_node, strk);
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
|
||||
line_symbolizer dfl;
|
||||
if ( sym.get_rasterizer() != dfl.get_rasterizer() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( sym_node, "rasterizer", sym.get_rasterizer() );
|
||||
}
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( line_pattern_symbolizer const& sym )
|
||||
|
@ -99,7 +101,7 @@ public:
|
|||
ptree()))->second;
|
||||
|
||||
add_image_attributes( sym_node, sym );
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( polygon_symbolizer const& sym )
|
||||
|
@ -124,7 +126,7 @@ public:
|
|||
{
|
||||
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
|
||||
}
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( polygon_pattern_symbolizer const& sym )
|
||||
|
@ -147,7 +149,7 @@ public:
|
|||
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
|
||||
}
|
||||
add_image_attributes( sym_node, sym );
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( raster_symbolizer const& sym )
|
||||
|
@ -156,10 +158,11 @@ public:
|
|||
ptree::value_type("RasterSymbolizer", ptree()))->second;
|
||||
raster_symbolizer dfl;
|
||||
|
||||
if ( sym.get_mode() != dfl.get_mode() || explicit_defaults_ )
|
||||
// should be serialized as comp-op now…
|
||||
/*if ( sym.get_mode() != dfl.get_mode() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( sym_node, "mode", sym.get_mode() );
|
||||
}
|
||||
}*/
|
||||
|
||||
if ( sym.get_scaling() != dfl.get_scaling() || explicit_defaults_ )
|
||||
{
|
||||
|
@ -180,7 +183,7 @@ public:
|
|||
serialize_raster_colorizer(sym_node, sym.get_colorizer(),
|
||||
explicit_defaults_);
|
||||
}
|
||||
//Note: raster_symbolizer doesn't support metawriters
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( shield_symbolizer const& sym )
|
||||
|
@ -191,7 +194,6 @@ public:
|
|||
|
||||
add_font_attributes(sym_node, sym);
|
||||
add_image_attributes(sym_node, sym);
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
|
||||
// pseudo-default-construct a shield_symbolizer. It is used
|
||||
// to avoid printing of attributes with default values without
|
||||
|
@ -217,7 +219,7 @@ public:
|
|||
{
|
||||
set_attr(sym_node, "shield-dy", displacement.second);
|
||||
}
|
||||
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( text_symbolizer const& sym )
|
||||
|
@ -227,7 +229,7 @@ public:
|
|||
ptree()))->second;
|
||||
|
||||
add_font_attributes( sym_node, sym);
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( building_symbolizer const& sym )
|
||||
|
@ -249,7 +251,7 @@ public:
|
|||
set_attr( sym_node, "height", mapnik::to_expression_string(*sym.height()) );
|
||||
}
|
||||
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
void operator () ( markers_symbolizer const& sym)
|
||||
|
@ -310,7 +312,7 @@ public:
|
|||
add_stroke_attributes(sym_node, *strk);
|
||||
}
|
||||
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
serialize_symbolizer_base(sym_node, sym);
|
||||
}
|
||||
|
||||
template <typename Symbolizer>
|
||||
|
@ -318,13 +320,41 @@ public:
|
|||
{
|
||||
// not-supported
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << typeid(sym).name() << " is not supported" << std::endl;
|
||||
MAPNIK_LOG_WARN(save_map) << typeid(sym).name() << " is not supported" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
serialize_symbolizer();
|
||||
|
||||
void serialize_symbolizer_base(ptree & node, symbolizer_base const& sym)
|
||||
{
|
||||
symbolizer_base dfl = symbolizer_base();
|
||||
if (!sym.get_metawriter_name().empty() || explicit_defaults_) {
|
||||
set_attr(node, "meta-writer", sym.get_metawriter_name());
|
||||
}
|
||||
if (!sym.get_metawriter_properties_overrides().empty() || explicit_defaults_) {
|
||||
set_attr(node, "meta-output", sym.get_metawriter_properties_overrides().to_string());
|
||||
}
|
||||
if (sym.get_transform())
|
||||
{
|
||||
std::string tr_str = sym.get_transform_string();
|
||||
set_attr( node, "geometry-transform", tr_str );
|
||||
}
|
||||
if (sym.clip() != dfl.clip() || explicit_defaults_)
|
||||
{
|
||||
set_attr( node, "clip", sym.clip() );
|
||||
}
|
||||
if (sym.smooth() != dfl.smooth() || explicit_defaults_)
|
||||
{
|
||||
set_attr( node, "smooth", sym.smooth() );
|
||||
}
|
||||
if (sym.comp_op() != dfl.comp_op() || explicit_defaults_)
|
||||
{
|
||||
set_attr( node, "comp-op", *comp_op_to_string(sym.comp_op()) );
|
||||
}
|
||||
}
|
||||
|
||||
void serialize_raster_colorizer(ptree & sym_node,
|
||||
raster_colorizer_ptr const& colorizer,
|
||||
bool explicit_defaults)
|
||||
|
@ -349,7 +379,7 @@ private:
|
|||
|
||||
}
|
||||
|
||||
void add_image_attributes(ptree & node, const symbolizer_with_image & sym)
|
||||
void add_image_attributes(ptree & node, symbolizer_with_image const& sym)
|
||||
{
|
||||
if (sym.get_filename())
|
||||
{
|
||||
|
@ -439,21 +469,6 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void add_metawriter_attributes(ptree & node, symbolizer_base const& sym)
|
||||
{
|
||||
if (!sym.get_metawriter_name().empty() || explicit_defaults_) {
|
||||
set_attr(node, "meta-writer", sym.get_metawriter_name());
|
||||
}
|
||||
if (!sym.get_metawriter_properties_overrides().empty() || explicit_defaults_) {
|
||||
set_attr(node, "meta-output", sym.get_metawriter_properties_overrides().to_string());
|
||||
}
|
||||
if (sym.get_transform())
|
||||
{
|
||||
std::string tr_str = sym.get_transform_string();
|
||||
set_attr( node, "view-transform", tr_str );
|
||||
}
|
||||
}
|
||||
|
||||
ptree & rule_;
|
||||
bool explicit_defaults_;
|
||||
};
|
||||
|
@ -536,6 +551,16 @@ void serialize_style( ptree & map_node, Map::const_style_iterator style_it, bool
|
|||
set_attr(style_node, "opacity", opacity);
|
||||
}
|
||||
|
||||
boost::optional<composite_mode_e> comp_op = style.comp_op();
|
||||
if (comp_op)
|
||||
{
|
||||
set_attr(style_node, "comp-op", *comp_op_to_string(*comp_op));
|
||||
}
|
||||
else if (explicit_defaults)
|
||||
{
|
||||
set_attr(style_node, "comp-op", "src-over");
|
||||
}
|
||||
|
||||
rules::const_iterator it = style.get_rules().begin();
|
||||
rules::const_iterator end = style.get_rules().end();
|
||||
for (; it != end; ++it)
|
||||
|
|
Loading…
Reference in a new issue