Ejemplo n.º 1
0
 def add_to_list(osmid, tags, ref):
     """Add a new barrier to the list of barriers."""
     if 'barrier' in tags:
         settingsSection = Settings.get_section('barrier', tags['barrier'])
         if settingsSection is None:
             return
         if Settings.has_option(settingsSection, 'ignore') and Settings.get(
                 settingsSection, 'ignore') == 'TRUE':
             return
         barrier = Barrier()
         barrier.OSMID = osmid
         barrier.type = tags['barrier']
         barrier.ref = ref
         if 'height' in tags:
             barrier.height = extract_float_from_string(tags['height'])
         elif Settings.has_option(settingsSection, 'height'):
             barrier.height = Settings.getfloat(settingsSection, 'height')
         if 'width' in tags:
             barrier.width = extract_float_from_string(tags['width'])
         elif Settings.has_option(settingsSection, 'width'):
             barrier.width = Settings.getfloat(settingsSection, 'width')
         if WebotsObject.enable3D:
             barrier.ref = Barrier.add_intermediate_point_where_needed(
                 barrier.ref)
         Barrier.list.append(barrier)
Ejemplo n.º 2
0
 def add_to_list(osmid, tags, ref):
     """Add a new river to the list of rivers."""
     if 'waterway' in tags:
         settingsSection = Settings.get_section('waterway', tags['waterway'])
         if settingsSection is None:
             return
         river = River()
         river.OSMID = osmid
         river.type = tags['waterway']
         river.ref = ref
         if 'name' in tags:
             river.name = clean_string(tags['name'])
         if 'width' in tags:
             river.width = extract_float_from_string(tags['width'])
         elif Settings.has_option(settingsSection, 'width'):
             river.width = Settings.getfloat(settingsSection, 'width')
         if WebotsObject.enable3D:
             river.ref = River.add_intermediate_point_where_needed(river.ref)
         River.list.append(river)
Ejemplo n.º 3
0
 def add_to_list(osmid, tags, ref):
     """Add a new building to the list of buildings."""
     if 'building' in tags or 'building:part' in tags:
         building = Building()
         building.OSMID = osmid
         if 'building' in tags:
             building.type = tags['building']
         if 'building:material' in tags:
             building.material = tags['building:material']
         if 'roof:material' in tags:
             building.roofMaterial = tags['roof:material']
         elif 'material' in tags:
             building.material = tags['material']
         if 'building:colour' in tags:
             if tags['building:colour'].startswith("#"):
                 building.color = int(tags['building:colour'][1:], 16)
                 building.red = float((building.color & 0xFF0000) >> 16) / 255.0
                 building.green = float((building.color & 0x00FF00) >> 8) / 255.0
                 building.blue = float(building.color & 0x0000FF) / 255.0
             else:
                 try:
                     building.color = tags['building:colour']
                     red, green, blue = name_to_rgb(building.color, spec='css3')
                     building.red = float(red) / 255.0
                     building.green = float(green) / 255.0
                     building.blue = float(blue) / 255.0
                 except:
                     building.color = ""
         if 'roof:colour' in tags:
             if tags['roof:colour'].startswith("#"):
                 building.roofColor = int(tags['roof:colour'][1:], 16)
                 building.roofRed = float((building.roofColor & 0xFF0000) >> 16) / 255.0
                 building.roofGreen = float((building.roofColor & 0x00FF00) >> 8) / 255.0
                 building.roofBlue = float(building.roofColor & 0x0000FF) / 255.0
             else:
                 try:
                     building.roofColor = tags['roof:colour']
                     roofRed, roofGreen, roofBlue = name_to_rgb(building.roofColor, spec='css3')
                     building.roofRed = float(roofRed) / 255.0
                     building.roofGreen = float(roofGreen) / 255.0
                     building.roofBlue = float(roofBlue) / 255.0
                 except:
                     building.roofColor = ""
         if 'name' in tags:
             building.name = tags['name']
         elif 'ref' in tags:
             building.name = tags['ref']
         if 'roof:height' in tags:
             building.roofHeight = extract_float_from_string(tags['roof:height'])
         if 'min_height' in tags:
             building.minHeight = extract_float_from_string(tags['min_height'])
         if 'height' in tags:
             if building.roofHeight > 0:
                 building.height = extract_float_from_string(tags['height']) - building.roofHeight
             else:
                 building.height = extract_float_from_string(tags['height'])
         if 'roof:shape' in tags:
             building.roofShape = tags['roof:shape']
         if 'layer' in tags:
             building.layer = extract_float_from_string(tags['layer'])
         if 'building:levels' in tags:
             building.levels = int(extract_float_from_string(tags['building:levels']))
         if 'building:min_level' in tags:
             building.minLevel = int(extract_float_from_string(tags['building:min_level']))
         building.ref = ref
         if len(building.ref) > 0 and building.ref[0] == building.ref[-1]:  # often last and first reference are the same => this is useless for us
             del building.ref[-1]
         Building.list.append(building)