<commit_before>
/** Replacement of $.extend
 * 
 */

function extend(child, supertype)
{
	// https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Inheritance
   // child.prototype.__proto__ = supertype.prototype; 
   // Do not work in IE8
   
   var c = function() {};
    c.prototype = supertype.prototype;
    child.prototype = new c();

}

/** Convert a GLatLngBounds object into an array of geohash with 
 * assigned prefix length
 * 
 */

function hashBounds(bounds,prefix_len) {
    var points = [];
    var hashs = new Object();
    var sw = bounds.getSouthWest();
    var ne = bounds.getNorthEast();
    points.push(sw)
    points.push(new GLatLng(ne.lat(),sw.lng())  )
    points.push(ne)
    points.push(new GLatLng(sw.lat(),ne.lng())  )
    
    for (var i =0 ; i < points.length ;i++) {
        var h = encodeGeoHash(points[i].lat() , points[i].lng() );
        hashs[h.substr(0,prefix_len)] = true;
    }
    
    var ret = []
    for (var h in hashs){
        ret.push(h);
    }
    return ret;
}<commit_msg>utils.js - hashBounds : Improved the algorithm , not only the corners points are returned. It can cover the whole area. Added hashLatlng : Create geohash on a given point and prefix length<commit_after>
/** Replacement of $.extend
 * 
 */

function extend(child, supertype)
{
	// https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Inheritance
   // child.prototype.__proto__ = supertype.prototype; 
   // Do not work in IE8
   
   var c = function() {};
    c.prototype = supertype.prototype;
    child.prototype = new c();

}

/** Create geohash on a given point and prefix length
 * 
 */

function hashLatLng(pt , prefix_len) {
    var hash = encodeGeoHash(pt.lat() , pt.lng() );
    return hash.substr(0,prefix_len);
}

/** Convert a GLatLngBounds object into an array of geohash with 
 * assigned prefix length
 * 
 */

function hashBounds(bounds,prefix_len) {    
    var sw = bounds.getSouthWest();
    var ne = bounds.getNorthEast();
        
    var hashSW = hashLatLng(sw,prefix_len);
    //var hashNE = encodeGeoHash(ne.lat() , ne.lng() )
    var hashNW = hashLatLng(new GLatLng(ne.lat() , sw.lng() ) , prefix_len);
    var hashSE = hashLatLng(new GLatLng(sw.lat() , ne.lng() ) , prefix_len);
    var ret = [];
    
    var x = 1;
    var y = 1;
    var hash0 = hashSW;
        
    while (hash0 != hashNW) {
        y++;
        hash0 = calculateAdjacent(hash0 , "top");
    }   
        
    hash0 = hashSW;
    while (hash0 != hashSE){
        x++;
        hash0 = calculateAdjacent(hash0 , "right");
    }
    
    hash0 = hashSW;
    for (var i = 0 ; i < y;i++){
        var hash1 = hash0
        for (var j = 0 ; j < x ;j++) {
            ret.push(hash1);
            hash1 = calculateAdjacent(hash1 , "right");
        }
        
        hash0 = calculateAdjacent(hash0 , "top");
    }
    
    return ret;
}
{'fraction_non_alphanumeric': 0.13806361412093673, 'fraction_numerical': 0.010136315973435861, 'mean_word_length': 2.423444976076555, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3788143', 'n_tokens_mistral': 1003, 'n_tokens_neox': 971, 'n_words': 242}