Commit fe8b41eedad83dd974f8af394e26c1f51cd16d1d
1 parent
ab67bc41
Exists in
master
and in
7 other branches
Validação com JSLint
Showing
1 changed file
with
72 additions
and
65 deletions
Show diff stats
classesjs/classe_calculo.js
... | ... | @@ -64,8 +64,8 @@ i3GEO.calculo = { |
64 | 64 | cd = cd * -1; |
65 | 65 | sinal = 'negativo'; |
66 | 66 | } |
67 | - spm = cs / 3600; | |
68 | - mpg = cm / 60; | |
67 | + var spm = cs / 3600; | |
68 | + var mpg = cm / 60; | |
69 | 69 | var dd = (cd * 1) + (mpg * 1) + (spm * 1); |
70 | 70 | if (sinal == 'negativo') |
71 | 71 | {dd = dd * -1;} |
... | ... | @@ -97,35 +97,36 @@ i3GEO.calculo = { |
97 | 97 | */ |
98 | 98 | dd2tela: function (vx,vy,docmapa,ext,cellsize){ |
99 | 99 | try{ |
100 | + var pos; | |
100 | 101 | if(i3GEO.Interface.ATUAL == "googlemaps"){ |
101 | - var pos = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO)); | |
102 | + pos = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO)); | |
102 | 103 | var latlng = new GLatLng(vy,vx); |
103 | 104 | var xyn = i3GeoMap.fromLatLngToContainerPixel(latlng); |
104 | - var xy = []; | |
105 | + xy = []; | |
105 | 106 | return [(xyn.x)+pos[0],(xyn.y)+pos[1]]; |
106 | 107 | } |
107 | 108 | if(i3GEO.Interface.ATUAL == "openlayers"){ |
108 | - var pos = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO)); | |
109 | - var xy = i3geoOL.getViewPortPxFromLonLat(new OpenLayers.LonLat(vx,vy)); | |
109 | + pos = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO)); | |
110 | + xy = i3geoOL.getViewPortPxFromLonLat(new OpenLayers.LonLat(vx,vy)); | |
110 | 111 | return [(xy.x)+pos[0],(xy.y)+pos[1]]; |
111 | 112 | } |
112 | 113 | if(arguments.length == 3){ |
113 | - var ext = i3GEO.parametros.mapexten; | |
114 | - var cellsize = i3GEO.parametros.pixelsize; | |
114 | + ext = i3GEO.parametros.mapexten; | |
115 | + cellsize = i3GEO.parametros.pixelsize; | |
115 | 116 | } |
116 | 117 | if(arguments.length == 4){ |
117 | - var cellsize = i3GEO.parametros.pixelsize; | |
118 | + cellsize = i3GEO.parametros.pixelsize; | |
118 | 119 | } |
119 | 120 | |
120 | 121 | if(!docmapa) |
121 | - {var docmapa = window.document;} | |
122 | + {docmapa = window.document;} | |
122 | 123 | var dc = docmapa; |
123 | - var pos = i3GEO.util.pegaPosicaoObjeto(dc); | |
124 | + pos = i3GEO.util.pegaPosicaoObjeto(dc); | |
124 | 125 | var imgext = ext; //i3GEO.parametros.mapexten; |
125 | - var imgext = imgext.split(" "); | |
126 | + imgext = imgext.split(" "); | |
126 | 127 | vx = (vx * 1) - (imgext[0] * 1); |
127 | 128 | vy = (vy * -1) + (imgext[3] * 1); |
128 | - c = cellsize * 1; | |
129 | + var c = cellsize * 1; | |
129 | 130 | //var xy = []; |
130 | 131 | return [(vx / c) + pos[0],(vy / c) + pos[1]]; |
131 | 132 | } |
... | ... | @@ -147,59 +148,61 @@ i3GEO.calculo = { |
147 | 148 | {Array} - Array com o valor de x [0] e y [1] no formato dd mm ss |
148 | 149 | */ |
149 | 150 | dd2dms: function(x,y){ |
151 | + var restod,mx,sx,mm,restos,my,sy; | |
150 | 152 | var m = 0; |
151 | 153 | var s = 0; |
152 | - var dx = parseInt(x); | |
154 | + var dx = parseInt(x,10); | |
153 | 155 | if (dx > 0) |
154 | - {var restod = x - dx;} | |
156 | + {restod = x - dx;} | |
155 | 157 | if (dx < 0) |
156 | 158 | {restod = (x * -1) - (dx * -1);} |
157 | 159 | dx = dx; |
158 | - if (restod != 0){ | |
159 | - var mm = restod * 60; | |
160 | - var m = parseInt(restod * 60); | |
161 | - var restos = mm - m; | |
162 | - var mx = m; | |
163 | - if (restos != 0){ | |
164 | - var s = restos * 60; | |
165 | - var s = (s+"_").substring(0,5); | |
166 | - var sx = s; | |
160 | + if (restod !== 0){ | |
161 | + mm = restod * 60; | |
162 | + m = parseInt(restod * 60,10); | |
163 | + restos = mm - m; | |
164 | + mx = m; | |
165 | + if (restos !== 0){ | |
166 | + s = restos * 60; | |
167 | + s = (s+"_").substring(0,5); | |
168 | + sx = s; | |
167 | 169 | } |
168 | - else { s = "00.00" } | |
170 | + else{s = "00.00";} | |
169 | 171 | } |
170 | 172 | else{ |
171 | - var mx = "00"; | |
172 | - var sx = "00.00"; | |
173 | + mx = "00"; | |
174 | + sx = "00.00"; | |
173 | 175 | } |
174 | 176 | if (m.length == 2){m = "0"+m+"";} |
175 | 177 | if (s*1 < 10){s = "0"+s;} |
176 | 178 | var xv = dx+" "+mx+" "+sx; |
177 | - var m = 0; | |
178 | - var s = 0; | |
179 | - var dy = parseInt(y); | |
179 | + m = 0; | |
180 | + s = 0; | |
181 | + var dy = parseInt(y,10); | |
180 | 182 | if (dy > 0) |
181 | - {var restod = y - dy;} | |
183 | + {restod = y - dy;} | |
182 | 184 | if (dy < 0) |
183 | - {var restod = (y * -1) - (dy * -1);} | |
185 | + {restod = (y * -1) - (dy * -1);} | |
184 | 186 | dy = dy; |
185 | - if (restod != 0){ | |
186 | - var mm = restod * 60; | |
187 | - var m = parseInt(restod * 60); | |
188 | - var restos = mm - m; | |
189 | - var my = m; | |
190 | - if (restos != 0){ | |
191 | - var s = restos * 60; | |
187 | + if (restod !== 0){ | |
188 | + mm = restod * 60; | |
189 | + m = parseInt(restod * 60,10); | |
190 | + restos = mm - m; | |
191 | + my = m; | |
192 | + if (restos !== 0){ | |
193 | + s = restos * 60; | |
192 | 194 | s = (s+"_").substring(0,5); |
193 | - var sy = s; | |
195 | + sy = s; | |
194 | 196 | } |
195 | - else { var s = "00.00";} | |
197 | + else { s = "00.00";} | |
196 | 198 | } |
197 | 199 | else{ |
198 | - var my = "00"; | |
199 | - var sy = "00.00"; | |
200 | + my = "00"; | |
201 | + sy = "00.00"; | |
200 | 202 | } |
201 | 203 | if (m.length == 2){m = "0"+m;} |
202 | - if (s*1 < 10){s = "0"+s;} | |
204 | + if (s*1 < 10) | |
205 | + {s = "0"+s;} | |
203 | 206 | var yv = dy+" "+my+" "+sy; |
204 | 207 | var res = []; |
205 | 208 | res[0] = xv; |
... | ... | @@ -271,6 +274,7 @@ i3GEO.calculo = { |
271 | 274 | {Numeric} |
272 | 275 | */ |
273 | 276 | area: function(pontos,pixel){ |
277 | + var $polygon_area; | |
274 | 278 | try{ |
275 | 279 | if(pontos.xpt.length > 2){ |
276 | 280 | var $array_length = pontos.xpt.length; |
... | ... | @@ -278,7 +282,7 @@ i3GEO.calculo = { |
278 | 282 | pontos.ytela.push(pontos.ytela[0]); |
279 | 283 | pontos.xtela.push(pontos.xtela[0]); |
280 | 284 | pontos.ytela.push(pontos.ytela[1]); |
281 | - var $polygon_area = 0; | |
285 | + $polygon_area = 0; | |
282 | 286 | for (var $i=0;$i <= $array_length;$i++) |
283 | 287 | {$polygon_area += ((pontos.xtela[$i] * pontos.ytela[$i+1])-(pontos.ytela[$i] * pontos.xtela[$i+1]));} |
284 | 288 | $polygon_area = Math.abs($polygon_area) / 2; |
... | ... | @@ -356,8 +360,8 @@ i3GEO.calculo = { |
356 | 360 | var x = Math.cos(lat1)*Math.sin(lat2) - |
357 | 361 | Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon); |
358 | 362 | var r = Math.atan2(y, x); |
359 | - var r = r * 180 / Math.PI; | |
360 | - var r = r + 360; | |
363 | + r = r * 180 / Math.PI; | |
364 | + r = r + 360; | |
361 | 365 | return r % 360; |
362 | 366 | }, |
363 | 367 | /* |
... | ... | @@ -394,8 +398,10 @@ i3GEO.calculo = { |
394 | 398 | var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) + Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) ); |
395 | 399 | var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1),Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2)); |
396 | 400 | lon2 = (lon2+Math.PI)%(2*Math.PI) - Math.PI; // normalise to -180...+180 |
397 | - if (isNaN(lat2) || isNaN(lon2)) return null; | |
398 | - return new Array((lon2 * 180 / Math.PI),(lat2 * 180 / Math.PI)); | |
401 | + if (isNaN(lat2) || isNaN(lon2)) | |
402 | + {return null;} | |
403 | + var resultado = [(lon2 * 180 / Math.PI),(lat2 * 180 / Math.PI)]; | |
404 | + return resultado; | |
399 | 405 | }, |
400 | 406 | /* |
401 | 407 | Function: rect2ext |
... | ... | @@ -415,36 +421,37 @@ i3GEO.calculo = { |
415 | 421 | {Array} - extensão, xmin, ymin, xmax, ymax |
416 | 422 | */ |
417 | 423 | rect2ext: function(idrect,mapext,pixel){ |
424 | + var bx,bxs,xfig,yfig,nx,ny,pix,piy; | |
418 | 425 | eval ('pix = parseInt(document.getElementById("'+idrect+'").style.' + g_tipoleft + ")"); |
419 | 426 | eval ('piy = parseInt(document.getElementById("'+idrect+'").style.' + g_tipotop + ")"); |
420 | 427 | if($i(idrect)){ |
421 | - var bx = $i(idrect); | |
422 | - var bxs = bx.style; | |
428 | + bx = $i(idrect); | |
429 | + bxs = bx.style; | |
423 | 430 | } |
424 | 431 | else |
425 | 432 | {alert("Box nao encontrado");return;} |
426 | 433 | var pos = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.Interface.IDCORPO)); |
427 | - var xfig0 = parseInt(bxs.width) - pos[0]; | |
428 | - var yfig0 = parseInt(bxs.height) - pos[1]; | |
429 | - var xfig = pix + (parseInt(bxs.width)) - pos[0]; | |
430 | - var yfig = piy + (parseInt(bxs.height)) - pos[1]; | |
434 | + xfig = pix + (parseInt(bxs.width,10)) - pos[0]; | |
435 | + yfig = piy + (parseInt(bxs.height,10)) - pos[1]; | |
431 | 436 | var amext = mapext.split(" "); |
432 | 437 | var dx = ((amext[0] * -1) - (amext[2] * -1)) / -1; |
433 | 438 | var dy = ((amext[1] * 1) - (amext[3] * 1)) / -1; |
434 | - if (dy < 0) dy=dy * -1; | |
435 | - var nx = pixel * xfig; | |
436 | - var ny = pixel * yfig; | |
439 | + if (dy < 0) | |
440 | + {dy=dy * -1;} | |
441 | + nx = pixel * xfig; | |
442 | + ny = pixel * yfig; | |
437 | 443 | var x1 = (amext[0] * 1) + nx; |
438 | 444 | var y1 = (amext[3] * 1) - ny; |
439 | - var xfig = pix - pos[0]; | |
440 | - var yfig = piy - pos[1]; | |
441 | - if (dy < 0) dy=dy * -1; | |
442 | - var nx = pixel * xfig; | |
443 | - var ny = pixel * yfig; | |
445 | + xfig = pix - pos[0]; | |
446 | + yfig = piy - pos[1]; | |
447 | + if (dy < 0) | |
448 | + {dy=dy * -1;} | |
449 | + nx = pixel * xfig; | |
450 | + ny = pixel * yfig; | |
444 | 451 | var x2 = (amext[0] * 1) + nx; |
445 | 452 | var y2 = (amext[3] * 1) - ny; |
446 | 453 | var v = x2+" "+y2+" "+x1+" "+y1; |
447 | - var res = new Array(v,x1,y1,x2,y2); | |
454 | + var res = [v,x1,y1,x2,y2]; | |
448 | 455 | return (res); |
449 | 456 | }, |
450 | 457 | /* |
... | ... | @@ -488,7 +495,7 @@ i3GEO.calculo = { |
488 | 495 | box.style.left = l + "px"; |
489 | 496 | box.style.display=d; |
490 | 497 | } |
491 | - return new Array(w,h,xyMax[1],xyMin[0]); | |
498 | + return [w,h,xyMax[1],xyMin[0]]; | |
492 | 499 | } |
493 | 500 | }; |
494 | 501 | //YAHOO.log("carregou classe calculo", "Classes i3geo"); |
495 | 502 | \ No newline at end of file | ... | ... |