From aa34157b36d2fb389a51400698689e4b5b71d598 Mon Sep 17 00:00:00 2001 From: Komzpa Date: Sat, 30 Jul 2011 19:43:09 +0300 Subject: [PATCH] Text-positions and multiple sizes for label --- src/komap.py | 3 ++- src/libkomapnik.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/komap.py b/src/komap.py index 54968c5..0dfa621 100644 --- a/src/komap.py +++ b/src/komap.py @@ -470,6 +470,7 @@ if options.renderer == "mapnik": twrap= entry["style"].get("max-width",256) talign= entry["style"].get("text-align","center") topacity= entry["style"].get("text-opacity",entry["style"].get("opacity","1")) + tpos = entry["style"].get("text-placement","X") xml += xml_rule_start() xml += x_scale @@ -483,7 +484,7 @@ if options.renderer == "mapnik": ttext,tface,tsize,tcolor, thcolor, thradius, tplace, toffset,toverlap,tdistance,twrap,talign,topacity) else: - xml += xml_textsymbolizer(ttext,tface,tsize,tcolor, thcolor, thradius, tplace, toffset,toverlap,tdistance,twrap,talign,topacity) + xml += xml_textsymbolizer(ttext,tface,tsize,tcolor, thcolor, thradius, tplace, toffset,toverlap,tdistance,twrap,talign,topacity,tpos) sql.add(entry["sql"]) itags.update(entry["chooser"].get_interesting_tags(entry["type"], zoom)) xml += xml_rule_end() diff --git a/src/libkomapnik.py b/src/libkomapnik.py index 67ee304..83883d6 100644 --- a/src/libkomapnik.py +++ b/src/libkomapnik.py @@ -120,31 +120,31 @@ def xml_linepatternsymbolizer(path=""): """%(icons_path, path) -def xml_textsymbolizer(text="name",face="DejaVu Sans Book",size="10",color="#000000", halo_color="#ffffff", halo_radius="0", placement="line", offset="0", overlap="false", distance="26", wrap_width=256, align="center", opacity="1"): +def xml_textsymbolizer(text="name",face="DejaVu Sans Book",size="10",color="#000000", halo_color="#ffffff", halo_radius="0", placement="line", offset="0", overlap="false", distance="26", wrap_width=256, align="center", opacity="1", pos="X"): color = nicecolor(color) halo_color = nicecolor(halo_color) + pos = pos.replace("exact", "X").replace("any","X, S, E, N, W, NE, SE, NW, SW").split(",") + pos.extend(size.split(",")) + pos = ",".join(pos) + size = size.split(",")[0] + placement = {"center": "point"}.get(placement.lower(), placement) align = {"center": "middle"}.get(align.lower(), align) return """ - - """%(text,face,int(float(size)),color,halo_color,halo_radius,placement,offset,overlap,wrap_width,distance,align,opacity) + + """%(text,face,int(float(size)),color,halo_color,halo_radius,placement,offset,overlap,wrap_width,distance,align,opacity,pos) def xml_shieldsymbolizer(path="", width="", height="",text="name",face="DejaVu Sans Book",size="10",color="#000000", halo_color="#ffffff", halo_radius="0", placement="line", offset="0", overlap="false", distance="26", wrap_width=256, align="center", opacity="1"): - color = nicecolor(color) halo_color = nicecolor(halo_color) placement = {"center": "point"}.get(placement.lower(), placement) align = {"center": "middle"}.get(align.lower(), align) + size = size.split(",")[0] if width: width =' width="%s" '%width if height: height =' height="%s" '%height - vertical_alignment = "middle" - if float(offset) > 0: - vertical_alignment = "bottom" - if float(offset) < 0: - vertical_alignment = "top" return """ """%(icons_path, \