<commit_before>// Ideas from:
// https://github.com/ScanEx/Leaflet.imageTransform/blob/master/src/L.ImageTransform.js
// https://github.com/BenjaminVadant/leaflet-ugeojson

// Depends on:
// https://github.com/santilland/plotty
// https://github.com/constantinius/geotiff.js

// Note this will only work with ESPG:4326 tiffs

if(typeof(plotty)=='undefined'){
    throw new Error("plotty not defined");
};

if(typeof(GeoTIFF)=='undefined'){
    throw new Error("GeoTIFF not defined");
};

L.LeafletGeotiff = L.ImageOverlay.extend({
    initialize: function (url, options) { 
        this.raster = {};
        if (options.bounds) {
            this._rasterBounds = L.latLngBounds(options.bounds);
        } 
        L.Util.setOptions(this, options);
        
        this.options.colorScale = (options.colorScale==undefined) ? 'viridis' : options.colorScale;
        this.options.clampLow = (options.clampLow==undefined) ? true : options.clampLow;
        this.options.clampHigh = (options.clampHigh==undefined) ? true : options.clampHigh;
        this.options.arrowSize = (options.arrowSize==undefined) ? 20 : options.arrowSize;
        
        this._preLoadColorScale(); //Make sure colorScale is ready even if image takes a while to load
        this._getData(url);
    },
    setURL: function(newURL) {
        this._getData(newURL);
    },
    onAdd: function (map) {
        this._map = map;
        if (!this._image) {
            this._initImage();
        }

        map._panes.overlayPane.appendChild(this._image);

        map.on('moveend', this._reset, this);<commit_msg>Move depenency checks inside init.<commit_after>// Ideas from:
// https://github.com/ScanEx/Leaflet.imageTransform/blob/master/src/L.ImageTransform.js
// https://github.com/BenjaminVadant/leaflet-ugeojson

// Depends on:
// https://github.com/santilland/plotty
// https://github.com/constantinius/geotiff.js

// Note this will only work with ESPG:4326 tiffs


L.LeafletGeotiff = L.ImageOverlay.extend({
    initialize: function (url, options) { 
        if(typeof(plotty)=='undefined'){
            throw new Error("plotty not defined");
        };

        if(typeof(GeoTIFF)=='undefined'){
            throw new Error("GeoTIFF not defined");
        };

        this.raster = {};
        if (options.bounds) {
            this._rasterBounds = L.latLngBounds(options.bounds);
        } 
        L.Util.setOptions(this, options);
        
        this.options.colorScale = (options.colorScale==undefined) ? 'viridis' : options.colorScale;
        this.options.clampLow = (options.clampLow==undefined) ? true : options.clampLow;
        this.options.clampHigh = (options.clampHigh==undefined) ? true : options.clampHigh;
        this.options.arrowSize = (options.arrowSize==undefined) ? 20 : options.arrowSize;
        
        this._preLoadColorScale(); //Make sure colorScale is ready even if image takes a while to load
        this._getData(url);
    },
    setURL: function(newURL) {
        this._getData(newURL);
    },
    onAdd: function (map) {
        this._map = map;
        if (!this._image) {
            this._initImage();
        }

        map._panes.overlayPane.appendChild(this._image);

        map.on('moveend', this._reset, this);
{'fraction_non_alphanumeric': 0.13883735312306741, 'fraction_numerical': 0.0037105751391465678, 'mean_word_length': 2.6887115165336373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '1731821', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1000, 'n_words': 179}