def build_feature(node):
    """
    Build and return a (decoded) GeoJSON Feature corresponding to this KML node (typically a KML Placemark).
    Return ``None`` if no Feature can be built.
    """
    geoms_and_times = build_geometry(node)
    if not geoms_and_times['geoms']:
        return None

    props = {}
    for x in get(node, 'name')[:1]:
        name = val(x)
        if name:
            props['name'] = val(x)
    for x in get(node, 'description')[:1]:
        desc = val(x)
        if desc:
            props['description'] = desc
    for x in get(node, 'styleUrl')[:1]:
        style_url = val(x)
        if style_url[0] != '#':
            style_url = '#' + style_url
        props['styleUrl'] = style_url
    for x in get(node, 'PolyStyle')[:1]:
        color = val(get1(x, 'color'))
        if color:
            rgb, opacity = build_rgb_and_opacity(color)
            props['fill'] = rgb
            props['fill-opacity'] = opacity
            # Set default border style
            props['stroke'] = rgb
            props['stroke-opacity'] = opacity
            props['stroke-width'] = 1
        fill = valf(get1(x, 'fill'))
        if fill == 0:
            props['fill-opacity'] = fill
        elif fill == 1 and 'fill-opacity' not in props:
            props['fill-opacity'] = fill
        outline = valf(get1(x, 'outline'))
        if outline == 0:
            props['stroke-opacity'] = outline
        elif outline == 1 and 'stroke-opacity' not in props:
            props['stroke-opacity'] = outline
    for x in get(node, 'LineStyle')[:1]:
        color = val(get1(x, 'color'))
        if color:
            rgb, opacity = build_rgb_and_opacity(color)
            props['stroke'] = rgb
            props['stroke-opacity'] = opacity
        width = valf(get1(x, 'width'))
        if width:
            props['stroke-width'] = width
    for x in get(node, 'ExtendedData')[:1]:
        datas = get(x, 'Data')
        for data in datas:
            props[attr(data, 'name')] = val(get1(data, 'value'))
        simple_datas = get(x, 'SimpleData')
        for simple_data in simple_datas:
            props[attr(simple_data, 'name')] = val(simple_data)
    for x in get(node, 'TimeSpan')[:1]:
        begin = val(get1(x, 'begin'))
        end = val(get1(x, 'end'))
        props['timeSpan'] = {'begin': begin, 'end': end}
    if geoms_and_times['times']:
        times = geoms_and_times['times']
        if len(times) == 1:
            props['times'] = times[0]
        else:
            props['times'] = times

    feature = {
      'type': 'Feature',
      'properties': props,
    }

    geoms = geoms_and_times['geoms']
    if len(geoms) == 1:
        feature['geometry'] = geoms[0]
    else:
        feature['geometry'] = {
          'type': 'GeometryCollection',
          'geometries': geoms,
        }

    if attr(node, 'id'):
        feature['id'] = attr(node, 'id')

    return feature
def build_feature ( node ) : geoms_and_times = build_geometry ( node ) if not geoms_and_times [ 'geoms' ] : return None props = { } for x in get ( node , 'name' ) [ : 1 ] : name = val ( x ) if name : props [ 'name' ] = val ( x ) for x in get ( node , 'description' ) [ : 1 ] : desc = val ( x ) if desc : props [ 'description' ] = desc for x in get ( node , 'styleUrl' ) [ : 1 ] : style_url = val ( x ) if style_url [ 0 ] != '#' : style_url = '#' + style_url props [ 'styleUrl' ] = style_url for x in get ( node , 'PolyStyle' ) [ : 1 ] : color = val ( get1 ( x , 'color' ) ) if color : rgb , opacity = build_rgb_and_opacity ( color ) props [ 'fill' ] = rgb props [ 'fill-opacity' ] = opacity props [ 'stroke' ] = rgb props [ 'stroke-opacity' ] = opacity props [ 'stroke-width' ] = 1 fill = valf ( get1 ( x , 'fill' ) ) if fill == 0 : props [ 'fill-opacity' ] = fill elif fill == 1 and 'fill-opacity' not in props : props [ 'fill-opacity' ] = fill outline = valf ( get1 ( x , 'outline' ) ) if outline == 0 : props [ 'stroke-opacity' ] = outline elif outline == 1 and 'stroke-opacity' not in props : props [ 'stroke-opacity' ] = outline for x in get ( node , 'LineStyle' ) [ : 1 ] : color = val ( get1 ( x , 'color' ) ) if color : rgb , opacity = build_rgb_and_opacity ( color ) props [ 'stroke' ] = rgb props [ 'stroke-opacity' ] = opacity width = valf ( get1 ( x , 'width' ) ) if width : props [ 'stroke-width' ] = width for x in get ( node , 'ExtendedData' ) [ : 1 ] : datas = get ( x , 'Data' ) for data in datas : props [ attr ( data , 'name' ) ] = val ( get1 ( data , 'value' ) ) simple_datas = get ( x , 'SimpleData' ) for simple_data in simple_datas : props [ attr ( simple_data , 'name' ) ] = val ( simple_data ) for x in get ( node , 'TimeSpan' ) [ : 1 ] : begin = val ( get1 ( x , 'begin' ) ) end = val ( get1 ( x , 'end' ) ) props [ 'timeSpan' ] = { 'begin' : begin , 'end' : end } if geoms_and_times [ 'times' ] : times = geoms_and_times [ 'times' ] if len ( times ) == 1 : props [ 'times' ] = times [ 0 ] else : props [ 'times' ] = times feature = { 'type' : 'Feature' , 'properties' : props , } geoms = geoms_and_times [ 'geoms' ] if len ( geoms ) == 1 : feature [ 'geometry' ] = geoms [ 0 ] else : feature [ 'geometry' ] = { 'type' : 'GeometryCollection' , 'geometries' : geoms , } if attr ( node , 'id' ) : feature [ 'id' ] = attr ( node , 'id' ) return feature
Build and return a (decoded) GeoJSON Feature corresponding to this KML node (typically a KML Placemark).
    Return ``None`` if no Feature can be built.