
function WMSTileLayer(){}
WMSTileLayer.prototype.makeTileLayer=function(baseUrl,layer,imageType,style,copyright){
var nlayer=new GTileLayer(new GCopyrightCollection(""),1,17);
nlayer.getTileUrl=this.getTileUrl;
nlayer.isPng=this.isPng;
nlayer.getOpacity=this.getOpacity;
nlayer.animate=this.animate;
nlayer.baseUrl=baseUrl;
nlayer.layer=layer;
nlayer.style=style;
nlayer.imageType=imageType;
return nlayer;}
function makeImgUrl(obj,layer,bbox,width,height){
return obj.baseUrl+"version=1.1.1&request=GetMap&Layers="+layer+"&Styles="+obj.style+"&SRS=EPSG:4326&BBOX="+bbox+"&width="+width+"&height="+height+"&format="+obj.imageType+"&TRANSPARENT=true";}
function makeRadarImageArray(obj,bounds){
var ret=[];
var bbox=bounds.getSouthWest().lng()+","+bounds.getSouthWest().lat()+","+bounds.getNorthEast().lng()+","+bounds.getNorthEast().lat();
var width=400;
var height=400;
ret.push(makeImgUrl(obj,"nexrad-n0r-m45m",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r-m40m",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r-m35m",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r-m25m",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r-m20m",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r-m15m",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r-m10m",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r-m05min",bbox,width,height));
ret.push(makeImgUrl(obj,"nexrad-n0r",bbox,width,height));
return ret;}
WMSTileLayer.prototype.animate=function(speed){
var map=mapApp.map;
map.setMapType(mapApp.prevMapType);
var images=makeRadarImageArray(this,map.getBounds());
var ov=new EInsert(map.getBounds(),images[0],.7,50);
this.singleOverlay=ov;
this.noRemove=true;
map.addOverlay(ov);
ov.startAnimate(images,speed,0);}
WMSTileLayer.prototype.minResolution=function(){
return this.minResolution;}
WMSTileLayer.prototype.maxResolution=function(){
return this.maxResolution;}
WMSTileLayer.prototype.getTileUrl=function(tile,zoom){
var proj=G_NORMAL_MAP.getProjection();
var p1=proj.fromPixelToLatLng(new GPoint(tile.x*256,tile.y*256),zoom);
var p2=proj.fromPixelToLatLng(new GPoint((tile.x+1)*256,(tile.y+1)*256),zoom);
var bbox=p1.lng()+","+p2.lat()+","+p2.lng()+","+p1.lat();
var url=this.baseUrl+"version=1.1.1&request=GetMap&Layers="+this.layer+"&Styles="+this.style+"&SRS=EPSG:4326&BBOX="+bbox+"&width="+256+"&height="+256+"&format="+this.imageType+"&TRANSPARENT=true";
return url;}
WMSTileLayer.prototype.isPng=function(){
return this.imageType=='image/png';}
WMSTileLayer.prototype.getOpacity=function(){
return .7;}
function TRTileLayer(){}
TRTileLayer.prototype=new WMSTileLayer();
TRTileLayer.prototype.isPng=function(){
return this.imageType=='image/png';}
TRTileLayer.prototype.getOpacity=function(){
return .7;}
TRTileLayer.prototype.getTileUrl=function(tile,zoom){
var proj=G_NORMAL_MAP.getProjection();
var url=this.baseUrl+quadKey(tile.x,tile.y,zoom);
return url+".png";}
function quadKey(tx,ty,zl){
var quad="";
for(var i=zl;i>0;i--){
var mask=1<<(i-1);
var cell=0;
if((tx&mask)!=0)cell++;
if((ty&mask)!=0)cell+=2;
quad=quad+cell;}
return quad;}
function SGTileLayer(){}
SGTileLayer.prototype=new TRTileLayer();
SGTileLayer.prototype.getTileUrl=function(tile,zoom){
return this.baseUrl+"zoom="+zoom+"&x="+tile.x+"&y="+tile.y;}
function RadarControl(){}
RadarControl.prototype=new GControl();
RadarControl.prototype.initialize=function(map){
var container=document.createElement("div");
var zoomInDiv=document.createElement("div");
this.setButtonStyle_(zoomInDiv);
container.appendChild(zoomInDiv);
zoomInDiv.appendChild(document.createTextNode("Zoom In"));
GEvent.addDomListener(zoomInDiv,"click",function(){
map.zoomIn();});
var zoomOutDiv=document.createElement("div");
this.setButtonStyle_(zoomOutDiv);
container.appendChild(zoomOutDiv);
zoomOutDiv.appendChild(document.createTextNode("Zoom Out"));
GEvent.addDomListener(zoomOutDiv,"click",function(){
map.zoomOut();});
map.getContainer().appendChild(container);
return container;}
RadarControl.prototype.getDefaultPosition=function(){
return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,41));}
RadarControl.prototype.setButtonStyle_=function(button){
button.style.textDecoration="underline";
button.style.color="#0000cc";
button.style.backgroundColor="white";
button.style.font="small Arial";
button.style.border="1px solid black";
button.style.padding="2px";
button.style.marginBottom="3px";
button.style.textAlign="center";
button.style.width="6em";
button.style.cursor="pointer";}

