Ignore:
Timestamp:
04/26/10 19:12:49 (14 years ago)
Author:
cbipsl
Message:

maj eccad V3.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ether_eccad/trunk/ECCAD_INTERFACE/JavaScript/selectSouris.js

    r68 r70  
    1919         
    2020function onClicCarte(e) { 
    21         var coeff =1/parseInt((imgHaut/(imgLATmax-imgLATmin))*resolution); 
    22         document.getElementById("form_carte:clicX").value = parseInt( ( xCurseur(e) - findPosX(document.getElementById("form_carte:carte")) ) *coeff) / coeff; 
    23         document.getElementById("form_carte:clicY").value = parseInt( ( yCurseur(e) - findPosY(document.getElementById("form_carte:carte")) ) *coeff) / coeff; 
     21        var posX = xCurseur(e); 
     22        var posY = yCurseur(e); 
     23        var posXimg = posX - findPosX(document.getElementById("form_carte:carte")); 
     24        var posYimg = posY - findPosY(document.getElementById("form_carte:carte")); 
     25//      var coeff =1/parseInt((imgHaut/(imgLATmax-imgLATmin))*resolution); 
     26//      document.getElementById("form_carte:clicX").value = parseInt( posXimg *coeff) / coeff; 
     27//      document.getElementById("form_carte:clicY").value = parseInt( posYimg *coeff) / coeff; 
     28        document.getElementById("form_carte:clicX").value = posXimg; 
     29        document.getElementById("form_carte:clicY").value = posYimg; 
    2430         
    2531        document.getElementById("form_carte:centerLonClick").value = findLonN(document.getElementById("form_carte:clicX").value); 
    2632        document.getElementById("form_carte:centerLatClick").value = findLatN(document.getElementById("form_carte:clicY").value); 
     33//alert("imgHaut="+imgHaut+",imglatmax="+imgLATmax+",imglatmin="+imgLATmin+",resol="+resolution+",coef="+coeff+",latcenter="+document.getElementById("form_carte:centerLatClick").value+",loncenter="+document.getElementById("form_carte:centerLonClick").value); 
    2734        document.getElementById("calque_chargement").style.display = "inline"; 
    2835        document.getElementById("resizediv").style.display = "none"; 
    29          
    30          
     36 
    3137        //alert("nouvelle position :: " + document.getElementById("form_carte:clicX").value + " " + document.getElementById("form_carte:clicY").value ); 
    3238         
    33          
    3439}        
    3540         
    36         // position x de la sourie 
     41        // position x de la souris 
    3742        function xCurseur(e) { 
    3843                if (document.all) return event.clientX + document.body.scrollLeft; 
     
    4045        } 
    4146         
    42         // position y de la sourie 
     47        // position y de la souris 
    4348        function yCurseur(e) { 
    4449                if (document.all) return event.clientY + document.body.scrollTop; 
     
    6974        var posY = yCurseur(e); 
    7075        //var coeff =1/parseInt((imgHaut/(imgLATmax-imgLATmin))*resolution); 
    71          
    72          
    7376        //var posXimg = parseInt( ( xCurseur(e) - findPosX(document.getElementById("form_carte:carte")) ) *coeff) / coeff; 
    7477        //var posYimg = parseInt( ( yCurseur(e) - findPosY(document.getElementById("form_carte:carte")) ) *coeff) / coeff; 
    75          
     78 
    7679        var posXimg = posX - findPosX(document.getElementById("form_carte:carte")); 
    7780        var posYimg = posY - findPosY(document.getElementById("form_carte:carte")); 
     81//alert("X="+posX+", Y="+posY+", Ximg="+posXimg+", Yimg="+posYimg+", lon="+findLonN(posXimg)+", lat="+findLatN(posYimg)); 
     82 
    7883        var div1 = document.getElementById("position1"); 
    7984        //div.style.left = (posX + 10) + "px"; 
     
    116121                //imgLarg = parseInt( 720/ (imgLONmax-imgLONmin))*(imgLONmax-imgLONmin); 
    117122                resolution = document.getElementById("form_carte:resolution").value; 
    118                  
     123//              alert("latmin="+imgLATmin+",latmax="+imgLATmax+",lonmin="+imgLONmin+",lonmax="+imgLONmax); 
    119124                if (imgLATmax == null || imgLATmin == null || imgLONmax == null || imgLONmin == null) 
    120125                        alert("erreur d'initialisation des coordonnees"); 
     
    133138                                        curleft += obj.offsetLeft; 
    134139                                        obj = obj.offsetParent;  
    135                                         }  
    136140                                }  
    137                 else  
    138                         if (obj.x){  
    139                                 curleft += obj.x; }  
    140                         return curleft;  
    141                         }  
     141                         } 
     142                        else if (obj.x){ 
     143                                curleft += obj.x; 
     144                        } 
     145                        return curleft+2;  
     146                }  
    142147                return 0;  
    143148        } 
     
    153158                                }  
    154159                        }  
    155                 else if (obj.y) {  
    156                         curtop += obj.y; }  
    157                 return curtop;  
     160                        else if (obj.y) {  
     161                                curtop += obj.y; 
     162                        }  
     163                        return curtop+2;  
    158164                }  
    159         return 0;  
     165                return 0;  
    160166        }  
    161167 
     
    165171 
    166172//converti de pixel ? Lat bloque a -90 90 
    167 function findLatN(lat) {  
    168         var coef = (imgLATmax-imgLATmin)/imgHaut; 
    169         var lati = (imgHaut-lat)*coef - (-imgLATmin); 
    170         if (lati>90) 
     173function findLatN(lat) { 
     174//      var coef = (imgLATmax-imgLATmin)/imgHaut; 
     175//      var lati = (imgHaut-lat+resolution)*coef - (-imgLATmin); 
     176        var hauteur = imgLATmax-imgLATmin; 
     177        var lat1 = hauteur * (lat-1); 
     178        var lat2 = imgHaut * resolution; 
     179        var y = Math.floor(lat1/lat2)+1; 
     180        var latitude = parseFloat(imgLATmax) - resolution*(y-0.5); 
     181        if (latitude>90) { 
    171182                return 90; 
    172         if (lati<-90) 
    173                 return -90 
    174         return Math.round(lati*100)/100;  
     183        } else if (latitude<-90) { 
     184                return -90; 
     185        } 
     186//      return Math.round(lati*100)/100;  
     187        return latitude; 
    175188}  
    176189  
    177190//converti de pixel ? Lon bloque a -180 180 
    178 function findLonN(lon){  
    179         coef = (imgLONmax - imgLONmin)/imgLarg; 
    180         longitude = lon*coef - (-imgLONmin); 
    181         if (longitude>180) 
     191function findLonN(lon){ 
     192//      coef = (imgLONmax - imgLONmin)/imgLarg; 
     193//      longitude = (lon-resolution)*coef - (-imgLONmin); 
     194        var largeur = imgLONmax - imgLONmin; 
     195        var lon1 = largeur * (lon-1); 
     196        var lon2 = imgLarg * resolution; 
     197        var x = Math.floor(lon1/lon2)+1; 
     198        var longitude = parseFloat(imgLONmin) + resolution*(x-0.5); 
     199        if (longitude>180) { 
    182200                return 180; 
    183         if (longitude <-180) 
     201        } else if (longitude <-180) { 
    184202                return -180; 
    185         return Math.round(longitude*100)/100; 
     203        } 
     204//      return Math.round(longitude*100)/100; 
     205        return longitude; 
    186206}  
    187207 
     
    212232        pixelY = (imgLATmax-lat)/(imgLATmax-imgLATmin)*imgHaut; 
    213233        return Math.round(pixelY);  
    214 }        
     234} 
     235 
     236function showClickedPixel() { 
     237        showPosPixel = document.getElementById("form_carte:showPosPixel").value; 
     238        if (showPosPixel == "true") { 
     239                document.getElementById("title_pixel").style.visibility = "visible"; 
     240                document.getElementById("title_pixel").style.display = ""; 
     241                document.getElementById("pos_pixel").style.visibility = "visible"; 
     242                document.getElementById("pos_pixel").style.display = ""; 
     243                document.getElementById("value_pixel").style.visibility = "visible"; 
     244                document.getElementById("value_pixel").style.display = ""; 
     245        } else { 
     246                document.getElementById("title_pixel").style.visibility = "hidden"; 
     247                document.getElementById("title_pixel").style.display = "none"; 
     248                document.getElementById("pos_pixel").style.visibility = "hidden"; 
     249                document.getElementById("pos_pixel").style.display = "none"; 
     250                document.getElementById("value_pixel").style.visibility = "hidden"; 
     251                document.getElementById("value_pixel").style.display = "none"; 
     252        } 
     253} 
     254 
     255function changeMode(elemId) { 
     256        var val; 
     257        if (elemId != null) 
     258                val = elemId.value; 
     259        else 
     260                val = ""; 
     261        if (val == "totals") { 
     262                document.getElementById("title_globalsum").style.visibility = "visible"; 
     263                document.getElementById("title_globalsum").style.display = ""; 
     264                document.getElementById("value_globalsum").style.visibility = "visible"; 
     265                document.getElementById("value_globalsum").style.display = ""; 
     266        } else { 
     267                document.getElementById("title_globalsum").style.visibility = "hidden"; 
     268                document.getElementById("title_globalsum").style.display = "none"; 
     269                document.getElementById("value_globalsum").style.visibility = "hidden"; 
     270                document.getElementById("value_globalsum").style.display = "none"; 
     271        } 
     272} 
Note: See TracChangeset for help on using the changeset viewer.