def extract_wpts(protocols, get_trks_pkts, index):
    i = iter(get_trks_pkts)
    # position iter at first wpt record of given index
    for pid, length, data in i:
        if pid == protocols.link_proto.PID_TRK_HDR and data.index == index:
            break
    # extract wpts
    for pkt in i:
        if pkt.pid == protocols.link_proto.PID_TRK_HDR:
            break
        elif pkt.pid == protocols.link_proto.PID_TRK_DATA:
            yield data
        elif pkt.pid == protocols.link_proto.PID_TRK_DATA_ARRAY:
            for wpt in pkt.data.wpts: yield wpt
Given a collection of track points packets,
dataset/ETHPy150Open braiden/python-ant-downloader/antd/garmin.py/extract_wpts