Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1291 from mapnik/non-buffered-avoid-edged-check

Non buffered placement dimensions for consistent avoid edged checking (#1283 and #1287)
  • Loading branch information...
commit 6915d3fea525b33e56647af09b978565946c759b 2 parents 44769de + 9dd69d0
@springmeyer springmeyer authored
View
12 bindings/python/mapnik_python.cpp
@@ -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
View
2  demo/viewer/mapwidget.cpp
@@ -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);
View
7 include/mapnik/cairo_renderer.hpp
@@ -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);
};
}
View
3  include/mapnik/image_util.hpp
@@ -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>
View
5 src/agg/process_shield_symbolizer.cpp
@@ -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_,
View
5 src/agg/process_text_symbolizer.cpp
@@ -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
35 src/cairo_renderer.cpp
@@ -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());
View
4 src/grid/process_shield_symbolizer.cpp
@@ -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_,
View
2  src/grid/process_text_symbolizer.cpp
@@ -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
9 src/image_util.cpp
@@ -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")
Please sign in to comment.
Something went wrong with that request. Please try again.