<commit_before>
function Tile (maperial, x, y, z) {

   //--------------------------------//

   this.maperial = maperial;
   this.config = maperial.config;

   this.x         = x;
   this.y         = y;
   this.z         = z;
   
   this.layers    = {};

   this.assets       = maperial.context.assets;
   this.gl           = this.assets.ctx;

   // preparing double buffering to render as texture !
   this.frameBufferL = [];
   this.texL         = [];
   this.tex          = null;

   //--------------------------------//

   this.Init();
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.Init = function () {
   this.initLayers();
   this.maperial.sourcesManager.loadSources(this.x, this.y, this.z);
   this.prepareBuffering();
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.initLayers = function () {

   for(var i = 0; i< this.config.layers.length; i++){

      switch(this.config.layers[i].type){
   
         case LayersManager.Vector:
            this.layers[i] = new VectorialLayer ( this.maperial , this.z);
            break;
   
         case LayersManager.Raster:
            this.layers[i] = new RasterLayer    ( this.maperial , this.z);
            break;
   
         case LayersManager.Images:
            this.layers[i] = new ImageLayer     ( this.maperial.context.assets.ctx , this.z);
            break;
            
      }
      
   }
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.prepareBuffering = function () {
   var gltools = new GLTools ()
   for ( var i = 0 ; i < 2 ; i = i + 1 ) {
      var fbtx = gltools.CreateFrameBufferTex(this.gl, Maperial.tileSize, Maperial.tileSize);
      this.frameBufferL.push        ( fbtx[0] );
      this.texL.push                ( fbtx[1] );
   }
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.Release = function() {

   this.maperial.sourcesManager.release(this.x, this.y, this.z);
   
   for(var i = 0; i< this.config.layers.length; i++)
         this.layers[i].Release();
   
   var gl = this.gl;
   for ( var i = 0 ; i < 2 ; i = i + 1 ) {
      gl.deleteFramebuffer ( this.frameBufferL[i] );
      gl.deleteTexture     ( this.texL[i] );
   }
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.Reset = function ( ) {
   if(this.IsLoaded()) {
      for (i in this.layers) {      
         this.layers[i].Reset ( );
      }

      this.tex = null;
   }
}

Tile.prototype.IsUpToDate = function ( ) {
   return this.tex;
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.appendDataToLayers = function ( sourceType, data ) {
   for(var i = 0; i< this.config.layers.length; i++){
      try{
         if ( this.config.layers[i].source.type == sourceType )
            this.layers[i].Init( data );
      }
      catch(e){}
   }   
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.RenderVectorialLayers = function ( context, wx, wy ) {
   for (i in this.layers) {
      if (this.layers[i].GetType() == LayersManager.Vector && this.layers[i].IsUpToDate() && this.layers[i].cnv) {
         context.drawImage(this.layers[i].cnv, wx, wy);
      }
   }
}

//----------------------------------------------------------------------------------------------------------------------//

/*
 *  render the tile inside an invisibleCanvas with the layerId colors
 */
Tile.prototype.FindSubLayerId = function ( tileClickCoord, zoom, styleContent ) {

   // create an invisibleCanvas to render the pixel for every layers
   var canvas = document.getElementById("fakeCanvas");
   var ctx = canvas.getContext("2d");
   ExtendCanvasContext ( ctx );
   canvas.height = 1;
   canvas.width = 1;

   ctx.translate(-tileClickCoord.x, -tileClickCoord.y);
<commit_msg>tile WMS<commit_after>
function Tile (maperial, x, y, z) {

   //--------------------------------//

   this.maperial = maperial;
   this.config = maperial.config;

   this.x         = x;
   this.y         = y;
   this.z         = z;
   
   this.layers    = {};

   this.assets       = maperial.context.assets;
   this.gl           = this.assets.ctx;

   // preparing double buffering to render as texture !
   this.frameBufferL = [];
   this.texL         = [];
   this.tex          = null;

   //--------------------------------//

   this.Init();
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.Init = function () {
   this.initLayers();
   this.maperial.sourcesManager.loadSources(this.x, this.y, this.z);
   this.prepareBuffering();
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.initLayers = function () {

   for(var i = 0; i< this.config.layers.length; i++){

      switch(this.config.layers[i].type){
   
         case LayersManager.Vector:
            this.layers[i] = new VectorialLayer ( this.maperial , this.z);
            break;
   
         case LayersManager.Raster:
            this.layers[i] = new RasterLayer    ( this.maperial , this.z);
            break;
   
         case LayersManager.Images:
         case LayersManager.WMS:
            this.layers[i] = new ImageLayer     ( this.maperial.context.assets.ctx , this.z);
            break;
            
      }
      
   }
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.prepareBuffering = function () {
   var gltools = new GLTools ()
   for ( var i = 0 ; i < 2 ; i = i + 1 ) {
      var fbtx = gltools.CreateFrameBufferTex(this.gl, Maperial.tileSize, Maperial.tileSize);
      this.frameBufferL.push        ( fbtx[0] );
      this.texL.push                ( fbtx[1] );
   }
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.Release = function() {

   this.maperial.sourcesManager.release(this.x, this.y, this.z);
   
   for(var i = 0; i< this.config.layers.length; i++)
         this.layers[i].Release();
   
   var gl = this.gl;
   for ( var i = 0 ; i < 2 ; i = i + 1 ) {
      gl.deleteFramebuffer ( this.frameBufferL[i] );
      gl.deleteTexture     ( this.texL[i] );
   }
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.Reset = function ( ) {
   if(this.IsLoaded()) {
      for (i in this.layers) {      
         this.layers[i].Reset ( );
      }

      this.tex = null;
   }
}

Tile.prototype.IsUpToDate = function ( ) {
   return this.tex;
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.appendDataToLayers = function ( sourceType, data ) {
   for(var i = 0; i< this.config.layers.length; i++){
      try{
         if ( this.config.layers[i].source.type == sourceType )
            this.layers[i].Init( data );
      }
      catch(e){
         console.log("Could not append")
         console.log(e)
      }
   }   
}

//----------------------------------------------------------------------------------------------------------------------//

Tile.prototype.RenderVectorialLayers = function ( context, wx, wy ) {
   for (i in this.layers) {
      if (this.layers[i].GetType() == LayersManager.Vector && this.layers[i].IsUpToDate() && this.layers[i].cnv) {
         context.drawImage(this.layers[i].cnv, wx, wy);
      }
   }
}

//----------------------------------------------------------------------------------------------------------------------//

/*
 *  render the tile inside an invisibleCanvas with the layerId colors
 */
Tile.prototype.FindSubLayerId = function ( tileClickCoord, zoom, styleContent ) {

   // create an invisibleCanvas to render the pixel for every layers
   var canvas = document.getElementById("fakeCanvas");
   var ctx = canvas.getContext("2d");
   ExtendCanvasContext ( ctx );
   canvas.height = 1;
   canvas.width = 1;

   ctx.translate(-tileClickCoord.x, -tileClickCoord.y);

{'fraction_non_alphanumeric': 0.34829109509416417, 'fraction_numerical': 0.0032550569634968614, 'mean_word_length': 1.0507747318235996, 'pattern_counts': {'":': 0, '<': 13, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2555440', 'n_tokens_mistral': 2293, 'n_tokens_neox': 2230, 'n_words': 433}