<commit_before>goog.provide('og.layer.XYZ');

goog.require('og.layer.Layer');
goog.require('og.quadTree');

og.layer.XYZ = function (name, options) {
    og.base(this, name, options);
};

og.extend(og.layer.XYZ, og.layer.Layer);

og.layer.XYZ.prototype.handleSegmentTile = function (material) {
    if (og.layer.requestsCounter >= og.layer.MAX_REQUESTS && this.counter) {
        this.pendingsQueue.push(material);
    } else {
        this.loadSegmentTileImage(material);
    }
};

og.layer.XYZ.prototype.GetHTTPRequestString = function (segment) {
    return og.layer.replaceTemplate(this.url, {
        "tilex": segment.tileX.toString(),
        "tiley": segment.tileY.toString(),
        "zoom": segment.zoomIndex.toString()
    });
};

og.layer.XYZ.prototype.loadSegmentTileImage = function (material) {
    var that = this;
    this.counter++;
    og.layer.requestsCounter++;
    var img = new Image();
    img.crossOrigin = '';
    img.onload = function () {
        that.events.callEvents(that.events.onload, {
            "image": this,
            "segment": material.segment
        });
        material.applyTexture.call(material, this);<commit_msg>You shouldn't to call onload if there are no events.<commit_after>goog.provide('og.layer.XYZ');

goog.require('og.layer.Layer');
goog.require('og.quadTree');

og.layer.XYZ = function (name, options) {
    og.base(this, name, options);
};

og.extend(og.layer.XYZ, og.layer.Layer);

og.layer.XYZ.prototype.handleSegmentTile = function (material) {
    if (og.layer.requestsCounter >= og.layer.MAX_REQUESTS && this.counter) {
        this.pendingsQueue.push(material);
    } else {
        this.loadSegmentTileImage(material);
    }
};

og.layer.XYZ.prototype.GetHTTPRequestString = function (segment) {
    return og.layer.replaceTemplate(this.url, {
        "tilex": segment.tileX.toString(),
        "tiley": segment.tileY.toString(),
        "zoom": segment.zoomIndex.toString()
    });
};

og.layer.XYZ.prototype.loadSegmentTileImage = function (material) {
    var that = this;
    this.counter++;
    og.layer.requestsCounter++;
    var img = new Image();
    img.crossOrigin = '';
    img.onload = function () {
        var e = that.events.onload;
        if (e.length) {
            that.events.callEvents(e, {
                "image": this,
                "segment": material.segment
            });
        }
        material.applyTexture.call(material, this);
{'fraction_non_alphanumeric': 0.15432098765432098, 'fraction_numerical': 0.0, 'mean_word_length': 2.9083601286173635, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 5, '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': '1314298', 'n_tokens_mistral': 770, 'n_tokens_neox': 758, 'n_words': 123}