def METHOD_NAME(t, msg, msg_types, vars, fields, field_types, position_field_type):
    '''add some data'''
    mtype = msg.get_type()
    if mtype not in msg_types:
        return
    for i in range(0, len(fields)):
        if mtype not in field_types[i]:
            continue
        f = fields[i]
        v = mavutil.evaluate_expression(f, vars)
        if v is None:
            continue
        # Check if we have position or state information
        if f == mainstate_field:
            # Handle main state information
            # add_data.mainstate_current >= 0 : avoid starting a new linestring
            # when mainstate comes after the first position data in the log
            if (v != METHOD_NAME.mainstate_current and
                    METHOD_NAME.mainstate_current >= 0):
                METHOD_NAME.new_linestring = True
            METHOD_NAME.mainstate_current = v
        else:
            # Handle position information
            # make sure lon, lat, alt is saved in the correct order in
            # position_data (the same as in position_field_types)
            METHOD_NAME.position_data[i] = v
    # check if we have a full gps measurement
    gps_measurement_ready = True
    for v in METHOD_NAME.position_data:
        if v is None:
            gps_measurement_ready = False
    if not gps_measurement_ready:
        return
    # if new line string is needed (because of state change): add previous
    # linestring to kml_linestrings list, add a new linestring to the kml
    # multigeometry and append to the new linestring
    # else: append to current linestring
    if METHOD_NAME.new_linestring:
        if METHOD_NAME.current_kml_linestring is not None:
            kml_linestrings.append(METHOD_NAME.current_kml_linestring)
        name = "".join([args.source, ":", str(METHOD_NAME.mainstate_current)])
        METHOD_NAME.current_kml_linestring = \
            kml.newlinestring(name=name, altitudemode='absolute')
        # set rendering options
        if args.extrude:
            METHOD_NAME.current_kml_linestring.extrude = 1
        METHOD_NAME.current_kml_linestring.style.linestyle.color = \
            colors[max([METHOD_NAME.mainstate_current, 0])]
        METHOD_NAME.new_linestring = False
        add_to_linestring(METHOD_NAME.position_data,
                      METHOD_NAME.current_kml_linestring)
        METHOD_NAME.last_time = msg._timestamp
    else:
        if (msg._timestamp - METHOD_NAME.last_time) > 0.1:
            add_to_linestring(METHOD_NAME.position_data,
                      METHOD_NAME.current_kml_linestring)
            METHOD_NAME.last_time = msg._timestamp
    # reset position_data
    METHOD_NAME.position_data = [None for n in position_field_type]