function tp = proctp(fname)
    tp.t = zeros(0, 3);
    tp.lat = zeros(0,3);
    tp.lon = zeros(0,3);
    tp.n = zeros(1, 3);
    tp.qf = zeros(0,3);

    dn0 = datenum([2007, 1, 1, 0, 0, 0]);
    log = fopen(fname);
    if log == -1
       fprintf('could not open file %s\n', fname);
       return
    end

    while (1)
        dataline = fgets(log);
        if dataline == -1
           break;
        end
        if length(dataline) < 20
            continue;
        end
        dn = dataline(1:13);
        dataline = dataline(15:end);
        yd = str2num(dn) - dn0;
        if strncmp(dataline, '$GPGGA', 6)
           [data, count] = sscanf(dataline, ...
                            '$GPGGA,%02d%02d%02d,%02f%f,%c,%03f%f,%c,', 9);
           if count == 9
               ship_pos(1) = data(7) + data(8)/60.0;
               if data(9) == 87
                   ship_pos(1) = -ship_pos(1);
               end    
               ship_pos(2) = data(4) + data(5)/60.0;
               if data(6) == 83
                   ship_pos(2) = -ship_pos(2);
               end   
           end
        elseif strncmp(dataline, '$HEHDT', 6)
            [data, count] = sscanf(dataline, '$HEHDT,%f,T,', 1);
            if count == 1
                ship_heading = data;
            end
        elseif strncmp(dataline, '$PORE', 5)
            [data, count] = sscanf(dataline, '$PORE,%02d,%02d%02d%02d,,,%f,%f,%f,%f,%f,%f,%d,%d*', 12);

            if count == 12 
                id = data(1);
                hour = data(2);
                minute = data(3);
                second = data(4);
                bearing = data(5);
                xcoord = data(6);
                ycoord = data(7);
                zcoord = data(8);
                slant = sqrt(xcoord^2 + ycoord^2 + zcoord^2);
                roll = data(9);
                pitch = data(10);
                err = data(11);
                qf = data(12);

               [lat, lon] = reckon(ship_pos(2), ship_pos(1), km2deg(slant/1000), ship_heading + bearing);
               tp.n(id) = tp.n(id) + 1;
               tp.t(tp.n(id), id) = yd + 7.0/24.0; 
               tp.lat(tp.n(id), id) = lat;
               tp.lon(tp.n(id), id) = lon;
               tp.qf(tp.n(id), id) = qf;
               fprintf('%d %.7f %.3f %.3f %d\n', id, yd + 7/24, lat, lon, qf);
            end	
        end
    end
    fclose(log);
