From 501d6a9da7f95095093fbded72af2741f0b75967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kom=D1=8Fpa?= Date: Sun, 2 May 2010 15:58:45 +0300 Subject: [PATCH] Better styling. - added bridges --- src/kothic.py | 19 ++++++++++++++++--- src/style.py | 12 ++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/kothic.py b/src/kothic.py index cbefb38..10d1619 100644 --- a/src/kothic.py +++ b/src/kothic.py @@ -225,7 +225,17 @@ def poly(cr, c): for k in range(2, len(c), 2): cr.line_to(c[k], c[k + 1]) cr.fill() - +class Color: + def __init__(self): + self.colortable = {} + def translate(self, col): + try: + return self.colortable[col] + except KeyError: + colz = gtk.gdk.Color(col) + self.colortable[col] = (colz.red/65536., colz.green/65536., colz.blue/65536.) + return self.colortable[col] +color_tool = Color() class RasterTile: @@ -298,9 +308,12 @@ class RasterTile: for obj in data: #debug(obj[1]) if "fill-color" in obj[1]: + #color = color_tool.translate(obj[1]["fill-color"]) color = gtk.gdk.Color(obj[1]["fill-color"]) - cr.set_source_rgb(color.red, color.green, color.blue) - cr.set_line_width (0) + #debug((color.red/65536., color.green/65536., color.blue/65536.)) + cr.set_source_rgb(color.red/65535., color.green/65535., color.blue/65535.) + #cr.set_source_rgb(color[0], color[1], color[2]) + cr.set_line_width (1) #debug("poly!") poly(cr, obj[0].cs) # - draw casings on layer diff --git a/src/style.py b/src/style.py index d2eafeb..1724ebb 100644 --- a/src/style.py +++ b/src/style.py @@ -31,8 +31,16 @@ class Styling(): self.Selectors["relation"] = [] if not stylefile: ### using "builtin" styling - self.Selectors["way"].append(StyleSelector( ( [ ( ("highway",),("residential", "tertiary", "living_street")) ] ),{"width": 3, "color":"#ffffff", "casing-width": 5, "z-index":100} )) - self.Selectors["way"].append(StyleSelector( ( [ ( ("building",),(None) ) ] ),{"fill-color":"#ff0000"} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("highway",),(None) ) ] ),{"width":1,"color":"#ff0000"} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("highway",),("residential", "tertiary", "living_street")) ] ),{"width": 3, "color":"#ffffff", "casing-width": 5, "z-index":10} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("highway",),("service", "unclassified")) ] ),{"width": 3, "color":"#ccc", "casing-width": 5, "z-index":9} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("highway",),("primary", "motorway", "trunk")) ] ),{"width": 4, "color":"#ff0", "casing-width": 6, "z-index":11} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("highway",),("primary_link", "motorway_link", "trunk_link")) ] ),{"width": 3.5, "color":"#ff0", "casing-width": 6, "z-index":11} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("living_street",),("yes")) ] ),{"width": 2, "casing-width": 3, "z-index": 0} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("landuse","natural"),("forest", "wood") ) ] ),{"fill-color": "#3e3"} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("bridge",),("yes") ) ] ),{"casing-width":10,"z-index": 100} )) + self.Selectors["way"].append(StyleSelector( ( [ ( ("building",),(None) ) ] ),{"fill-color": "#522"} )) + self.stylefile = stylefile self.useful_keys = set() for objtype in self.Selectors.values(): # getting useful keys