line-style => pattern-image, forceRHR for them

This commit is contained in:
Komzpa 2011-08-25 17:04:58 +03:00
parent 8f329b5d72
commit 93c228bc39
2 changed files with 15 additions and 7 deletions

View file

@ -331,6 +331,7 @@ if options.renderer == "mapnik":
## lines and polygons pass
sql_g = set()
there_are_dashed_lines = False
there_are_line_patterns = False
itags_g = set()
xml_g = ""
for zindex in ta:
@ -348,7 +349,7 @@ if options.renderer == "mapnik":
continue
if "width" in entry["style"] or "line-style" in entry["style"] or (("fill-color" in entry["style"] or "fill-image" in entry["style"]) and layer_type == "polygon"):
if "width" in entry["style"] or "pattern-image" in entry["style"] or (("fill-color" in entry["style"] or "fill-image" in entry["style"]) and layer_type == "polygon"):
xml += xml_rule_start()
xml += x_scale
xml += xml_filter(entry["rulestring"])
@ -367,11 +368,12 @@ if options.renderer == "mapnik":
if entry["style"].get("dashes", ""):
there_are_dashed_lines = True
#print "dashes!!!"
if "line-style" in entry["style"]:
if entry["style"]["line-style"] == "arrows":
if "pattern-image" in entry["style"]:
there_are_line_patterns = True
if entry["style"]["pattern-image"] == "arrows":
xml += xml_hardcoded_arrows()
else:
xml += xml_linepatternsymbolizer(entry["style"]["line-style"])
xml += xml_linepatternsymbolizer(entry["style"]["pattern-image"])
sql.add(entry["sql"])
itags.update(entry["chooser"].get_interesting_tags(entry["type"], zoom))
xml += xml_rule_end()
@ -395,6 +397,12 @@ if options.renderer == "mapnik":
sql = "("+ sql +') and "layer" = \'%s\''%zlayer
oitags = itags
itags = add_numerics_to_itags(itags)
if layer_type == "polygon" and there_are_line_patterns:
itags = ", ".join(itags)
oitags = '"'+ "\", \"".join(oitags) +'"'
sqlz = """SELECT %s, ST_ForceRHR(way) from planet_osm_polygon where (%s) and way && !bbox! and ST_IsValid(way)"""%(itags,sql)
mfile.write(xml_layer("postgis-process", layer_type, itags, sqlz ))
#### FIXME: Performance degrades painfully on large lines ST_Union. Gotta find workaround :(
#if layer_type == "polygon" and there_are_dashed_lines:
@ -409,8 +417,8 @@ if options.renderer == "mapnik":
## group by %s
## """%(itags,sql,oitags)
#mfile.write(xml_layer("postgis-process", layer_type, itags, sqlz ))
#else:
mfile.write(xml_layer("postgis", layer_type, itags, sql ))
else:
mfile.write(xml_layer("postgis", layer_type, itags, sql ))
else:
xml_nolayer()

View file

@ -83,7 +83,7 @@ class StyleChooser:
"""
a = set()
b = ""
needed = set(["width", "casing-width", "fill-color", "fill-image", "icon-image", "text", "extrude", "background-image", "background-color", "line-style"])
needed = set(["width", "casing-width", "fill-color", "fill-image", "icon-image", "text", "extrude", "background-image", "background-color", "pattern-image"])
if not needed.isdisjoint(set(self.styles[0].keys())):
for c in self.ruleChains: