implement 'avoid-adges' for markers placements (point placement)
(TODO: support all placement types)
This commit is contained in:
parent
3cb047fc5c
commit
2727eddf90
7 changed files with 23 additions and 8 deletions
|
@ -80,10 +80,11 @@ struct raster_markers_rasterizer_dispatch_grid : mapnik::noncopyable
|
|||
marker_placement_enum placement_method = get<marker_placement_enum>(sym_, keys::markers_placement_type, feature_, vars_, MARKER_POINT_PLACEMENT);
|
||||
bool ignore_placement = get<bool>(sym_, keys::ignore_placement, feature_, vars_, false);
|
||||
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
|
||||
bool avoid_edges = get<bool>(sym_, keys::avoid_edges, feature_, vars_, false);
|
||||
box2d<double> bbox(0,0, src_.width(), src_.height());
|
||||
double spacing = get<double>(sym_, keys::spacing, feature_, vars_, 100.0);
|
||||
double max_error = get<double>(sym_, keys::max_error, feature_, vars_, 0.2);
|
||||
markers_placement_params params { bbox, marker_trans_, spacing * scale_factor_, max_error, allow_overlap };
|
||||
markers_placement_params params { bbox, marker_trans_, spacing * scale_factor_, max_error, allow_overlap, avoid_edges };
|
||||
markers_placement_finder<T, label_collision_detector4> placement_finder(
|
||||
placement_method, path, detector_, params);
|
||||
double x, y, angle = .0;
|
||||
|
@ -190,11 +191,12 @@ struct vector_markers_rasterizer_dispatch_grid : mapnik::noncopyable
|
|||
bool ignore_placement = get<bool>(sym_, keys::ignore_placement, feature_, vars_, false);
|
||||
double opacity = get<double>(sym_,keys::opacity, feature_, vars_, 1.0);
|
||||
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
|
||||
bool avoid_edges = get<bool>(sym_, keys::avoid_edges, feature_, vars_, false);
|
||||
coord2d center = bbox_.center();
|
||||
agg::trans_affine_translation recenter(-center.x, -center.y);
|
||||
double spacing = get<double>(sym_, keys::spacing, feature_, vars_, 100.0);
|
||||
double max_error = get<double>(sym_, keys::max_error, feature_, vars_, 0.2);
|
||||
markers_placement_params params { bbox_, marker_trans_, spacing * scale_factor_, max_error, allow_overlap };
|
||||
markers_placement_params params { bbox_, marker_trans_, spacing * scale_factor_, max_error, allow_overlap, avoid_edges };
|
||||
markers_placement_finder<T, Detector> placement_finder(
|
||||
placement_method, path, detector_, params);
|
||||
double x, y, angle = .0;
|
||||
|
|
|
@ -111,13 +111,14 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable
|
|||
marker_placement_enum placement_method = get<marker_placement_enum>(sym_, keys::markers_placement_type, feature_, vars_, MARKER_POINT_PLACEMENT);
|
||||
bool ignore_placement = get<bool>(sym_, keys::ignore_placement, feature_, vars_, false);
|
||||
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
|
||||
bool avoid_edges = get<bool>(sym_, keys::avoid_edges, feature_, vars_, false);
|
||||
double opacity = get<double>(sym_,keys::opacity, feature_, vars_, 1.0);
|
||||
double spacing = get<double>(sym_, keys::spacing, feature_, vars_, 100.0);
|
||||
double max_error = get<double>(sym_, keys::max_error, feature_, vars_, 0.2);
|
||||
coord2d center = bbox_.center();
|
||||
agg::trans_affine_translation recenter(-center.x, -center.y);
|
||||
agg::trans_affine tr = recenter * marker_trans_;
|
||||
markers_placement_params params { bbox_, tr, spacing * scale_factor_, max_error, allow_overlap };
|
||||
markers_placement_params params { bbox_, tr, spacing * scale_factor_, max_error, allow_overlap, avoid_edges };
|
||||
markers_placement_finder<T, Detector> placement_finder(
|
||||
placement_method, path, detector_, params);
|
||||
double x, y, angle = .0;
|
||||
|
@ -195,12 +196,13 @@ struct raster_markers_rasterizer_dispatch : mapnik::noncopyable
|
|||
{
|
||||
marker_placement_enum placement_method = get<marker_placement_enum>(sym_, keys::markers_placement_type, feature_, vars_, MARKER_POINT_PLACEMENT);
|
||||
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
|
||||
bool avoid_edges = get<bool>(sym_, keys::avoid_edges, feature_, vars_, false);
|
||||
box2d<double> bbox_(0,0, src_.width(),src_.height());
|
||||
double opacity = get<double>(sym_, keys::opacity, feature_, vars_, 1.0);
|
||||
bool ignore_placement = get<bool>(sym_, keys::ignore_placement, feature_, vars_, false);
|
||||
double spacing = get<double>(sym_, keys::spacing, feature_, vars_, 100.0);
|
||||
double max_error = get<double>(sym_, keys::max_error, feature_, vars_, 0.2);
|
||||
markers_placement_params params { bbox_, marker_trans_, spacing * scale_factor_, max_error, allow_overlap };
|
||||
markers_placement_params params { bbox_, marker_trans_, spacing * scale_factor_, max_error, allow_overlap, avoid_edges };
|
||||
markers_placement_finder<T, label_collision_detector4> placement_finder(
|
||||
placement_method, path, detector_, params);
|
||||
double x, y, angle = .0;
|
||||
|
|
|
@ -37,6 +37,7 @@ struct markers_placement_params
|
|||
double spacing;
|
||||
double max_error;
|
||||
bool allow_overlap;
|
||||
bool avoid_edges;
|
||||
};
|
||||
|
||||
template <typename Locator, typename Detector>
|
||||
|
@ -87,6 +88,10 @@ public:
|
|||
angle = 0;
|
||||
box2d<double> box = perform_transform(angle, x, y);
|
||||
|
||||
if (params_.avoid_edges && !detector_.extent().contains(box))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!params_.allow_overlap && !detector_.has_placement(box))
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -90,6 +90,7 @@ enum class keys : std::uint8_t
|
|||
justify_alignment,
|
||||
vertical_alignment,
|
||||
upright,
|
||||
avoid_edges,
|
||||
MAX_SYMBOLIZER_KEY
|
||||
};
|
||||
|
||||
|
|
|
@ -81,13 +81,14 @@ struct markers_dispatch : mapnik::noncopyable
|
|||
sym_, keys::markers_placement_type, feature_, vars_, MARKER_POINT_PLACEMENT);
|
||||
bool ignore_placement = get<bool>(sym_, keys::ignore_placement, feature_, vars_, false);
|
||||
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
|
||||
bool avoid_edges = get<bool>(sym_, keys::avoid_edges, feature_, vars_, false);
|
||||
double opacity = get<double>(sym_, keys::opacity, feature_, vars_, 1.0);
|
||||
double spacing = get<double>(sym_, keys::spacing, feature_, vars_, 100.0);
|
||||
double max_error = get<double>(sym_, keys::max_error, feature_, vars_, 0.2);
|
||||
coord2d center = bbox_.center();
|
||||
agg::trans_affine_translation recenter(-center.x, -center.y);
|
||||
agg::trans_affine tr = recenter * marker_trans_;
|
||||
markers_placement_params params { bbox_, tr, spacing * scale_factor_, max_error, allow_overlap };
|
||||
markers_placement_params params { bbox_, tr, spacing * scale_factor_, max_error, allow_overlap, avoid_edges };
|
||||
markers_placement_finder<T, label_collision_detector4> placement_finder(
|
||||
placement_method, path, detector_, params);
|
||||
double x, y, angle = .0;
|
||||
|
@ -148,9 +149,10 @@ struct raster_markers_dispatch : mapnik::noncopyable
|
|||
double spacing = get<double>(sym_, keys::spacing, feature_, vars_, 100.0);
|
||||
double max_error = get<double>(sym_, keys::max_error, feature_, vars_, 0.2);
|
||||
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
|
||||
bool avoid_edges = get<bool>(sym_, keys::avoid_edges, feature_, vars_, false);
|
||||
bool ignore_placement = get<bool>(sym_, keys::ignore_placement, feature_, vars_, false);
|
||||
box2d<double> bbox_(0,0, src_.width(),src_.height());
|
||||
markers_placement_params params { bbox_, marker_trans_, spacing * scale_factor_, max_error, allow_overlap };
|
||||
markers_placement_params params { bbox_, marker_trans_, spacing * scale_factor_, max_error, allow_overlap, avoid_edges };
|
||||
markers_placement_finder<T, label_collision_detector4> placement_finder(
|
||||
placement_method, path, detector_, params);
|
||||
double x, y, angle = .0;
|
||||
|
|
|
@ -957,6 +957,8 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& node)
|
|||
set_symbolizer_property<markers_symbolizer,double>(sym, keys::max_error, node);
|
||||
// allow-overlap
|
||||
set_symbolizer_property<markers_symbolizer,boolean_type>(sym, keys::allow_overlap, node);
|
||||
// avoid-edges
|
||||
set_symbolizer_property<markers_symbolizer,boolean_type>(sym, keys::avoid_edges, node);
|
||||
// ignore-placement
|
||||
set_symbolizer_property<markers_symbolizer,boolean_type>(sym, keys::ignore_placement, node);
|
||||
// width
|
||||
|
|
|
@ -116,7 +116,8 @@ static const property_meta_type key_meta[const_max_key] =
|
|||
property_types::target_vertical_alignment},
|
||||
property_meta_type{ "upright", enumeration_wrapper(UPRIGHT_AUTO), [](enumeration_wrapper e)
|
||||
{return enumeration<text_upright_enum,text_upright_enum_MAX>(text_upright_enum(e.value)).as_string();},
|
||||
property_types::target_upright}
|
||||
property_types::target_upright},
|
||||
property_meta_type{ "avoid-edges",false, nullptr, property_types::target_bool },
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue