/*****************************************************************************
 *
 * File     : BoundingBox.js
 * 
 * Project  : WMS Viewer Client
 * 
 * Contents : 
 *
 * Author: Milan Trninic
 *
 * Copyright 1999-2005 Galdos Systems, Inc.
 * All rights reserved.
 * 
 ***|***************************|***********************|*******************|*/

/************************************************************************
*
*	function:	BoundingBox
*
*	purpose:	Constructor
*
*************************************************************************/
function BoundingBox(minx, miny, maxx, maxy, srsName)
{
	// method assignments
	this.init = BoundingBox.init;
	this.getSrsName = BoundingBox.getSrsName;
	this.getMinX = BoundingBox.getMinX;
	this.getMinY = BoundingBox.getMinY;
	this.getMaxX = BoundingBox.getMaxX;
	this.getMaxY = BoundingBox.getMaxY;
	this.toWmsRequest = BoundingBox.toWmsRequest;
	
	// instance field declarations
	this._minx;
	this._miny;
	this._maxx;
	this._maxy;
	this._srsName;
	
	// initialization
	this.init(minx, miny, maxx, maxy, srsName);
}

/************************************************************************
*
*	function:	init
*
*	purpose:	initialization
*
*************************************************************************/
function BoundingBox.init(minx, miny, maxx, maxy, srsName)
{
	this._minx = parseFloat(minx);
	if (isNaN(this._minx)) throw new Exception("Invalid bounding box (min x)");
	this._miny = parseFloat(miny);
	if (isNaN(this._miny)) throw new Exception("Invalid bounding box (min y)");
	this._maxx = parseFloat(maxx);
	if (isNaN(this._maxx)) throw new Exception("Invalid bounding box (max x)");
	this._maxy = parseFloat(maxy);
	if (isNaN(this._maxy)) throw new Exception("Invalid bounding box (max y)");
	this._srsName = srsName;
}

/************************************************************************
*
*	function:	getSrsName
*
*	purpose:	
*
*************************************************************************/
function BoundingBox.getSrsName()
{
	return 	this._srsName;
}

/************************************************************************
*
*	function:	getMinX
*
*	purpose:	
*
*************************************************************************/
function BoundingBox.getMinX()
{
	return 	this._minx;
}

/************************************************************************
*
*	function:	getMinY
*
*	purpose:	
*
*************************************************************************/
function BoundingBox.getMinY()
{
	return 	this._miny;
}

/************************************************************************
*
*	function:	getMaxX
*
*	purpose:	
*
*************************************************************************/
function BoundingBox.getMaxX()
{
	return 	this._maxx;
}

/************************************************************************
*
*	function:	getMaxY
*
*	purpose:	
*
*************************************************************************/
function BoundingBox.getMaxY()
{
	return 	this._maxy;
}

/************************************************************************
*
*	function:	toWmsRequest
*
*	purpose:	
*
*************************************************************************/
function BoundingBox.toWmsRequest()
{
	var result = "SRS=\"" + this._srsName + "\" ";
	result += "BBOX=\"";
	result += this._minx + ",";
	result += this._miny + ",";
	result += this._maxx + ",";
	result += this._maxy;
	result += "\"";
	return result;
}

