Fixed maximal zoom level issue

This commit is contained in:
Komяpa 2010-07-16 13:59:52 +03:00
parent 2bee32f97d
commit 2f9bab6373
2 changed files with 12 additions and 9 deletions

View file

@ -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):
"""

View file

@ -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
#}