<commit_before>'use strict';

var fs = require('fs');
var concaveHull = require('./');

var points = require('./tmp/test.json');

var colors = ['#006837', '#1a9850', '#66bd63', '#a6d96a', '#d9ef8b', '#fee08b', '#fdae61', '#f46d43', '#d73027', '#a50026'];
var dist = 100000;
var end = 0;
var hulls = [];

for (var i = 0, last; i < 3; i++) {
    while (points[end][2] < dist) end++;

    var id = 'concave hull on ' + end + ' points';
    console.time(id);
    var hull = concaveHull(points.slice(0, end), 1.7, 0.005);
    console.timeEnd(id);

    console.log('concave hull size: ' + hull.length + '\n');

    hulls.push({
        type: 'Feature',
        geometry: {
            type: 'Polygon',
            coordinates: last ? [hull, last] : [hull]
        },
        properties: {
            stroke: 'black',
            'stroke-opacity': 0.8,
            fill: colors[i],
            'fill-opacity': 0.5
        }
    });

    last = hull;
    dist += 100000;
}

var collection = {
    type: 'FeatureCollection',
    features: hulls.reverse()
};

fs.writeFileSync('./tmp/output.json', JSON.stringify(collection));
<commit_msg>use incremental approach for isodists debug example<commit_after>'use strict';

var fs = require('fs');
var concaveHull = require('./');

var points = require('./tmp/test.json');

var colors = ['#006837', '#1a9850', '#66bd63', '#a6d96a', '#d9ef8b', '#fee08b', '#fdae61', '#f46d43', '#d73027', '#a50026'];
var distStep = 100000;
var numClasses = 10;

var dist = distStep;
var start = 0;
var end = 0;
var hulls = [];

console.time('total');
for (var i = 0, last = []; i < numClasses; i++) {
    start = end;
    while (points[end][2] < dist) end++;

    var now = Date.now();
    var hull = concaveHull(points.slice(start, end).concat(last), 1.5, 0.005, true);
    console.log('concave hull on ' + (end - start + last.length) + ' points in ' +
        (Date.now() - now) + ', size: ' + hull.length);

    hulls.push({
        type: 'Feature',
        geometry: {
            type: 'Polygon',
            coordinates: last.length ? [hull, last] : [hull]
        },
        properties: {
            stroke: 'black',
            'stroke-opacity': 0.8,
            fill: colors[i],
            'fill-opacity': 0.5
        }
    });

    last = hull;
    dist += distStep;
}
console.timeEnd('total');

var collection = {
    type: 'FeatureCollection',
    features: hulls.reverse()
};

fs.writeFileSync('./tmp/output.json', JSON.stringify(collection));

{'fraction_non_alphanumeric': 0.1925716592652402, 'fraction_numerical': 0.050464271295922486, 'mean_word_length': 2.5706051873198845, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1098700', 'n_tokens_mistral': 944, 'n_tokens_neox': 846, 'n_words': 211}