Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Text Symbolizer and checking label_placement #127

Open
millapet opened this issue Sep 3, 2019 · 0 comments
Open

C++ Text Symbolizer and checking label_placement #127

millapet opened this issue Sep 3, 2019 · 0 comments

Comments

@millapet
Copy link

millapet commented Sep 3, 2019

Hi!
I am trying to print out the set values of various symbolizers and am having a hard time with getting enum as string from the TextSymbolizer. I would appreciate a nudge in the right direction as I have read through the mapnik code but I think I still don't fully understand this.

When I try getting a value that has previously been set in TextSymbolizer and label_placement, the resulting enum is always the default one (point), no matter to what I set it beforehand.
Setting it up:

text_symbolizer text_sym;
text_placements_ptr placement_finder = std::make_shared<text_placements_dummy>();
placement_finder->defaults.format_defaults.face_name = "DejaVu Sans Book";
placement_finder->defaults.format_defaults.text_size = 24;
mapnik::label_placement_e e;
e.from_string("line");
placement_finder->defaults.expressions.label_placement = enumeration_wrapper(e);
mapnik::put<text_placements_ptr>(text_sym, keys::text_placements_, placement_finder);

Trying to get the set value back:

mapnik::label_placement_e plc = mapnik::get<mapnik::label_placement_enum>(text_sym, mapnik::keys::label_placement);
std::cout << plc.as_string() << std::endl;

The above code prints "point", even though I have set the value to "line" before. I assume the value is set correctly, since it renders the correct placement in the output file.

I also tried getting the value through the text_placements_ptr, but I am not sure how to convert the symbolizer_base::value_type into anything useful.

I had no trouble getting and printing the enum from MarkersSymbolizer like so :

markers_symbolizer is;
mapnik::marker_placement_e plc = mapnik::get<mapnik::marker_placement_enum>(is, mapnik::keys::markers_placement_type); 
std::cout<< plc.as_string() << std::endl;

Any help with this would be much appreciated, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant