Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
2 parents 0458928 + 7499013 commit 8598202f8f05e42ea6667a32263e41493d968729 @artemp artemp committed Jul 6, 2012
View
@@ -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']))
View
@@ -43,15 +43,7 @@ def is_py3():
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 @@ class cairo_face_manager : private boost::noncopyable
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 @@ class MAPNIK_DECL cairo_renderer_base : private boost::noncopyable
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 @@ class ImageWriterException : public std::exception
#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_,
View
@@ -737,9 +737,16 @@ class cairo_context : private boost::noncopyable
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);
View
@@ -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,
View
@@ -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")
Oops, something went wrong.

0 comments on commit 8598202

Please sign in to comment.