// JavaScript Document

var geo = new Object();

geo.vMap = function(xMax,xMin,yMax,yMin,mapWidth,mapHeight){
	//alert(mapHeight+"/"+document.getElementById("mapImage").offsetHeight)
	
   this.wXMax = xMax;
   this.wYMax = yMax;
   this.wXMin = xMin;
   this.wYMin =yMin;
   this.mapWidth = mapWidth;
   this.mapHeight = mapHeight;
   this.xFact=(this.wXMax-this.wXMin)/this.mapWidth;
   this.yFact=(this.wYMax-this.wYMin)/this.mapHeight;
   
}

geo.vPoint = function(){
this.X = 0;
this.Y = 0;
}

geo.vMap.prototype.toViewPoint = function(x,y)
{
	var vpt = new geo.vPoint();
	vpt.X = parseInt((x - this.wXMin) / this.xFact); 
	vpt.Y = parseInt(((this.wYMax - y)) / this.yFact);
	return vpt;	
}


geo.vMap.prototype.toWorldPoint = function(x,y)
{
	var vpt = new geo.vPoint();
	vpt.X = parseInt(this.wXMin + (x * this.xFact));
	vpt.Y = parseInt(this.wYMax - (y * this.yFact));
	return vpt;	
}

geo.vMap.prototype.toViewLength = function(l)
{
	var vpt = l / this.xFact
	return vpt;	
}
geo.vMap.prototype.toWorldLength = function(l)
{
	var vpt = l * this.xFact
	return vpt;	
}

