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', './WMSLayer'], 
 21 	function(Utils, WMSLayer) {
 22 
 23 /**************************************************************************************************************/
 24 
 25 /** @export
 26 	@constructor
 27 	WMSElevationLayer constructor
 28  */
 29 var WMSElevationLayer = function( options )
 30 {
 31 	options['format'] = 'image/x-aaigrid';
 32 	options['tilePixelSize'] = options['tilePixelSize'] || 33;
 33 	WMSLayer.prototype.constructor.call( this, options );
 34 }
 35 
 36 Utils.inherits(WMSLayer,WMSElevationLayer);
 37 
 38 
 39 /**************************************************************************************************************/
 40 
 41 /**
 42 	Parse a elevation response
 43  */
 44 WMSElevationLayer.prototype.parseElevations = function(text)
 45 {
 46 	var elevations = [];
 47 	var lines = text.trim().split('\n');
 48 	
 49 	for ( var i = 5; i < lines.length; i++ )
 50 	{
 51 		var elts = lines[i].trim().split(/\s+/);
 52 		for ( var n=0; n < elts.length; n++ )
 53 		{
 54 			elevations.push( parseInt(elts[n]) );
 55 		}
 56 	}
 57 	
 58 	return elevations;
 59 }
 60 
 61 /**************************************************************************************************************/
 62 
 63 return WMSElevationLayer;
 64 
 65 });
 66