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)
Ejemplo n.º 3
0
        Road.process()
        Road.export(outputFile)
        print(" * " + str(len(Road.roads)) + " roads generated")
        print(" * " + str(len(Road.crossroads)) + " crossroads generated")
    if not options.noBuildings:
        Building.export(outputFile)
        print(" * " + str(len(Building.list)) + " buildings generated")
    if not options.noTrees:
        Tree.export(outputFile)
        print(" * " + str(len(Tree.list)) + " trees generated")
    if not options.noBarriers:
        Barrier.export(outputFile)
        print(" * " + str(len(Barrier.list)) + " barriers generated")
    if not options.noRivers:
        River.export(outputFile)
        print(" * " + str(len(River.list)) + " rivers generated")
    if not options.noAreas:
        Area.export(outputFile, options.noParkings)
        print(" * " + str(len(Area.list)) +
              " areas (forest, water, farmland, etc.) generated")
    if not options.noParkings:
        ParkingLines.export(outputFile)
        print(" * " + str(len(ParkingLines.list)) + " parking lines generated")

    print(" * map centered with this offset: " + str(xOffset) + "," +
          str(zOffset) + ").")
    print(" * reference coordinates: " + str(lat0) + "," + str(long0) + ".")
    print(" * projection used: '" + Projection.getProjectionString() + "'.")
    outputFile.close()
    print("Done.")