Commit 96c2acf3b9ae722fff8b1fef38f6d298d5213e95
1 parent
8860e2e7
Exists in
master
and in
7 other branches
Cálculo de área com OL3
Showing
3 changed files
with
181 additions
and
162 deletions
Show diff stats
ferramentas/selecao/index.js
| @@ -595,6 +595,9 @@ i3GEOF.selecao = | @@ -595,6 +595,9 @@ i3GEOF.selecao = | ||
| 595 | */ | 595 | */ |
| 596 | removeFiguras : { | 596 | removeFiguras : { |
| 597 | ol3 : function(){ | 597 | ol3 : function(){ |
| 598 | + if(!i3GEO.desenho.layergrafico){ | ||
| 599 | + return; | ||
| 600 | + } | ||
| 598 | var features, n, f, i, remover = [], temp; | 601 | var features, n, f, i, remover = [], temp; |
| 599 | features = i3GEO.desenho.layergrafico.getSource().getFeatures(); | 602 | features = i3GEO.desenho.layergrafico.getSource().getFeatures(); |
| 600 | n = features.length; | 603 | n = features.length; |
js/analise.js
| @@ -514,6 +514,15 @@ i3GEO.analise = | @@ -514,6 +514,15 @@ i3GEO.analise = | ||
| 514 | */ | 514 | */ |
| 515 | openlayers : { | 515 | openlayers : { |
| 516 | draw : "", | 516 | draw : "", |
| 517 | + estilo: new ol.style.Style({ | ||
| 518 | + stroke: new ol.style.Stroke({ | ||
| 519 | + color: '#ffcc33', | ||
| 520 | + width: 5 | ||
| 521 | + }), | ||
| 522 | + fill: new ol.style.Fill({ | ||
| 523 | + color: 'rgba(255, 153, 0, 0.8)' | ||
| 524 | + }) | ||
| 525 | + }), | ||
| 517 | featureListener : null, | 526 | featureListener : null, |
| 518 | //numero de pontos da geometria atual | 527 | //numero de pontos da geometria atual |
| 519 | //utilizado para saber se houve um clique ou nao | 528 | //utilizado para saber se houve um clique ou nao |
| @@ -543,22 +552,20 @@ i3GEO.analise = | @@ -543,22 +552,20 @@ i3GEO.analise = | ||
| 543 | m.draw.setActive(false); | 552 | m.draw.setActive(false); |
| 544 | m.draw.setActive(true); | 553 | m.draw.setActive(true); |
| 545 | }); | 554 | }); |
| 546 | - i3GEO.analise.medeDistancia.openlayers.draw.on('drawstart', function(evt) { | 555 | + m.draw.on('drawstart', function(evt) { |
| 547 | i3GEO.analise.medeDistancia.pontos = { | 556 | i3GEO.analise.medeDistancia.pontos = { |
| 548 | xpt : [], | 557 | xpt : [], |
| 549 | ypt : [], | 558 | ypt : [], |
| 550 | dist : [] | 559 | dist : [] |
| 551 | }; | 560 | }; |
| 552 | - // set sketch | ||
| 553 | var m = i3GEO.analise.medeDistancia.openlayers, | 561 | var m = i3GEO.analise.medeDistancia.openlayers, |
| 554 | sketch = evt.feature; | 562 | sketch = evt.feature; |
| 555 | - | 563 | + m.estilo = sketch.getStyle(); |
| 556 | m.numpontos = 1; | 564 | m.numpontos = 1; |
| 557 | - | ||
| 558 | m.featureListener = sketch.getGeometry().on('change', function(evt) { | 565 | m.featureListener = sketch.getGeometry().on('change', function(evt) { |
| 559 | var ponto, | 566 | var ponto, |
| 560 | geom = evt.target, | 567 | geom = evt.target, |
| 561 | - coords = geom.getCoordinates(); | 568 | + coords = geom.getCoordinates(), |
| 562 | n = coords.length, | 569 | n = coords.length, |
| 563 | m = i3GEO.analise.medeDistancia.openlayers; | 570 | m = i3GEO.analise.medeDistancia.openlayers; |
| 564 | ponto = new ol.geom.Point(coords[n-1]); | 571 | ponto = new ol.geom.Point(coords[n-1]); |
| @@ -575,7 +582,7 @@ i3GEO.analise = | @@ -575,7 +582,7 @@ i3GEO.analise = | ||
| 575 | i3geoOL.addInteraction(m.draw); | 582 | i3geoOL.addInteraction(m.draw); |
| 576 | }, | 583 | }, |
| 577 | modify : function(point) { | 584 | modify : function(point) { |
| 578 | - var n, x1, y1, x2, y2, trecho, parcial, direcao, | 585 | + var temp, n, x1, y1, x2, y2, trecho, parcial, direcao, |
| 579 | coord = point.getCoordinates(); | 586 | coord = point.getCoordinates(); |
| 580 | n = i3GEO.analise.medeDistancia.pontos.ypt.length; | 587 | n = i3GEO.analise.medeDistancia.pontos.ypt.length; |
| 581 | if (n > 0) { | 588 | if (n > 0) { |
| @@ -602,8 +609,8 @@ i3GEO.analise = | @@ -602,8 +609,8 @@ i3GEO.analise = | ||
| 602 | }, | 609 | }, |
| 603 | point : function(point) { | 610 | point : function(point) { |
| 604 | var n, x1, y1, x2, y2, trecho, temp, circ, label, raio, | 611 | var n, x1, y1, x2, y2, trecho, temp, circ, label, raio, |
| 605 | - estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao]; | ||
| 606 | - coord = point.getCoordinates(); | 612 | + estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], |
| 613 | + coord = point.getCoordinates(), | ||
| 607 | total = 0; | 614 | total = 0; |
| 608 | i3GEO.analise.medeDistancia.pontos.xpt.push(coord[0]); | 615 | i3GEO.analise.medeDistancia.pontos.xpt.push(coord[0]); |
| 609 | i3GEO.analise.medeDistancia.pontos.ypt.push(coord[1]); | 616 | i3GEO.analise.medeDistancia.pontos.ypt.push(coord[1]); |
| @@ -1273,154 +1280,155 @@ i3GEO.analise = | @@ -1273,154 +1280,155 @@ i3GEO.analise = | ||
| 1273 | * Funcoes especificas da interface openlayers | 1280 | * Funcoes especificas da interface openlayers |
| 1274 | */ | 1281 | */ |
| 1275 | openlayers : { | 1282 | openlayers : { |
| 1283 | + draw : "", | ||
| 1284 | + estilo: new ol.style.Style({ | ||
| 1285 | + stroke: new ol.style.Stroke({ | ||
| 1286 | + color: '#ffcc33', | ||
| 1287 | + width: 5 | ||
| 1288 | + }), | ||
| 1289 | + fill: new ol.style.Fill({ | ||
| 1290 | + color: 'rgba(255, 153, 0, 0.8)' | ||
| 1291 | + }) | ||
| 1292 | + }), | ||
| 1293 | + featureListener : null, | ||
| 1294 | + //numero de pontos da geometria atual | ||
| 1295 | + //utilizado para saber se houve um clique ou nao | ||
| 1296 | + numpontos : 0, | ||
| 1297 | + removeControle : function() { | ||
| 1298 | + i3geoOL.removeInteraction(i3GEO.analise.medeArea.openlayers.draw); | ||
| 1299 | + i3GEO.analise.medeArea.openlayers.draw = ""; | ||
| 1300 | + }, | ||
| 1276 | /** | 1301 | /** |
| 1277 | * Inicializa o processo Cria a variavel para guardar os pontos Executa a funcao de inicializacao do desenho, que cria o | 1302 | * Inicializa o processo Cria a variavel para guardar os pontos Executa a funcao de inicializacao do desenho, que cria o |
| 1278 | * layer para receber os graficos | 1303 | * layer para receber os graficos |
| 1279 | */ | 1304 | */ |
| 1280 | inicia : function() { | 1305 | inicia : function() { |
| 1281 | - var poligono, estilo = i3GEO.desenho.estilos[i3GEO.desenho.estiloPadrao], controle = | ||
| 1282 | - i3geoOL.getControlsBy("id", "i3GeoMedeArea"); | 1306 | + var m = i3GEO.analise.medeArea.openlayers; |
| 1283 | i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); | 1307 | i3GEO.desenho[i3GEO.Interface["ATUAL"]].inicia(); |
| 1284 | - i3GEO.analise.medeArea.pontos = { | ||
| 1285 | - xpt : [], | ||
| 1286 | - ypt : [], | ||
| 1287 | - dist : [] | ||
| 1288 | - }; | ||
| 1289 | - if (controle.length === 0) { | ||
| 1290 | - poligono = | ||
| 1291 | - new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Polygon, { | ||
| 1292 | - autoActivate : true, | ||
| 1293 | - id : "i3GeoMedeArea", | ||
| 1294 | - type : OpenLayers.Control.TYPE_TOOL, | ||
| 1295 | - callbacks : { | ||
| 1296 | - done : function(feature) { | ||
| 1297 | - var f = new OpenLayers.Feature.Vector(feature, { | ||
| 1298 | - origem : "medeArea" | ||
| 1299 | - }, { | ||
| 1300 | - graphicName : "square", | ||
| 1301 | - pointRadius : 10, | ||
| 1302 | - graphicOpacity : 1, | ||
| 1303 | - fillColor : "white", | ||
| 1304 | - fillOpacity : 0.4, | ||
| 1305 | - strokeColor : "black", | ||
| 1306 | - strokeOpacity : 1, | ||
| 1307 | - strokeWidth : 2 | ||
| 1308 | - }); | ||
| 1309 | - i3GEO.desenho.layergrafico.addFeatures([ | ||
| 1310 | - f | ||
| 1311 | - ]); | ||
| 1312 | - if (i3GEO.Interface) { | ||
| 1313 | - i3GEO.Interface.openlayers.sobeLayersGraficos(); | ||
| 1314 | - } | ||
| 1315 | - i3GEO.analise.medeArea.openlayers.mostraParcial(0, 0, 0, 0); | ||
| 1316 | - i3GEO.analise.medeArea.ultimoWkt = i3GEO.analise.medeArea.pontos2wkt(); | ||
| 1317 | - i3GEO.analise.medeArea.openlayers.inicia(); | ||
| 1318 | - }, | ||
| 1319 | - modify : function(point, poligono) { | ||
| 1320 | - var n, x1, y1, x2, y2, trecho = 0, per = 0, direcao = 0, area = 0, proj = | ||
| 1321 | - new OpenLayers.Projection("EPSG:4326"); | ||
| 1322 | - n = i3GEO.analise.medeArea.pontos.ypt.length; | ||
| 1323 | - if (n > 1) { | ||
| 1324 | - x1 = i3GEO.analise.medeArea.pontos.xpt[n - 1]; | ||
| 1325 | - y1 = i3GEO.analise.medeArea.pontos.ypt[n - 1]; | ||
| 1326 | - x2 = point.x; | ||
| 1327 | - y2 = point.y; | ||
| 1328 | - // projeta | ||
| 1329 | - if (i3GEO.Interface.openlayers.googleLike) { | ||
| 1330 | - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 1331 | - temp = temp.split(" "); | ||
| 1332 | - x1 = temp[0]; | ||
| 1333 | - y1 = temp[1]; | ||
| 1334 | - x2 = temp[2]; | ||
| 1335 | - y2 = temp[3]; | ||
| 1336 | - proj = new OpenLayers.Projection("EPSG:900913"); | ||
| 1337 | - } | ||
| 1338 | - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 1339 | - direcao = i3GEO.calculo.direcao(x1, y1, x2, y2); | ||
| 1340 | - direcao = i3GEO.calculo.dd2dms(direcao, direcao); | ||
| 1341 | - direcao = direcao[0]; | ||
| 1342 | - per = i3GEO.analise.medeArea.openlayers.somaDist(); | ||
| 1343 | - // soma ate o primeiro ponto | ||
| 1344 | - x1 = i3GEO.analise.medeArea.pontos.xpt[0]; | ||
| 1345 | - y1 = i3GEO.analise.medeArea.pontos.ypt[0]; | ||
| 1346 | - // projeta | ||
| 1347 | - if (i3GEO.Interface.openlayers.googleLike) { | ||
| 1348 | - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1); | ||
| 1349 | - temp = temp.split(" "); | ||
| 1350 | - x1 = temp[0]; | ||
| 1351 | - y1 = temp[1]; | ||
| 1352 | - } | ||
| 1353 | - per += i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 1354 | - area = poligono.geometry.getGeodesicArea(proj); | ||
| 1355 | - i3GEO.analise.medeArea.openlayers.mostraParcial(trecho, per, area, direcao); | ||
| 1356 | - } | ||
| 1357 | - }, | ||
| 1358 | - point : function(point, poligono) { | ||
| 1359 | - var n, x1, y1, x2, y2, temp, label, | ||
| 1360 | - // registra os pontos e calcula a distancia | ||
| 1361 | - per = 0, trecho = 0, area = 0, proj = new OpenLayers.Projection("EPSG:4326"); | ||
| 1362 | - i3GEO.analise.medeArea.pontos.xpt.push(point.x); | ||
| 1363 | - i3GEO.analise.medeArea.pontos.ypt.push(point.y); | ||
| 1364 | - n = i3GEO.analise.medeArea.pontos.ypt.length; | ||
| 1365 | - if (n > 1) { | ||
| 1366 | - x1 = i3GEO.analise.medeArea.pontos.xpt[n - 2]; | ||
| 1367 | - y1 = i3GEO.analise.medeArea.pontos.ypt[n - 2]; | ||
| 1368 | - x2 = point.x; | ||
| 1369 | - y2 = point.y; | ||
| 1370 | - // projeta | ||
| 1371 | - if (i3GEO.Interface.openlayers.googleLike) { | ||
| 1372 | - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 1373 | - temp = temp.split(" "); | ||
| 1374 | - x1 = temp[0]; | ||
| 1375 | - y1 = temp[1]; | ||
| 1376 | - x2 = temp[2]; | ||
| 1377 | - y2 = temp[3]; | ||
| 1378 | - proj = new OpenLayers.Projection("EPSG:900913"); | ||
| 1379 | - } | ||
| 1380 | - trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 1381 | - i3GEO.analise.medeArea.pontos.dist.push(trecho); | ||
| 1382 | - per = i3GEO.analise.medeArea.openlayers.somaDist(); | ||
| 1383 | - // soma ate o primeiro ponto | ||
| 1384 | - x1 = i3GEO.analise.medeArea.pontos.xpt[0]; | ||
| 1385 | - y1 = i3GEO.analise.medeArea.pontos.ypt[0]; | ||
| 1386 | - // projeta | ||
| 1387 | - if (i3GEO.Interface.openlayers.googleLike) { | ||
| 1388 | - temp = i3GEO.util.extOSM2Geo(x1 + " " + y1); | ||
| 1389 | - temp = temp.split(" "); | ||
| 1390 | - x1 = temp[0]; | ||
| 1391 | - y1 = temp[1]; | ||
| 1392 | - } | ||
| 1393 | - per += i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 1394 | - // desenha ponto | ||
| 1395 | - // if($i("parartextos") && | ||
| 1396 | - // $i("parartextos").checked === true ){ | ||
| 1397 | - label = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(point.x, point.y), { | ||
| 1398 | - origem : "medeAreaExcluir" | ||
| 1399 | - }, { | ||
| 1400 | - graphicName : "square", | ||
| 1401 | - pointRadius : 3, | ||
| 1402 | - strokeColor : "black", | ||
| 1403 | - graphicOpacity : 1, | ||
| 1404 | - strokeWidth : 1, | ||
| 1405 | - fillColor : "white", | ||
| 1406 | - label : trecho.toFixed(3), | ||
| 1407 | - labelAlign : "rb", | ||
| 1408 | - fontColor : estilo.textcolor, | ||
| 1409 | - fontSize : 12, | ||
| 1410 | - fontWeight : "bold" | ||
| 1411 | - }); | ||
| 1412 | - i3GEO.desenho.layergrafico.addFeatures([ | ||
| 1413 | - label | ||
| 1414 | - ]); | ||
| 1415 | - if (n > 2) { | ||
| 1416 | - area = poligono.getGeodesicArea(proj); | ||
| 1417 | - } | ||
| 1418 | - } | ||
| 1419 | - i3GEO.analise.medeArea.openlayers.mostraTotal(per, area); | ||
| 1420 | - } | ||
| 1421 | - } | ||
| 1422 | - }); | ||
| 1423 | - i3geoOL.addControl(poligono); | 1308 | + m.removeControle(); |
| 1309 | + m.draw = new ol.interaction.Draw({ | ||
| 1310 | + type : "Polygon" | ||
| 1311 | + }); | ||
| 1312 | + i3GEO.Interface.openlayers.interacoes[0].setActive(false); | ||
| 1313 | + m.draw.on("drawend", function(evt) { | ||
| 1314 | + evt.feature.setProperties({ | ||
| 1315 | + origem : "i3GeoMedeArea" | ||
| 1316 | + }); | ||
| 1317 | + var m = i3GEO.analise.medeArea.openlayers; | ||
| 1318 | + i3GEO.desenho.layergrafico.getSource().addFeature(evt.feature); | ||
| 1319 | + m.draw.setActive(false); | ||
| 1320 | + m.draw.setActive(true); | ||
| 1321 | + }); | ||
| 1322 | + m.draw.on('drawstart', function(evt) { | ||
| 1323 | + i3GEO.analise.medeArea.pontos = { | ||
| 1324 | + xpt : [], | ||
| 1325 | + ypt : [], | ||
| 1326 | + dist : [] | ||
| 1327 | + }; | ||
| 1328 | + var m = i3GEO.analise.medeArea.openlayers, | ||
| 1329 | + sketch = evt.feature; | ||
| 1330 | + m.estilo = sketch.getStyle(); | ||
| 1331 | + m.numpontos = 1; | ||
| 1332 | + m.featureListener = sketch.getGeometry().on('change', function(evt) { | ||
| 1333 | + var ponto, | ||
| 1334 | + geom = evt.target, | ||
| 1335 | + coords = geom.getLinearRing(0).getCoordinates(), | ||
| 1336 | + n = coords.length, | ||
| 1337 | + m = i3GEO.analise.medeArea.openlayers; | ||
| 1338 | + ponto = new ol.geom.Point(coords[n-1]); | ||
| 1339 | + if(m.numpontos === n-1){ | ||
| 1340 | + //clicou | ||
| 1341 | + m.numpontos = n; | ||
| 1342 | + m.point(ponto,geom); | ||
| 1343 | + } | ||
| 1344 | + else{ | ||
| 1345 | + m.modify(ponto,geom); | ||
| 1346 | + } | ||
| 1347 | + }); | ||
| 1348 | + }); | ||
| 1349 | + i3geoOL.addInteraction(m.draw); | ||
| 1350 | + }, | ||
| 1351 | + modify : function(point,geom) { | ||
| 1352 | + var temp,sourceProj,coordinates,wgs84Sphere, per, area, n, x1, y1, x2, y2, trecho, direcao, | ||
| 1353 | + coord = point.getCoordinates(); | ||
| 1354 | + n = i3GEO.analise.medeArea.pontos.ypt.length; | ||
| 1355 | + if (n > 1) { | ||
| 1356 | + x1 = i3GEO.analise.medeArea.pontos.xpt[n - 1]; | ||
| 1357 | + y1 = i3GEO.analise.medeArea.pontos.ypt[n - 1]; | ||
| 1358 | + x2 = coord[0]; | ||
| 1359 | + y2 = coord[1]; | ||
| 1360 | + // projeta | ||
| 1361 | + if (i3GEO.Interface.openlayers.googleLike) { | ||
| 1362 | + temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 1363 | + temp = temp.split(" "); | ||
| 1364 | + x1 = temp[0]; | ||
| 1365 | + y1 = temp[1]; | ||
| 1366 | + x2 = temp[2]; | ||
| 1367 | + y2 = temp[3]; | ||
| 1368 | + } | ||
| 1369 | + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 1370 | + //parcial = i3GEO.analise.medeArea.openlayers.somaDist(); | ||
| 1371 | + direcao = i3GEO.calculo.direcao(x1, y1, x2, y2); | ||
| 1372 | + direcao = i3GEO.calculo.dd2dms(direcao, direcao); | ||
| 1373 | + direcao = direcao[0]; | ||
| 1374 | + per = i3GEO.analise.medeArea.openlayers.somaDist(); | ||
| 1375 | + // soma ate o primeiro ponto | ||
| 1376 | + x1 = i3GEO.analise.medeArea.pontos.xpt[0]; | ||
| 1377 | + y1 = i3GEO.analise.medeArea.pontos.ypt[0]; | ||
| 1378 | + // projeta | ||
| 1379 | + if (i3GEO.Interface.openlayers.googleLike) { | ||
| 1380 | + temp = i3GEO.util.extOSM2Geo(x1 + " " + y1); | ||
| 1381 | + temp = temp.split(" "); | ||
| 1382 | + x1 = temp[0]; | ||
| 1383 | + y1 = temp[1]; | ||
| 1384 | + } | ||
| 1385 | + per += i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 1386 | + //getGeodesicArea | ||
| 1387 | + sourceProj = i3geoOL.getView().getProjection(); | ||
| 1388 | + geom = (geom.clone().transform(sourceProj, 'EPSG:4326')); | ||
| 1389 | + coordinates = geom.getLinearRing(0).getCoordinates(); | ||
| 1390 | + wgs84Sphere = new ol.Sphere(6378137); | ||
| 1391 | + area = Math.abs(wgs84Sphere.geodesicArea(coordinates)); | ||
| 1392 | + i3GEO.analise.medeArea.openlayers.mostraParcial(trecho, per, area, direcao); | ||
| 1393 | + } | ||
| 1394 | + | ||
| 1395 | + }, | ||
| 1396 | + point : function(point,geom) { | ||
| 1397 | + var wgs84Sphere,area,coordinates,sourceProj,n, x1, y1, x2, y2, trecho, temp, | ||
| 1398 | + coord = point.getCoordinates(), | ||
| 1399 | + total = 0; | ||
| 1400 | + i3GEO.analise.medeArea.pontos.xpt.push(coord[0]); | ||
| 1401 | + i3GEO.analise.medeArea.pontos.ypt.push(coord[1]); | ||
| 1402 | + i3GEO.analise.pontos.xpt.push(coord[0]); | ||
| 1403 | + i3GEO.analise.pontos.ypt.push(coord[1]); | ||
| 1404 | + n = i3GEO.analise.medeArea.pontos.ypt.length; | ||
| 1405 | + if (n > 1) { | ||
| 1406 | + x1 = i3GEO.analise.medeArea.pontos.xpt[n - 2]; | ||
| 1407 | + y1 = i3GEO.analise.medeArea.pontos.ypt[n - 2]; | ||
| 1408 | + x2 = coord[0]; | ||
| 1409 | + y2 = coord[1]; | ||
| 1410 | + raio = new ol.geom.LineString([[x1, y1],[x2, y2]]).getLength(); | ||
| 1411 | + // projeta | ||
| 1412 | + if (i3GEO.Interface.openlayers.googleLike) { | ||
| 1413 | + temp = i3GEO.util.extOSM2Geo(x1 + " " + y1 + " " + x2 + " " + y2); | ||
| 1414 | + temp = temp.split(" "); | ||
| 1415 | + x1 = temp[0]; | ||
| 1416 | + y1 = temp[1]; | ||
| 1417 | + x2 = temp[2]; | ||
| 1418 | + y2 = temp[3]; | ||
| 1419 | + } | ||
| 1420 | + trecho = i3GEO.calculo.distancia(x1, y1, x2, y2); | ||
| 1421 | + i3GEO.analise.medeArea.pontos.dist.push(trecho); | ||
| 1422 | + total = i3GEO.analise.medeArea.openlayers.somaDist(); | ||
| 1423 | + | ||
| 1424 | + sourceProj = i3geoOL.getView().getProjection(); | ||
| 1425 | + geom = (geom.clone().transform(sourceProj, 'EPSG:4326')); | ||
| 1426 | + coordinates = geom.getLinearRing(0).getCoordinates(); | ||
| 1427 | + wgs84Sphere = new ol.Sphere(6378137); | ||
| 1428 | + area = Math.abs(wgs84Sphere.geodesicArea(coordinates)); | ||
| 1429 | + | ||
| 1430 | + i3GEO.analise.medeArea.openlayers.mostraTotal(total, area); | ||
| 1431 | + i3GEO.analise.medeArea.ultimoWkt = i3GEO.analise.medeArea.pontos2wkt(); | ||
| 1424 | } | 1432 | } |
| 1425 | }, | 1433 | }, |
| 1426 | /** | 1434 | /** |
| @@ -1439,22 +1447,30 @@ i3GEO.analise = | @@ -1439,22 +1447,30 @@ i3GEO.analise = | ||
| 1439 | * atributo "origem" Os raios e pontos sao sempre removidos | 1447 | * atributo "origem" Os raios e pontos sao sempre removidos |
| 1440 | */ | 1448 | */ |
| 1441 | fechaJanela : function() { | 1449 | fechaJanela : function() { |
| 1442 | - var temp, controle = i3geoOL.getControlsBy("id", "i3GeoMedeArea"), f = | ||
| 1443 | - i3GEO.desenho.layergrafico.getFeaturesByAttribute("origem", "medeArea"); | ||
| 1444 | - if (controle.length > 0) { | ||
| 1445 | - controle[0].deactivate(); | ||
| 1446 | - i3geoOL.removeControl(controle[0]); | 1450 | + var m = i3GEO.analise.medeArea.openlayers; |
| 1451 | + ol.Observable.unByKey(m.featureListener); | ||
| 1452 | + m.featureListener = null; | ||
| 1453 | + m.removeControle(); | ||
| 1454 | + m.numpontos = 0; | ||
| 1455 | + i3GEO.eventos.cliquePerm.ativa(); | ||
| 1456 | + | ||
| 1457 | + var features, n, f, i, remover = [], temp; | ||
| 1458 | + features = i3GEO.desenho.layergrafico.getSource().getFeatures(); | ||
| 1459 | + n = features.length; | ||
| 1460 | + for (i = 0; i < n; i++) { | ||
| 1461 | + f = features[i]; | ||
| 1462 | + if (f.getProperties().origem === "i3GeoMedeArea" || f.getProperties().origem === "medeAreaExcluir") { | ||
| 1463 | + remover.push(f); | ||
| 1464 | + } | ||
| 1447 | } | 1465 | } |
| 1448 | - if (f && f.length > 0) { | 1466 | + if (remover.length > 0) { |
| 1449 | temp = window.confirm($trad("x94")); | 1467 | temp = window.confirm($trad("x94")); |
| 1450 | if (temp) { | 1468 | if (temp) { |
| 1451 | - i3GEO.desenho.layergrafico.destroyFeatures(f); | 1469 | + for (r in remover) { |
| 1470 | + i3GEO.desenho.layergrafico.getSource().removeFeature(remover[r]); | ||
| 1471 | + } | ||
| 1452 | } | 1472 | } |
| 1453 | } | 1473 | } |
| 1454 | - f = i3GEO.desenho.layergrafico.getFeaturesByAttribute("origem", "medeAreaExcluir"); | ||
| 1455 | - if (f && f.length > 0) { | ||
| 1456 | - i3GEO.desenho.layergrafico.destroyFeatures(f); | ||
| 1457 | - } | ||
| 1458 | }, | 1474 | }, |
| 1459 | /** | 1475 | /** |
| 1460 | * Mostra a totalizacao das linhas ja digitalizadas | 1476 | * Mostra a totalizacao das linhas ja digitalizadas |
js/desenho.js
| @@ -417,7 +417,7 @@ i3GEO.desenho = | @@ -417,7 +417,7 @@ i3GEO.desenho = | ||
| 417 | }), | 417 | }), |
| 418 | stroke : new ol.style.Stroke({ | 418 | stroke : new ol.style.Stroke({ |
| 419 | color : '#ffcc33', | 419 | color : '#ffcc33', |
| 420 | - width : 2 | 420 | + width : 4 |
| 421 | }), | 421 | }), |
| 422 | image : new ol.style.Circle({ | 422 | image : new ol.style.Circle({ |
| 423 | radius : 7, | 423 | radius : 7, |