<commit_before>iD.actions.Orthogonalize = function(wayId, map) {

    var action = function(graph) {
        var way = graph.entity(wayId),
        nodes = graph.childNodes(way),
        tags = {},key,role;

        var points = nodes.map(function(n) {
            return map.projection(n.loc);
        }),
        quad_nodes = [];

        var score = squareness();
        for (var i = 0; i < 1000; ++i) {
            var motions = points.map(stepMap);
            //return false;
            for (var j = 0; j < motions.length; ++j) {
                points[j] = addPoints(points[j],motions[j]);
            }
            var newScore = squareness();
            if (newScore > score) {
                return false;
            }
            score = newScore;
            if (score < 1.0e-8) {
                break;
            }
        }
        for (var i = 0; i < points.length; i++) {
                quad_nodes.push(iD.Node({ loc: map.projection.invert(points[i]) }));
        }
        quad_nodes.push(quad_nodes[0]);

        for (var i = 0; i < nodes.length; i++) {
                graph = graph.remove(nodes[i]);<commit_msg>Fix case where parentnodes present<commit_after>iD.actions.Orthogonalize = function(wayId, map) {

    var action = function(graph) {
        var way = graph.entity(wayId),
        nodes = graph.childNodes(way),
        tags = {},key,role;

        var points = nodes.map(function(n) {
            return map.projection(n.loc);
        }),
        quad_nodes = [];

        var score = squareness();
        for (var i = 0; i < 1000; ++i) {
            var motions = points.map(stepMap);
            //return false;
            for (var j = 0; j < motions.length; ++j) {
                points[j] = addPoints(points[j],motions[j]);
            }
            var newScore = squareness();
            if (newScore > score) {
                return graph;
            }
            score = newScore;
            if (score < 1.0e-8) {
                break;
            }
        }
        for (var i = 0; i < points.length; i++) {
                quad_nodes.push(iD.Node({ loc: map.projection.invert(points[i]) }));
        }
        quad_nodes.push(quad_nodes[0]);

        for (i = 0; i < nodes.length; i++) {
            if (graph.parentWays(nodes[i]).length > 1) {
                var closest, closest_dist = Infinity, dist;
                for (var j = 0; j < quad_nodes.length; j++) {
                    dist = iD.geo.dist(quad_nodes[j].loc, nodes[i].loc);
                    if (dist < closest_dist) {
                        closest_dist = dist;
                        closest = j;
                    }
                }
                quad_nodes.splice(closest, 1, nodes[i]);
                if (closest === 0) quad_nodes.splice(quad_nodes.length - 1, 1, nodes[i]);
                else if (closest === quad_nodes.length - 1) quad_nodes.splice(0, 1, nodes[i]);
            } else {
                graph = graph.remove(nodes[i]);
            }
{'fraction_non_alphanumeric': 0.1376545272302038, 'fraction_numerical': 0.011025726695623121, 'mean_word_length': 1.4067524115755627, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 6, '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': '2861212', 'n_tokens_mistral': 940, 'n_tokens_neox': 882, 'n_words': 200}