Ejemplo n.º 1
0
    def parse_way(self, way):
        """Parse a way element and create the corresponding object."""
        osmId = way.attrib['id']
        tags = self.get_tags(way)
        refs = []
        for ref in way.findall('nd'):
            refs.append(ref.attrib['ref'])
        self.wayRefList[
            osmId] = refs  # we need to store them because the can then be usefull when parsin 'relations'

        # dont take into acount underground structure
        if float(tags.get('layer', '0')) < 0:
            return

        if 'building' in tags or 'building:part' in tags:
            Building.add_to_list(osmId, tags, refs)
        elif 'highway' in tags:
            Road.add_to_list(osmId, tags, refs)
        elif tags.get('waterway') == 'river' or tags.get(
                'waterway') == 'stream':
            River.add_to_list(osmId, tags, refs)
        elif tags.get('barrier') == 'fence' or tags.get('barrier') == 'wall':
            Barrier.add_to_list(osmId, tags, refs)
        elif 'natural' in tags:
            Area.add_to_list(osmId, tags['natural'], tags, refs)
        elif 'landuse' in tags:
            Area.add_to_list(osmId, tags['landuse'], tags, refs)
        elif 'waterway' in tags:
            Area.add_to_list(osmId, tags['waterway'], tags, refs)
        elif 'amenity' in tags and tags['amenity'] == 'parking':
            Area.add_to_list(osmId, 'parking', tags, refs)
        elif 'name' in tags and tags['name'] == 'parking line':
            ParkingLines.add_to_list(osmId, tags, refs)
Ejemplo n.º 2
0
 def process_relations(self, disableMultipolygonBuildings):
     """Process all the multipolygons."""
     for relation in self.relations:  # reference, type, role
         OSMMultipolygon.add(relation['osmId'], relation['tags'],
                             relation['members'], self.wayRefList)
     OSMMultipolygon.process(disableMultipolygonBuildings)
     if not disableMultipolygonBuildings:
         for multipolygon in OSMMultipolygon.multipolygonList:
             # create a building from the multipolygon
             if 'building' in multipolygon.tags and not OSMMultipolygon.disableMultipolygonBuildings:
                 Building.add_to_list(multipolygon.OSMID, multipolygon.tags,
                                      multipolygon.ref)
             # create an area from the multipolygon
             elif 'natural' in multipolygon.tags:
                 Area.add_to_list(multipolygon.OSMID,
                                  multipolygon.tags['natural'],
                                  multipolygon.tags, multipolygon.ref)
             elif 'landuse' in multipolygon.tags:
                 Area.add_to_list(multipolygon.OSMID,
                                  multipolygon.tags['landuse'],
                                  multipolygon.tags, multipolygon.ref)
             elif 'amenity' in multipolygon.tags and multipolygon.tags[
                     'amenity'] == 'parking':
                 Area.add_to_list(multipolygon.OSMID, 'parking',
                                  multipolygon.tags, multipolygon.ref)