1 /***************************************
  2  * Copyright 2011, 2012 GlobWeb contributors.
  3  *
  4  * This file is part of GlobWeb.
  5  *
  6  * GlobWeb is free software: you can redistribute it and/or modify
  7  * it under the terms of the GNU Lesser General Public License as published by
  8  * the Free Software Foundation, version 3 of the License, or
  9  * (at your option) any later version.
 10  *
 11  * GlobWeb is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14  * GNU Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU General Public License
 17  * along with GlobWeb. If not, see <http://www.gnu.org/licenses/>.
 18  ***************************************/
 19 
 20  define(['./Utils', './BaseLayer', './RasterOverlayRenderer' ], 
 21 	function(Utils, BaseLayer, RasterOverlayRenderer) {
 22 
 23 /**************************************************************************************************************/
 24 
 25 
 26 /** @name RasterLayer
 27 	@class
 28 	Base class for raster layer
 29 	@augments BaseLayer
 30 	@param options Configuration properties for the RasterLayer. See {@link BaseLayer} for base properties :
 31 		<ul>
 32 			<li>tilePixelSize : the image size for a tile, default is 256.</li>
 33 			<li>numberOfLevels : the maximum number of levels</li> 
 34 			<li>geoBound : the extent of the layer</li> 
 35 		</ul>
 36 */
 37 var RasterLayer = function( options )
 38 {
 39 	BaseLayer.prototype.constructor.call( this, options );
 40 	
 41 	// Base properties
 42 	this.tilePixelSize = -1;
 43 	this.tiling = null;
 44 	this.numberOfLevels = -1;
 45 	this.geoBound = options['geoBound'] || null;
 46 	this.coordinates = options['coordinates'] || null;
 47 	
 48 	// Internal
 49 	this._overlay = true; 
 50 	this._ready = true; // Ready is use by TileManager
 51 }
 52 
 53 /**************************************************************************************************************/
 54 
 55 Utils.inherits( BaseLayer,RasterLayer );
 56 
 57 /**************************************************************************************************************/
 58 
 59 /** 
 60   Attach the raster layer to the globe
 61  */
 62 RasterLayer.prototype._attach = function( g )
 63 {
 64 	if ( !this._overlay )
 65 	{
 66 		// Override id of background layer because of unicity of background not overlayed layer
 67 		this.id = 0;
 68 	}
 69 
 70 	BaseLayer.prototype._attach.call( this, g );
 71 		
 72 	if ( this._overlay )
 73 	{
 74 		// Create the renderer if needed
 75 		if ( !g.rasterOverlayRenderer )
 76 		{
 77 			var renderer = new RasterOverlayRenderer(g.tileManager);
 78 			g.tileManager.addPostRenderer(renderer);
 79 			g.rasterOverlayRenderer = renderer;
 80 		}
 81 		g.rasterOverlayRenderer.addOverlay(this);
 82 	}
 83 }
 84 
 85 /**************************************************************************************************************/
 86 
 87 /** 
 88   Detach the raster layer from the globe
 89  */
 90 RasterLayer.prototype._detach = function()
 91 {
 92 	// Remove raster from overlay renderer if needed
 93 	if ( this._overlay && this.globe.rasterOverlayRenderer )
 94 	{
 95 		this.globe.rasterOverlayRenderer.removeOverlay(this);
 96 	}
 97 	
 98 	BaseLayer.prototype._detach.call(this);
 99 }
100 
101 /**************************************************************************************************************/
102 
103 return RasterLayer;
104 
105 });
106