var mod_measure_color1 = "white"; var mod_measure_color2 = "black"; var mod_measure_font = "Arial, Helvetica, sans-serif"; var mod_measure_fontsize = "9px"; var mod_measure_basepoint = "#8a2be2"; var mod_measure_linepoint = "#ff00ff"; var mod_measure_bg = ""; var mod_measure_pgsql = true; var mod_measure_win = null; var mod_measure_elName = "measure"; var mod_measure_frameName = ""; var mod_measure_epsg; var mod_measure_width; var mod_measure_height; var mod_measure_RX = new Array(); var mod_measure_RY = new Array(); var mod_measure_Dist = new Array(); var mod_measure_TotalDist = new Array(); var mod_measureSubFunctions = new Array(); var mod_measure_img_on = new Image(); mod_measure_img_on.src = ""; var mod_measure_img_off = new Image(); mod_measure_img_off.src = ""; var mod_measure_img_over = new Image(); mod_measure_img_over.src = ""; function init_mod_measure(ind){ mb_button[ind] = document.getElementById(mod_measure_elName); mb_button[ind].img_over = mod_measure_img_over.src; mb_button[ind].img_on = mod_measure_img_on.src; mb_button[ind].img_off = mod_measure_img_off.src; mb_button[ind].status = 0; mb_button[ind].elName = mod_measure_elName; mb_button[ind].fName = mod_measure_frameName; mb_button[ind].go = new Function ("mod_measure_go()"); mb_button[ind].stop = new Function ("mod_measure_disable()"); var ind = getMapObjIndexByName(mod_measure_target); mod_measure_width = mb_mapObj[ind].width; mod_measure_height = mb_mapObj[ind].height; mod_measure_epsg = mb_mapObj[ind].epsg; mb_registerSubFunctions("drawDashedLine()"); mb_registerPanSubElement("measuring"); } function register_measureSubFunctions(stringFunction){ mod_measureSubFunctions[mod_measureSubFunctions.length] = stringFunction; } function mod_measure_go(){ var el = window.frames[mod_measure_target].document; el.onmousedown = mod_measure_start; el.onmousemove = mod_measure_run; el.onmouseover = function () { el.body.style.cursor = 'crosshair'; } el.onmouseout = function () { el.body.style.cursor = 'auto'; } var measureSub = ""; for(var i=0; i 1){ var dist; if(mod_measure_epsg=="EPSG:4326"){ //convert coordinates to radian var lon_from=(mod_measure_RX[mod_measure_RX.length-2]*Math.PI)/180; var lat_from=(mod_measure_RY[mod_measure_RY.length-2]*Math.PI)/180; var lon_to=(mod_measure_RX[mod_measure_RX.length-1]*Math.PI)/180; var lat_to=(mod_measure_RY[mod_measure_RY.length-1]*Math.PI)/180; dist=6371229*Math.acos(Math.sin(lat_from)*Math.sin(lat_to)+Math.cos(lat_from)*Math.cos(lat_to)*Math.cos(lon_from-lon_to)); dist=Math.round(dist*100)/100; } else{ var dist_x = Math.abs(mod_measure_RX[mod_measure_RX.length-2] - mod_measure_RX[mod_measure_RX.length-1]); var dist_y = Math.abs(mod_measure_RY[mod_measure_RY.length-2] - mod_measure_RY[mod_measure_RY.length-1]); dist = Math.round(Math.sqrt(Math.pow(dist_x,2) + Math.pow(dist_y,2))*100)/100; } mod_measure_Dist[mod_measure_Dist.length] = dist; var totalDist = mod_measure_TotalDist[mod_measure_TotalDist.length-1] + dist; mod_measure_TotalDist[mod_measure_TotalDist.length] = Math.round(totalDist * 100)/100; } else{ mod_measure_Dist[mod_measure_Dist.length] = 0; mod_measure_TotalDist[mod_measure_TotalDist.length] = 0; } drawDashedLine(); } function drawDashedLine(){ //check if epsg has changed var ind = getMapObjIndexByName(mod_measure_target); mod_measure_width = mb_mapObj[ind].width; mod_measure_height = mb_mapObj[ind].height; if(mod_measure_epsg != mb_mapObj[ind].epsg){ mod_measure_delete(); mod_measure_epsg = mb_mapObj[ind].epsg; } var str_mPoints = "
"; str_mPoints += "
"; for(var i=0; i"; if(i>0){ str_mPoints += "
"+mod_measure_TotalDist[i]+"
"; str_mPoints += "
"+mod_measure_TotalDist[i]+"
"; } } if(mod_measure_RX.length>1){ for(var k=1; k= 0 && x <= mod_measure_width && y >= 0 && y <= mod_measure_height){ str_dashedLine += "
"; } } str_dashedLine += "
"+mod_measure_Dist[count]+"
"; str_dashedLine += "
"+mod_measure_Dist[count]+"
"; return str_dashedLine; } function mod_measure_run(e){ mb_getMousePos(e,mod_measure_target); var pos = makeClickPos2RealWorldPos(mod_measure_target,clickX,clickY); var dist; if(mod_measure_epsg=="EPSG:4326"){ //convert coordinates to radian var lon_from=(pos[0]*Math.PI)/180; var lat_from=(pos[1]*Math.PI)/180; var lon_to=(mod_measure_RX[mod_measure_RX.length-1]*Math.PI)/180; var lat_to=(mod_measure_RY[mod_measure_RY.length-1]*Math.PI)/180; dist=6371229*Math.acos(Math.sin(lat_from)*Math.sin(lat_to)+Math.cos(lat_from)*Math.cos(lat_to)*Math.cos(lon_from-lon_to)); } else{ var dist_x = Math.abs(mod_measure_RX[mod_measure_RX.length-1] - pos[0]); var dist_y = Math.abs(mod_measure_RY[mod_measure_RY.length-1] - pos[1]); dist=Math.sqrt(dist_x*dist_x+dist_y*dist_y); } if(isNaN(dist) == false && clickX > 0 && clickX < mod_measure_width && clickY > 0 && clickY < mod_measure_height){ var str_display = ""+(Math.round(dist*100)/100)+" m"; writeTag(mod_measure_target,"measure_display",str_display); mb_arrangeElement(mod_measure_target,"measure_display",clickX +2, clickY - 10); } else{ writeTag(mod_measure_target,"measure_display",""); } } function mod_measure_close(){ if(mod_measure_RX.length < 3 || (mod_measure_RX[mod_measure_RX.length-1] == mod_measure_RX[0] && mod_measure_RY[mod_measure_RY.length-1] == mod_measure_RY[0])){return;} mod_measure_RX[mod_measure_RX.length] = mod_measure_RX[0]; mod_measure_RY[mod_measure_RY.length] = mod_measure_RY[0]; if(mod_measure_RX.length > 1){ var dist; if(mod_measure_epsg=="EPSG:4326"){ //convert coordinates to radian var lon_from=(mod_measure_RX[mod_measure_RX.length-2]*Math.PI)/180; var lat_from=(mod_measure_RY[mod_measure_RY.length-2]*Math.PI)/180; var lon_to=(mod_measure_RX[mod_measure_RX.length-1]*Math.PI)/180; var lat_to=(mod_measure_RY[mod_measure_RY.length-1]*Math.PI)/180; dist=6371229*Math.acos(Math.sin(lat_from)*Math.sin(lat_to)+Math.cos(lat_from)*Math.cos(lat_to)*Math.cos(lon_from-lon_to)); dist=Math.round(dist*100)/100; } else{ var dist_x = Math.abs(mod_measure_RX[mod_measure_RX.length-2] - mod_measure_RX[mod_measure_RX.length-1]); var dist_y = Math.abs(mod_measure_RY[mod_measure_RY.length-2] - mod_measure_RY[mod_measure_RY.length-1]); dist = Math.round(Math.sqrt(Math.pow(dist_x,2) + Math.pow(dist_y,2))*100)/100; } mod_measure_Dist[mod_measure_Dist.length] = dist; var totalDist = mod_measure_TotalDist[mod_measure_TotalDist.length-1] + dist; mod_measure_TotalDist[mod_measure_TotalDist.length] = Math.round(totalDist * 100)/100; } else{ mod_measure_Dist[mod_measure_Dist.length] = 0; mod_measure_TotalDist[mod_measure_TotalDist.length] = 0; } drawDashedLine(); } function mod_measure_delete(){ mod_measure_RX = new Array(); mod_measure_RY = new Array(); mod_measure_Dist = new Array(); mod_measure_TotalDist = new Array(); writeTag(mod_measure_target,"measuring",""); writeTag(mod_measure_target,"measure_display",""); }