/* Copyright (C) 2006 ALPS Mapping K.K. */
var _delaytime=300;function getObjPos(g,obj){var pos=new Point(0,0);while(g&&g!=obj){pos.x+=g.offsetLeft;pos.y+=g.offsetTop;g=g.offsetParent;}return pos;};function getObjPos2(obj){var pos=new Point(0,0);while(obj){pos.x+=obj.offsetLeft;pos.y+=obj.offsetTop;obj=obj.offsetParent;}return pos;};function getRelativePos(e,obj,pos){if(!pos){pos=new Point(0,0);}if(typeof e.pageX!="undefined"){var Kd=getObjPos2(obj);pos.x=e.pageX-Kd.x;pos.y=e.pageY-Kd.y;}else if(typeof e.offsetX!="undefined"){var targetObj=e.target||e.srcElement;var xg=getObjPos(targetObj,obj);pos.x=e.offsetX+xg.x;pos.y=e.offsetY+xg.y;}return pos;};function KeyCodesArray(keyCodes){if(keyCodes){for(var i=keyCodes.length-1;i>=0;--i){this.add(keyCodes[i]);}}};KeyCodesArray.prototype.add=function(keyCode){if(!this.contains(keyCode)){this["key"+keyCode]=1;}};KeyCodesArray.prototype.remove=function(keyCode){if(this.exist(keyCode)){delete this["key"+keyCode];}};KeyCodesArray.prototype.contains=function(keyCode){return this["key"+keyCode]==1;};KeyCodesArray.prototype.exist=function(keyCode){return this["key"+keyCode]==1||this["key"+keyCode]==2;};KeyCodesArray.prototype.sleep=function(){for(prop in this){if(typeof this[prop]!="function"){this[prop]=2;}}};KeyCodesArray.prototype.wakeup=function(){for(prop in this){if(typeof this[prop]!="function"){this[prop]=1;}}};function Nothing(){return false;};function CancelBubble(e){if(_bi.type==1){window.event.cancelBubble=true;window.event.returnValue=false;}else{e.cancelBubble=true;if(e.preventDefault){e.preventDefault();}if(e.stopPropagation){e.stopPropagation();}}};function setMouseCursor(obj,shape){try{obj.style.cursor=shape;}catch(p){if(shape=="pointer"){setMouseCursor(obj,"hand");}}};function loadLatLonFromDOMNode(n){var unit=n.getAttribute("unit");var latlon=AlpsUtil.getNodeContent(n);var spLatlon=latlon.split(",");var lat=spLatlon[0];var lon=spLatlon[1];if(unit=="dms"){return new LLPoint(lat,lon);}else if(unit=="degree"){return new LLPoint(parseFloat(lat),parseFloat(lon));}else if(unit=="msec"){return new LLPoint(parseInt(lat)/3600000,parseInt(lon)/3600000);}};function ImageMaker(){};ImageMaker.createImg=function(path,visibility,zIndex,width,height){var img=document.createElement("IMG");img.src=path;if(width){img.width=width;}if(height){img.height=height;}img.style.position="absolute";img.style.top="0px";img.style.left="0px";if(zIndex){img.style.zIndex=zIndex;}if(_bi.type==1){img.unselectable="on";img.onselectstart=Nothing;img.galleryImg="no";}else{img.style.MozUserSelect="none";}img.oncontextmenu=Nothing;img.style.border="0";img.style.padding="0";img.style.margin="0";if(visibility){img.style.visibility=visibility;}return img;};function SpecType(){this.id="";this.name="";};SpecType.prototype.toString=function(){var str="SpecType:";str+="id: "+this.id+"\t"+"name: "+this.name;return str;};function SpecItem(){this.id="";this.name="";};SpecItem.prototype.toString=function(){var str="SpecItem:";str+="id: "+this.id+"\t"+"name: "+this.name;return str;};function ProjInfo(n2){if(n2.nodeName=="projection"){this.loadXML(n2);}else{this.name=arguments[0]; this.code=arguments[1]; this.origin=new LLPoint(arguments[2],arguments[3]); this.subInfo=arguments[4]; this.org1stMeshCode=0; this.id=0;}};ProjInfo.prototype.loadXML=function(n2){this.name=n2.getAttribute("name");var code=n2.getAttribute("type");if(code=="UTM"){this.code=0;}else{this.code=1;}var nl3=n2.childNodes;for(var i=0;i<nl3.length;++i){var n3=nl3[i];if(n3.nodeType==1&&n3.nodeName=="origin"){this.origin=loadLatLonFromDOMNode(n3);this.org1stMeshCode=Math.floor(this.origin.lat*1.5)*100+Math.floor(this.origin.lon-100);}else if(n3.nodeType==1&&n3.nodeName=="projfactor"){this.subInfo=parseFloat(AlpsUtil.getNodeContent(n3));}else if(n3.nodeType==1&&n3.nodeName=="ellipse"){var ellipse=AlpsUtil.getNodeContent(n3);if(ellipse=="bessele"){this.subInfo=1;}else if(ellipse=="sphere"){this.subInfo=0;}}}};ProjInfo.prototype.release=function(){this.origin.release();this._release();};function MapLayer(n1){this.projInfo=new Array; this.scrollrange=new Object; this.scrollrange.enable=false;this.specType=new Array; this.specItem=new Array; if(n1.nodeName=="layer"){this.loadXML(n1);}else{this.scale=n1; this.operation=true; }};MapLayer.prototype.toString=function(){var str="MapLayer:\n";str+="scale: "+this.scale+"\n";return str;};MapLayer.prototype.loadXML=function(n1){this.operation=true;if(n1.getAttribute("operation")=="no"){this.operation=false;}var nl2=n1.childNodes;for(var i=0;i<nl2.length;++i){var n2=nl2[i];if(n2.nodeType==1&&n2.nodeName=="projection"){var proj=new ProjInfo(n2);this.addProjInfo(proj);proj.id=this.projInfo.length-1;}else if(n2.nodeType==1&&n2.nodeName=="scale"){this.scale=parseInt(AlpsUtil.getNodeContent(n2));}else if(n2.nodeType==1&&n2.nodeName=="scrollrange"){this.scrollrange.enable=true;var nl3=n2.childNodes;for(var j=0;j<nl3.length;++j){var n3=nl3[j];if(n3.nodeType==1&&n3.nodeName=="bottomleft"){this.scrollrange.bottomleftLatLon=loadLatLonFromDOMNode(n3);}if(n3.nodeType==1&&n3.nodeName=="topright"){this.scrollrange.toprightLatLon=loadLatLonFromDOMNode(n3);}}}else if(n2.nodeType==1&&n2.nodeName=="speclist"){this.loadSpecTypeList(n2);}else if(n2.nodeType==1&&n2.nodeName=="specgroup"){this.loadSpecItemList(n2);}}};MapLayer.prototype.addProjInfo=function(projInfo){this.projInfo.push(projInfo);};MapLayer.prototype.getNearestProjInfo=function(target){var projInfo=this.projInfo[0];if(this.projInfo.length>=2){var mindist=Number.MAX_VALUE;for(var i=0;i<this.projInfo.length;++i){var org=this.projInfo[i].origin;var dist=(target.lat-org.lat)*(target.lat-org.lat)+(target.lon-org.lon)*(target.lon-org.lon);if(dist<mindist){mindist=dist;projInfo=this.projInfo[i];}}}return projInfo;};MapLayer.prototype.getProjInfoById=function(projId){var projInfo=this.projInfo[0];if(this.projInfo.length>=2){for(var i=0;i<this.projInfo.length;++i){if(this.projInfo[i].id==projId){projInfo=this.projInfo[i];break;}}}return projInfo;};MapLayer.prototype.getProjInfoByCode=function(code){var projInfo=this.projInfo[0];if(this.projInfo.length>=2){for(var i=0;i<this.projInfo.length;++i){if(this.projInfo[i].org1stMeshCode==code){projInfo=this.projInfo[i];break;}}}return projInfo;};MapLayer.prototype.getEnableProjInfo=function(layerCodeList,currentProjId){var changeProjInfo;for(var i=0;i<layerCodeList.length;++i){var layerCode=layerCodeList[i];if(layerCode.scale==this.scale){var projInfo=this.getProjInfoByCode(layerCode.code);changeProjInfo=projInfo;if(projInfo.id==currentProjId){break;}}}return changeProjInfo;};MapLayer.prototype.loadSpecTypeList=function(n2){var nl3=n2.childNodes;for(var j=0;j<nl3.length;++j){var n3=nl3[j];if(n3.nodeType==1&&n3.nodeName=="svespec"){var spectype=new SpecType();spectype.id=n3.getAttribute("id");spectype.name=n3.getAttribute("name");this.specType.push(spectype);}}};MapLayer.prototype.loadSpecItemList=function(n2){var nl3=n2.childNodes;for(var j=0;j<nl3.length;++j){var n3=nl3[j];if(n3.nodeType==1&&n3.nodeName=="svegroup"){var specgroup=new SpecItem();specgroup.id=n3.getAttribute("id");specgroup.name=n3.getAttribute("name");this.specItem.push(specgroup);}}};MapLayer.prototype.release=function(){this.projInfo.release();this.scrollrange.release();this.specType.release();this.specItem.release();this._release();};function MapPackage(n0){this.layerCollect=new Array; if(n0.nodeName=="mappackage"){this.loadXML(n0);}else{this.id="map";this.mapServerName=n0.baseURL; this.mapServerType=n0.type; this.mapServerSourceType=1; this.layerServerName=""; this.format="png"; this.setLayerInfo(n0);}};MapPackage.prototype.toString=function(){var str="MapPackage: "+this.id+"\n";for(var i=0;i<this.layerCollect.length;++i){str+=this.layerCollect[i].toString();}return str;};MapPackage.prototype.loadXML=function(n0){this.id=n0.getAttribute("id");var nl1=n0.childNodes;for(var i=0;i<nl1.length;++i){var n1=nl1[i];if(n1.nodeType==1&&n1.nodeName=="layer"){var layer=new MapLayer(n1);this.layerCollect.push(layer);}else if(n1.nodeType==1&&n1.nodeName=="mapservername"){var mapServerType=n1.getAttribute("type");if(mapServerType=="pes"){this.mapServerType=1}else if(mapServerType=="presplit"){this.mapServerType=2;}else if(mapServerType=="yahoo"){this.mapServerType=3;}var format=n1.getAttribute("format");if(format){this.format=format;}else{this.format="png";}var sourceType=n1.getAttribute("sourcetype");if(sourceType&&sourceType=="vector"){this.mapServerSourceType=2; }else{this.mapServerSourceType=1; }this.mapServerName=AlpsUtil.getNodeContent(n1);new Image().src=this.mapServerName;}else if(n1.nodeType==1&&n1.nodeName=="layerservername"){this.layerServerName=AlpsUtil.getNodeContent(n1);}}this.layerCollect.sort(function(a,b){return a.scale-b.scale;});};MapPackage.prototype.setLayerInfo=function(layerInfo){for(var i=0;i<layerInfo.count;++i){var projInfo=new ProjInfo("",layerInfo.projCode[i],layerInfo.projOrgLt[i]/3600000,layerInfo.projOrgLn[i]/3600000,layerInfo.projInfo[i]);var layer=new MapLayer(layerInfo.scale[i]);layer.addProjInfo(projInfo);this.layerCollect.push(layer);}};MapPackage.prototype.getLayerScale=function(layerId){var count=this.layerCollect.length;if(layerId<0){layerId=0;}else if(layerId>=count){layerId=count-1;}return this.layerCollect[layerId].scale;};MapPackage.prototype.getLayerId=function(scale,mode){var count=this.layerCollect.length;if(scale<=0){return 0;}if(scale>=this.getLayerScale(count-1)){return count-1;}var layerId=0;var diff=this.getLayerScale(count-1);for(var i=0;i<count;++i){var tempDiff=this.getLayerScale(i)-scale;if(mode&&mode==1&&tempDiff<0){continue;}if(mode&&mode==2&&tempDiff>0){continue;}tempDiff=Math.abs(tempDiff);if(tempDiff==0){diff=tempDiff;layerId=i;break;}if(tempDiff<diff){diff=tempDiff;layerId=i;}}return layerId;};MapPackage.prototype.release=function(){this.layerCollect.release();this._release();};function Tile(tileCollect){this.tileCollect=tileCollect; this.id=null; this.centerLatLon=null; this.enable=false; this.img=ImageMaker.createImg("/common/script/geo/vacantTile.gif","inherit",0,this.tileCollect.gazoSize.width,this.tileCollect.gazoSize.height);};Tile.prototype.setTileURL=function(){var strMapURI;var mapPackage=this.tileCollect.getCurrentPackage();var gazoSize=this.tileCollect.gazoSize;var layerId=this.tileCollect.layerId;var projId=this.tileCollect.projId;var angle=this.tileCollect.angle;if(mapPackage.mapServerType==0){}else if(mapPackage.mapServerType==3){var lpTileCenter = this.centerLatLon;var strOmajinai = "no part=0&la=0";var strScale = "scale=" + mapPackage.getLayerScale(layerId);var strWidth = "width=" + gazoSize.width;var strHeight = "height=" + gazoSize.height;var strLat = "nl=" + lpTileCenter.lat;var strLon = "el=" + lpTileCenter.lon;strMapURI = mapPackage.mapServerName + "?" +  strOmajinai + "&" +  strScale + "&" +  strWidth + "&" +  strHeight + "&" +  strLat + "&" +  strLon;}else if(mapPackage.mapServerType==1){var lpTileCenter= this.centerLatLon;var strScale= "scale="+mapPackage.getLayerScale(layerId);var strSize= "width="+gazoSize.width+"&height="+gazoSize.height;var strPos= "c="+lpTileCenter.lat+","+lpTileCenter.lon;var strOmajinai= "copyright=no&scalebar=no";strMapURI= mapPackage.mapServerName+"/"+mapPackage.format+"?"+strScale+"&"+strSize+"&"+strPos+"&"+strOmajinai;}else if(mapPackage.mapServerType==2){var org1stMeshCode= 0;if(mapPackage.layerCollect[layerId].projInfo.length>=2){org1stMeshCode= mapPackage.layerCollect[layerId].projInfo[projId].org1stMeshCode;}strMapURI= mapPackage.mapServerName+"/"+mapPackage.getLayerScale(layerId)+"/"+org1stMeshCode+"/"+Math.floor(this.id.x/100)+"_"+Math.floor(this.id.y/100)+"/"+this.id.x+"_"+this.id.y+"."+mapPackage.format;if(mapPackage.mapServerSourceType==2){strMapURI+="?";var vectorOpe=this.tileCollect.mapView.mapCtrl.vectorOpe;if(!vectorOpe.visibleVecHeimen){strMapURI+="heimen=no&"}if(!vectorOpe.visibleVecTyuki){strMapURI+="tyuki=no&"}if(!vectorOpe.visibleVecRaster){strMapURI+="raster=no&";}if(vectorOpe.specHide.length){strMapURI+="spechide=";strMapURI+=vectorOpe.specHide.join(",");strMapURI+="&";}strMapURI+="spectype=";if(vectorOpe.vecSpecType!="normal"){strMapURI+=vectorOpe.vecSpecType;}else{strMapURI+="normal";}if(angle!=0){strMapURI+="&angle=";strMapURI+=angle;}}}if(this.img.src!=strMapURI){if(this.tileCollect.mapView.mapCtrl.vacantTilePath){this.img.src=this.tileCollect.mapView.mapCtrl.vacantTilePath;}else{this.img.src="/common/script/geo/vacantTile.gif";}this.img.src=strMapURI;}};function ProAtlasSheet(mapView,parentContainer,bUpper){this.mapView=mapView;this.bUpper=bUpper; this.packageId="map"; this.layerId=null; this.projId=null; this.scale=0; this.magnify=1; this.angle=0; this.gazoSize=new Size(256,256); this.tileSize=new Size(this.gazoSize.width,this.gazoSize.height); this.div=document.createElement("div");this.div.style.position="absolute";this.div.style.top="0px";this.div.style.left="0px";parentContainer.appendChild(this.div);this.tileArray=new Array();this.tileXCount=0;this.tileYCount=0;this.tileCount=0;this.bTileIntialized=false;};ProAtlasSheet.prototype.getCurrentPackage=function(){return this.mapView.getMapPackage(this.packageId);};ProAtlasSheet.prototype.getTileById=function(id){for(var i=0;i<this.tileCount;++i){var tile=this.tileArray[i];if((tile.id!=null)&&(tile.id.x==id.x)&&(tile.id.y==id.y)){return tile;}}return null;};ProAtlasSheet.prototype.getTileByIndex=function(index){return this.tileArray[index];};ProAtlasSheet.prototype.getFirstEditableTile=function(){for(var i=0;i<this.tileCount;++i){var tile=this.tileArray[i];if(!tile.enable){return tile;}}return null;};ProAtlasSheet.prototype.resetAllTiles=function(){for(var i=0;i<this.tileCount;++i){var tile=this.tileArray[i];tile.id=null;tile.centerLatLon=null;tile.enable=false;tile.img.src="/common/script/geo/vacantTile.gif";}};ProAtlasSheet.prototype.setVisible=function(visible){this.div.style.visibility=visible?"visible":"hidden";};ProAtlasSheet.prototype.setOpacity=function(val){if(_bi.type==1){for(var i=0;i<this.tileCount;++i){this.tileArray[i].img.style.filter="alpha(opacity=0)";this.tileArray[i].img.filters.alpha.Opacity=(val*100);}}else if(_bi.type==2){this.div.style.MozOpacity=val;}else if(_bi.type==3){this.div.style.opacity=val;}else{if(val<0.5){this.setVisible(false);}else{this.setVisible(true);}}};ProAtlasSheet.prototype.ResetOpacity=function(){if(_bi.type==1){for(var i=0;i<this.tileCount;++i){this.tileArray[i].img.style.filter="";}}else if(_bi.type==2){}else if(_bi.type==3){}else{}};ProAtlasSheet.prototype.setZIndex=function(val){this.div.style.zIndex=val;};ProAtlasSheet.prototype.isImageAllLoaded=function(){if(_bi.type==3){return true;}else{var ret=true;for(var i=0;i<this.tileCount;++i){if(!this.tileArray[i].img.complete){ret=false;}}return ret;}};ProAtlasSheet.prototype.setTileCount=function(width,height,bGetNewImage){var gazoSize=this.gazoSize;var tileSize=this.tileSize;tileSize.width=gazoSize.width*this.magnify;tileSize.height=gazoSize.height*this.magnify;if(bGetNewImage){var tileXCount=Math.floor(width/tileSize.width)+2;var tileYCount=Math.floor(height/tileSize.height)+2;var tileTotalCount=tileXCount*tileYCount;var diff=tileTotalCount-this.tileCount;if(diff>0){for(var i=0;i<diff;++i){var tile=new Tile(this);this.div.appendChild(tile.img);this.tileArray.push(tile);}}else if(diff<0){for(var i=0;i<-diff;++i){var tile=this.tileArray.pop();this.div.removeChild(tile.img);}}this.tileXCount=tileXCount;this.tileYCount=tileYCount;this.tileCount=tileTotalCount;}var tileWidth=Math.round(tileSize.width);var tileHeight=Math.round(tileSize.height);for(var i=0;i<this.tileCount;++i){this.tileArray[i].img.width=tileWidth;this.tileArray[i].img.height=tileHeight;}};ProAtlasSheet.prototype.setCenterAndScale=function(center,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange){var packageChanged=false; if(this.packageId!=packageId&&this.mapView.ExistMapPackage(packageId)){packageChanged=true;var scale=0;if(this.layerId!=null&&layerId==null){scale=this.mapView.getMapPackage(this.packageId).getLayerScale(this.layerId);}this.packageId=packageId; if(scale!=0){layerId=this.getCurrentPackage().getLayerId(scale);}}if(layerId==null){layerId=0;}var mapPackage=this.getCurrentPackage();if(layerId<0||layerId>=mapPackage.layerCollect.length){layerId=this.layerId;}var layer=mapPackage.layerCollect[layerId];var projInfo;if(bProjectionChange){if(this.mapView.mapCtrl.layerCodeList){projInfo=layer.getEnableProjInfo(this.mapView.mapCtrl.layerCodeList[mapPackage.id],this.projId);}if(!projInfo){projInfo=layer.getNearestProjInfo(center);}this.projId=projInfo.id;}else{projInfo=layer.getProjInfoById(this.projId);}if(this.getCurrentPackage().mapServerSourceType!=2){angle=0;}var scale=layer.scale/magnify;this.mapView.setCenterAndScale(projInfo,center,scale,angle);if(packageChanged||this.layerId!=layerId||this.angle!=angle){ this.resetAllTiles(); }if(this.layerId!=layerId){this.layerId=layerId; }if(!this.bTileIntialized||this.magnify!=magnify){ this.magnify=magnify; this.setTileCount(this.mapView.conv.m_windowWidth,this.mapView.conv.m_windowHeight,bGetNewImage);this.bTileIntialized=true;}if(this.angle!=angle){this.angle=angle; }this.configureAllTiles(bGetNewImage);if(_bi.type==1){var dummy1=this.mapView.mapContainer.offsetWidth;var dummy2=this.mapView.mapContainer.offsetHeight;}};ProAtlasSheet.prototype.configureAllTiles=function(bGetNewImage){if(this.layerId==null){return;}var topleft=this.mapView.conv.LL2Log(this.mapView.conv.getProjOrigin());var gamenLeft=topleft.x*-1;var gamenTop=topleft.y*-1;var gamenRight=gamenLeft+this.mapView.conv.m_windowWidth;var gamenBottom=gamenTop+this.mapView.conv.m_windowHeight;var gamenCenterX=(gamenLeft+gamenRight)/2;var gamenCenterY=(gamenTop+gamenBottom)/2;var centerTileId=new Point(Math.floor(gamenCenterX/this.tileSize.width),Math.floor(gamenCenterY/this.tileSize.height));var centerTileTopLeft=new Point(Math.round(this.mapView.conv.m_windowWidth/2+(centerTileId.x*this.tileSize.width-gamenCenterX)),Math.round(this.mapView.conv.m_windowHeight/2+(centerTileId.y*this.tileSize.height-gamenCenterY)));var tileLeft,tileTop,tileRight,tileBottom;if(this.tileXCount%2!=0){ var temp=Math.floor(this.tileXCount/2);tileLeft=centerTileId.x-temp;tileRight=centerTileId.x+temp;}else{ var temp=Math.floor(this.tileXCount/2);if(gamenCenterX/this.tileSize.width-centerTileId.x>0.5){tileLeft=centerTileId.x-(temp-1);tileRight=centerTileId.x+temp;}else{tileLeft=centerTileId.x-temp;tileRight=centerTileId.x+(temp-1);}}if(this.tileYCount%2!=0){ var temp=Math.floor(this.tileYCount/2);tileTop=centerTileId.y-temp;tileBottom=centerTileId.y+temp;}else{ var temp=Math.floor(this.tileYCount/2);if(gamenCenterY/this.tileSize.height-centerTileId.y>0.5){tileTop=centerTileId.y-(temp-1);tileBottom=centerTileId.y+temp;}else{tileTop=centerTileId.y-temp;tileBottom=centerTileId.y+(temp-1);}}for(var i=0;i<this.tileCount;++i){this.getTileByIndex(i).enable=false;}var requestTiles=new Array();var gamenCenter=new Point((gamenLeft+gamenRight)/2,(gamenTop+gamenBottom)/2);for(var j=tileTop;j<=tileBottom;++j){for(var i=tileLeft;i<=tileRight;++i){var id=new Point(i,j);var tile=this.getTileById(id);if(tile!=null){ tile.enable=true;var bSetImage=false;this.configureTile(tile,bSetImage,centerTileId,centerTileTopLeft);}else if(bGetNewImage){ var tileCenter=new Point((i+0.5)*this.tileSize.width,(j+0.5)*this.tileSize.height);var sqdist=Point.sqdist(gamenCenter,tileCenter);var centerLatLon=null;var mapServerType=this.getCurrentPackage().mapServerType;if(mapServerType==1||mapServerType==3){ centerLatLon=this.mapView.conv.Log2LL(new Point(tileCenter.x-gamenLeft,tileCenter.y-gamenTop));}var rqTile=new TileRequest(id,sqdist,centerLatLon);requestTiles.push(rqTile);}}}requestTiles.sort(tileSort);for(var i=0;i<requestTiles.length;++i){var request=requestTiles[i];var tile=this.getFirstEditableTile();if(tile!=null){tile.enable=true;tile.id=request.id; tile.centerLatLon=request.centerLatLon; var bSetImage=true;this.configureTile(tile,bSetImage,centerTileId,centerTileTopLeft);}}};function tileSort(a,b){return a.sqdist-b.sqdist;};ProAtlasSheet.prototype.configureTile=function(tile,bSetImage,centerTileId,centerTileTopLeft){var diffX=(tile.id.x-centerTileId.x)*Math.round(this.tileSize.width);var diffY=(tile.id.y-centerTileId.y)*Math.round(this.tileSize.height);var tileLeft=centerTileTopLeft.x+diffX;var tileTop=centerTileTopLeft.y+diffY;tile.img.style.left=tileLeft+"px";tile.img.style.top=tileTop+"px";if(bSetImage==true){tile.setTileURL();}};ProAtlasSheet.prototype.release=function(){this.gazoSize.release();this.tileSize.release();this.tileArray.release();this._release();};function TileRequest(id,sqdist,centerLatLon){this.id=id;this.sqdist=sqdist;this.centerLatLon=centerLatLon;};function ProAtlasMapView(mapContainer,mapCtrl){this.mapContainer=mapContainer; this.mapCtrl=mapCtrl; this.packageCollect=new Array; this.conv=new CoordinatesConversion(); this.fadeinTimerId=0;this.mapContainer.style.overflow="hidden";if(this.mapContainer.style.position!="absolute"){this.mapContainer.style.position="relative"}this.viewContainer=document.createElement("div");this.viewContainer.style.position="absolute";this.viewContainer.style.top="0px";this.viewContainer.style.left="0px";this.mapContainer.appendChild(this.viewContainer);this.backSheet=new ProAtlasSheet(this,this.viewContainer,false); this.frontSheet=new ProAtlasSheet(this,this.viewContainer,true); this.frontSheet.setVisible(true);this.backSheet.setVisible(false);this.setVisibleCopyright(true);};ProAtlasMapView.prototype.toString=function(){var str="ProAtlasMapView\n";for(var i=0;i<this.packageCollect.length;++i){var packageId=this.packageCollect[i];var aaa=this.getMapPackage(packageId);str+=aaa.toString();}return str;};var _mAlpsCopy='';ProAtlasMapView.prototype.setVisibleCopyright=function(visible){if(!this.copyright){this.copyright=this.createCopyright(_mAlpsCopy);this.copyright.style.right="22px";this.copyright.style.bottom="3px";this.mapContainer.appendChild(this.copyright);}this.copyright.style.visibility=visible?"visible":"hidden";};ProAtlasMapView.prototype.createCopyright=function(strCopyright){var obj=document.createElement("div");obj.style.position="absolute";obj.style.zIndex="5000";obj.style.backgroundImage="url('/sh/images/mcontrol/copyright.gif')";obj.style.width="150px";obj.style.height="23px";if(_bi.type==1){obj.unselectable="on";obj.onselectstart=Nothing;}else{obj.style.MozUserSelect="none";}obj.oncontextmenu=Nothing;setMouseCursor(obj,"default"); obj.innerHTML=strCopyright;return obj;};ProAtlasMapView.prototype.getVisibleCopyright=function(){if(!this.copyright){return false;}return this.copyright.style.visibility=="visible";};ProAtlasMapView.prototype.createCenterMark=function(path,size){this.centerImg=ImageMaker.createImg(path,"visible",0,size,size);this.mapContainer.appendChild(this.centerImg);this.centerImg.style.left=(this.mapContainer.offsetWidth-this.centerImg.width)/2 + "px";this.centerImg.style.top=(this.mapContainer.offsetHeight-this.centerImg.height)/2 + "px";};ProAtlasMapView.prototype.getVisibleCenterMark=function(){if(!this.centerImg){return false;}return this.centerImg.style.visibility=="visible";};ProAtlasMapView.prototype.setVisibleCenterMark=function(visible){if(!this.centerImg){return;}this.centerImg.style.visibility=visible?"visible":"hidden";};ProAtlasMapView.prototype.addMapPackage=function(mapPackage){this.packageCollect.push(mapPackage.id);this.packageCollect[mapPackage.id]=mapPackage;};ProAtlasMapView.prototype.getMapPackage=function(packageId){return this.packageCollect[packageId];};ProAtlasMapView.prototype.ExistMapPackage=function(packageId){for(var i=0;i<this.packageCollect.length;++i){if(this.packageCollect[i]==packageId){return true;}}return false;};ProAtlasMapView.prototype.resizeMapView=function(){this.conv.setWindowSize(this.mapContainer.offsetWidth,this.mapContainer.offsetHeight);var bGetNewImage=this.mapCtrl.zoomTimerId?false:true;this.frontSheet.setTileCount(this.mapContainer.offsetWidth,this.mapContainer.offsetHeight,bGetNewImage);var bGetNewImage=true;this.frontSheet.configureAllTiles(bGetNewImage);if(this.centerImg){this.centerImg.style.left=(this.mapContainer.offsetWidth-this.centerImg.width)/2 + "px";this.centerImg.style.top=(this.mapContainer.offsetHeight-this.centerImg.height)/2 + "px";}};ProAtlasMapView.prototype.flipSheet=function(){var frontSheet=this.frontSheet;this.frontSheet=this.backSheet;this.backSheet=frontSheet;this.frontSheet.setVisible(true);this.backSheet.setVisible(false);this.backSheet.resetAllTiles();};ProAtlasMapView.prototype.fadeinFlipSheet=function(type){var frontSheet=this.frontSheet;this.frontSheet=this.backSheet;this.backSheet=frontSheet;if(!this.frontSheet.bUpper){this.viewContainer.removeChild(this.frontSheet.div);this.viewContainer.appendChild(this.frontSheet.div);this.frontSheet.bUpper=true;this.backSheet.bUpper=false;}this.frontSheet.setOpacity(0);this.frontSheet.setVisible(true);var func="this.timerFadein(1,'"+type+"')";this.fadeinTimerId=this.setTimeout(func,10);};ProAtlasMapView.prototype.timerFadein=function(val,type){if(val>10){this.backSheet.setVisible(false);this.frontSheet.setOpacity(1);this.frontSheet.ResetOpacity();this.backSheet.ResetOpacity();this.backSheet.resetAllTiles();this.fadeinTimerId=0;if(type=="package"){AlpsEvent.triggerEvent(this.mapCtrl,"packageChanged");if(this.frontSheet.angle!=this.backSheet.angle){AlpsEvent.triggerEvent(this.mapCtrl,"angleChanged");}}else if(type=="angle"){AlpsEvent.triggerEvent(this.mapCtrl,"angleChanged");}}else{this.frontSheet.setOpacity(val/10);var newval=val+1.25;var func="this.timerFadein("+newval+",'"+type+"')";this.fadeinTimerId=this.setTimeout(func,150);}};ProAtlasMapView.prototype.setCenterAndScale=function(projInfo,center,scale,angle){var org=new LLPoint(projInfo.origin.lat,projInfo.origin.lon);this.conv.setProjConv(projInfo.code,org,projInfo.subInfo);this.conv.setScale(scale);this.conv.setAngle(angle);this.conv.setCenter(center);};ProAtlasMapView.prototype.release=function(){for(var i=0;i<this.packageCollect.length;++i){var id=this.packageCollect[i];this.packageCollect[id].release();delete this.packageCollect[id];}this.conv.release();this.backSheet.release();this.frontSheet.release();this._release();};var _maxMagnify=5;var _minMagnify=0.5;function ProAtlasMapCtrl(mapContainer,layerInfo,strType){this.mouseX=0;this.mouseY=0;this.mouseDownX=0;this.mouseDownY=0;this.scrollType=0; this.autoScrollTimerId=0;this.enableDragScroll=true;this.enableDbClickCentering=true;this.enableSingleClickCentering=false;this.isMouseMoved=false; this.isMouseDown=false; this.mouseDownTime=null; this.zoomTimerId=0;this.zoomElapseTime=50;this.targetMagnify=0;this.stepMagnify=0;this.isSmoothZoomEnd=false;this.enableWheelOperation=true;this.cntrngTimerId=0;this.cntrngElapseTime=10; this.cntrngTotalTime=300; this.cntrngCrrntStep=0; this.targetSize=new Size(0,0); this.currentPos=new Point(0,0); this.flightScrollTimerId=0;this.flightScrollElapseTime=30; this.coefficientOfAirResistance=10; this.objectMass=2; this.accelerationOfJetEngine=5000; this.velocityX=0; this.velocityY=0; this.arrowKeys=new KeyCodesArray();this.enableKeyboardOperation=true;this.enableMagnifyOperation=true;this.enableLayerOperation=true;this.enableSmoothLayerOperation=true;this.enableAngleOperation=false;this.enableSmoothScroll=true;this.vectorOpe=new Object;this.vectorOpe.visibleVecHeimen=true; this.vectorOpe.visibleVecTyuki=true; this.vectorOpe.visibleVecRaster=true; this.vectorOpe.vecSpecType="normal"; this.vectorOpe.specHide=new Array; this.enableAutoLayerChange=false;this.mapView=new ProAtlasMapView(mapContainer,this);AlpsEvent.addBuiltInEvent(window,"resize",this.eventHandler("onResize"));this.eventSrc=mapContainer.setCapture?mapContainer:window; this.mouseDownHandler=this.eventHandler("onMouseDown");this.mouseMoveHandler=this.eventHandler("onMouseMove");this.mouseUpHandler=this.eventHandler("onMouseUp");AlpsEvent.addBuiltInEvent(mapContainer,"mousedown",this.mouseDownHandler);AlpsEvent.addBuiltInEvent(this.eventSrc,"mousemove",this.mouseMoveHandler);AlpsEvent.addBuiltInEvent(this.eventSrc,"mouseup",this.mouseUpHandler);if(_bi.type==2){AlpsEvent.bindBuiltInEvent(window,"mouseout",this,this.onWindowMouseOut);} AlpsEvent.bindEvent(this,"mapMoved",this,this.mapMoved);AlpsEvent.bindEvent(this,"mapMoving",this,this.mapMoving);this.mapMovedTimerId=0;AlpsEvent.bindEvent(this,"layerListChanged",this,this.layerListChanged);if(_bi.type==3){ AlpsEvent.addBuiltInEvent(window.document,"keypress",this.eventHandler("onKeyDown"));}else{ AlpsEvent.addBuiltInEvent(window.document,"keydown",this.eventHandler("onKeyDown"));}AlpsEvent.addBuiltInEvent(window.document,"keyup",this.eventHandler("onKeyUp"));if(_bi.type==2){ AlpsEvent.addBuiltInEvent(window.document,"DOMMouseScroll",this.eventHandler("onMouseWheel"));}else{ AlpsEvent.addBuiltInEvent(window.document,"mousewheel",this.eventHandler("onMouseWheel"));}AlpsEvent.addBuiltInEvent(mapContainer,"click",this.eventHandler("onClick"));AlpsEvent.addBuiltInEvent(mapContainer,"dblclick",this.eventHandler("onDblClick"));this.onResizeEnd();this.loadMap(layerInfo,strType);this.layerScaleList=new Object;this.layerCodeList=new Object;for(var i=0;i<this.mapView.packageCollect.length;++i){var packageId=this.mapView.packageCollect[i];this.layerScaleList[packageId]=new Array;var layerCollect=this.mapView.getMapPackage(packageId).layerCollect;for(var j=0;j<layerCollect.length;++j){this.layerScaleList[packageId].push(layerCollect[j].scale);}this.layerCodeList[packageId]=new Array;}};ProAtlasMapCtrl.prototype.toString=function(){var str="ProAtlasMapCtrl\n";str+=this.mapView.toString();return str;};ProAtlasMapCtrl.prototype.loadMap=function(layerInfo,strType){if(typeof(layerInfo)=="object"){var mapPackage=new MapPackage(layerInfo);this.mapView.addMapPackage(mapPackage);}else if(typeof(layerInfo)=="string"){this.loadXML(layerInfo,strType);}};ProAtlasMapCtrl.prototype.loadXML=function(param,strType){var doc=null;if(strType!=null&&strType=="string"){doc=AlpsUtil.getXMLDOMFromStr(param);}else{doc=AlpsUtil.getXMLDOM(param);}if(!doc)return;var n=doc.getElementsByTagName("proatlasmap")[0];if(!n)return;var nl0=n.childNodes;for(var i=0;i<nl0.length;++i){var n0=nl0[i];if(n0.nodeType==1&&n0.nodeName=="mappackage"){var mapPackage=new MapPackage(n0);this.mapView.addMapPackage(mapPackage);}else if(n0.nodeType==1&&n0.nodeName=="defaultposition"){this.loadDefaultPosition(n0);}else if(n0.nodeType==1&&n0.nodeName=="centermark"){this.loadCenterMark(n0);}else if(n0.nodeType==1&&n0.nodeName=="autoscrollanchor"){this.loadAnchor(n0);}else if(n0.nodeType==1&&n0.nodeName=="vacanttile"){this.loadVacantTile(n0);}}this.defaultTo();};ProAtlasMapCtrl.prototype.loadCenterMark=function(n0){var path=n0.getAttribute("src");var size=n0.getAttribute("size");this.mapView.createCenterMark(path,size);};ProAtlasMapCtrl.prototype.loadAnchor=function(n0){var path=n0.getAttribute("src");var size=n0.getAttribute("size");this.anchorImg=ImageMaker.createImg(path,"hidden",0,size,size);this.mapView.mapContainer.appendChild(this.anchorImg);};ProAtlasMapCtrl.prototype.loadVacantTile=function(n0){this.vacantTilePath=n0.getAttribute("src");};ProAtlasMapCtrl.prototype.loadDefaultPosition=function(n0){var nl1=n0.childNodes;for(var i=0;i<nl1.length;++i){var n1=nl1[i];if(n1.nodeType==1&&n1.nodeName=="mappackage"){this.defPackageId=AlpsUtil.getNodeContent(n1);}else if(n1.nodeType==1&&n1.nodeName=="position"){this.defPos=loadLatLonFromDOMNode(n1);}else if(n1.nodeType==1&&n1.nodeName=="scale"){this.defScale=parseInt(AlpsUtil.getNodeContent(n1));}}};ProAtlasMapCtrl.prototype.onResize=function(){if(_bi.type==1||_bi.type==4||_bi.type==3){this.resizeEnd=(this.resizeEnd==null)?(new Object()):this.resizeEnd;clearTimeout(this.resizeEnd);this.resizeEnd=this.setTimeout("this.onResizeEnd()",100);}else{this.onResizeEnd();}};ProAtlasMapCtrl.prototype.onResizeEnd=function(){this.mapView.resizeMapView();AlpsEvent.triggerEvent(this,"resize");};ProAtlasMapCtrl.prototype.getWindowSize=function(){var sz=new Size(0,0);if(window.self&&self.innerWidth){sz.width=self.innerWidth;sz.height=self.innerHeight;return sz;}if(document.documentElement&&document.documentElement.clientHeight){sz.width=document.documentElement.clientWidth;sz.height=document.documentElement.clientHeight;return sz;}sz.width=document.body.clientWidth;sz.height=document.body.clientHeight;return sz;};ProAtlasMapCtrl.prototype.onMouseDown=function(e){if(e.button!=0&&e.button!=1){CancelBubble(e);return false;}this.isMouseDown=true;this.isMouseMoved=false;this.mouseX=e.screenX;this.mouseY=e.screenY;this.mouseDownX=e.screenX;this.mouseDownY=e.screenY;if(this.mapView.mapContainer.setCapture){this.mapView.mapContainer.setCapture()}CancelBubble(e);if(this.arrowKeys.contains(16)){if(this.anchorImg){var pos=getRelativePos(e,this.mapView.mapContainer);this.anchorImg.style.left=pos.x-this.anchorImg.width/2 + "px";this.anchorImg.style.top=pos.y-this.anchorImg.height/2 + "px";this.anchorImg.style.visibility="visible";}this.scrollType=1;this.autoScrollCount=0;this.autoScroll(); }else{this.scrollType=0;}this.mouseDownTime=(new Date()).getTime();};ProAtlasMapCtrl.prototype.onMouseMove=function(e){if(!this.isMouseDown){return;}var scrollX=e.screenX-this.mouseX;var scrollY=e.screenY-this.mouseY;if(Math.abs(scrollX)>0||Math.abs(scrollY)>0){this.isMouseMoved=true;if(this.scrollType==0&&this.enableDragScroll){this.dragScroll(scrollX,scrollY);}this.mouseX=e.screenX;this.mouseY=e.screenY;}};ProAtlasMapCtrl.prototype.onMouseUp=function(e){if(document.releaseCapture){document.releaseCapture();}if(this.scrollType==1){if(this.anchorImg){this.anchorImg.style.visibility="hidden";}clearTimeout(this.autoScrollTimerId);this.autoScrollTimerId=0;AlpsEvent.triggerEvent(this,"mapMoved",true);this.isMouseDown=false;return;}var currTime=(new Date()).getTime();if(currTime-this.mouseDownTime<=500&&!this.isMouseMoved){}else if(this.isMouseDown&&this.isMouseMoved&&this.enableDragScroll){AlpsEvent.triggerEvent(this,"mapMoved",true);}this.isMouseDown=false;};ProAtlasMapCtrl.prototype.autoScroll=function(){var targetX=this.mouseX-this.mouseDownX;var targetY=this.mouseY-this.mouseDownY;var target = new Point(this.mapView.conv.m_windowWidth/2+targetX/10,this.mapView.conv.m_windowHeight/2+targetY/10);var lpTarget=this.mapView.conv.Log2LL(target);this.moveTo(lpTarget,null,true/*fromUI*/);if(this.autoScrollCount>=30){this.autoScrollCount=0;AlpsEvent.triggerEvent(this,"mapMoved",true);}else{this.autoScrollCount+=1;}this.autoScrollTimerId=this.setTimeout("this.autoScroll()", 10);};ProAtlasMapCtrl.prototype.dragScroll=function(scrollX,scrollY){var target = new Point(this.mapView.conv.m_windowWidth/2-scrollX,this.mapView.conv.m_windowHeight/2-scrollY);var lpTarget=this.mapView.conv.Log2LL(target);this.moveTo(lpTarget,null,true/*fromUI*/);};ProAtlasMapCtrl.prototype.onWindowMouseOut=function(e){if(!e.relatedTarget&&this.isMouseDown){this.onMouseUp(e);}};ProAtlasMapCtrl.prototype.onKeyDown=function(e){if(!this.enableKeyboardOperation){return true;}e=(e?e:window.event);switch(e.keyCode){case 33: if(this.enableLayerOperation){var layerId=this.mapView.frontSheet.layerId+1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.layerTo(layerId,null,true);}CancelBubble(e);return false;}else{return true;}case 34: if(this.enableLayerOperation){var layerId=this.mapView.frontSheet.layerId-1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.layerTo(layerId,null,true);}CancelBubble(e);return false;}else{return true;}case 36: if(this.enableMagnifyOperation){var magnify=1;if(this.arrowKeys.contains(16)){if(this.mapView.frontSheet.magnify>1){magnify=1;}else{magnify=_minMagnify;}}else{magnify=this.mapView.frontSheet.magnify/1.2;}this.magnifyTo(magnify,true);CancelBubble(e);return false; }else{return true;}case 35: if(this.enableMagnifyOperation){var magnify=1;if(this.arrowKeys.contains(16)){if(this.mapView.frontSheet.magnify<1){magnify=1;}else{magnify=_maxMagnify;}}else{magnify=this.mapView.frontSheet.magnify*1.2;}this.magnifyTo(magnify,true);CancelBubble(e);return false;}else{return true;}case 45: if(this.enableSmoothLayerOperation){var layerId=this.mapView.frontSheet.layerId+1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.smoothLayerTo(layerId,true);}CancelBubble(e);return false;}else{return true;}case 46: if(this.enableSmoothLayerOperation){var layerId=this.mapView.frontSheet.layerId-1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.smoothLayerTo(layerId,true);}CancelBubble(e);return false;}else{return true;}case 82: if(this.enableAngleOperation){var angle=this.getCurrentAngle()+5;if(this.arrowKeys.contains(16)){this.smoothAngleTo(angle);}else{this.angleTo(angle,true);}CancelBubble(e);return false;}else{return true;}case 76: if(this.enableAngleOperation){var angle=this.getCurrentAngle()-5;if(this.arrowKeys.contains(16)){this.smoothAngleTo(angle);}else{this.angleTo(angle,true);}CancelBubble(e);return false;}else{return true;}case 37: case 38: case 39: case 40: this.arrowKeys.add(e.keyCode);this.startFlightScroll();CancelBubble(e);return false;case 16: this.arrowKeys.add(e.keyCode);CancelBubble(e);return false;case 18: if(_bi.type==2&&_bi.subType==1){CancelBubble(e);return false;}return true;}return true;};ProAtlasMapCtrl.prototype.onKeyUp=function(e){switch(e.keyCode){case 37: case 38: case 39: case 40: case 16: this.arrowKeys.remove(e.keyCode);CancelBubble(e);return false;}return true;};ProAtlasMapCtrl.prototype.smoothZoom=function(){if(!this.isSmoothZoomEnd){var currentMagnify=this.mapView.frontSheet.magnify;var targetMagnify=currentMagnify*this.stepMagnify;if(targetMagnify>100||targetMagnify<0.01){this.isSmoothZoomEnd=true;}else{if((this.stepMagnify>1&&targetMagnify>this.targetMagnify)||   (this.stepMagnify<1&&targetMagnify<this.targetMagnify)){targetMagnify=this.targetMagnify;this.isSmoothZoomEnd=true;}var lpTarget=this.mapView.conv.m_center;var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var angle=this.mapView.frontSheet.angle;var bGetNewImage=false;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(lpTarget,packageId,layerId,targetMagnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"layerChanging");}this.zoomTimerId=this.setTimeout("this.smoothZoom()", this.zoomElapseTime);}else{var packageId=this.mapView.backSheet.packageId;var layerId=this.mapView.backSheet.layerId;this.mapView.backSheet.magnify=1;var bGetNewImage=true;this.mapView.backSheet.setTileCount(this.mapView.conv.m_windowWidth,this.mapView.conv.m_windowHeight,bGetNewImage);var lpTarget=this.mapView.conv.m_center;var angle=this.mapView.backSheet.angle;var bProjectionChange=false;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,this.mapView.backSheet.magnify,angle,bGetNewImage,bProjectionChange);this.mapView.flipSheet();this.mapView.backSheet.magnify=1;this.mapView.backSheet.setTileCount(this.mapView.conv.m_windowWidth,this.mapView.conv.m_windowHeight,bGetNewImage);bProjectionChange=true;this.zoomTimerId=0;AlpsEvent.triggerEvent(this,"layerChanged");}};ProAtlasMapCtrl.prototype.onMouseWheel=function(e){if(!this.enableWheelOperation){return;}e=(e?e:window.event);var target=e.srcElement||e.target;var delta=e.wheelDelta?e.wheelDelta:e.detail*-1;while(target.id!=this.mapView.mapContainer.id){if(target.parentNode==null)return;target=target.parentNode;}var layerId;if(delta<0){ layerId=this.mapView.frontSheet.layerId-1;}else{ layerId=this.mapView.frontSheet.layerId+1;}if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.smoothLayerTo(layerId,true);}CancelBubble(e);return;};ProAtlasMapCtrl.prototype.onClick=function(e){if(!this.isMouseMoved){var pos=getRelativePos(e,this.mapView.mapContainer);var lpPoint=this.log2LatLon(pos);if(this.enableSingleClickCentering){if(this.enableSmoothScroll){this.startSmoothCentering(pos,true);}else{this.moveTo(lpPoint,null,true/*fromUI*/);}}AlpsEvent.triggerEvent(this,"click",lpPoint);}};ProAtlasMapCtrl.prototype.onDblClick=function(e){var pos=getRelativePos(e,this.mapView.mapContainer);var lpPoint=this.log2LatLon(pos);if(this.enableDbClickCentering){if(this.enableSmoothScroll){this.startSmoothCentering(pos,true);}else{this.moveTo(lpPoint,null,true/*fromUI*/);}}AlpsEvent.triggerEvent(this,"dbClick",lpPoint);};ProAtlasMapCtrl.prototype.startSmoothCentering=function(pos,fromUI){this.stopFlightScroll(fromUI);AlpsEvent.triggerEvent(this,"mapSmoothMoving");var centerX=this.mapView.conv.m_windowWidth/2;var centerY=this.mapView.conv.m_windowHeight/2;var targetX=pos.x-centerX;var targetY=pos.y-centerY;var dist=Math.sqrt((targetX*targetX+targetY*targetY)/(centerX*centerX+centerY*centerY));this.cntrngCrrntStep=0; this.cntrngElapseTime=10; this.cntrngTotalTime=dist>0.2?200:50; this.targetSize.width=targetX; this.targetSize.height=targetY; this.currentPos.x=0; this.currentPos.y=0; if(fromUI==null){fromUI=false;}this.cntrngTimerId=this.setTimeout("this.smoothCentering(" + fromUI+ ")", 1);};ProAtlasMapCtrl.prototype.smoothCentering=function(fromUI){this.cntrngCrrntStep+=1;var t=this.cntrngCrrntStep*this.cntrngElapseTime/this.cntrngTotalTime;var targetX=this.targetSize.width*(2*t-t*t);var targetY=this.targetSize.height*(2*t-t*t);var targetPos=new Point(this.mapView.conv.m_windowWidth/2+targetX-this.currentPos.x,this.mapView.conv.m_windowHeight/2+targetY-this.currentPos.y);var lpTarget=this.mapView.conv.Log2LL(targetPos);this.moveTo(lpTarget,null,fromUI,true/*fromSmoothCentering*/);this.currentPos.x=targetX;this.currentPos.y=targetY;if(t<1){this.cntrngTimerId=this.setTimeout("this.smoothCentering(" + fromUI+ ")", this.cntrngElapseTime);}else{this.cntrngTimerId=0;if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);}};ProAtlasMapCtrl.prototype.stopSmoothCentering=function(fromUI){if(this.cntrngTimerId!=0){clearTimeout(this.cntrngTimerId);this.cntrngTimerId=0;if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);return true;}else{return false;}};ProAtlasMapCtrl.prototype.startFlightScroll=function(){if(this.flightScrollTimerId==0){this.flightScrollCount=0;this.flightScrollTimerId=this.setTimeout("this.flightScroll()",5);}};ProAtlasMapCtrl.prototype.stopFlightScroll=function(fromUI){if(this.flightScrollTimerId!=0){clearTimeout(this.flightScrollTimerId);this.flightScrollTimerId=0;this.velocityX=0;this.velocityY=0;if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);return true;}else{return false;}};ProAtlasMapCtrl.prototype.flightScroll=function(){var accelerationX=0;var accelerationY=0;var acceleration=this.accelerationOfJetEngine;if(this.arrowKeys.contains(16)){acceleration*=3;} if(this.arrowKeys.contains(37)){accelerationX-=acceleration;}if(this.arrowKeys.contains(39)){accelerationX+=acceleration;}if(this.arrowKeys.contains(38)){accelerationY-=acceleration;}if(this.arrowKeys.contains(40)){accelerationY+=acceleration;}this.flightScrollCore(accelerationX,accelerationY,this.flightScrollElapseTime/1000);if(this.velocityX!=0||this.velocityY!=0){if(this.flightScrollCount>=50){this.flightScrollCount=0;AlpsEvent.triggerEvent(this,"mapMoved",true);}else{this.flightScrollCount+=1;}this.flightScrollTimerId=this.setTimeout("this.flightScroll()",this.flightScrollElapseTime)}else{this.flightScrollTimerId=0;AlpsEvent.triggerEvent(this,"mapMoved",true);}};ProAtlasMapCtrl.prototype.flightScrollCore=function(accelerationX,accelerationY,duration){var airResistanceX=-this.coefficientOfAirResistance*this.velocityX;var airResistanceY=-this.coefficientOfAirResistance*this.velocityY;var resultantX=this.objectMass*accelerationX+airResistanceX;var resultantY=this.objectMass*accelerationY+airResistanceY;var aX=resultantX/this.objectMass;var aY=resultantY/this.objectMass;var targetX=this.velocityX*duration+0.5*aX*duration*duration;var targetY=this.velocityY*duration+0.5*aY*duration*duration;if(Math.abs(targetX)<2&&Math.abs(targetY)<2){this.velocityX=0;this.velocityY=0;}else{this.velocityX=targetX/duration;this.velocityY=targetY/duration;if(targetX!=0||targetY!=0){var targetPos=new Point(this.mapView.conv.m_windowWidth/2+targetX,this.mapView.conv.m_windowHeight/2+targetY);var lpTarget=this.mapView.conv.Log2LL(targetPos);this.moveTo(lpTarget,true,true/*fromUI*/);}}};ProAtlasMapCtrl.prototype.mapMoving=function(){if(this.mapMovedTimerId){window.clearTimeout(this.mapMovedTimerId);this.mapMovedTimerId=0;}};ProAtlasMapCtrl.prototype.mapMoved=function(){if(this.mapMovedTimerId){window.clearTimeout(this.mapMovedTimerId);this.mapMovedTimerId=0;}this.mapMovedTimerId=this.setTimeout("this.timer_updateLayerScaleList()",_delaytime);};ProAtlasMapCtrl.prototype.timer_updateLayerScaleList=function(){for(var i=0;i<this.mapView.packageCollect.length;++i){this.updateLayerScaleList(this.mapView.packageCollect[i]);}};ProAtlasMapCtrl.prototype.layerListChanged=function(packageId,lpCenter){if(packageId!=this.getCurrentPackageId()){return;}if(packageId==this.mapView.frontSheet.packageId){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var currentProjId=this.mapView.frontSheet.projId;var projInfo=layer.getEnableProjInfo(this.layerCodeList[packageId],currentProjId);if(projInfo&&currentProjId!=projInfo.id){this.mapView.frontSheet.projId=projInfo.id;var tempPackageId=this.mapView.frontSheet.packageId;var lpTarget=this.mapView.conv.m_center;var tempLayerId=this.mapView.frontSheet.layerId;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.frontSheet.setCenterAndScale(lpTarget,tempPackageId,tempLayerId,magnify,angle,bGetNewImage,bProjectionChange);}}if(this.enableAutoLayerChange){var layerId=this.getCurrentLayerId();if(this.IsEnableLayer(packageId,layerId)){return;}while(true){layerId+=1;if(layerId>=this.getLayerCount()){break;}if(this.IsEnableLayer(packageId,layerId)){this.smoothLayerTo(layerId,true);break;}}}};ProAtlasMapCtrl.prototype.updateLayerScaleList=function(packageId){var xmlhttp=AlpsUtil.getXMLHttp();if(!xmlhttp)return;var p=this.getCenterLatLon();var layerServerName=this.mapView.getMapPackage(packageId).layerServerName;var mapCtrl=this;var timerIdProp="getLayerTimerId_"+packageId;xmlhttp.open("POST",layerServerName,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(mapCtrl[timerIdProp]){window.clearTimeout(mapCtrl[timerIdProp]);mapCtrl[timerIdProp]=null;}var currentCenter=mapCtrl.getCenterLatLon();if(currentCenter.lat!=p.lat||currentCenter.lon!=p.lon){return;}var count=mapCtrl.layerScaleList[packageId].length;for(var i=0;i<count;++i){mapCtrl.layerScaleList[packageId].pop();mapCtrl.layerCodeList[packageId].pop();}if(xmlhttp.status==200){var layers=AlpsUtil.getElementContent(xmlhttp.responseXML,"layers");if(layers){var s=layers.split(",");for(var i=0;i<s.length;++i){mapCtrl.layerScaleList[packageId].push(parseInt(s[i]));}}var nR=xmlhttp.responseXML.getElementsByTagName("result")[0];var nRChild=nR.childNodes;for(var i=0;i<nRChild.length;++i){var n=nRChild[i];if(n.nodeType==1&&n.nodeName=="layer"){var code=n.getAttribute("code");var scale=AlpsUtil.getNodeContent(n);var layerCode=new Object;layerCode.scale=scale;layerCode.code=code;mapCtrl.layerCodeList[packageId].push(layerCode);}}}else {var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){mapCtrl.layerScaleList[packageId].push(layerCollect[i].scale);}}AlpsEvent.triggerEvent(mapCtrl,"layerListChanged",packageId,p);}};var doc=AlpsUtil.createXMLDOM();var query=doc.createElement("query");doc.appendChild(query);var coordinates=doc.createElement("coordinates");query.appendChild(coordinates);coordinates.appendChild(doc.createTextNode(p.toString()));xmlhttp.send(doc);if(this[timerIdProp]){window.clearTimeout(this[timerIdProp]);this[timerIdProp]=null;}this[timerIdProp]=this.setTimeout('this.getLayerTimeoutFn("'+packageId+'")',3000);};ProAtlasMapCtrl.prototype.getLayerTimeoutFn=function(packageId){var count=this.layerScaleList[packageId].length;for(var i=0;i<count;++i){this.layerScaleList[packageId].pop();}var timerIdProp="getLayerTimerId_"+packageId;this[timerIdProp]=null;var layerCollect=this.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){this.layerScaleList[packageId].push(layerCollect[i].scale);}AlpsEvent.triggerEvent(this,"layerListChanged",packageId);};ProAtlasMapCtrl.prototype.IsEnableLayer=function(packageId,layerId){var mapPackage=this.mapView.getMapPackage(packageId);var scale=mapPackage.getLayerScale(layerId);var layerScaleList=this.layerScaleList[packageId];for(var i=0;i<layerScaleList.length;++i){if(layerScaleList[i]==scale){return true;}}return false;};ProAtlasMapCtrl.prototype.moveTo=function(lpPoint,bAvoidStopFlightScroll,fromUI,fromSmoothCentering){var target=this.checkScrollRange(lpPoint);if(fromSmoothCentering==null){fromSmoothCentering=false;}if(!fromSmoothCentering){this.stopSmoothCentering(fromUI);}if(bAvoidStopFlightScroll==null){bAvoidStopFlightScroll=false;}if(!bAvoidStopFlightScroll){this.stopFlightScroll(fromUI);}var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(target,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"mapMoving");if(!this.isMouseDown&& !fromSmoothCentering&& this.velocityX==0&&this.velocityY==0 ){if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);}};ProAtlasMapCtrl.prototype.checkScrollRange=function(lpPoint){var mapLayer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.getCurrentLayerId()];var projInfo=mapLayer.projInfo[this.mapView.frontSheet.projId];var target=new LLPoint(lpPoint.lat,lpPoint.lon);if(!mapLayer.scrollrange.enable){return target;}var conv=new CoordinatesConversion();conv.setProjConv(projInfo.code,new LLPoint(projInfo.origin.lat,projInfo.origin.lon),projInfo.subInfo);conv.setScale(this.getCurrentScale()/this.getCurrentMagnify());conv.setAngle(0);conv.setCenter(this.getCenterLatLon());var mtrBottomLeft=conv.LL2Meter(mapLayer.scrollrange.bottomleftLatLon);var mtrTopRight=conv.LL2Meter(mapLayer.scrollrange.toprightLatLon);var mtrTarget=conv.LL2Meter(target);var restricted=false;if(mtrTarget.x<mtrBottomLeft.x){restricted=true;mtrTarget.x=mtrBottomLeft.x;}if(mtrTarget.y<mtrBottomLeft.y){restricted=true;mtrTarget.y=mtrBottomLeft.y;}if(mtrTopRight.x<mtrTarget.x){restricted=true;mtrTarget.x=mtrTopRight.x;}if(mtrTopRight.y<mtrTarget.y){restricted=true;mtrTarget.y=mtrTopRight.y;}if(restricted){target=conv.Meter2LL(mtrTarget);}return target;};ProAtlasMapCtrl.prototype.smoothMoveTo=function(lpPoint){this.stopSmoothCentering();this.stopFlightScroll();var targetPos=this.mapView.conv.LL2Log(lpPoint);this.startSmoothCentering(targetPos);};ProAtlasMapCtrl.prototype.packageTo=function(packageId){if(this.zoomTimerId!=0){return;}this.stopSmoothCentering();this.stopFlightScroll();var layerId=null;var scale=0;if(this.mapView.frontSheet.layerId!=null){scale=this.mapView.getMapPackage(this.mapView.frontSheet.packageId).getLayerScale(this.mapView.frontSheet.layerId);}if(scale!=0){layerId=this.mapView.getMapPackage(packageId).getLayerId(scale);}var lpTarget=this.mapView.conv.m_center;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.flipSheet();AlpsEvent.triggerEvent(this,"packageChanged");if(this.mapView.frontSheet.angle!=this.mapView.backSheet.angle){AlpsEvent.triggerEvent(this,"angleChanged");}};ProAtlasMapCtrl.prototype.smoothPackageTo=function(packageId){if(_bi.type!=1&&_bi.type!=2&&_bi.type!=3){this.packageTo(packageId);return;}if(this.mapView.fadeinTimerId!=0){return;}if(this.zoomTimerId!=0){return;}if(packageId==this.mapView.frontSheet.packageId){return;}this.stopSmoothCentering();this.stopFlightScroll();AlpsEvent.triggerEvent(this,"smoothPackageChanging",this.mapView.frontSheet.packageId,packageId);var layerId=null;var scale=0;if(this.mapView.frontSheet.layerId!=null){scale=this.mapView.getMapPackage(this.mapView.frontSheet.packageId).getLayerScale(this.mapView.frontSheet.layerId);}if(scale!=0){layerId=this.mapView.getMapPackage(packageId).getLayerId(scale);}var lpTarget=this.mapView.conv.m_center;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.fadeinFlipSheet("package");};ProAtlasMapCtrl.prototype.layerTo=function(layerId,sheet,fromUI){if(this.zoomTimerId!=0){return;}if(sheet==null){sheet=this.mapView.frontSheet;}if(fromUI){var mapPackage=sheet.getCurrentPackage();if(0<=layerId&&layerId<mapPackage.layerCollect.length){if(!mapPackage.layerCollect[layerId].operation){return;}}}if(layerId<0||sheet.getCurrentPackage().layerCollect.length<=layerId){return;}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);var packageId=sheet.packageId;var lpTarget=this.mapView.conv.m_center;var magnify=sheet.magnify;var angle=sheet.angle;var bGetNewImage=true;var bProjectionChange=true;sheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"layerChanged");};ProAtlasMapCtrl.prototype.smoothLayerTo=function(layerId,fromUI){if(this.zoomTimerId!=0){return;}var mapPackage=this.mapView.frontSheet.getCurrentPackage();if(layerId<0||layerId>=mapPackage.layerCollect.length){return;}if(layerId==this.mapView.frontSheet.layerId){return;}if(fromUI){if(!mapPackage.layerCollect[layerId].operation){return;}}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);AlpsEvent.triggerEvent(this,"smoothLayerChanging",this.mapView.frontSheet.layerId,layerId);this.mapView.backSheet.magnify=1;var bGetNewImage=true;this.mapView.backSheet.setTileCount(this.mapView.conv.m_windowWidth,this.mapView.conv.m_windowHeight,bGetNewImage);var packageId=this.mapView.frontSheet.packageId;var lpTarget=this.mapView.conv.m_center;var angle=this.mapView.frontSheet.angle;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,this.mapView.backSheet.magnify,angle,bGetNewImage,bProjectionChange);var currentScale=mapPackage.getLayerScale(this.mapView.frontSheet.layerId);var targetScale=mapPackage.getLayerScale(this.mapView.backSheet.layerId);this.targetMagnify=currentScale/targetScale;this.stepMagnify=Math.pow(this.targetMagnify,0.1);this.isSmoothZoomEnd=false;this.zoomTimerId=this.setTimeout("this.smoothZoom()", this.zoomElapseTime);};ProAtlasMapCtrl.prototype.moveAndLayerTo=function(lpPoint,layerId){if(this.zoomTimerId!=0){return;}this.stopSmoothCentering();this.stopFlightScroll();var packageId=this.mapView.frontSheet.packageId;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.frontSheet.setCenterAndScale(lpPoint,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"mapMoving");AlpsEvent.triggerEvent(this,"mapMoved",false);AlpsEvent.triggerEvent(this,"layerChanged");};ProAtlasMapCtrl.prototype.magnifyTo=function(magnify,fromUI){if(this.zoomTimerId!=0){return;}if(magnify<_minMagnify){magnify=_minMagnify;}if(magnify>_maxMagnify){magnify=_maxMagnify;}if(this.getCurrentMagnify()==magnify){return;}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);var lpTarget=this.mapView.conv.m_center;var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"magnifyChanged");};ProAtlasMapCtrl.prototype.defaultTo=function(){var layerId=this.mapView.getMapPackage(this.defPackageId).getLayerId(this.defScale);this.magnifyTo(1);this.packageTo(this.defPackageId);this.moveAndLayerTo(this.defPos,layerId);};ProAtlasMapCtrl.prototype.latLon2Log=function(lpPoint){return this.mapView.conv.LL2Log(lpPoint);};ProAtlasMapCtrl.prototype.log2LatLon=function(point){return this.mapView.conv.Log2LL(point);};ProAtlasMapCtrl.prototype.setEnableDragScroll=function(bEnable){this.enableDragScroll=bEnable;};ProAtlasMapCtrl.prototype.getEnableDragScroll=function(){return this.enableDragScroll;};ProAtlasMapCtrl.prototype.setEnableDbClickCentering=function(newVal){this.enableDbClickCentering=newVal;};ProAtlasMapCtrl.prototype.getEnableDbClickCentering=function(){return this.enableDbClickCentering;};ProAtlasMapCtrl.prototype.setEnableSingleClickCentering=function(newVal){this.enableSingleClickCentering=newVal;};ProAtlasMapCtrl.prototype.getEnableSingleClickCentering=function(){return this.enableSingleClickCentering;};ProAtlasMapCtrl.prototype.setEnableKeyboardOperation=function(bEnable){this.enableKeyboardOperation=bEnable;if(!bEnable){this.arrowKeys.sleep();}else{this.arrowKeys.wakeup();this.startFlightScroll();}};ProAtlasMapCtrl.prototype.getEnableKeyboardOperation=function(){return this.enableKeyboardOperation;};ProAtlasMapCtrl.prototype.setEnableMagnifyOperation=function(bEnable){this.enableMagnifyOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableMagnifyOperation=function(){return this.enableMagnifyOperation;};ProAtlasMapCtrl.prototype.setEnableLayerOperation=function(bEnable){this.enableLayerOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableLayerOperation=function(){return this.enableLayerOperation;};ProAtlasMapCtrl.prototype.setEnableSmoothLayerOperation=function(bEnable){this.enableSmoothLayerOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableSmoothLayerOperation=function(){return this.enableSmoothLayerOperation;};ProAtlasMapCtrl.prototype.setEnableAngleOperation=function(bEnable){this.enableAngleOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableAngleOperation=function(){return this.enableAngleOperation;};ProAtlasMapCtrl.prototype.setEnableSmoothScroll=function(bEnable){this.enableSmoothScroll=bEnable;};ProAtlasMapCtrl.prototype.getEnableSmoothScroll=function(){return this.enableSmoothScroll;};ProAtlasMapCtrl.prototype.setEnableWheelOperation=function(bEnable){this.enableWheelOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableWheelOperation=function(){return this.enableWheelOperation;};ProAtlasMapCtrl.prototype.setVisibleCenterMark=function(newVal){this.mapView.setVisibleCenterMark(newVal);};ProAtlasMapCtrl.prototype.getVisibleCenterMark=function(){return this.mapView.getVisibleCenterMark();};ProAtlasMapCtrl.prototype.setVisibleCopyright=function(newVal){this.mapView.setVisibleCopyright(newVal);};ProAtlasMapCtrl.prototype.getVisibleCopyright=function(){this.mapView.getVisibleCopyright();};ProAtlasMapCtrl.prototype.setEnableAutoLayerChange=function(newVal){this.enableAutoLayerChange=newVal;};ProAtlasMapCtrl.prototype.getEnableAutoLayerChange=function(){return this.enableAutoLayerChange;};ProAtlasMapCtrl.prototype.getCenterLatLon=function(){return new LLPoint(this.mapView.conv.m_center.lat,this.mapView.conv.m_center.lon);};ProAtlasMapCtrl.prototype.getCurrentPackageId=function(){return this.mapView.frontSheet.packageId;};ProAtlasMapCtrl.prototype.getPackageList=function(){var array=new Array;for(var i=0;i<this.mapView.packageCollect.length;++i){array.push(this.mapView.packageCollect[i]);}return array;};ProAtlasMapCtrl.prototype.getCurrentLayerId=function(){return this.mapView.frontSheet.layerId;};ProAtlasMapCtrl.prototype.getCurrentScale=function(){return this.getLayerScale(this.getCurrentLayerId());};ProAtlasMapCtrl.prototype.getCurrentMagnify=function(){return this.mapView.frontSheet.magnify;};ProAtlasMapCtrl.prototype.getLayerCount=function(){var mapPackage=this.mapView.frontSheet.getCurrentPackage();return mapPackage.layerCollect.length;};ProAtlasMapCtrl.prototype.getLayerId=function(scale,mode){return this.mapView.frontSheet.getCurrentPackage().getLayerId(scale,mode);};ProAtlasMapCtrl.prototype.getLayerScale=function(layerId){var mapPackage=this.mapView.frontSheet.getCurrentPackage();return mapPackage.getLayerScale(layerId);};ProAtlasMapCtrl.prototype.getContainer=function(){return this.mapView.mapContainer;};ProAtlasMapCtrl.prototype.getLayerScaleList=function(packageId){if(packageId==null){packageId=this.mapView.frontSheet.packageId;}var ret=new Array;for(var i=0;i<this.layerScaleList[packageId].length;++i){ret.push(this.layerScaleList[packageId][i]);}return ret;};ProAtlasMapCtrl.prototype.asyncGetLayerScaleList=function(packageId,lpPoint,returnFunc){if(packageId==null){packageId=this.mapView.frontSheet.packageId;}if(!this.mapView.ExistMapPackage(packageId)){return;}var xmlhttp=AlpsUtil.getXMLHttp();if(!xmlhttp)return;var layerServerName=this.mapView.getMapPackage(packageId).layerServerName;var mapCtrl=this;var timerIdProp="asyncGetLayerTimerId_"+packageId+lpPoint.toString();xmlhttp.open("POST",layerServerName,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(mapCtrl[timerIdProp]){window.clearTimeout(mapCtrl[timerIdProp]);mapCtrl[timerIdProp]=null;}var layerScaleList=new Array;if(xmlhttp.status==200){var layers=AlpsUtil.getElementContent(xmlhttp.responseXML,"layers");if(layers){var s=layers.split(",");for(var i=0;i<s.length;++i){layerScaleList.push(parseInt(s[i]));}}}else {var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){layerScaleList.unshift(layerCollect[i].scale);}}returnFunc(layerScaleList);}};var doc=AlpsUtil.createXMLDOM();var query=doc.createElement("query");doc.appendChild(query);var coordinates=doc.createElement("coordinates");query.appendChild(coordinates);coordinates.appendChild(doc.createTextNode(lpPoint.toString()));xmlhttp.send(doc);};ProAtlasMapCtrl.prototype.setSize=function(width,height){if(width){this.mapView.mapContainer.style.width=width;}if(height){this.mapView.mapContainer.style.height=height;}this.mapView.resizeMapView();AlpsEvent.triggerEvent(this,"resize");};ProAtlasMapCtrl.prototype.resetCenter=function(){this.mapView.resizeMapView();AlpsEvent.triggerEvent(this,"resize");};ProAtlasMapCtrl.prototype.getProjOrigin=function(){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var projInfo=layer.getProjInfoById(this.mapView.frontSheet.projId);return new LLPoint(projInfo.origin.lat,projInfo.origin.lon);};ProAtlasMapCtrl.prototype.getProjection=function(){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var projInfo=layer.getProjInfoById(this.mapView.frontSheet.projId);if(projInfo.code==0){return 0;}else{if(projInfo.subInfo==0){return 1;}else{return 2;}}};ProAtlasMapCtrl.prototype.getProjFactor=function(){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var projInfo=layer.getProjInfoById(this.mapView.frontSheet.projId);if(projInfo.code==0){return projInfo.subInfo;}else{return 0;}};ProAtlasMapCtrl.prototype.getSuitableScale=function(lpBottomLeft,lpTopRight){var mtClientWidth=this.mapView.conv.m_windowWidth;var mtClientHeight=this.mapView.conv.m_windowHeight;var mtOrigin=this.mapView.conv.LL2Meter(lpBottomLeft);var mtEnd=this.mapView.conv.LL2Meter(lpTopRight);var mtTargetWidth=Math.abs(mtEnd.x-mtOrigin.x);var mtTargetHeight=Math.abs(mtEnd.y-mtOrigin.y);return Math.max(mtTargetWidth/mtClientWidth*10*1000, mtTargetHeight/mtClientHeight*10*1000);};ProAtlasMapCtrl.prototype.getSuitableLayerId=function(lpBottomLeft,lpTopRight){var mode=1; return this.getLayerId(this.getSuitableScale(lpBottomLeft,lpTopRight),mode);};ProAtlasMapCtrl.prototype.setVecHeimenVisible=function(visible){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.visibleVecHeimen=visible;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecHeimenVisible=function(){return this.vectorOpe.visibleVecHeimen;};ProAtlasMapCtrl.prototype.setVecTyukiVisible=function(visible){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.visibleVecTyuki=visible;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecTyukiVisible=function(){return this.vectorOpe.visibleVecTyuki;};ProAtlasMapCtrl.prototype.setVecRasterVisible=function(visible){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.visibleVecRaster=visible;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecRasterVisible=function(){return this.vectorOpe.visibleVecRaster;};ProAtlasMapCtrl.prototype.setVecSpecType=function(specType){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.vecSpecType=specType;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecSpecType=function(){return this.vectorOpe.vecSpecType;};ProAtlasMapCtrl.prototype.getVecSpecTypeList=function(packageId,layerId){var layer=this.mapView.getMapPackage(packageId).layerCollect[layerId];var newSpecType=new Array;for(var i=0;i<layer.specType.length;++i){var spec=new SpecType();spec.id=layer.specType[i].id;spec.name=layer.specType[i].name;newSpecType.push(spec);}return newSpecType;};ProAtlasMapCtrl.prototype.setVecSpecItemVisible=function(itemId,visible){if(visible){var newSpecHide=new Array;var alreadyHide=false;for(var i=0;i<this.vectorOpe.specHide.length;++i){if(this.vectorOpe.specHide[i]==itemId){alreadyHide=true;}else{newSpecHide.push(this.vectorOpe.specHide[i]);}}if(alreadyHide){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.specHide=newSpecHide;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);}}else{var alreadyHide=false;for(var i=0;i<this.vectorOpe.specHide.length;++i){if(this.vectorOpe.specHide[i]==itemId){alreadyHide=true;break;}}if(!alreadyHide){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.specHide.push(itemId);var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);}}};ProAtlasMapCtrl.prototype.getVecSpecItemVisible=function(itemId){for(var i=0;i<this.vectorOpe.specHide.length;++i){if(this.vectorOpe.specHide[i]==itemId){return false;}}return true;};ProAtlasMapCtrl.prototype.getVecSpecItemList=function(packageId,layerId){var layer=this.mapView.getMapPackage(packageId).layerCollect[layerId];var newSpecItem=new Array;for(var i=0;i<layer.specItem.length;++i){var item=new SpecItem();item.id=layer.specItem[i].id;item.name=layer.specItem[i].name;newSpecItem.push(item);}return newSpecItem;};ProAtlasMapCtrl.prototype.angleTo=function(angle,fromUI){if(this.mapView.frontSheet.getCurrentPackage().mapServerSourceType!=2){return;}if(this.zoomTimerId!=0){return;}if(angle>=360) {angle-=360;}else if(angle<0){angle+=360;}if(this.getCurrentAngle()==angle){return;}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);var lpTarget=this.mapView.conv.m_center;var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var magnify=this.mapView.frontSheet.magnify;var bGetNewImage=true;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"angleChanged");};ProAtlasMapCtrl.prototype.getCurrentAngle=function(){return this.mapView.frontSheet.angle;};ProAtlasMapCtrl.prototype.smoothAngleTo=function(angle){if(this.mapView.frontSheet.getCurrentPackage().mapServerSourceType!=2){return;}if(_bi.type!=1&&_bi.type!=2&&_bi.type!=3){this.angleTo(angle);return;}if(this.mapView.fadeinTimerId!=0){return;}if(this.zoomTimerId!=0){return;}if(angle>=360) {angle-=360;}else if(angle<0){angle+=360;}if(angle==this.getCurrentAngle()){return;}this.stopSmoothCentering();this.stopFlightScroll();AlpsEvent.triggerEvent(this,"smoothAngleChanging",this.getCurrentAngle(),angle);var lpTarget=this.mapView.conv.m_center;var packageId=this.getCurrentPackageId();var layerId=this.getCurrentLayerId();var magnify=this.mapView.frontSheet.magnify;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.fadeinFlipSheet("angle");};ProAtlasMapCtrl.prototype.getMapserverSrcType=function(packageId){return this.mapView.getMapPackage(packageId).mapServerSourceType;};ProAtlasMapCtrl.prototype.setVisible=function(visible){this.mapView.frontSheet.setVisible(visible);};ProAtlasMapCtrl.prototype.release=function(){if(_bi.type!=1)return;this.targetSize.release();this.currentPos.release();this.arrowKeys.release();this.vectorOpe.specHide.release();this.vectorOpe.release();for(var i=0;i<this.mapView.packageCollect.length;++i){var packageId=this.mapView.packageCollect[i];this.layerScaleList[packageId].release();this.layerCodeList[packageId].release();}this.layerScaleList.release();this.layerCodeList.release();this.mapView.release();this._release();};
