Changeset 4fa8af6 in osmose-backend


Ignore:
Timestamp:
Jun 9, 2014 1:55:08 PM (5 years ago)
Author:
Jocelyn Jaubert <jocelyn.jaubert@…>
Branches:
master
Children:
112c8c5
Parents:
8fe9cb8 (diff), adbe33d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'TagMissing_LookLike'

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • analysers/Analyser.py

    r642beae radbe33d  
    109109        assert False, "Error not found" 
    110110 
    111     def check_num_err(self, num): 
     111    def check_num_err(self, num=None, min=None): 
    112112        xml_num = len(self.root_err.find("analyser").findall('error')) 
    113         self.assertEquals(num, xml_num, "Found %d errors instead of %d" % (xml_num, num)) 
     113        if num is not None: 
     114            self.assertEquals(xml_num, num, "Found %d errors instead of %d" % (xml_num, num)) 
     115        if min is not None: 
     116            self.assertGreaterEqual(xml_num, min, "Found %d errors instead of > %d" % (xml_num, min)) 
     117 
    114118 
    115119########################################################################### 
  • analysers/analyser_sax.py

    r03bf3c1 radbe33d  
    462462 
    463463        self.root_err = self.load_errors() 
    464         self.check_num_err(37) 
     464        self.check_num_err(min=37) 
    465465 
    466466    def test_FR(self): 
     
    473473 
    474474        self.root_err = self.load_errors() 
    475         self.check_num_err(53) 
     475        self.check_num_err(min=53) 
    476476 
    477477    def test_fr(self): 
     
    483483 
    484484        self.root_err = self.load_errors() 
    485         self.check_num_err(41) 
     485        self.check_num_err(min=41) 
    486486 
    487487 
  • modules/downloader.py

    rd0944e5 r0801116  
    3030HTTP_DATE_FMT = "%a, %d %b %Y %H:%M:%S GMT" 
    3131 
    32 def update_cache(url, delay): 
     32def update_cache(url, delay, bz2_decompress=False): 
    3333    if not os.path.exists(config.dir_cache): 
    3434        os.makedirs(config.dir_cache) 
     
    6161    # write the file 
    6262    try: 
     63        if bz2_decompress: 
     64            import bz2 
     65            decompressor = bz2.BZ2Decompressor() 
    6366        outfile = open(tmp_file, "wb") 
    6467        while True: 
    65             data = answer.read(2048) 
     68            data = answer.read(100 * 1024) 
    6669            if len(data) == 0: 
    6770                break 
     71            if bz2_decompress: 
     72                data = decompressor.decompress(data) 
    6873            outfile.write(data) 
     74    except: 
     75        raise 
    6976    finally: 
    7077        outfile.close() 
  • plugins/TagMissing_LookLike.py

    r53f7279 r93d5b53  
    2121 
    2222from plugins.Plugin import Plugin 
     23from modules.downloader import update_cache 
    2324import os 
    2425import sqlite3 
     
    4041sql02 = """ 
    4142SELECT 
    42     keypairs.key2 AS key, 
    43     keypairs.key1 AS other_key, 
    44     CAST(keypairs.count_%(type)s AS REAL) / count.count_%(type)s AS together_faction, 
    45     CAST(keypairs.count_%(type)s AS REAL) / keys.count_%(type)s AS from_fraction 
     43    k.key2 AS key, 
     44    k.key1 AS other_key, 
     45    CAST(k.count_%(type)s AS REAL) / count.count_%(type)s AS together_faction, 
     46    CAST(k.count_%(type)s AS REAL) / keys.count_%(type)s AS from_fraction 
    4647FROM 
    47     keypairs 
     48    key_combinations k 
    4849    JOIN keys ON 
    49         keypairs.key1 = keys.key AND 
     50        k.key1 = keys.key AND 
    5051        keys.count_%(type)s > 100 
    5152    JOIN temp.count ON 
    52         keypairs.key2 = count.key AND 
     53        k.key2 = count.key AND 
    5354        together_faction > 0.1 
    5455WHERE 
    55     keypairs.count_%(type)s > 100 AND 
     56    k.count_%(type)s > 100 AND 
    5657    from_fraction > .9 AND 
    5758    from_fraction < 1.0 
    5859UNION 
    5960SELECT 
    60     keypairs.key1 AS key, 
    61     keypairs.key2 AS other_key, 
    62     CAST(keypairs.count_%(type)s AS REAL) / count.count_%(type)s AS together_faction, 
    63     CAST(keypairs.count_%(type)s AS REAL) / keys.count_%(type)s AS from_fraction 
     61    k.key1 AS key, 
     62    k.key2 AS other_key, 
     63    CAST(k.count_%(type)s AS REAL) / count.count_%(type)s AS together_faction, 
     64    CAST(k.count_%(type)s AS REAL) / keys.count_%(type)s AS from_fraction 
    6465FROM 
    65     keypairs 
     66    key_combinations k 
    6667    JOIN keys ON 
    67         keypairs.key2 = keys.key AND 
     68        k.key2 = keys.key AND 
    6869        keys.count_%(type)s > 100 
    6970    JOIN temp.count ON 
    70         keypairs.key1 = count.key AND 
     71        k.key1 = count.key AND 
    7172        together_faction > 0.1 
    7273WHERE 
    73     keypairs.count_%(type)s > 100 AND 
     74    k.count_%(type)s > 100 AND 
    7475    from_fraction > .9 AND 
    7576    from_fraction < 1.0 
     
    8384        self.errors[2070] = {"item": 2070, "level": 2, "tag": ["tag", "fix:chair"], "desc": T_(u"Missing tag by cooccurrence") } 
    8485 
    85         if not os.path.exists('taginfo-db.db'): 
     86        bdd = update_cache("http://taginfo.openstreetmap.org/download/taginfo-db.db.bz2", 30, bz2_decompress=True) 
     87 
     88        if not os.path.exists(bdd): 
    8689            self.info = {} 
    8790            for type in ['nodes', 'ways', 'relations']: 
     
    9093 
    9194        # Taginfo wiki extract database 
    92         # http://taginfo.openstreetmap.org/download/taginfo-db.db.bz2 
    93         con = sqlite3.connect('taginfo-db.db') 
     95        con = sqlite3.connect(bdd) 
    9496 
    9597        with con: 
     
    113115            if tag in self.info[type]: 
    114116                for mwm in self.info[type][tag]: 
    115                     print mwm 
    116117                    if mwm[0] not in tags: 
    117118                        arg = (mwm[0], round(mwm[3],2)) 
     
    136137        a = TagMissing_LookLike(None) 
    137138        a.init(None) 
    138         r = a.node(None, {u"ref:INSEE":"33", u"place":"La-Haut-sur-la-Montagne"}) 
    139         print r 
    140         # TODO: add tests 
     139        self.check_err(a.node(None, {u"ref:INSEE":"33"})) 
     140        self.check_err(a.node(None, {u"ref:INSEE":"33", u"population":100})) 
     141        self.check_err(a.node(None, {u"ref:INSEE":"33", u"population":100, u"place":"Ici"})) 
     142        assert not a.node(None, {u"ref:INSEE":"33", u"population":100, u"place":"Ici", u"name": u"Toto"}) 
     143        self.check_err(a.node(None, {u"place":"La-Haut-sur-la-Montagne"})) 
     144        assert not a.node(None, {u"place":"La-Haut-sur-la-Montagne", u"name":"Toto"}) 
  • analysers/analyser_merge_recycling_FR_cub.py

    rd53a9cf r8ecd1e4  
    2727    def __init__(self, config, logger = None): 
    2828        self.missing_official = {"item":"8120", "class": 1, "level": 3, "tag": ["merge", "recycling"], "desc": T_(u"CUB glass recycling not integrated") } 
    29         self.possible_merge   = {"item":"8121", "class": 1, "level": 3, "tag": ["merge", "recycling"], "desc": T_(u"CUB glass recycling, integration suggestion") } 
     29        self.possible_merge   = {"item":"8121", "class": 3, "level": 3, "tag": ["merge", "recycling"], "desc": T_(u"CUB glass recycling, integration suggestion") } 
    3030        Analyser_Merge.__init__(self, config, logger, 
    3131            Source( 
Note: See TracChangeset for help on using the changeset viewer.