Commit 73aff5d074f704b109a97c7b5ea0da26d608c905
1 parent
83da6908
Exists in
master
and in
5 other branches
Reformulação do código da ferramenta de cálculo de distâncias para permitir a mo…
…dificação da função que mostra os totais e as parciais
Showing
3 changed files
with
609 additions
and
620 deletions
Show diff stats
ferramentas/area/index.js
| @@ -4,23 +4,14 @@ if (typeof (i3GEOF) === 'undefined') { | @@ -4,23 +4,14 @@ if (typeof (i3GEOF) === 'undefined') { | ||
| 4 | i3GEOF.area = | 4 | i3GEOF.area = |
| 5 | { | 5 | { |
| 6 | position: [150,0], | 6 | position: [150,0], |
| 7 | - /** | ||
| 8 | - * Armazena os pontos clicados para realizar os calculos | ||
| 9 | - */ | ||
| 10 | - pontos : {}, | ||
| 11 | - /** | ||
| 12 | - * Armazena o WKT da ultima linha | ||
| 13 | - */ | ||
| 14 | - ultimoWkt : "", | ||
| 15 | - /** | ||
| 16 | - * Armazena a ultima medida | ||
| 17 | - */ | ||
| 18 | - ultimaMedida : "", | ||
| 19 | renderFunction: i3GEO.janela.formModal, | 7 | renderFunction: i3GEO.janela.formModal, |
| 20 | _parameters : { | 8 | _parameters : { |
| 21 | "mustache": "", | 9 | "mustache": "", |
| 22 | "idContainer": "i3GEOareaContainer", | 10 | "idContainer": "i3GEOareaContainer", |
| 23 | - "namespace": "area" | 11 | + "namespace": "area", |
| 12 | + "pontos" : {}, | ||
| 13 | + "ultimoWkt": "", | ||
| 14 | + "ultimaMedida" : "" | ||
| 24 | }, | 15 | }, |
| 25 | start : function(){ | 16 | start : function(){ |
| 26 | var p = this._parameters, | 17 | var p = this._parameters, |
| @@ -45,8 +36,9 @@ i3GEOF.area = | @@ -45,8 +36,9 @@ i3GEOF.area = | ||
| 45 | //nao use this aqui | 36 | //nao use this aqui |
| 46 | i3GEOF.area.renderFunction.call(); | 37 | i3GEOF.area.renderFunction.call(); |
| 47 | i3GEO.analise.pontos = {}; | 38 | i3GEO.analise.pontos = {}; |
| 48 | - i3GEOF.area.ultimaMedida = ""; | 39 | + i3GEOF.area._parameters.ultimaMedida = ""; |
| 49 | i3GEOF.area[i3GEO.Interface["ATUAL"]].fechaJanela(); | 40 | i3GEOF.area[i3GEO.Interface["ATUAL"]].fechaJanela(); |
| 41 | + i3GEOF.area._parameters.pontos = {}; | ||
| 50 | }, | 42 | }, |
| 51 | html:function() { | 43 | html:function() { |
| 52 | var p = this._parameters, | 44 | var p = this._parameters, |
| @@ -61,7 +53,7 @@ i3GEOF.area = | @@ -61,7 +53,7 @@ i3GEOF.area = | ||
| 61 | this, | 53 | this, |
| 62 | { | 54 | { |
| 63 | texto: Mustache.render(p.mustache, hash), | 55 | texto: Mustache.render(p.mustache, hash), |
| 64 | - header: "<span class='copyToMemory' onclick='i3GEO.util.copyToClipboard(i3GEOF.area.ultimaMedida);return false;'></span>", | 56 | + header: "<span class='copyToMemory' onclick='i3GEO.util.copyToClipboard(i3GEOF.area._parameters.ultimaMedida);return false;'></span>", |
| 65 | onclose: i3f.destroy | 57 | onclose: i3f.destroy |
| 66 | }); | 58 | }); |
| 67 | i3GEO.eventos.cliquePerm.desativa(); | 59 | i3GEO.eventos.cliquePerm.desativa(); |
| @@ -79,7 +71,7 @@ i3GEOF.area = | @@ -79,7 +71,7 @@ i3GEOF.area = | ||
| 79 | * Converte a lista de pontos em WKT | 71 | * Converte a lista de pontos em WKT |
| 80 | */ | 72 | */ |
| 81 | pontos2wkt : function() { | 73 | pontos2wkt : function() { |
| 82 | - var pontos = [], x = i3GEOF.area.pontos.xpt, y = i3GEOF.area.pontos.ypt, n = x.length, i; | 74 | + var pontos = [], x = i3GEOF.area._parameters.pontos.xpt, y = i3GEOF.area._parameters.pontos.ypt, n = x.length, i; |
| 83 | for (i = 0; i < n; i++) { | 75 | for (i = 0; i < n; i++) { |
| 84 | pontos.push(x[i] + " " + y[i]); | 76 | pontos.push(x[i] + " " + y[i]); |
| 85 | } | 77 | } |
| @@ -134,7 +126,7 @@ i3GEOF.area = | @@ -134,7 +126,7 @@ i3GEOF.area = | ||
| 134 | i3GEO.desenho.layergrafico.getSource().addFeature(evt.feature); | 126 | i3GEO.desenho.layergrafico.getSource().addFeature(evt.feature); |
| 135 | }); | 127 | }); |
| 136 | m.draw.on('drawstart', function(evt) { | 128 | m.draw.on('drawstart', function(evt) { |
| 137 | - i3GEOF.area.pontos = { | 129 | + i3GEOF.area._parameters.pontos = { |
| 138 | xpt : [], | 130 | xpt : [], |
| 139 | ypt : [], | 131 | ypt : [], |
| 140 | dist : [] | 132 | dist : [] |
| @@ -171,10 +163,10 @@ i3GEOF.area = | @@ -171,10 +163,10 @@ i3GEOF.area = | ||
| 171 | var temp,sourceProj,coordinates,wgs84Sphere, per, area, n, x1, y1, x2, y2, trecho, direcao, | 163 | var temp,sourceProj,coordinates,wgs84Sphere, per, area, n, x1, y1, x2, y2, trecho, direcao, |
| 172 | coord = point.getCoordinates(); | 164 | coord = point.getCoordinates(); |
| 173 | 165 | ||
| 174 | - n = i3GEOF.area.pontos.ypt.length; | 166 | + n = i3GEOF.area._parameters.pontos.ypt.length; |
| 175 | if (n > 1) { | 167 | if (n > 1) { |
| 176 | - x1 = i3GEOF.area.pontos.xpt[n - 1]; | ||
| 177 | - y1 = i3GEOF.area.pontos.ypt[n - 1]; | 168 | + x1 = i3GEOF.area._parameters.pontos.xpt[n - 1]; |
| 169 | + y1 = i3GEOF.area._parameters.pontos.ypt[n - 1]; | ||
| 178 | x2 = coord[0]; | 170 | x2 = coord[0]; |
| 179 | y2 = coord[1]; | 171 | y2 = coord[1]; |
| 180 | // projeta | 172 | // projeta |
| @@ -193,8 +185,8 @@ i3GEOF.area = | @@ -193,8 +185,8 @@ i3GEOF.area = | ||
| 193 | direcao = direcao[0]; | 185 | direcao = direcao[0]; |
| 194 | per = i3GEOF.area.openlayers.somaDist(); | 186 | per = i3GEOF.area.openlayers.somaDist(); |
| 195 | // soma ate o primeiro ponto | 187 | // soma ate o primeiro ponto |
| 196 | - x1 = i3GEOF.area.pontos.xpt[0]; | ||
| 197 | - y1 = i3GEOF.area.pontos.ypt[0]; | 188 | + x1 = i3GEOF.area._parameters.pontos.xpt[0]; |
| 189 | + y1 = i3GEOF.area._parameters.pontos.ypt[0]; | ||
| 198 | // projeta | 190 | // projeta |
| 199 | if (i3GEO.Interface.openlayers.googleLike) { | 191 | if (i3GEO.Interface.openlayers.googleLike) { |
| 200 | temp = i3GEO.util.extOSM2Geo(x1 + " " + y1); | 192 | temp = i3GEO.util.extOSM2Geo(x1 + " " + y1); |
| @@ -220,14 +212,14 @@ i3GEOF.area = | @@ -220,14 +212,14 @@ i3GEOF.area = | ||
| 220 | var wgs84Sphere,area,coordinates,sourceProj,n, x1, y1, x2, y2, trecho, temp, | 212 | var wgs84Sphere,area,coordinates,sourceProj,n, x1, y1, x2, y2, trecho, temp, |
| 221 | coord = point.getCoordinates(), | 213 | coord = point.getCoordinates(), |
| 222 | total = 0; | 214 | total = 0; |
| 223 | - i3GEOF.area.pontos.xpt.push(coord[0]); | ||
| 224 | - i3GEOF.area.pontos.ypt.push(coord[1]); | 215 | + i3GEOF.area._parameters.pontos.xpt.push(coord[0]); |
| 216 | + i3GEOF.area._parameters.pontos.ypt.push(coord[1]); | ||
| 225 | i3GEO.analise.pontos.xpt.push(coord[0]); | 217 | i3GEO.analise.pontos.xpt.push(coord[0]); |
| 226 | i3GEO.analise.pontos.ypt.push(coord[1]); | 218 | i3GEO.analise.pontos.ypt.push(coord[1]); |
| 227 | - n = i3GEOF.area.pontos.ypt.length; | 219 | + n = i3GEOF.area._parameters.pontos.ypt.length; |
| 228 | if (n > 1) { | 220 | if (n > 1) { |
| 229 | - x1 = i3GEOF.area.pontos.xpt[n - 2]; | ||
| 230 | - y1 = i3GEOF.area.pontos.ypt[n - 2]; | 221 | + x1 = i3GEOF.area._parameters.pontos.xpt[n - 2]; |
| 222 | + y1 = i3GEOF.area._parameters.pontos.ypt[n - 2]; | ||
| 231 | x2 = coord[0]; | 223 | x2 = coord[0]; |
| 232 | y2 = coord[1]; | 224 | y2 = coord[1]; |
| 233 | raio = new ol.geom.LineString([[x1, y1],[x2, y2]]).getLength(); | 225 | raio = new ol.geom.LineString([[x1, y1],[x2, y2]]).getLength(); |
| @@ -241,7 +233,7 @@ i3GEOF.area = | @@ -241,7 +233,7 @@ i3GEOF.area = | ||
| 241 | y2 = temp[3]; | 233 | y2 = temp[3]; |
| 242 | } | 234 | } |
| 243 | trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | 235 | trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); |
| 244 | - i3GEOF.area.pontos.dist.push(trecho); | 236 | + i3GEOF.area._parameters.pontos.dist.push(trecho); |
| 245 | total = i3GEOF.area.openlayers.somaDist(); | 237 | total = i3GEOF.area.openlayers.somaDist(); |
| 246 | 238 | ||
| 247 | sourceProj = i3geoOL.getView().getProjection(); | 239 | sourceProj = i3geoOL.getView().getProjection(); |
| @@ -251,7 +243,7 @@ i3GEOF.area = | @@ -251,7 +243,7 @@ i3GEOF.area = | ||
| 251 | area = Math.abs(wgs84Sphere.geodesicArea(coordinates)); | 243 | area = Math.abs(wgs84Sphere.geodesicArea(coordinates)); |
| 252 | 244 | ||
| 253 | i3GEOF.area.openlayers.mostraTotal(total, area); | 245 | i3GEOF.area.openlayers.mostraTotal(total, area); |
| 254 | - i3GEOF.area.ultimoWkt = i3GEOF.area.pontos2wkt(); | 246 | + i3GEOF.area._parameters.ultimoWkt = i3GEOF.area.pontos2wkt(); |
| 255 | } | 247 | } |
| 256 | }, | 248 | }, |
| 257 | /** | 249 | /** |
| @@ -259,9 +251,9 @@ i3GEOF.area = | @@ -259,9 +251,9 @@ i3GEOF.area = | ||
| 259 | */ | 251 | */ |
| 260 | somaDist : function() { | 252 | somaDist : function() { |
| 261 | var n, i, total = 0; | 253 | var n, i, total = 0; |
| 262 | - n = i3GEOF.area.pontos.dist.length; | 254 | + n = i3GEOF.area._parameters.pontos.dist.length; |
| 263 | for (i = 0; i < n; i++) { | 255 | for (i = 0; i < n; i++) { |
| 264 | - total += i3GEOF.area.pontos.dist[i]; | 256 | + total += i3GEOF.area._parameters.pontos.dist[i]; |
| 265 | } | 257 | } |
| 266 | return total; | 258 | return total; |
| 267 | }, | 259 | }, |
| @@ -322,7 +314,7 @@ i3GEOF.area = | @@ -322,7 +314,7 @@ i3GEOF.area = | ||
| 322 | + i3GEO.calculo.metododistancia | 314 | + i3GEO.calculo.metododistancia |
| 323 | + "</div>"; | 315 | + "</div>"; |
| 324 | mostra.innerHTML = texto; | 316 | mostra.innerHTML = texto; |
| 325 | - i3GEOF.area.ultimaMedida = $.number((area / 1000000),3,$trad("dec"),$trad("mil")) + " km2"; | 317 | + i3GEOF.area._parameters.ultimaMedida = $.number((area / 1000000),3,$trad("dec"),$trad("mil")) + " km2"; |
| 326 | } | 318 | } |
| 327 | }, | 319 | }, |
| 328 | /** | 320 | /** |
| @@ -362,7 +354,7 @@ i3GEOF.area = | @@ -362,7 +354,7 @@ i3GEOF.area = | ||
| 362 | * layer para receber os graficos | 354 | * layer para receber os graficos |
| 363 | */ | 355 | */ |
| 364 | inicia : function() { | 356 | inicia : function() { |
| 365 | - i3GEOF.area.pontos = { | 357 | + i3GEOF.area._parameters.pontos = { |
| 366 | xpt : [], | 358 | xpt : [], |
| 367 | ypt : [], | 359 | ypt : [], |
| 368 | dist : [] | 360 | dist : [] |
| @@ -403,7 +395,7 @@ i3GEOF.area = | @@ -403,7 +395,7 @@ i3GEOF.area = | ||
| 403 | i3GEO.desenho.googlemaps.shapes.push(pontos.line); | 395 | i3GEO.desenho.googlemaps.shapes.push(pontos.line); |
| 404 | pontos = null; | 396 | pontos = null; |
| 405 | } | 397 | } |
| 406 | - i3GEOF.area.ultimoWkt = i3GEOF.area.pontos2wkt(); | 398 | + i3GEOF.area._parameters.ultimoWkt = i3GEOF.area.pontos2wkt(); |
| 407 | }; | 399 | }; |
| 408 | evtclick = google.maps.event.addListener(i3GeoMap, "click", function(evt) { | 400 | evtclick = google.maps.event.addListener(i3GeoMap, "click", function(evt) { |
| 409 | i3GEO.eventos.cliquePerm.desativa(); | 401 | i3GEO.eventos.cliquePerm.desativa(); |
| @@ -413,8 +405,8 @@ i3GEOF.area = | @@ -413,8 +405,8 @@ i3GEOF.area = | ||
| 413 | pontos.mvcLine.push(evt.latLng); | 405 | pontos.mvcLine.push(evt.latLng); |
| 414 | pontos.xpt.push(evt.latLng.lng()); | 406 | pontos.xpt.push(evt.latLng.lng()); |
| 415 | pontos.ypt.push(evt.latLng.lat()); | 407 | pontos.ypt.push(evt.latLng.lat()); |
| 416 | - i3GEOF.area.pontos.xpt.push(evt.latLng.lng()); | ||
| 417 | - i3GEOF.area.pontos.ypt.push(evt.latLng.lat()); | 408 | + i3GEOF.area._parameters.pontos.xpt.push(evt.latLng.lng()); |
| 409 | + i3GEOF.area._parameters.pontos.ypt.push(evt.latLng.lat()); | ||
| 418 | // desenha um circulo | 410 | // desenha um circulo |
| 419 | if (pontos.mvcLine.getLength() > 0) { | 411 | if (pontos.mvcLine.getLength() > 0) { |
| 420 | per = google.maps.geometry.spherical.computeLength(pontos.mvcLine); | 412 | per = google.maps.geometry.spherical.computeLength(pontos.mvcLine); |
| @@ -545,7 +537,7 @@ i3GEOF.area = | @@ -545,7 +537,7 @@ i3GEOF.area = | ||
| 545 | + ": " | 537 | + ": " |
| 546 | + i3GEO.calculo.metododistancia; | 538 | + i3GEO.calculo.metododistancia; |
| 547 | mostra.innerHTML = texto + "<hr>"; | 539 | mostra.innerHTML = texto + "<hr>"; |
| 548 | - i3GEOF.area.ultimaMedida = (area / 1000000).toFixed(3) + " km2"; | 540 | + i3GEOF.area._parameters.ultimaMedida = (area / 1000000).toFixed(3) + " km2"; |
| 549 | } | 541 | } |
| 550 | }, | 542 | }, |
| 551 | /** | 543 | /** |
ferramentas/distancia/index.js
| @@ -3,24 +3,14 @@ if (typeof (i3GEOF) === 'undefined') { | @@ -3,24 +3,14 @@ if (typeof (i3GEOF) === 'undefined') { | ||
| 3 | } | 3 | } |
| 4 | i3GEOF.distancia = | 4 | i3GEOF.distancia = |
| 5 | { | 5 | { |
| 6 | - position: [150,0], | ||
| 7 | - /** | ||
| 8 | - * Armazena os pontos clicados para realizar os calculos | ||
| 9 | - */ | ||
| 10 | - pontos : {}, | ||
| 11 | - /** | ||
| 12 | - * Armazena o WKT da ultima linha | ||
| 13 | - */ | ||
| 14 | - ultimoWkt : "", | ||
| 15 | - /** | ||
| 16 | - * Armazena a ultima medida | ||
| 17 | - */ | ||
| 18 | - ultimaMedida : "", | 6 | + position: [150,0], |
| 19 | renderFunction: i3GEO.janela.formModal, | 7 | renderFunction: i3GEO.janela.formModal, |
| 20 | _parameters : { | 8 | _parameters : { |
| 21 | "mustache": "", | 9 | "mustache": "", |
| 22 | "idContainer": "i3GEOdistanciaContainer", | 10 | "idContainer": "i3GEOdistanciaContainer", |
| 23 | - "namespace": "distancia" | 11 | + "namespace": "distancia", |
| 12 | + "pontos": {}, | ||
| 13 | + "ultimoWkt": "", | ||
| 24 | }, | 14 | }, |
| 25 | start : function(){ | 15 | start : function(){ |
| 26 | var p = this._parameters, | 16 | var p = this._parameters, |
| @@ -45,11 +35,12 @@ i3GEOF.distancia = | @@ -45,11 +35,12 @@ i3GEOF.distancia = | ||
| 45 | //nao use this aqui | 35 | //nao use this aqui |
| 46 | i3GEOF.distancia.renderFunction.call(); | 36 | i3GEOF.distancia.renderFunction.call(); |
| 47 | i3GEO.analise.pontos = { | 37 | i3GEO.analise.pontos = { |
| 48 | - xpt : [], | ||
| 49 | - ypt : [] | ||
| 50 | - }; | ||
| 51 | - i3GEOF.distancia.ultimaMedida = ""; | 38 | + xpt : [], |
| 39 | + ypt : [] | ||
| 40 | + }; | ||
| 41 | + i3GEOF.distancia._parameters.ultimaMedida = ""; | ||
| 52 | i3GEOF.distancia[i3GEO.Interface["ATUAL"]].fechaJanela(); | 42 | i3GEOF.distancia[i3GEO.Interface["ATUAL"]].fechaJanela(); |
| 43 | + i3GEOF.distancia._parameters.pontos = {}; | ||
| 53 | }, | 44 | }, |
| 54 | html:function() { | 45 | html:function() { |
| 55 | var p = this._parameters, | 46 | var p = this._parameters, |
| @@ -65,576 +56,582 @@ i3GEOF.distancia = | @@ -65,576 +56,582 @@ i3GEOF.distancia = | ||
| 65 | this, | 56 | this, |
| 66 | { | 57 | { |
| 67 | texto: Mustache.render(p.mustache, hash), | 58 | texto: Mustache.render(p.mustache, hash), |
| 68 | - header: "<span class='copyToMemory' onclick='i3GEO.util.copyToClipboard(i3GEOF.distancia.ultimaMedida);return false;'></span>", | 59 | + header: "<span class='copyToMemory' onclick='i3GEO.util.copyToClipboard(i3GEOF.distancia._parameters.ultimaMedida);return false;'></span>", |
| 69 | onclose: i3f.destroy | 60 | onclose: i3f.destroy |
| 70 | }); | 61 | }); |
| 71 | i3GEO.eventos.cliquePerm.desativa(); | 62 | i3GEO.eventos.cliquePerm.desativa(); |
| 72 | i3GEOF.distancia[i3GEO.Interface["ATUAL"]].inicia(); | 63 | i3GEOF.distancia[i3GEO.Interface["ATUAL"]].inicia(); |
| 73 | i3GEO.janela.snackBar({content: $trad("inicia",i3f.dicionario)}); | 64 | i3GEO.janela.snackBar({content: $trad("inicia",i3f.dicionario)}); |
| 74 | }, | 65 | }, |
| 75 | - perfil: function (){ | ||
| 76 | - var js = i3GEO.configura.locaplic + "/ferramentas/perfil/dependencias.php", temp = function() { | ||
| 77 | - i3GEOF.perfil.iniciaJanelaFlutuante(i3GEO.analise.pontos); | ||
| 78 | - }; | ||
| 79 | - i3GEO.util.scriptTag(js, temp, "i3GEOF.perfil_script"); | ||
| 80 | - }, | ||
| 81 | - isOn : function() { | ||
| 82 | - if($i("i3GEOF.distancia")){ | ||
| 83 | - return true; | ||
| 84 | - } else { | ||
| 85 | - return false; | ||
| 86 | - } | ||
| 87 | - }, | 66 | + perfil: function (){ |
| 67 | + var js = i3GEO.configura.locaplic + "/ferramentas/perfil/dependencias.php", temp = function() { | ||
| 68 | + i3GEOF.perfil.iniciaJanelaFlutuante(i3GEO.analise.pontos); | ||
| 69 | + }; | ||
| 70 | + i3GEO.util.scriptTag(js, temp, "i3GEOF.perfil_script"); | ||
| 71 | + }, | ||
| 72 | + isOn : function() { | ||
| 73 | + if($i("i3GEOF.distancia")){ | ||
| 74 | + return true; | ||
| 75 | + } else { | ||
| 76 | + return false; | ||
| 77 | + } | ||
| 78 | + }, | ||
| 88 | 79 | ||
| 89 | - /** | ||
| 90 | - * Converte a lista de pontos em WKT | ||
| 91 | - */ | ||
| 92 | - pontos2wkt : function() { | ||
| 93 | - var pontos = [], x = i3GEOF.distancia.pontos.xpt, y = i3GEOF.distancia.pontos.ypt, n = x.length, i; | ||
| 94 | - for (i = 0; i < n; i++) { | ||
| 95 | - pontos.push(x[i] + " " + y[i]); | ||
| 96 | - } | ||
| 97 | - return "LINESTRING(" + pontos.join(",") + ")"; | ||
| 98 | - }, | ||
| 99 | - removeFiguras : function(){ | ||
| 100 | - i3GEOF.distancia[i3GEO.Interface["ATUAL"]].removeFiguras(); | ||
| 101 | - }, | ||
| 102 | - /** | ||
| 103 | - * Funcoes especificas da interface openlayers | ||
| 104 | - */ | ||
| 105 | - openlayers : { | ||
| 106 | - draw : "", | ||
| 107 | - estilo: "", | ||
| 108 | - featureListener : null, | ||
| 109 | - //numero de pontos da geometria atual | ||
| 110 | - //utilizado para saber se houve um clique ou nao | ||
| 111 | - numpontos : 0, | ||
| 112 | - removeControle : function() { | ||
| 113 | - i3geoOL.removeInteraction(i3GEOF.distancia.openlayers.draw); | ||
| 114 | - i3GEOF.distancia.openlayers.draw = ""; | ||
| 115 | - }, | ||
| 116 | - /** | ||
| 117 | - * Inicializa o processo Cria a variavel para guardar os pontos Executa a funcao de inicializacao do desenho, que cria o | ||
| 118 | - * layer para receber os graficos | ||
| 119 | - */ | ||
| 120 | - inicia : function() { | ||
| 121 | - i3GEOF.distancia.openlayers.estilo = | ||
| 122 | - new ol.style.Style({ | ||
| 123 | - stroke: new ol.style.Stroke({ | ||
| 124 | - color: '#ffcc33', | ||
| 125 | - width: 5 | ||
| 126 | - }), | ||
| 127 | - fill: new ol.style.Fill({ | ||
| 128 | - color: 'rgba(255, 153, 0, 0.8)' | ||
| 129 | - }) | ||
| 130 | - }); | ||
| 131 | - i3GEO.desenho.estiloPadrao = "normal"; | ||
| 132 | - var m = i3GEOF.distancia.openlayers; | ||
| 133 | - i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); | ||
| 134 | - m.removeControle(); | ||
| 135 | - m.draw = new ol.interaction.Draw({ | ||
| 136 | - type : "LineString" | ||
| 137 | - }); | ||
| 138 | - i3GEO.Interface.openlayers.parametrosMap.interactions[0].setActive(false); | ||
| 139 | - m.draw.on("drawend", function(evt) { | ||
| 140 | - evt.feature.setProperties({ | ||
| 141 | - origem : "medeDistancia" | ||
| 142 | - }); | ||
| 143 | - var m = i3GEOF.distancia.openlayers; | ||
| 144 | - evt.feature.setStyle( | ||
| 145 | - new ol.style.Style({ | ||
| 146 | - stroke: new ol.style.Stroke({ | ||
| 147 | - color: i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao].linecolor, | ||
| 148 | - width: 5 | ||
| 149 | - }) | ||
| 150 | - }) | ||
| 151 | - ); | ||
| 152 | - i3GEO.desenho.layergrafico.getSource().addFeature(evt.feature); | ||
| 153 | - m.draw.setActive(false); | ||
| 154 | - m.draw.setActive(true); | ||
| 155 | - }); | ||
| 156 | - m.draw.on('drawstart', function(evt) { | ||
| 157 | - i3GEOF.distancia.pontos = { | ||
| 158 | - xpt : [], | ||
| 159 | - ypt : [], | ||
| 160 | - dist : [] | ||
| 161 | - }; | ||
| 162 | - //usado no perfil | ||
| 163 | - i3GEO.analise.pontos = { | ||
| 164 | - xpt : [], | ||
| 165 | - ypt : [] | ||
| 166 | - }; | ||
| 167 | - var m = i3GEOF.distancia.openlayers, | ||
| 168 | - sketch = evt.feature; | ||
| 169 | - m.estilo = sketch.getStyle(); | ||
| 170 | - m.numpontos = 1; | ||
| 171 | - m.featureListener = sketch.getGeometry().on('change', function(evt) { | ||
| 172 | - var ponto, | ||
| 173 | - geom = evt.target, | ||
| 174 | - coords = geom.getCoordinates(), | ||
| 175 | - n = coords.length, | ||
| 176 | - m = i3GEOF.distancia.openlayers; | ||
| 177 | - ponto = new ol.geom.Point(coords[n-1]); | ||
| 178 | - if(m.numpontos === n-1){ | ||
| 179 | - //clicou | ||
| 180 | - m.numpontos = n; | ||
| 181 | - m.point(ponto); | ||
| 182 | - } | ||
| 183 | - else{ | ||
| 184 | - m.modify(ponto); | ||
| 185 | - } | ||
| 186 | - }); | ||
| 187 | - }); | ||
| 188 | - i3geoOL.addInteraction(m.draw); | ||
| 189 | - }, | ||
| 190 | - modify : function(point) { | ||
| 191 | - var temp, n, x1, y1, x2, y2, trecho, parcial, direcao, | ||
| 192 | - coord = point.getCoordinates(); | ||
| 193 | - n = i3GEOF.distancia.pontos.ypt.length; | ||
| 194 | - if (n > 0) { | ||
| 195 | - x1 = i3GEOF.distancia.pontos.xpt[n - 1]; | ||
| 196 | - y1 = i3GEOF.distancia.pontos.ypt[n - 1]; | ||
| 197 | - x2 = coord[0]; | ||
| 198 | - y2 = coord[1]; | ||
| 199 | - // projeta | ||
| 200 | - if (i3GEO.Interface.openlayers.googleLike) { | ||
| 201 | - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 202 | - temp = temp.split(" "); | ||
| 203 | - x1 = temp[0]; | ||
| 204 | - y1 = temp[1]; | ||
| 205 | - x2 = temp[2]; | ||
| 206 | - y2 = temp[3]; | ||
| 207 | - } | ||
| 208 | - //console.info(x1+" "+y1+" "+x2+" "+y2) | ||
| 209 | - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 210 | - parcial = i3GEOF.distancia.openlayers.somaDist(); | ||
| 211 | - direcao = i3GEO.calculo.direcao(x1, y1, x2, y2); | ||
| 212 | - direcao = i3GEO.calculo.dd2dms(direcao, direcao); | ||
| 213 | - direcao = direcao[0]; | ||
| 214 | - i3GEOF.distancia.openlayers.mostraParcial(trecho, parcial, direcao); | ||
| 215 | - } | ||
| 216 | - }, | ||
| 217 | - point : function(point) { | ||
| 218 | - i3GEO.eventos.cliquePerm.desativa(); | ||
| 219 | - var n, x1, y1, x2, y2, trecho, temp, circ, label, raio, | ||
| 220 | - estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], | ||
| 221 | - coord = point.getCoordinates(), | ||
| 222 | - total = 0; | ||
| 223 | - i3GEOF.distancia.pontos.xpt.push(coord[0]); | ||
| 224 | - i3GEOF.distancia.pontos.ypt.push(coord[1]); | ||
| 225 | - i3GEO.analise.pontos.xpt.push(coord[0]); | ||
| 226 | - i3GEO.analise.pontos.ypt.push(coord[1]); | ||
| 227 | - n = i3GEOF.distancia.pontos.ypt.length; | ||
| 228 | - if (n > 1) { | ||
| 229 | - x1 = i3GEOF.distancia.pontos.xpt[n - 2]; | ||
| 230 | - y1 = i3GEOF.distancia.pontos.ypt[n - 2]; | ||
| 231 | - x2 = coord[0]; | ||
| 232 | - y2 = coord[1]; | ||
| 233 | - raio = new ol.geom.LineString([[x1, y1],[x2, y2]]).getLength(); | ||
| 234 | - // projeta | ||
| 235 | - if (i3GEO.Interface.openlayers.googleLike) { | ||
| 236 | - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 237 | - temp = temp.split(" "); | ||
| 238 | - x1 = temp[0]; | ||
| 239 | - y1 = temp[1]; | ||
| 240 | - x2 = temp[2]; | ||
| 241 | - y2 = temp[3]; | ||
| 242 | - } | ||
| 243 | - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 244 | - i3GEOF.distancia.pontos.dist.push(trecho); | ||
| 245 | - total = i3GEOF.distancia.openlayers.somaDist(); | ||
| 246 | - i3GEOF.distancia.openlayers.mostraTotal(trecho, total); | ||
| 247 | - i3GEOF.distancia.ultimoWkt = i3GEOF.distancia.pontos2wkt(); | ||
| 248 | - // raio | ||
| 249 | - if ($i("pararraios") && $i("pararraios").checked === true) { | 80 | + /** |
| 81 | + * Converte a lista de pontos em WKT | ||
| 82 | + */ | ||
| 83 | + pontos2wkt : function() { | ||
| 84 | + var pontos = [], x = i3GEOF.distancia._parameters.pontos.xpt, y = i3GEOF.distancia._parameters.pontos.ypt, n = x.length, i; | ||
| 85 | + for (i = 0; i < n; i++) { | ||
| 86 | + pontos.push(x[i] + " " + y[i]); | ||
| 87 | + } | ||
| 88 | + return "LINESTRING(" + pontos.join(",") + ")"; | ||
| 89 | + }, | ||
| 90 | + removeFiguras : function(){ | ||
| 91 | + i3GEOF.distancia[i3GEO.Interface["ATUAL"]].removeFiguras(); | ||
| 92 | + }, | ||
| 93 | + mostraTotal : function(trecho, total){ | ||
| 94 | + i3GEOF.distancia[i3GEO.Interface["ATUAL"]].mostraTotal(trecho, total); | ||
| 95 | + }, | ||
| 96 | + mostraParcial : function(trecho, parcial, direcao){ | ||
| 97 | + i3GEOF.distancia[i3GEO.Interface["ATUAL"]].mostraParcial(trecho, parcial, direcao); | ||
| 98 | + }, | ||
| 99 | + /** | ||
| 100 | + * Funcoes especificas da interface openlayers | ||
| 101 | + */ | ||
| 102 | + openlayers : { | ||
| 103 | + draw : "", | ||
| 104 | + estilo: "", | ||
| 105 | + featureListener : null, | ||
| 106 | + //numero de pontos da geometria atual | ||
| 107 | + //utilizado para saber se houve um clique ou nao | ||
| 108 | + numpontos : 0, | ||
| 109 | + removeControle : function() { | ||
| 110 | + i3geoOL.removeInteraction(i3GEOF.distancia.openlayers.draw); | ||
| 111 | + i3GEOF.distancia.openlayers.draw = ""; | ||
| 112 | + }, | ||
| 113 | + /** | ||
| 114 | + * Inicializa o processo Cria a variavel para guardar os pontos Executa a funcao de inicializacao do desenho, que cria o | ||
| 115 | + * layer para receber os graficos | ||
| 116 | + */ | ||
| 117 | + inicia : function() { | ||
| 118 | + i3GEOF.distancia.openlayers.estilo = | ||
| 119 | + new ol.style.Style({ | ||
| 120 | + stroke: new ol.style.Stroke({ | ||
| 121 | + color: '#ffcc33', | ||
| 122 | + width: 5 | ||
| 123 | + }), | ||
| 124 | + fill: new ol.style.Fill({ | ||
| 125 | + color: 'rgba(255, 153, 0, 0.8)' | ||
| 126 | + }) | ||
| 127 | + }); | ||
| 128 | + i3GEO.desenho.estiloPadrao = "normal"; | ||
| 129 | + var m = i3GEOF.distancia.openlayers; | ||
| 130 | + i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); | ||
| 131 | + m.removeControle(); | ||
| 132 | + m.draw = new ol.interaction.Draw({ | ||
| 133 | + type : "LineString" | ||
| 134 | + }); | ||
| 135 | + i3GEO.Interface.openlayers.parametrosMap.interactions[0].setActive(false); | ||
| 136 | + m.draw.on("drawend", function(evt) { | ||
| 137 | + evt.feature.setProperties({ | ||
| 138 | + origem : "medeDistancia" | ||
| 139 | + }); | ||
| 140 | + var m = i3GEOF.distancia.openlayers; | ||
| 141 | + evt.feature.setStyle( | ||
| 142 | + new ol.style.Style({ | ||
| 143 | + stroke: new ol.style.Stroke({ | ||
| 144 | + color: i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao].linecolor, | ||
| 145 | + width: 5 | ||
| 146 | + }) | ||
| 147 | + }) | ||
| 148 | + ); | ||
| 149 | + i3GEO.desenho.layergrafico.getSource().addFeature(evt.feature); | ||
| 150 | + m.draw.setActive(false); | ||
| 151 | + m.draw.setActive(true); | ||
| 152 | + }); | ||
| 153 | + m.draw.on('drawstart', function(evt) { | ||
| 154 | + i3GEOF.distancia._parameters.pontos = { | ||
| 155 | + xpt : [], | ||
| 156 | + ypt : [], | ||
| 157 | + dist : [] | ||
| 158 | + }; | ||
| 159 | + //usado no perfil | ||
| 160 | + i3GEO.analise.pontos = { | ||
| 161 | + xpt : [], | ||
| 162 | + ypt : [] | ||
| 163 | + }; | ||
| 164 | + var m = i3GEOF.distancia.openlayers, | ||
| 165 | + sketch = evt.feature; | ||
| 166 | + m.estilo = sketch.getStyle(); | ||
| 167 | + m.numpontos = 1; | ||
| 168 | + m.featureListener = sketch.getGeometry().on('change', function(evt) { | ||
| 169 | + var ponto, | ||
| 170 | + geom = evt.target, | ||
| 171 | + coords = geom.getCoordinates(), | ||
| 172 | + n = coords.length, | ||
| 173 | + m = i3GEOF.distancia.openlayers; | ||
| 174 | + ponto = new ol.geom.Point(coords[n-1]); | ||
| 175 | + if(m.numpontos === n-1){ | ||
| 176 | + //clicou | ||
| 177 | + m.numpontos = n; | ||
| 178 | + m.point(ponto); | ||
| 179 | + } | ||
| 180 | + else{ | ||
| 181 | + m.modify(ponto); | ||
| 182 | + } | ||
| 183 | + }); | ||
| 184 | + }); | ||
| 185 | + i3geoOL.addInteraction(m.draw); | ||
| 186 | + }, | ||
| 187 | + modify : function(point) { | ||
| 188 | + var temp, n, x1, y1, x2, y2, trecho, parcial, direcao, | ||
| 189 | + coord = point.getCoordinates(); | ||
| 190 | + n = i3GEOF.distancia._parameters.pontos.ypt.length; | ||
| 191 | + if (n > 0) { | ||
| 192 | + x1 = i3GEOF.distancia._parameters.pontos.xpt[n - 1]; | ||
| 193 | + y1 = i3GEOF.distancia._parameters.pontos.ypt[n - 1]; | ||
| 194 | + x2 = coord[0]; | ||
| 195 | + y2 = coord[1]; | ||
| 196 | + // projeta | ||
| 197 | + if (i3GEO.Interface.openlayers.googleLike) { | ||
| 198 | + temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 199 | + temp = temp.split(" "); | ||
| 200 | + x1 = temp[0]; | ||
| 201 | + y1 = temp[1]; | ||
| 202 | + x2 = temp[2]; | ||
| 203 | + y2 = temp[3]; | ||
| 204 | + } | ||
| 205 | + //console.info(x1+" "+y1+" "+x2+" "+y2) | ||
| 206 | + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 207 | + parcial = i3GEOF.distancia.openlayers.somaDist(); | ||
| 208 | + direcao = i3GEO.calculo.direcao(x1, y1, x2, y2); | ||
| 209 | + direcao = i3GEO.calculo.dd2dms(direcao, direcao); | ||
| 210 | + direcao = direcao[0]; | ||
| 211 | + i3GEOF.distancia.mostraParcial(trecho, parcial, direcao); | ||
| 212 | + } | ||
| 213 | + }, | ||
| 214 | + point : function(point) { | ||
| 215 | + i3GEO.eventos.cliquePerm.desativa(); | ||
| 216 | + var n, x1, y1, x2, y2, trecho, temp, circ, label, raio, | ||
| 217 | + estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], | ||
| 218 | + coord = point.getCoordinates(), | ||
| 219 | + total = 0; | ||
| 220 | + i3GEOF.distancia._parameters.pontos.xpt.push(coord[0]); | ||
| 221 | + i3GEOF.distancia._parameters.pontos.ypt.push(coord[1]); | ||
| 222 | + i3GEO.analise.pontos.xpt.push(coord[0]); | ||
| 223 | + i3GEO.analise.pontos.ypt.push(coord[1]); | ||
| 224 | + n = i3GEOF.distancia._parameters.pontos.ypt.length; | ||
| 225 | + if (n > 1) { | ||
| 226 | + x1 = i3GEOF.distancia._parameters.pontos.xpt[n - 2]; | ||
| 227 | + y1 = i3GEOF.distancia._parameters.pontos.ypt[n - 2]; | ||
| 228 | + x2 = coord[0]; | ||
| 229 | + y2 = coord[1]; | ||
| 230 | + raio = new ol.geom.LineString([[x1, y1],[x2, y2]]).getLength(); | ||
| 231 | + // projeta | ||
| 232 | + if (i3GEO.Interface.openlayers.googleLike) { | ||
| 233 | + temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 234 | + temp = temp.split(" "); | ||
| 235 | + x1 = temp[0]; | ||
| 236 | + y1 = temp[1]; | ||
| 237 | + x2 = temp[2]; | ||
| 238 | + y2 = temp[3]; | ||
| 239 | + } | ||
| 240 | + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 241 | + i3GEOF.distancia._parameters.pontos.dist.push(trecho); | ||
| 242 | + total = i3GEOF.distancia.openlayers.somaDist(); | ||
| 243 | + i3GEOF.distancia.mostraTotal(trecho, total); | ||
| 244 | + i3GEOF.distancia._parameters.ultimoWkt = i3GEOF.distancia.pontos2wkt(); | ||
| 245 | + // raio | ||
| 246 | + if ($i("pararraios") && $i("pararraios").checked === true) { | ||
| 250 | 247 | ||
| 251 | - temp = i3GEO.util.projGeo2OSM(new ol.geom.Point([x1*1, y1*1])); | ||
| 252 | - circ = new ol.Feature({ | ||
| 253 | - geometry: new ol.geom.Circle(temp.getCoordinates(),raio) | ||
| 254 | - }); | ||
| 255 | - circ.setProperties({ | ||
| 256 | - origem : "medeDistanciaExcluir" | ||
| 257 | - }); | 248 | + temp = i3GEO.util.projGeo2OSM(new ol.geom.Point([x1*1, y1*1])); |
| 249 | + circ = new ol.Feature({ | ||
| 250 | + geometry: new ol.geom.Circle(temp.getCoordinates(),raio) | ||
| 251 | + }); | ||
| 252 | + circ.setProperties({ | ||
| 253 | + origem : "medeDistanciaExcluir" | ||
| 254 | + }); | ||
| 258 | 255 | ||
| 259 | - circ.setStyle( | ||
| 260 | - new ol.style.Style({ | ||
| 261 | - stroke: new ol.style.Stroke({ | ||
| 262 | - color: estilo.circcolor, | ||
| 263 | - width: 1 | ||
| 264 | - }), | ||
| 265 | - zIndex: 2 | ||
| 266 | - }) | ||
| 267 | - ); | 256 | + circ.setStyle( |
| 257 | + new ol.style.Style({ | ||
| 258 | + stroke: new ol.style.Stroke({ | ||
| 259 | + color: estilo.circcolor, | ||
| 260 | + width: 1 | ||
| 261 | + }), | ||
| 262 | + zIndex: 2 | ||
| 263 | + }) | ||
| 264 | + ); | ||
| 268 | 265 | ||
| 269 | - i3GEO.desenho.layergrafico.getSource().addFeature(circ); | ||
| 270 | - } | ||
| 271 | - // desenha ponto | ||
| 272 | - if ($i("parartextos") && $i("parartextos").checked === true) { | ||
| 273 | - label = new ol.Feature({ | ||
| 274 | - geometry: i3GEO.util.projGeo2OSM(new ol.geom.Point([x2*1, y2*1])) | ||
| 275 | - }); | ||
| 276 | - label.setProperties({ | ||
| 277 | - origem : "medeDistanciaExcluir" | ||
| 278 | - }); | ||
| 279 | - label.setStyle( | ||
| 280 | - new ol.style.Style({ | ||
| 281 | - image: new ol.style.Circle({ | ||
| 282 | - radius: 3, | ||
| 283 | - fill: new ol.style.Fill({ | ||
| 284 | - color: estilo.circcolor | ||
| 285 | - }), | ||
| 286 | - stroke: new ol.style.Stroke({ | ||
| 287 | - color: estilo.circcolor, | ||
| 288 | - width: 1 | ||
| 289 | - }) | ||
| 290 | - }), | ||
| 291 | - text: new ol.style.Text({ | ||
| 292 | - text : $.number(trecho,3,$trad("dec"),$trad("mil")), | ||
| 293 | - font: 'Bold 14px Arial', | ||
| 294 | - textAlign: 'left', | ||
| 295 | - stroke: new ol.style.Stroke({ | ||
| 296 | - color: 'white', | ||
| 297 | - width: 1 | ||
| 298 | - }), | ||
| 299 | - fill: new ol.style.Fill({ | ||
| 300 | - color: estilo.textcolor | ||
| 301 | - }), | ||
| 302 | - zIndex: 2000 | ||
| 303 | - }) | ||
| 304 | - }) | ||
| 305 | - ); | ||
| 306 | - i3GEO.desenho.layergrafico.getSource().addFeature(label); | ||
| 307 | - } | ||
| 308 | - } | ||
| 309 | - }, | ||
| 310 | - /** | ||
| 311 | - * Soma os valores de distancia guardados em pontos.dist | ||
| 312 | - */ | ||
| 313 | - somaDist : function() { | ||
| 314 | - var n, i, total = 0; | ||
| 315 | - n = i3GEOF.distancia.pontos.dist.length; | ||
| 316 | - for (i = 0; i < n; i++) { | ||
| 317 | - total += i3GEOF.distancia.pontos.dist[i]; | ||
| 318 | - } | ||
| 319 | - return total; | ||
| 320 | - }, | ||
| 321 | - /** | ||
| 322 | - * Fecha a janela que mostra os dados Pergunta ao usuario se os graficos devem ser removidos Os graficos sao marcados com o | ||
| 323 | - * atributo "origem" Os raios e pontos sao sempre removidos | ||
| 324 | - */ | ||
| 325 | - fechaJanela : function() { | ||
| 326 | - i3GEO.Interface.openlayers.parametrosMap.interactions[0].setActive(false); | ||
| 327 | - var m = i3GEOF.distancia.openlayers; | ||
| 328 | - ol.Observable.unByKey(m.featureListener); | ||
| 329 | - m.featureListener = null; | ||
| 330 | - m.removeControle(); | ||
| 331 | - m.numpontos = 0; | ||
| 332 | - i3GEO.eventos.cliquePerm.ativa(); | ||
| 333 | - i3GEOF.distancia.openlayers.removeFiguras(); | ||
| 334 | - }, | ||
| 335 | - removeFiguras: function(){ | ||
| 336 | - var features, n, f, i, remover = [], temp; | ||
| 337 | - features = i3GEO.desenho.layergrafico.getSource().getFeatures(); | ||
| 338 | - n = features.length; | ||
| 339 | - for (i = 0; i < n; i++) { | ||
| 340 | - f = features[i]; | ||
| 341 | - if (f.getProperties().origem === "medeDistancia" || f.getProperties().origem === "medeDistanciaExcluir") { | ||
| 342 | - remover.push(f); | ||
| 343 | - } | ||
| 344 | - } | ||
| 345 | - if (remover.length > 0) { | ||
| 346 | - temp = window.confirm($trad("x94")); | ||
| 347 | - if (temp) { | ||
| 348 | - for (r in remover) { | ||
| 349 | - i3GEO.desenho.layergrafico.getSource().removeFeature(remover[r]); | ||
| 350 | - } | ||
| 351 | - } | ||
| 352 | - } | ||
| 353 | - }, | ||
| 354 | - /** | ||
| 355 | - * Mostra a totalizacao das linhas ja digitalizadas | ||
| 356 | - */ | ||
| 357 | - mostraTotal : function(trecho, total) { | ||
| 358 | - var mostra = $i("mostradistancia_calculo"), texto; | ||
| 359 | - if (mostra) { | ||
| 360 | - texto = | ||
| 361 | - "<strong>Total</strong><br>" + $trad("x96") | ||
| 362 | - + " km: " | ||
| 363 | - + $.number(total,3,$trad("dec"),$trad("mil")) | ||
| 364 | - + "<br>" | ||
| 365 | - + $trad("x96") | ||
| 366 | - + " m: " | ||
| 367 | - + $.number((total * 1000),2,$trad("dec"),$trad("mil")) | ||
| 368 | - + "<div class='hidden-sm hidden-xs' >" | ||
| 369 | - + $trad("x25") | ||
| 370 | - + ": " | ||
| 371 | - + i3GEO.calculo.metododistancia | ||
| 372 | - + "</div>"; | ||
| 373 | - i3GEOF.distancia.ultimaMedida = $.number(total,3,$trad("dec"),$trad("mil")) + " km"; | ||
| 374 | - mostra.innerHTML = texto; | ||
| 375 | - } | ||
| 376 | - }, | ||
| 377 | - /** | ||
| 378 | - * Mostra o valor do trecho entre o ultimo ponto clicado e a posicao do mouse | ||
| 379 | - */ | ||
| 380 | - mostraParcial : function(trecho, parcial, direcao) { | ||
| 381 | - var mostra = $i("mostradistancia_calculo_movel"), texto; | ||
| 382 | - if (mostra) { | ||
| 383 | - texto = | ||
| 384 | - "<strong>Parcial </strong><br>" + $trad("x95") | ||
| 385 | - + " km: " | ||
| 386 | - + $.number(trecho,3,$trad("dec"),$trad("mil")) | ||
| 387 | - + "<br>" | ||
| 388 | - + $trad("x97") | ||
| 389 | - + " km: " | ||
| 390 | - + $.number((parcial + trecho),3,$trad("dec"),$trad("mil")) | ||
| 391 | - + "<div class='hidden-sm hidden-xs' >" | ||
| 392 | - + $trad("x23") | ||
| 393 | - + " (DMS): " | ||
| 394 | - + direcao | ||
| 395 | - + "</div>"; | ||
| 396 | - mostra.innerHTML = texto; | ||
| 397 | - } | ||
| 398 | - } | ||
| 399 | - }, | ||
| 400 | - googlemaps : { | ||
| 401 | - /** | ||
| 402 | - * Inicializa o processo Cria a variavel para guardar os pontos Executa a funcao de inicializacao do desenho, que cria o | ||
| 403 | - * layer para receber os graficos | ||
| 404 | - */ | ||
| 405 | - inicia : function() { | ||
| 406 | - i3GEOF.distancia.pontos = { | ||
| 407 | - xpt : [], | ||
| 408 | - ypt : [], | ||
| 409 | - dist : [] | ||
| 410 | - }; | ||
| 411 | - i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); | ||
| 412 | - i3GeoMap.setOptions({ | ||
| 413 | - disableDoubleClickZoom : true | ||
| 414 | - }); | ||
| 415 | - i3GeoMap.setOptions({ | ||
| 416 | - draggableCursor : 'crosshair' | ||
| 417 | - }); | ||
| 418 | - var t, evtdblclick = null, evtclick = null, evtmousemove = null, pontos = { | ||
| 419 | - xpt : [], | ||
| 420 | - ypt : [], | ||
| 421 | - dist : [], | ||
| 422 | - mvcLine : new google.maps.MVCArray(), | ||
| 423 | - mvcMarkers : new google.maps.MVCArray(), | ||
| 424 | - line : null, | ||
| 425 | - polygon : null | ||
| 426 | - }, termina = function() { | ||
| 427 | - google.maps.event.removeListener(evtdblclick); | ||
| 428 | - google.maps.event.removeListener(evtclick); | ||
| 429 | - google.maps.event.removeListener(evtmousemove); | ||
| 430 | - pontos.line.setOptions({ | ||
| 431 | - clickable : true | ||
| 432 | - }); | ||
| 433 | - google.maps.event.addListener(pontos.line, 'click', function(shape) { | ||
| 434 | - if (shape.setEditable) { | ||
| 435 | - shape.setEditable(!shape.editable); | ||
| 436 | - } | ||
| 437 | - }); | ||
| 438 | - i3GEOF.distancia.ultimoWkt = i3GEOF.distancia.pontos2wkt(); | ||
| 439 | - t = i3GEOF.distancia.googlemaps.somaDist(pontos); | ||
| 440 | - i3GEOF.distancia.ultimaMedida = t.toFixed(3) + " km"; | ||
| 441 | - if (pontos) { | ||
| 442 | - i3GEO.desenho.googlemaps.shapes.push(pontos.mvcLine); | ||
| 443 | - i3GEO.desenho.googlemaps.shapes.push(pontos.line); | ||
| 444 | - pontos = null; | ||
| 445 | - } | ||
| 446 | - }; | ||
| 447 | - evtclick = google.maps.event.addListener(i3GeoMap, "click", function(evt) { | ||
| 448 | - i3GEO.eventos.cliquePerm.desativa(); | ||
| 449 | - var x1, x2, y1, y2, trecho = 0, total, n; | ||
| 450 | - // When the map is clicked, pass the LatLng obect to the | ||
| 451 | - // measureAdd function | ||
| 452 | - pontos.mvcLine.push(evt.latLng); | ||
| 453 | - pontos.xpt.push(evt.latLng.lng()); | ||
| 454 | - pontos.ypt.push(evt.latLng.lat()); | ||
| 455 | - i3GEOF.distancia.pontos.xpt.push(evt.latLng.lng()); | ||
| 456 | - i3GEOF.distancia.pontos.ypt.push(evt.latLng.lat()); | ||
| 457 | - n = pontos.xpt.length; | ||
| 458 | - // desenha um circulo | ||
| 459 | - if (pontos.mvcLine.getLength() > 1) { | ||
| 460 | - x1 = pontos.xpt[n - 2]; | ||
| 461 | - y1 = pontos.ypt[n - 2]; | ||
| 462 | - x2 = evt.latLng.lng(); | ||
| 463 | - y2 = evt.latLng.lat(); | ||
| 464 | - // raio = | ||
| 465 | - // google.maps.geometry.spherical.computeDistanceBetween(evt.latLng,new | ||
| 466 | - // google.maps.LatLng(y1,x1)) | ||
| 467 | - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 468 | - pontos.dist.push(trecho); | ||
| 469 | - total = i3GEOF.distancia.googlemaps.somaDist(pontos); | ||
| 470 | - i3GEOF.distancia.googlemaps.mostraTotal(trecho, total); | ||
| 471 | - if ($i("pararraios") && $i("pararraios").checked === true) { | ||
| 472 | - i3GEO.desenho.googlemaps.shapes.push(new google.maps.Circle({ | ||
| 473 | - map : i3GeoMap, | ||
| 474 | - fillOpacity : 0, | ||
| 475 | - clickable : false, | ||
| 476 | - strokeColor : "black", | ||
| 477 | - strokeOpacity : 1, | ||
| 478 | - strokeWeight : 2, | ||
| 479 | - center : new google.maps.LatLng(y1, x1), | ||
| 480 | - radius : trecho * 1000, | ||
| 481 | - origem : "medeDistanciaExcluir" | ||
| 482 | - })); | ||
| 483 | - } | ||
| 484 | - } | ||
| 485 | - // desenha uma marca no ponto | ||
| 486 | - if ($i("parartextos") && $i("parartextos").checked === true) { | ||
| 487 | - i3GEO.desenho.googlemaps.shapes.push(new google.maps.Marker({ | ||
| 488 | - map : i3GeoMap, | ||
| 489 | - fillOpacity : 0, | ||
| 490 | - clickable : false, | ||
| 491 | - position : evt.latLng, | ||
| 492 | - icon : { | ||
| 493 | - path : google.maps.SymbolPath.CIRCLE, | ||
| 494 | - scale : 2.5, | ||
| 495 | - strokeColor : "#ffffff", | ||
| 496 | - title : trecho.toFixed(0) + " km" | ||
| 497 | - }, | ||
| 498 | - origem : "medeDistanciaExcluir" | ||
| 499 | - })); | ||
| 500 | - } | ||
| 501 | - // mais um ponto para criar uma linha movel | ||
| 502 | - pontos.mvcLine.push(evt.latLng); | ||
| 503 | - }); | ||
| 504 | - evtmousemove = | ||
| 505 | - google.maps.event.addListener(i3GeoMap, "mousemove", function(evt) { | ||
| 506 | - if (!$i("mostradistancia_calculo")) { | ||
| 507 | - termina.call(); | ||
| 508 | - return; | ||
| 509 | - } | ||
| 510 | - var x1, y1, x2, y2, direcao, parcial, estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], n = | ||
| 511 | - pontos.xpt.length; | 266 | + i3GEO.desenho.layergrafico.getSource().addFeature(circ); |
| 267 | + } | ||
| 268 | + // desenha ponto | ||
| 269 | + if ($i("parartextos") && $i("parartextos").checked === true) { | ||
| 270 | + label = new ol.Feature({ | ||
| 271 | + geometry: i3GEO.util.projGeo2OSM(new ol.geom.Point([x2*1, y2*1])) | ||
| 272 | + }); | ||
| 273 | + label.setProperties({ | ||
| 274 | + origem : "medeDistanciaExcluir" | ||
| 275 | + }); | ||
| 276 | + label.setStyle( | ||
| 277 | + new ol.style.Style({ | ||
| 278 | + image: new ol.style.Circle({ | ||
| 279 | + radius: 3, | ||
| 280 | + fill: new ol.style.Fill({ | ||
| 281 | + color: estilo.circcolor | ||
| 282 | + }), | ||
| 283 | + stroke: new ol.style.Stroke({ | ||
| 284 | + color: estilo.circcolor, | ||
| 285 | + width: 1 | ||
| 286 | + }) | ||
| 287 | + }), | ||
| 288 | + text: new ol.style.Text({ | ||
| 289 | + text : $.number(trecho,3,$trad("dec"),$trad("mil")), | ||
| 290 | + font: 'Bold 14px Arial', | ||
| 291 | + textAlign: 'left', | ||
| 292 | + stroke: new ol.style.Stroke({ | ||
| 293 | + color: 'white', | ||
| 294 | + width: 1 | ||
| 295 | + }), | ||
| 296 | + fill: new ol.style.Fill({ | ||
| 297 | + color: estilo.textcolor | ||
| 298 | + }), | ||
| 299 | + zIndex: 2000 | ||
| 300 | + }) | ||
| 301 | + }) | ||
| 302 | + ); | ||
| 303 | + i3GEO.desenho.layergrafico.getSource().addFeature(label); | ||
| 304 | + } | ||
| 305 | + } | ||
| 306 | + }, | ||
| 307 | + /** | ||
| 308 | + * Soma os valores de distancia guardados em pontos.dist | ||
| 309 | + */ | ||
| 310 | + somaDist : function() { | ||
| 311 | + var n, i, total = 0; | ||
| 312 | + n = i3GEOF.distancia._parameters.pontos.dist.length; | ||
| 313 | + for (i = 0; i < n; i++) { | ||
| 314 | + total += i3GEOF.distancia._parameters.pontos.dist[i]; | ||
| 315 | + } | ||
| 316 | + return total; | ||
| 317 | + }, | ||
| 318 | + /** | ||
| 319 | + * Fecha a janela que mostra os dados Pergunta ao usuario se os graficos devem ser removidos Os graficos sao marcados com o | ||
| 320 | + * atributo "origem" Os raios e pontos sao sempre removidos | ||
| 321 | + */ | ||
| 322 | + fechaJanela : function() { | ||
| 323 | + i3GEO.Interface.openlayers.parametrosMap.interactions[0].setActive(false); | ||
| 324 | + var m = i3GEOF.distancia.openlayers; | ||
| 325 | + ol.Observable.unByKey(m.featureListener); | ||
| 326 | + m.featureListener = null; | ||
| 327 | + m.removeControle(); | ||
| 328 | + m.numpontos = 0; | ||
| 329 | + i3GEO.eventos.cliquePerm.ativa(); | ||
| 330 | + i3GEOF.distancia.openlayers.removeFiguras(); | ||
| 331 | + }, | ||
| 332 | + removeFiguras: function(){ | ||
| 333 | + var features, n, f, i, remover = [], temp; | ||
| 334 | + features = i3GEO.desenho.layergrafico.getSource().getFeatures(); | ||
| 335 | + n = features.length; | ||
| 336 | + for (i = 0; i < n; i++) { | ||
| 337 | + f = features[i]; | ||
| 338 | + if (f.getProperties().origem === "medeDistancia" || f.getProperties().origem === "medeDistanciaExcluir") { | ||
| 339 | + remover.push(f); | ||
| 340 | + } | ||
| 341 | + } | ||
| 342 | + if (remover.length > 0) { | ||
| 343 | + temp = window.confirm($trad("x94")); | ||
| 344 | + if (temp) { | ||
| 345 | + for (r in remover) { | ||
| 346 | + i3GEO.desenho.layergrafico.getSource().removeFeature(remover[r]); | ||
| 347 | + } | ||
| 348 | + } | ||
| 349 | + } | ||
| 350 | + }, | ||
| 351 | + /** | ||
| 352 | + * Mostra a totalizacao das linhas ja digitalizadas | ||
| 353 | + */ | ||
| 354 | + mostraTotal : function(trecho, total) { | ||
| 355 | + var mostra = $i("mostradistancia_calculo"), texto; | ||
| 356 | + if (mostra) { | ||
| 357 | + texto = | ||
| 358 | + "<strong>Total</strong><br>" + $trad("x96") | ||
| 359 | + + " km: " | ||
| 360 | + + $.number(total,3,$trad("dec"),$trad("mil")) | ||
| 361 | + + "<br>" | ||
| 362 | + + $trad("x96") | ||
| 363 | + + " m: " | ||
| 364 | + + $.number((total * 1000),2,$trad("dec"),$trad("mil")) | ||
| 365 | + + "<div class='hidden-sm hidden-xs' >" | ||
| 366 | + + $trad("x25") | ||
| 367 | + + ": " | ||
| 368 | + + i3GEO.calculo.metododistancia | ||
| 369 | + + "</div>"; | ||
| 370 | + i3GEOF.distancia._parameters.ultimaMedida = $.number(total,3,$trad("dec"),$trad("mil")) + " km"; | ||
| 371 | + mostra.innerHTML = texto; | ||
| 372 | + } | ||
| 373 | + }, | ||
| 374 | + /** | ||
| 375 | + * Mostra o valor do trecho entre o ultimo ponto clicado e a posicao do mouse | ||
| 376 | + */ | ||
| 377 | + mostraParcial : function(trecho, parcial, direcao) { | ||
| 378 | + var mostra = $i("mostradistancia_calculo_movel"), texto; | ||
| 379 | + if (mostra) { | ||
| 380 | + texto = | ||
| 381 | + "<strong>Parcial </strong><br>" + $trad("x95") | ||
| 382 | + + " km: " | ||
| 383 | + + $.number(trecho,3,$trad("dec"),$trad("mil")) | ||
| 384 | + + "<br>" | ||
| 385 | + + $trad("x97") | ||
| 386 | + + " km: " | ||
| 387 | + + $.number((parcial + trecho),3,$trad("dec"),$trad("mil")) | ||
| 388 | + + "<div class='hidden-sm hidden-xs' >" | ||
| 389 | + + $trad("x23") | ||
| 390 | + + " (DMS): " | ||
| 391 | + + direcao | ||
| 392 | + + "</div>"; | ||
| 393 | + mostra.innerHTML = texto; | ||
| 394 | + } | ||
| 395 | + } | ||
| 396 | + }, | ||
| 397 | + googlemaps : { | ||
| 398 | + /** | ||
| 399 | + * Inicializa o processo Cria a variavel para guardar os pontos Executa a funcao de inicializacao do desenho, que cria o | ||
| 400 | + * layer para receber os graficos | ||
| 401 | + */ | ||
| 402 | + inicia : function() { | ||
| 403 | + i3GEOF.distancia._parameters.pontos = { | ||
| 404 | + xpt : [], | ||
| 405 | + ypt : [], | ||
| 406 | + dist : [] | ||
| 407 | + }; | ||
| 408 | + i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); | ||
| 409 | + i3GeoMap.setOptions({ | ||
| 410 | + disableDoubleClickZoom : true | ||
| 411 | + }); | ||
| 412 | + i3GeoMap.setOptions({ | ||
| 413 | + draggableCursor : 'crosshair' | ||
| 414 | + }); | ||
| 415 | + var t, evtdblclick = null, evtclick = null, evtmousemove = null, pontos = { | ||
| 416 | + xpt : [], | ||
| 417 | + ypt : [], | ||
| 418 | + dist : [], | ||
| 419 | + mvcLine : new google.maps.MVCArray(), | ||
| 420 | + mvcMarkers : new google.maps.MVCArray(), | ||
| 421 | + line : null, | ||
| 422 | + polygon : null | ||
| 423 | + }, termina = function() { | ||
| 424 | + google.maps.event.removeListener(evtdblclick); | ||
| 425 | + google.maps.event.removeListener(evtclick); | ||
| 426 | + google.maps.event.removeListener(evtmousemove); | ||
| 427 | + pontos.line.setOptions({ | ||
| 428 | + clickable : true | ||
| 429 | + }); | ||
| 430 | + google.maps.event.addListener(pontos.line, 'click', function(shape) { | ||
| 431 | + if (shape.setEditable) { | ||
| 432 | + shape.setEditable(!shape.editable); | ||
| 433 | + } | ||
| 434 | + }); | ||
| 435 | + i3GEOF.distancia._parameters.ultimoWkt = i3GEOF.distancia.pontos2wkt(); | ||
| 436 | + t = i3GEOF.distancia.googlemaps.somaDist(pontos); | ||
| 437 | + i3GEOF.distancia._parameters.ultimaMedida = t.toFixed(3) + " km"; | ||
| 438 | + if (pontos) { | ||
| 439 | + i3GEO.desenho.googlemaps.shapes.push(pontos.mvcLine); | ||
| 440 | + i3GEO.desenho.googlemaps.shapes.push(pontos.line); | ||
| 441 | + pontos = null; | ||
| 442 | + } | ||
| 443 | + }; | ||
| 444 | + evtclick = google.maps.event.addListener(i3GeoMap, "click", function(evt) { | ||
| 445 | + i3GEO.eventos.cliquePerm.desativa(); | ||
| 446 | + var x1, x2, y1, y2, trecho = 0, total, n; | ||
| 447 | + // When the map is clicked, pass the LatLng obect to the | ||
| 448 | + // measureAdd function | ||
| 449 | + pontos.mvcLine.push(evt.latLng); | ||
| 450 | + pontos.xpt.push(evt.latLng.lng()); | ||
| 451 | + pontos.ypt.push(evt.latLng.lat()); | ||
| 452 | + i3GEOF.distancia._parameters.pontos.xpt.push(evt.latLng.lng()); | ||
| 453 | + i3GEOF.distancia._parameters.pontos.ypt.push(evt.latLng.lat()); | ||
| 454 | + n = pontos.xpt.length; | ||
| 455 | + // desenha um circulo | ||
| 456 | + if (pontos.mvcLine.getLength() > 1) { | ||
| 457 | + x1 = pontos.xpt[n - 2]; | ||
| 458 | + y1 = pontos.ypt[n - 2]; | ||
| 459 | + x2 = evt.latLng.lng(); | ||
| 460 | + y2 = evt.latLng.lat(); | ||
| 461 | + // raio = | ||
| 462 | + // google.maps.geometry.spherical.computeDistanceBetween(evt.latLng,new | ||
| 463 | + // google.maps.LatLng(y1,x1)) | ||
| 464 | + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 465 | + pontos.dist.push(trecho); | ||
| 466 | + total = i3GEOF.distancia.googlemaps.somaDist(pontos); | ||
| 467 | + i3GEOF.distancia.mostraTotal(trecho, total); | ||
| 468 | + if ($i("pararraios") && $i("pararraios").checked === true) { | ||
| 469 | + i3GEO.desenho.googlemaps.shapes.push(new google.maps.Circle({ | ||
| 470 | + map : i3GeoMap, | ||
| 471 | + fillOpacity : 0, | ||
| 472 | + clickable : false, | ||
| 473 | + strokeColor : "black", | ||
| 474 | + strokeOpacity : 1, | ||
| 475 | + strokeWeight : 2, | ||
| 476 | + center : new google.maps.LatLng(y1, x1), | ||
| 477 | + radius : trecho * 1000, | ||
| 478 | + origem : "medeDistanciaExcluir" | ||
| 479 | + })); | ||
| 480 | + } | ||
| 481 | + } | ||
| 482 | + // desenha uma marca no ponto | ||
| 483 | + if ($i("parartextos") && $i("parartextos").checked === true) { | ||
| 484 | + i3GEO.desenho.googlemaps.shapes.push(new google.maps.Marker({ | ||
| 485 | + map : i3GeoMap, | ||
| 486 | + fillOpacity : 0, | ||
| 487 | + clickable : false, | ||
| 488 | + position : evt.latLng, | ||
| 489 | + icon : { | ||
| 490 | + path : google.maps.SymbolPath.CIRCLE, | ||
| 491 | + scale : 2.5, | ||
| 492 | + strokeColor : "#ffffff", | ||
| 493 | + title : trecho.toFixed(0) + " km" | ||
| 494 | + }, | ||
| 495 | + origem : "medeDistanciaExcluir" | ||
| 496 | + })); | ||
| 497 | + } | ||
| 498 | + // mais um ponto para criar uma linha movel | ||
| 499 | + pontos.mvcLine.push(evt.latLng); | ||
| 500 | + }); | ||
| 501 | + evtmousemove = | ||
| 502 | + google.maps.event.addListener(i3GeoMap, "mousemove", function(evt) { | ||
| 503 | + if (!$i("mostradistancia_calculo")) { | ||
| 504 | + termina.call(); | ||
| 505 | + return; | ||
| 506 | + } | ||
| 507 | + var x1, y1, x2, y2, direcao, parcial, estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], n = | ||
| 508 | + pontos.xpt.length; | ||
| 512 | 509 | ||
| 513 | - // If there is more than one vertex on the line | ||
| 514 | - if (pontos.mvcLine.getLength() > 0) { | ||
| 515 | - // If the line hasn't been created yet | ||
| 516 | - if (!pontos.line) { | ||
| 517 | - // Create the line (google.maps.Polyline) | ||
| 518 | - pontos.line = new google.maps.Polyline({ | ||
| 519 | - map : i3GeoMap, | ||
| 520 | - clickable : false, | ||
| 521 | - strokeColor : estilo.linecolor, | ||
| 522 | - strokeOpacity : 1, | ||
| 523 | - strokeWeight : estilo.linewidth, | ||
| 524 | - path : pontos.mvcLine, | ||
| 525 | - origem : "medeDistancia" | ||
| 526 | - }); | ||
| 527 | - } | ||
| 528 | - pontos.mvcLine.pop(); | ||
| 529 | - pontos.mvcLine.push(evt.latLng); | ||
| 530 | - parcial = i3GEOF.distancia.googlemaps.somaDist(pontos); | ||
| 531 | - x1 = pontos.xpt[n - 1]; | ||
| 532 | - y1 = pontos.ypt[n - 1]; | ||
| 533 | - x2 = evt.latLng.lng(); | ||
| 534 | - y2 = evt.latLng.lat(); | ||
| 535 | - // raio = | ||
| 536 | - // google.maps.geometry.spherical.computeDistanceBetween(evt.latLng,new | ||
| 537 | - // google.maps.LatLng(y1,x1)) | ||
| 538 | - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 539 | - direcao = i3GEO.calculo.direcao(x1, y1, x2, y2); | ||
| 540 | - direcao = i3GEO.calculo.dd2dms(direcao, direcao); | ||
| 541 | - direcao = direcao[0]; | ||
| 542 | - i3GEOF.distancia.googlemaps.mostraParcial(trecho, parcial, direcao); | ||
| 543 | - } | ||
| 544 | - }); | ||
| 545 | - evtdblclick = google.maps.event.addListener(i3GeoMap, "dblclick", function(evt) { | ||
| 546 | - termina.call(); | ||
| 547 | - }); | ||
| 548 | - }, | ||
| 549 | - /** | ||
| 550 | - * Soma os valores de distancia guardados em pontos.dist | ||
| 551 | - */ | ||
| 552 | - somaDist : function(pontos) { | ||
| 553 | - var n, i, total = 0; | ||
| 554 | - n = pontos.dist.length; | ||
| 555 | - for (i = 0; i < n; i++) { | ||
| 556 | - total += pontos.dist[i]; | ||
| 557 | - } | ||
| 558 | - return total; | ||
| 559 | - }, | ||
| 560 | - /** | ||
| 561 | - * Fecha a janela que mostra os dados Pergunta ao usuario se os graficos devem ser removidos Os graficos sao marcados com o | ||
| 562 | - * atributo "origem" Os raios e pontos sao sempre removidos | ||
| 563 | - */ | ||
| 564 | - fechaJanela : function() { | ||
| 565 | - i3GeoMap.setOptions({ | ||
| 566 | - disableDoubleClickZoom : false | ||
| 567 | - }); | ||
| 568 | - i3GeoMap.setOptions({ | ||
| 569 | - draggableCursor : undefined | ||
| 570 | - }); | ||
| 571 | - i3GEOF.distancia.googlemaps.removeFiguras(); | ||
| 572 | - }, | ||
| 573 | - removeFiguras: function(){ | ||
| 574 | - var f = i3GEO.desenho.googlemaps.getFeaturesByAttribute("origem", "medeDistancia"); | ||
| 575 | - if (f && f.length > 0) { | ||
| 576 | - temp = window.confirm($trad("x94")); | ||
| 577 | - if (temp) { | ||
| 578 | - i3GEO.desenho.googlemaps.destroyFeatures(f); | ||
| 579 | - } | ||
| 580 | - } | ||
| 581 | - f = i3GEO.desenho.googlemaps.getFeaturesByAttribute("origem", "medeDistanciaExcluir"); | ||
| 582 | - if (f && f.length > 0) { | ||
| 583 | - i3GEO.desenho.googlemaps.destroyFeatures(f); | ||
| 584 | - } | ||
| 585 | - }, | ||
| 586 | - /** | ||
| 587 | - * Mostra a totalizacao das linhas ja digitalizadas | ||
| 588 | - */ | ||
| 589 | - mostraTotal : function(trecho, total) { | ||
| 590 | - var mostra = $i("mostradistancia_calculo"), texto; | ||
| 591 | - if (mostra) { | ||
| 592 | - texto = | ||
| 593 | - "<b>" + $trad("x96") | ||
| 594 | - + ":</b> " | ||
| 595 | - + total.toFixed(3) | ||
| 596 | - + " km" | ||
| 597 | - + "<br><b>" | ||
| 598 | - + $trad("x96") | ||
| 599 | - + ":</b> " | ||
| 600 | - + (total * 1000).toFixed(2) | ||
| 601 | - + " m" | ||
| 602 | - + "<br>" | ||
| 603 | - + $trad("x25") | ||
| 604 | - + ": " | ||
| 605 | - + i3GEO.calculo.metododistancia; | ||
| 606 | - mostra.innerHTML = texto; | ||
| 607 | - } | ||
| 608 | - }, | ||
| 609 | - /** | ||
| 610 | - * Mostra o valor do trecho entre o ultimo ponto clicado e a posicao do mouse | ||
| 611 | - */ | ||
| 612 | - mostraParcial : function(trecho, parcial, direcao) { | ||
| 613 | - var mostra = $i("mostradistancia_calculo_movel"), texto; | ||
| 614 | - if (mostra) { | ||
| 615 | - texto = | ||
| 616 | - "<b>" + $trad("x95") | ||
| 617 | - + ":</b> " | ||
| 618 | - + trecho.toFixed(3) | ||
| 619 | - + " km" | ||
| 620 | - + "<br><b>" | ||
| 621 | - + $trad("x97") | ||
| 622 | - + ":</b> " | ||
| 623 | - + (parcial + trecho).toFixed(3) | ||
| 624 | - + " km" | ||
| 625 | - + "<br><b>" | ||
| 626 | - + $trad("x23") | ||
| 627 | - + " (DMS):</b> " | ||
| 628 | - + direcao; | ||
| 629 | - mostra.innerHTML = texto; | ||
| 630 | - } | ||
| 631 | - } | ||
| 632 | - } | 510 | + // If there is more than one vertex on the line |
| 511 | + if (pontos.mvcLine.getLength() > 0) { | ||
| 512 | + // If the line hasn't been created yet | ||
| 513 | + if (!pontos.line) { | ||
| 514 | + // Create the line (google.maps.Polyline) | ||
| 515 | + pontos.line = new google.maps.Polyline({ | ||
| 516 | + map : i3GeoMap, | ||
| 517 | + clickable : false, | ||
| 518 | + strokeColor : estilo.linecolor, | ||
| 519 | + strokeOpacity : 1, | ||
| 520 | + strokeWeight : estilo.linewidth, | ||
| 521 | + path : pontos.mvcLine, | ||
| 522 | + origem : "medeDistancia" | ||
| 523 | + }); | ||
| 524 | + } | ||
| 525 | + pontos.mvcLine.pop(); | ||
| 526 | + pontos.mvcLine.push(evt.latLng); | ||
| 527 | + parcial = i3GEOF.distancia.googlemaps.somaDist(pontos); | ||
| 528 | + x1 = pontos.xpt[n - 1]; | ||
| 529 | + y1 = pontos.ypt[n - 1]; | ||
| 530 | + x2 = evt.latLng.lng(); | ||
| 531 | + y2 = evt.latLng.lat(); | ||
| 532 | + // raio = | ||
| 533 | + // google.maps.geometry.spherical.computeDistanceBetween(evt.latLng,new | ||
| 534 | + // google.maps.LatLng(y1,x1)) | ||
| 535 | + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 536 | + direcao = i3GEO.calculo.direcao(x1, y1, x2, y2); | ||
| 537 | + direcao = i3GEO.calculo.dd2dms(direcao, direcao); | ||
| 538 | + direcao = direcao[0]; | ||
| 539 | + i3GEOF.distancia.mostraParcial(trecho, parcial, direcao); | ||
| 540 | + } | ||
| 541 | + }); | ||
| 542 | + evtdblclick = google.maps.event.addListener(i3GeoMap, "dblclick", function(evt) { | ||
| 543 | + termina.call(); | ||
| 544 | + }); | ||
| 545 | + }, | ||
| 546 | + /** | ||
| 547 | + * Soma os valores de distancia guardados em pontos.dist | ||
| 548 | + */ | ||
| 549 | + somaDist : function(pontos) { | ||
| 550 | + var n, i, total = 0; | ||
| 551 | + n = pontos.dist.length; | ||
| 552 | + for (i = 0; i < n; i++) { | ||
| 553 | + total += pontos.dist[i]; | ||
| 554 | + } | ||
| 555 | + return total; | ||
| 556 | + }, | ||
| 557 | + /** | ||
| 558 | + * Fecha a janela que mostra os dados Pergunta ao usuario se os graficos devem ser removidos Os graficos sao marcados com o | ||
| 559 | + * atributo "origem" Os raios e pontos sao sempre removidos | ||
| 560 | + */ | ||
| 561 | + fechaJanela : function() { | ||
| 562 | + i3GeoMap.setOptions({ | ||
| 563 | + disableDoubleClickZoom : false | ||
| 564 | + }); | ||
| 565 | + i3GeoMap.setOptions({ | ||
| 566 | + draggableCursor : undefined | ||
| 567 | + }); | ||
| 568 | + i3GEOF.distancia.googlemaps.removeFiguras(); | ||
| 569 | + }, | ||
| 570 | + removeFiguras: function(){ | ||
| 571 | + var f = i3GEO.desenho.googlemaps.getFeaturesByAttribute("origem", "medeDistancia"); | ||
| 572 | + if (f && f.length > 0) { | ||
| 573 | + temp = window.confirm($trad("x94")); | ||
| 574 | + if (temp) { | ||
| 575 | + i3GEO.desenho.googlemaps.destroyFeatures(f); | ||
| 576 | + } | ||
| 577 | + } | ||
| 578 | + f = i3GEO.desenho.googlemaps.getFeaturesByAttribute("origem", "medeDistanciaExcluir"); | ||
| 579 | + if (f && f.length > 0) { | ||
| 580 | + i3GEO.desenho.googlemaps.destroyFeatures(f); | ||
| 581 | + } | ||
| 582 | + }, | ||
| 583 | + /** | ||
| 584 | + * Mostra a totalizacao das linhas ja digitalizadas | ||
| 585 | + */ | ||
| 586 | + mostraTotal : function(trecho, total) { | ||
| 587 | + var mostra = $i("mostradistancia_calculo"), texto; | ||
| 588 | + if (mostra) { | ||
| 589 | + texto = | ||
| 590 | + "<b>" + $trad("x96") | ||
| 591 | + + ":</b> " | ||
| 592 | + + total.toFixed(3) | ||
| 593 | + + " km" | ||
| 594 | + + "<br><b>" | ||
| 595 | + + $trad("x96") | ||
| 596 | + + ":</b> " | ||
| 597 | + + (total * 1000).toFixed(2) | ||
| 598 | + + " m" | ||
| 599 | + + "<br>" | ||
| 600 | + + $trad("x25") | ||
| 601 | + + ": " | ||
| 602 | + + i3GEO.calculo.metododistancia; | ||
| 603 | + mostra.innerHTML = texto; | ||
| 604 | + } | ||
| 605 | + }, | ||
| 606 | + /** | ||
| 607 | + * Mostra o valor do trecho entre o ultimo ponto clicado e a posicao do mouse | ||
| 608 | + */ | ||
| 609 | + mostraParcial : function(trecho, parcial, direcao) { | ||
| 610 | + var mostra = $i("mostradistancia_calculo_movel"), texto; | ||
| 611 | + if (mostra) { | ||
| 612 | + texto = | ||
| 613 | + "<b>" + $trad("x95") | ||
| 614 | + + ":</b> " | ||
| 615 | + + trecho.toFixed(3) | ||
| 616 | + + " km" | ||
| 617 | + + "<br><b>" | ||
| 618 | + + $trad("x97") | ||
| 619 | + + ":</b> " | ||
| 620 | + + (parcial + trecho).toFixed(3) | ||
| 621 | + + " km" | ||
| 622 | + + "<br><b>" | ||
| 623 | + + $trad("x23") | ||
| 624 | + + " (DMS):</b> " | ||
| 625 | + + direcao; | ||
| 626 | + mostra.innerHTML = texto; | ||
| 627 | + } | ||
| 628 | + } | ||
| 629 | + } | ||
| 633 | }; | 630 | }; |
| 634 | //aplica ao codigo i3GEOF definicoes feitas na interface do mapa | 631 | //aplica ao codigo i3GEOF definicoes feitas na interface do mapa |
| 635 | //isso permite a substituicao de funcoes e parametros | 632 | //isso permite a substituicao de funcoes e parametros |
| 636 | if(i3GEO.configura.ferramentas.hasOwnProperty("distancia")){ | 633 | if(i3GEO.configura.ferramentas.hasOwnProperty("distancia")){ |
| 637 | -jQuery.each( i3GEO.configura.ferramentas.distancia, function(index, value) { | ||
| 638 | - i3GEOF.distancia[index] = i3GEO.configura.ferramentas.distancia[index]; | ||
| 639 | -}); | 634 | + jQuery.each( i3GEO.configura.ferramentas.distancia, function(index, value) { |
| 635 | + i3GEOF.distancia[index] = i3GEO.configura.ferramentas.distancia[index]; | ||
| 636 | + }); | ||
| 640 | } | 637 | } |
| 641 | \ No newline at end of file | 638 | \ No newline at end of file |
interface/openlayersdebug.php
| @@ -3,14 +3,14 @@ | @@ -3,14 +3,14 @@ | ||
| 3 | <head> | 3 | <head> |
| 4 | <?php | 4 | <?php |
| 5 | $configInc = array( | 5 | $configInc = array( |
| 6 | - "debug" => "naocompacto", //posfixos inserido na carga do script do i3geo | 6 | + "debug" => "naocompacto", // posfixos inserido na carga do script do i3geo |
| 7 | "tipo" => "OL", // OL ou OSM | 7 | "tipo" => "OL", // OL ou OSM |
| 8 | - "inc" => "inc", //caminho para os includes PHP com os componentes da interface | ||
| 9 | - "pathjs" => "..", //caminho para o include dos arquivos JS | ||
| 10 | - "pathcss" => "..", //caminho para o include dos arquivos css | ||
| 11 | - "pathconfig" => ".", //caminho para o include do arquivo JS config.php | ||
| 12 | - "pathtutorial" => ".", //caminho para o include do arquivo JS tutorial.js | ||
| 13 | - "pathtemplates" => "templates", //caminho para a pasta template com os arquivos MUSTACHE | 8 | + "inc" => "inc", // caminho para os includes PHP com os componentes da interface |
| 9 | + "pathjs" => "..", // caminho para o include dos arquivos JS | ||
| 10 | + "pathcss" => "..", // caminho para o include dos arquivos css | ||
| 11 | + "pathconfig" => ".", // caminho para o include do arquivo JS config.php | ||
| 12 | + "pathtutorial" => ".", // caminho para o include do arquivo JS tutorial.js | ||
| 13 | + "pathtemplates" => "templates", // caminho para a pasta template com os arquivos MUSTACHE | ||
| 14 | "nocache" => time() | 14 | "nocache" => time() |
| 15 | ); | 15 | ); |
| 16 | include ($configInc["inc"] . "/meta.php"); | 16 | include ($configInc["inc"] . "/meta.php"); |
| @@ -66,7 +66,7 @@ include ($configInc["inc"] . "/css.php"); | @@ -66,7 +66,7 @@ include ($configInc["inc"] . "/css.php"); | ||
| 66 | include ($configInc["inc"] . "/iconecatalogo.php"); | 66 | include ($configInc["inc"] . "/iconecatalogo.php"); |
| 67 | include ($configInc["inc"] . "/iconelegenda.php"); | 67 | include ($configInc["inc"] . "/iconelegenda.php"); |
| 68 | include ($configInc["inc"] . "/iconebusca.php"); | 68 | include ($configInc["inc"] . "/iconebusca.php"); |
| 69 | - //include ($configInc["inc"] . "/iconeinfo.php"); | 69 | + // include ($configInc["inc"] . "/iconeinfo.php"); |
| 70 | include ($configInc["inc"] . "/iconetutorial.php"); | 70 | include ($configInc["inc"] . "/iconetutorial.php"); |
| 71 | ?> | 71 | ?> |
| 72 | </div> | 72 | </div> |