return without rendering if label placement algorithm returns false indicating a degenerate geometry - closes #1423 and refs #1424
This commit is contained in:
parent
ac313cf907
commit
0eff77c03e
6 changed files with 75 additions and 37 deletions
|
@ -78,15 +78,17 @@ struct raster_markers_rasterizer_dispatch_grid
|
|||
box2d<double> bbox_(0,0, src_.width(),src_.height());
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
{
|
||||
double x,y;
|
||||
path.rewind(0);
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
label::interior_position(path, x, y);
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
label::centroid(path, x, y);
|
||||
if (!label::centroid(path, x, y))
|
||||
return;
|
||||
}
|
||||
agg::trans_affine matrix = marker_trans_;
|
||||
matrix.translate(x,y);
|
||||
|
@ -207,15 +209,17 @@ struct vector_markers_rasterizer_dispatch_grid
|
|||
marker_placement_e placement_method = sym_.get_marker_placement();
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
{
|
||||
double x,y;
|
||||
path.rewind(0);
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
label::interior_position(path, x, y);
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
label::centroid(path, x, y);
|
||||
if (!label::centroid(path, x, y))
|
||||
return;
|
||||
}
|
||||
agg::trans_affine matrix = marker_trans_;
|
||||
matrix.translate(x,y);
|
||||
|
|
|
@ -87,15 +87,17 @@ struct vector_markers_rasterizer_dispatch
|
|||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
{
|
||||
double x,y;
|
||||
path.rewind(0);
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
label::interior_position(path, x, y);
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
label::centroid(path, x, y);
|
||||
if (!label::centroid(path, x, y))
|
||||
return;
|
||||
}
|
||||
agg::trans_affine matrix = marker_trans_;
|
||||
matrix.translate(x,y);
|
||||
|
@ -117,7 +119,9 @@ struct vector_markers_rasterizer_dispatch
|
|||
sym_.get_spacing() * scale_factor_,
|
||||
sym_.get_max_error(),
|
||||
sym_.get_allow_overlap());
|
||||
double x, y, angle;
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double angle = 0;
|
||||
while (placement.get_point(x, y, angle))
|
||||
{
|
||||
agg::trans_affine matrix = marker_trans_;
|
||||
|
@ -179,15 +183,17 @@ struct raster_markers_rasterizer_dispatch
|
|||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
{
|
||||
double x,y;
|
||||
path.rewind(0);
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
label::interior_position(path, x, y);
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
label::centroid(path, x, y);
|
||||
if (!label::centroid(path, x, y))
|
||||
return;
|
||||
}
|
||||
agg::trans_affine matrix = marker_trans_;
|
||||
matrix.translate(x,y);
|
||||
|
|
|
@ -77,9 +77,15 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
|
|||
double y;
|
||||
double z=0;
|
||||
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
|
||||
label::centroid(geom, x, y);
|
||||
{
|
||||
if (!label::centroid(geom, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
label::interior_position(geom ,x, y);
|
||||
{
|
||||
if (!label::interior_position(geom ,x, y))
|
||||
return;
|
||||
}
|
||||
|
||||
prj_trans.backward(x,y,z);
|
||||
t_.forward(&x,&y);
|
||||
|
|
|
@ -1203,9 +1203,15 @@ void cairo_renderer_base::process(point_symbolizer const& sym,
|
|||
double z = 0;
|
||||
|
||||
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
|
||||
label::centroid(geom, x, y);
|
||||
{
|
||||
if (!label::centroid(geom, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
label::interior_position(geom, x, y);
|
||||
{
|
||||
if (!label::interior_position(geom ,x, y))
|
||||
return;
|
||||
}
|
||||
|
||||
prj_trans.backward(x, y, z);
|
||||
t_.forward(&x, &y);
|
||||
|
@ -1490,15 +1496,17 @@ struct markers_dispatch
|
|||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
{
|
||||
double x,y;
|
||||
path.rewind(0);
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
label::interior_position(path, x, y);
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
label::centroid(path, x, y);
|
||||
if (!label::centroid(path, x, y))
|
||||
return;
|
||||
}
|
||||
coord2d center = bbox_.center();
|
||||
agg::trans_affine matrix = agg::trans_affine_translation(-center.x, -center.y);
|
||||
|
@ -1571,15 +1579,17 @@ struct markers_dispatch_2
|
|||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
{
|
||||
double x,y;
|
||||
path.rewind(0);
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
label::interior_position(path, x, y);
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
label::centroid(path, x, y);
|
||||
if (!label::centroid(path, x, y))
|
||||
return;
|
||||
}
|
||||
coord2d center = bbox_.center();
|
||||
agg::trans_affine matrix = agg::trans_affine_translation(-center.x, -center.y);
|
||||
|
|
|
@ -81,9 +81,15 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
|
|||
double y;
|
||||
double z=0;
|
||||
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
|
||||
label::centroid(geom, x, y);
|
||||
{
|
||||
if (!label::centroid(geom, x, y))
|
||||
return;
|
||||
}
|
||||
else
|
||||
label::interior_position(geom, x, y);
|
||||
{
|
||||
if (!label::interior_position(geom ,x, y))
|
||||
return;
|
||||
}
|
||||
|
||||
prj_trans.backward(x,y,z);
|
||||
t_.forward(&x,&y);
|
||||
|
|
|
@ -233,27 +233,33 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_points()
|
|||
}
|
||||
else
|
||||
{
|
||||
// https://github.com/mapnik/mapnik/issues/1423
|
||||
bool success = false;
|
||||
// https://github.com/mapnik/mapnik/issues/1350
|
||||
if (geom.type() == LineString)
|
||||
{
|
||||
label::middle_point(geom, label_x,label_y);
|
||||
success = label::middle_point(geom, label_x,label_y);
|
||||
}
|
||||
else if (how_placed == POINT_PLACEMENT)
|
||||
{
|
||||
label::centroid(geom, label_x, label_y);
|
||||
success = label::centroid(geom, label_x, label_y);
|
||||
}
|
||||
else if (how_placed == INTERIOR_PLACEMENT)
|
||||
{
|
||||
label::interior_position(geom, label_x, label_y);
|
||||
success = label::interior_position(geom, label_x, label_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAPNIK_LOG_ERROR(symbolizer_helpers) << "ERROR: Unknown placement type in initialize_points()";
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
prj_trans_.backward(label_x, label_y, z);
|
||||
t_.forward(&label_x, &label_y);
|
||||
points_.push_back(std::make_pair(label_x, label_y));
|
||||
}
|
||||
}
|
||||
}
|
||||
point_itr_ = points_.begin();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue