Permalink
Browse files

Add TextSymbolizer.name in python bindings.

Refs #1482.
  • Loading branch information...
1 parent 2ded866 commit d181313e90c317c97c9c07f4e60ee7b5f294742a @herm herm committed Sep 13, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 bindings/python/mapnik/__init__.py
@@ -699,6 +699,18 @@ def make_it(feat, idx):
class _TextSymbolizer(TextSymbolizer,_injector):
@property
+ def name(self):
+ if isinstance(self.properties.format_tree, FormattingText):
+ return self.properties.format_tree.text
+ else:
+ return None # This text symbolizer is using complex formatting features.
@springmeyer
springmeyer Sep 14, 2012 Member

shouldn't it return the first if there is one and throw if there are many?

@herm
herm Sep 14, 2012 Member

That's a better idea. What's your opinion: Should I throw one of the already defined exception classes or should I define a new one?

@springmeyer
springmeyer Sep 14, 2012 Member

std::runtime error would be better than a custom one. But, why not just return the list of all formatters?

@herm
herm Sep 15, 2012 Member

Because different return types would be confusing and probably useless. People who need the new formatting code must use the new interface. This is intended for backwards compatibility.

@springmeyer
springmeyer Sep 15, 2012 Member

okay. now can you please add tests back for text.name? I assume they were commented or removed in tests/python/*

+ # There is no single expression which could be returned as name
+
+ @name.setter
+ def name(self, name):
+ self.properties.format_tree = FormattingText(name)
+
+ @property
def text_size(self):
warnings.warn("'text_size' is deprecated, use format.text_size",
DeprecationWarning, 2)

0 comments on commit d181313

Please sign in to comment.