From 2f9bab63730921392ee768e99b5805603533b9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kom=D1=8Fpa?= Date: Fri, 16 Jul 2010 13:59:52 +0300 Subject: [PATCH] Fixed maximal zoom level issue --- src/mapcss/StyleChooser.py | 8 +++++--- src/mapcss/__init__.py | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/mapcss/StyleChooser.py b/src/mapcss/StyleChooser.py index c25a435..7ad86e7 100644 --- a/src/mapcss/StyleChooser.py +++ b/src/mapcss/StyleChooser.py @@ -40,11 +40,12 @@ class StyleChooser: """ def __repr__(self): return "{(%s) : [%s] }\n"%(self.ruleChains, self.styles) - def __init__(self): + def __init__(self, scalepair): self.ruleChains = [[],] self.styles = [] self.eval_type = type(Eval()) - + self.scalepair = scalepair + print scalepair self.rcpos=0 self.stylepos=0 @@ -250,7 +251,8 @@ class StyleChooser: adds into the current ruleChain (existing Rule) """ self.ruleChains[self.rcpos][len(self.ruleChains[self.rcpos])-1].conditions.append(c) - + self.ruleChains[self.rcpos][len(self.ruleChains[self.rcpos])-1].minZoom=float(self.scalepair[0]) + self.ruleChains[self.rcpos][len(self.ruleChains[self.rcpos])-1].maxZoom=float(self.scalepair[1]) def addStyles(self, a): """ diff --git a/src/mapcss/__init__.py b/src/mapcss/__init__.py index 7c4019d..3d72da8 100644 --- a/src/mapcss/__init__.py +++ b/src/mapcss/__init__.py @@ -89,6 +89,7 @@ class MapCSS(): """ self.minscale=minscale self.maxscale=maxscale + self.scalepair = (minscale, maxscale) self.choosers = [] self.style_loaded = False self.parse(builtin_style) @@ -145,7 +146,7 @@ class MapCSS(): self.choosers = [] log = logging.getLogger('mapcss.parser') previous = 0 # what was the previous CSS word? - sc=StyleChooser() #currently being assembled + sc=StyleChooser(self.scalepair) #currently being assembled #choosers=[] @@ -167,7 +168,7 @@ class MapCSS(): elif CLASS.match(css): if previous==oDECLARATION: self.choosers.append(sc) - sc = StyleChooser() + sc = StyleChooser(self.scalepair) cond = CLASS.match(css).groups()[0] log.debug("class found: %s"% (cond)) @@ -182,7 +183,7 @@ class MapCSS(): elif NOT_CLASS.match(css): if (previous==oDECLARATION): self.choosers.append(sc) - sc = StyleChooser() + sc = StyleChooser(self.scalepair) cond = NOT_CLASS.match(css).groups()[0] log.debug("not_class found: %s"% (cond)) @@ -219,7 +220,7 @@ class MapCSS(): elif CONDITION.match(css): if (previous==oDECLARATION): self.choosers.append(sc) - sc = StyleChooser() + sc = StyleChooser(self.scalepair) if (previous!=oOBJECT) and (previous!=oZOOM) and (previous!=oCONDITION): sc.newObject() cond = CONDITION.match(css).groups()[0] @@ -232,7 +233,7 @@ class MapCSS(): elif OBJECT.match(css): if (previous==oDECLARATION): self.choosers.append(sc) - sc = StyleChooser() + sc = StyleChooser(self.scalepair) obj = OBJECT.match(css).groups()[0] log.debug("object found: %s"% (obj)) css=OBJECT.sub("",css) @@ -262,7 +263,7 @@ class MapCSS(): #print sc if (previous==oDECLARATION): self.choosers.append(sc) - sc= StyleChooser() + sc= StyleChooser(self.scalepair) #print self.choosers return #}