Improve padding calculation
This commit is contained in:
parent
dbcd1b5fef
commit
fd961048ea
7 changed files with 32 additions and 51 deletions
|
@ -40,6 +40,8 @@
|
|||
namespace mapnik
|
||||
{
|
||||
|
||||
static constexpr double offset_converter_default_threshold = 5.0;
|
||||
|
||||
template <typename Geometry>
|
||||
struct offset_converter
|
||||
{
|
||||
|
@ -48,7 +50,7 @@ struct offset_converter
|
|||
offset_converter(Geometry & geom)
|
||||
: geom_(geom)
|
||||
, offset_(0.0)
|
||||
, threshold_(5.0)
|
||||
, threshold_(offset_converter_default_threshold)
|
||||
, half_turn_segments_(16)
|
||||
, status_(initial)
|
||||
, pre_first_(vertex2d::no_init)
|
||||
|
|
|
@ -134,12 +134,11 @@ private:
|
|||
box2d<double> clip_box = clipping_extent(common_);
|
||||
if (clip)
|
||||
{
|
||||
double padding = (double)(common_.query_extent_.width()/pixmap_.width());
|
||||
if (half_stroke > 1)
|
||||
padding *= half_stroke;
|
||||
if (std::fabs(offset) > 0)
|
||||
padding *= std::fabs(offset) * 1.2;
|
||||
padding *= common_.scale_factor_;
|
||||
double pad_per_pixel = static_cast<double>(common_.query_extent_.width()/common_.width_);
|
||||
double pixels = std::ceil(std::max(width / 2.0 + std::fabs(offset),
|
||||
(std::fabs(offset) * offset_converter_default_threshold)));
|
||||
double padding = pad_per_pixel * pixels * common_.scale_factor_;
|
||||
|
||||
clip_box.pad(padding);
|
||||
}
|
||||
using vertex_converter_type = vertex_converter<clip_line_tag, transform_tag,
|
||||
|
|
|
@ -139,23 +139,11 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
|
|||
line_rasterizer_enum rasterizer_e = get<line_rasterizer_enum, keys::line_rasterizer>(sym, feature, common_.vars_);
|
||||
if (clip)
|
||||
{
|
||||
double padding = static_cast<double>(common_.query_extent_.width()/pixmap_.width());
|
||||
double half_stroke = 0.5 * width;
|
||||
if (half_stroke > 1)
|
||||
{
|
||||
padding *= half_stroke;
|
||||
}
|
||||
if (std::fabs(offset) > 0)
|
||||
{
|
||||
padding *= std::fabs(offset) * 1.2;
|
||||
}
|
||||
|
||||
padding *= common_.scale_factor_;
|
||||
double pad_per_pixel = static_cast<double>(common_.query_extent_.width()/common_.width_);
|
||||
double pixels = std::ceil(std::max(width / 2.0 + std::fabs(offset),
|
||||
(std::fabs(offset) * offset_converter_default_threshold)));
|
||||
double padding = pad_per_pixel * pixels * common_.scale_factor_;
|
||||
clip_box.pad(padding);
|
||||
// debugging
|
||||
//box2d<double> inverse = query_extent_;
|
||||
//inverse.pad(-padding);
|
||||
//draw_geo_extent(inverse,mapnik::color("red"));
|
||||
}
|
||||
|
||||
if (rasterizer_e == RASTERIZER_FAST)
|
||||
|
|
|
@ -131,13 +131,11 @@ void cairo_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
box2d<double> clipping_extent = common_.query_extent_;
|
||||
if (clip)
|
||||
{
|
||||
double padding = (double)(common_.query_extent_.width()/common_.width_);
|
||||
double half_stroke = width/2.0;
|
||||
if (half_stroke > 1)
|
||||
padding *= half_stroke;
|
||||
if (std::fabs(offset) > 0)
|
||||
padding *= std::fabs(offset) * 1.2;
|
||||
padding *= common_.scale_factor_;
|
||||
double pad_per_pixel = static_cast<double>(common_.query_extent_.width()/common_.width_);
|
||||
double pixels = std::ceil(std::max(width / 2.0 + std::fabs(offset),
|
||||
(std::fabs(offset) * offset_converter_default_threshold)));
|
||||
double padding = pad_per_pixel * pixels * common_.scale_factor_;
|
||||
|
||||
clipping_extent.pad(padding);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,13 +73,11 @@ void cairo_renderer<T>::process(line_symbolizer const& sym,
|
|||
box2d<double> clipping_extent = common_.query_extent_;
|
||||
if (clip)
|
||||
{
|
||||
double padding = (double)(common_.query_extent_.width()/common_.width_);
|
||||
double half_stroke = width/2.0;
|
||||
if (half_stroke > 1)
|
||||
padding *= half_stroke;
|
||||
if (std::fabs(offset) > 0)
|
||||
padding *= std::fabs(offset) * 1.2;
|
||||
padding *= common_.scale_factor_;
|
||||
double pad_per_pixel = static_cast<double>(common_.query_extent_.width()/common_.width_);
|
||||
double pixels = std::ceil(std::max(width / 2.0 + std::fabs(offset),
|
||||
(std::fabs(offset) * offset_converter_default_threshold)));
|
||||
double padding = pad_per_pixel * pixels * common_.scale_factor_;
|
||||
|
||||
clipping_extent.pad(padding);
|
||||
}
|
||||
using vertex_converter_type = vertex_converter<clip_line_tag,
|
||||
|
|
|
@ -97,13 +97,11 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
box2d<double> clipping_extent = common_.query_extent_;
|
||||
if (clip)
|
||||
{
|
||||
double padding = (double)(common_.query_extent_.width()/pixmap_.width());
|
||||
double half_stroke = stroke_width/2.0;
|
||||
if (half_stroke > 1)
|
||||
padding *= half_stroke;
|
||||
if (std::fabs(offset) > 0)
|
||||
padding *= std::fabs(offset) * 1.2;
|
||||
padding *= common_.scale_factor_;
|
||||
double pad_per_pixel = static_cast<double>(common_.query_extent_.width()/common_.width_);
|
||||
double pixels = std::ceil(std::max(stroke_width / 2.0 + std::fabs(offset),
|
||||
(std::fabs(offset) * offset_converter_default_threshold)));
|
||||
double padding = pad_per_pixel * pixels * common_.scale_factor_;
|
||||
|
||||
clipping_extent.pad(padding);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,13 +84,11 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
|
|||
|
||||
if (clip)
|
||||
{
|
||||
double padding = (double)(common_.query_extent_.width()/pixmap_.width());
|
||||
double half_stroke = width/2.0;
|
||||
if (half_stroke > 1)
|
||||
padding *= half_stroke;
|
||||
if (std::fabs(offset) > 0)
|
||||
padding *= std::fabs(offset) * 1.2;
|
||||
padding *= common_.scale_factor_;
|
||||
double pad_per_pixel = static_cast<double>(common_.query_extent_.width()/common_.width_);
|
||||
double pixels = std::ceil(std::max(width / 2.0 + std::fabs(offset),
|
||||
(std::fabs(offset) * offset_converter_default_threshold)));
|
||||
double padding = pad_per_pixel * pixels * common_.scale_factor_;
|
||||
|
||||
clipping_extent.pad(padding);
|
||||
}
|
||||
using vertex_converter_type = vertex_converter<clip_line_tag, clip_poly_tag, transform_tag,
|
||||
|
|
Loading…
Reference in a new issue