forked from organicmaps/organicmaps
Removed get_sql and get_sql_hints unused functions
This commit is contained in:
parent
3843c26c03
commit
a96a172b08
4 changed files with 0 additions and 86 deletions
|
@ -182,40 +182,6 @@ class Condition:
|
|||
pass
|
||||
return self
|
||||
|
||||
def get_sql(self):
|
||||
# params = [re.escape(x) for x in self.params]
|
||||
params = self.params
|
||||
t = self.type
|
||||
if t == 'eq': # don't compare tags against sublayers
|
||||
if params[0][:2] == "::":
|
||||
return ("", "")
|
||||
try:
|
||||
if t == 'eq':
|
||||
return params[0], '"%s" = \'%s\'' % (params[0], params[1])
|
||||
if t == 'ne':
|
||||
return params[0], '("%s" != \'%s\' or "%s" IS NULL)' % (params[0], params[1], params[0])
|
||||
if t == 'regex':
|
||||
return params[0], '"%s" ~ \'%s\'' % (params[0], params[1].replace("'", "\\'"))
|
||||
if t == 'true':
|
||||
return params[0], '"%s" = \'yes\'' % (params[0])
|
||||
if t == 'untrue':
|
||||
return params[0], '"%s" = \'no\'' % (params[0])
|
||||
if t == 'set':
|
||||
return params[0], '"%s" IS NOT NULL' % (params[0])
|
||||
if t == 'unset':
|
||||
return params[0], '"%s" IS NULL' % (params[0])
|
||||
|
||||
if t == '<':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) < %s ELSE false END) """ % (params[0], params[0], params[1])
|
||||
if t == '<=':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) <= %s ELSE false END)""" % (params[0], params[0], params[1])
|
||||
if t == '>':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) > %s ELSE false END) """ % (params[0], params[0], params[1])
|
||||
if t == '>=':
|
||||
return params[0], """(CASE WHEN "%s" ~ E'^[-]?[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ("%s" AS FLOAT) >= %s ELSE false END) """ % (params[0], params[0], params[1])
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return "%s %s " % (self.type, repr(self.params))
|
||||
|
||||
|
|
|
@ -86,23 +86,6 @@ class Rule():
|
|||
a.discard(False)
|
||||
return a
|
||||
|
||||
def get_sql_hints(self, obj, zoom):
|
||||
if obj:
|
||||
if (self.subject != '') and not _test_feature_compatibility(obj, self.subject, {":area": "yes"}):
|
||||
return set()
|
||||
if not self.test_zoom(zoom):
|
||||
return set()
|
||||
a = set()
|
||||
b = set()
|
||||
for condition in self.conditions:
|
||||
q = condition.get_sql()
|
||||
if q:
|
||||
if q[1]:
|
||||
a.add(q[0])
|
||||
b.add(q[1])
|
||||
b = " AND ".join(b)
|
||||
return a, b
|
||||
|
||||
|
||||
def _test_feature_compatibility(f1, f2, tags={}):
|
||||
"""
|
||||
|
|
|
@ -131,29 +131,6 @@ class StyleChooser:
|
|||
a.add("*")
|
||||
return a
|
||||
|
||||
def get_sql_hints(self, type, zoom):
|
||||
"""
|
||||
Returns a set of tags that were used in here in form of SQL-hints.
|
||||
"""
|
||||
a = set()
|
||||
b = ""
|
||||
needed = set(["width", "casing-width", "fill-color", "fill-image", "icon-image", "text", "extrude", "background-image", "background-color", "pattern-image", "shield-text"])
|
||||
|
||||
if not needed.isdisjoint(set(self.styles[0].keys())):
|
||||
for r in self.ruleChains:
|
||||
p = r.get_sql_hints(type, zoom)
|
||||
if p:
|
||||
q = "(" + p[1] + ")" # [t[1] for t in p]
|
||||
if q == "()":
|
||||
q = ""
|
||||
if b and q:
|
||||
b += " OR " + q
|
||||
else:
|
||||
b = q
|
||||
a.update(p[0])
|
||||
# no need to check for eval's
|
||||
return a, b
|
||||
|
||||
def updateStyles(self, sl, ftype, tags, zoom, scale, zscale):
|
||||
# Are any of the ruleChains fulfilled?
|
||||
if self.selzooms:
|
||||
|
|
|
@ -186,18 +186,6 @@ class MapCSS():
|
|||
tags.update(chooser.get_interesting_tags(type, zoom))
|
||||
return tags
|
||||
|
||||
def get_sql_hints(self, type=None, zoom=None):
|
||||
"""
|
||||
Get set of interesting tags.
|
||||
"""
|
||||
hints = []
|
||||
for chooser in self.choosers:
|
||||
p = chooser.get_sql_hints(type, zoom)
|
||||
if p:
|
||||
if p[0] and p[1]:
|
||||
hints.append(p)
|
||||
return hints
|
||||
|
||||
def subst_variables(self, t):
|
||||
"""Expects an array from parseDeclaration."""
|
||||
for k in t[0]:
|
||||
|
|
Loading…
Add table
Reference in a new issue