function addPt(pt) {
        pts.push(pt);
        var prevFilterLen = ptsFiltered.length;
        var iLast = doneRawIndex;
        ptsFiltered.splice(doneFilteredIndex + 1);

        for(var i = iLast + 1; i < pts.length; i++) {
            if(i === pts.length - 1 || polygon.isSegmentBent(pts, iLast, i + 1, tolerance)) {
                ptsFiltered.push(pts[i]);
                if(ptsFiltered.length < prevFilterLen - 2) {
                    doneRawIndex = i;
                    doneFilteredIndex = ptsFiltered.length - 1;
                }
                iLast = i;
            }
        }
    }
Make a filtering polygon, to minimize the number of segments

@param pts Array of [x, y] pairs (must start with at least 1 pair)
@param tolerance the maximum deviation from straight allowed for
     removing points to simplify the polygon

@returns Object {addPt, raw, filtered}
     addPt is a function(pt: [x, y] pair) to add a raw point and
         continue filtering
     raw is all the input points
     filtered is the resulting filtered Array of [x, y] pairs