Changeset 561ded7 in osmose-backend


Ignore:
Timestamp:
Oct 11, 2014 6:24:08 PM (5 years ago)
Author:
Frédéric Rodrigo <fred.rodrigo@…>
Branches:
master
Children:
8eed907
Parents:
a781dcf
Message:

TagFix_MultipleTag, detect object with name and without any know kind. github #21

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/TagFix_MultipleTag.py

    r5dfd2ec r561ded7  
    3333        self.errors[20301] = { "item": 2030, "level": 1, "tag": ["tag", "highway", "cycleway", "fix:survey"], "desc": T_(u"Opposite cycleway without oneway") } 
    3434        self.errors[71301] = { "item": 7130, "level": 3, "tag": ["tag", "highway", "maxheight", "fix:survey"], "desc": T_(u"Missing maxheight tag") } 
     35        self.errors[21101] = { "item": 2110, "level": 3, "tag": ["tag"], "desc": T_(u"Missing object kind") } 
    3536        self.errors[1050] = { "item": 1050, "level": 1, "tag": ["highway", "roundabout", "fix:chair"], "desc": T_(u"Reverse roundabout") } 
    3637#        self.errors[70401] = { "item": 7040, "level": 2, "tag": ["tag", "power", "fix:chair"], "desc": T_(u"Bad power line kind") } 
    3738        self.driving_side_right = not(self.father.config.options.get("driving_side") == "left") 
    3839        self.driving_direction = "anticlockwise" if self.driving_side_right else "clockwise" 
     40        self.name_parent = set(('type', 'aerialway', 'aeroway', 'amenity', 'barrier', 'boundary', 'building', 'craft', 'emergency', 'geological', 'highway', 'historic', 'landuse', 'leisure', 'man_made', 'military', 'natural', 'office', 'place', 'power', 'public_transport', 'railway', 'route', 'shop', 'sport', 'tourism', 'waterway')) 
    3941        self.area_yes_good = set(('aerialway', 'aeroway', 'amenity', 'barrier', 'highway', 'historic', 'leisure', 'man_made', 'military', 'power', 'public_transport', 'sport', 'tourism', 'waterway')) 
    4042        self.area_yes_bad = set(('boundary', 'building', 'craft', 'geological', 'landuse', 'natural', 'office', 'place', 'shop')) 
    4143 
     44    def common(self, tags, key_set): 
     45        err = [] 
     46        if tags.get("name") and len(key_set & self.name_parent) == 0: 
     47            err.append((21101, 1, {})) 
     48 
     49        return err 
     50 
    4251    def node(self, data, tags): 
    43         err = [] 
     52        err = self.common(tags, set(tags.keys())) 
    4453        if "highway" in tags and tags["highway"] == "mini_roundabout" and "direction" in tags: 
    4554            clockwise = tags["direction"] == "clockwise" 
     
    5362 
    5463    def way(self, data, tags, nds): 
    55         err = [] 
     64        key_set = set(tags.keys()) 
     65        err = self.common(tags, key_set) 
    5666        if "highway" in tags and "fee" in tags: 
    5767            err.append((30320, 1000, {"en": u"Use tag \"toll\" instead of \"fee\"", "fr": u"Utiliser \"toll\" à la place de \"fee\"", "fix": {"-": ["fee"], "+": {"toll": tags["fee"]}} })) 
     
    6373            err.append((20801, 0, {})) 
    6474 
    65         if tags.get("area") == "yes" and not (len(set(tags.keys()) & self.area_yes_good) > 0 or ("railway" in tags and tags["railway"] == "platform")): 
     75        if tags.get("area") == "yes" and not (len(key_set & self.area_yes_good) > 0 or ("railway" in tags and tags["railway"] == "platform")): 
    6676            err.append((30323, 1001, {"en": u"Bad usage of area=yes. Object can be a surface", "fr": u"Mauvais usage de area=yes. L'objet ne peut pas être une surface"})) 
    67         if tags.get("area") == "yes" and len(set(tags.keys()) & self.area_yes_bad) > 0: 
     77        if tags.get("area") == "yes" and len(set(key_set & self.area_yes_bad)) > 0: 
    6878            err.append((30323, 1001, {"en": u"Bad usage of area=yes. Object is already an area by nature", "fr": u"Mauvais usage de area=yes. L'objet est déjà une surface par nature"})) 
    6979        if tags.get("area") == "no" and not "aeroway" in tags and not "building" in tags and not "landuse" in tags and not "leisure" in tags and not "natural": 
     
    8898        return err 
    8999 
     100    def relation(self, data, tags, members): 
     101        return self.common(tags, set(tags.keys())) 
    90102 
    91103########################################################################### 
     
    121133                 ]: 
    122134            assert not a.way(None, t, None), t 
     135 
     136        assert a.node(None, {"name": "foo"}) 
Note: See TracChangeset for help on using the changeset viewer.