Beispiel #1
0
bool placement_finder::next_position()
{
    if (info_.next())
    {
        // parent layout, has top-level ownership of a new evaluated_format_properties_ptr (TODO is this good enough to stay in scope???)
        // but does not take ownership of the text_symbolizer_properties (info_.properties)
        text_layout_ptr layout = std::make_shared<text_layout>(font_manager_,
                                                               feature_,
                                                               attr_,
                                                               scale_factor_,
                                                               info_.properties,
                                                               info_.properties.layout_defaults,
                                                               info_.properties.format_tree());
        // ensure layouts stay in scope after layouts_.clear()
        processed_layouts_.emplace_back(layout);
        // TODO: why is this call needed?
        // https://github.com/mapnik/mapnik/issues/2525
        text_props_ = evaluate_text_properties(info_.properties,feature_,attr_);
        // Note: this clear call is needed when multiple placements are tried
        // like with placement-type="simple|list"
        if (!layouts_.empty()) layouts_.clear();
        // Note: multiple layouts_ may result from this add() call
        layouts_.add(layout);
        layouts_.layout();
        // cache a few values for use elsewhere in placement finder
        move_dx_ = layout->displacement().x;
        horizontal_alignment_ = layout->horizontal_alignment();
        return true;
    }
    return false;
}
text_layout_generator::text_layout_generator(
    params_type const & params,
    detector_type & detector,
    face_manager_freetype & font_manager,
    text_placement_info & info)
    : params_(params),
      font_manager_(font_manager),
      info_(info),
      text_props_(evaluate_text_properties(
        info.properties, params.feature, params.vars)),
      detector_(detector)
{
}
Beispiel #3
0
placement_finder::placement_finder(feature_impl const& feature,
                                   attributes const& attr,
                                   DetectorType &detector,
                                   box2d<double> const& extent,
                                   text_placement_info const& placement_info,
                                   face_manager_freetype & font_manager,
                                   double scale_factor)
    : feature_(feature),
      attr_(attr),
      detector_(detector),
      extent_(extent),
      info_(placement_info),
      text_props_(evaluate_text_properties(info_.properties,feature_,attr_)),
      scale_factor_(scale_factor),
      font_manager_(font_manager),
      placements_(),
      has_marker_(false),
      marker_(),
      marker_box_() {}
bool text_layout_generator::next()
{
    if (!info_.next())
    {
        return false;
    }
    text_props_ = evaluate_text_properties(
        info_.properties, params_.feature, params_.vars);
    layouts_ = std::make_unique<layout_container>(
        std::move(std::make_unique<text_layout>(
            font_manager_,
            params_.feature,
            params_.vars,
            params_.scale_factor,
            info_.properties,
            info_.properties.layout_defaults,
            info_.properties.format_tree())));
    return true;
}
Beispiel #5
0
bool placement_finder::next_position()
{
    if (info_.next())
    {
        text_layout_ptr layout = std::make_shared<text_layout>(font_manager_, scale_factor_, info_.properties.layout_defaults);
        layout->evaluate_properties(feature_, attr_);
        move_dx_ = layout->displacement().x;
        // TODO: this call is needed (text-bug1533) ??
        // https://github.com/mapnik/mapnik/issues/2525
        text_props_ = evaluate_text_properties(info_.properties,feature_,attr_);
        info_.properties.process(*layout, feature_, attr_);
        // Note: this clear call is needed when multiple placements are tried
        // like with placement-type="simple|list"
        if (!layouts_.empty()) layouts_.clear();
        // Note: multiple layouts_ may result from this add() call
        layouts_.add(layout);
        layouts_.layout();
        horizontal_alignment_ = layout->horizontal_alignment();
        return true;
    }
    MAPNIK_LOG_WARN(placement_finder) << "next_position() called while last call already returned false!\n";
    return false;
}
Beispiel #6
0
base_symbolizer_helper::base_symbolizer_helper(
        symbolizer_base const& sym,
        feature_impl const& feature,
        attributes const& vars,
        proj_transform const& prj_trans,
        unsigned width, unsigned height, double scale_factor,
        view_transform const& t,
        box2d<double> const& query_extent)
    : sym_(sym),
      feature_(feature),
      vars_(vars),
      prj_trans_(prj_trans),
      t_(t),
      dims_(0, 0, width, height),
      query_extent_(query_extent),
      scale_factor_(scale_factor),
      placement_(get<text_placements_ptr>(sym_, keys::text_placements_)->get_placement_info(scale_factor)),
      text_props_(evaluate_text_properties(placement_->properties,feature_,vars_))
{
    initialize_geometries();
    if (!geometries_to_process_.size()) return; // FIXME - bad practise
    initialize_points();
}