Commit 67ddb62b8f8deb57c1aeeb61ddbb1d3513f8d78b

Authored by Edmar Moretti
1 parent b7a38ce3

--no commit message

classesjs/classe_barradebotoes.js
... ... @@ -1081,12 +1081,14 @@ i3GEO.barraDeBotoes = {
1081 1081 'ponto':true,
1082 1082 'poligono':true,
1083 1083 'edita':true,
  1084 + 'selecao':true,
1084 1085 'apaga':true,
1085 1086 'procura':false,
1086 1087 'propriedades':true,
1087 1088 'salva':true,
1088 1089 'ajuda':true,
1089   - 'fecha':true
  1090 + 'fecha':true,
  1091 + 'uniao':true
1090 1092 };
1091 1093 i3GEO.editorOL.layergrafico = new OpenLayers.Layer.Vector("Edição",{displayInLayerSwitcher:false,visibility:true});
1092 1094 i3GEO.editorOL.mapa.addLayers([i3GEO.editorOL.layergrafico]);
... ...
mashups/openlayers.css
... ... @@ -112,6 +112,12 @@ background-position:-522px 0;
112 112 .olControlEditingToolbar1 .propriedadesItemActive {
113 113 background-position:-522px -28px;
114 114 }
  115 +.olControlEditingToolbar1 .uniaoItemInactive {
  116 + background-position:-551px 0;
  117 +}
  118 +.olControlEditingToolbar1 .uniaoItemActive {
  119 + background-position:-551px -28px;
  120 +}
115 121 .olControlEditingToolbar1 {
116 122 width:600px;
117 123 float:right;
... ...
mashups/openlayers.js.php
... ... @@ -52,8 +52,10 @@ i3GEO.editorOL = {
52 52 'ponto':true,
53 53 'poligono':true,
54 54 'edita':true,
  55 + 'uniao':true,
55 56 'apaga':true,
56 57 'procura':true,
  58 + 'selecao':true,
57 59 'salva':true,
58 60 'ajuda':true,
59 61 'propriedades':true,
... ... @@ -617,6 +619,17 @@ i3GEO.editorOL = {
617 619 controles.push(button);
618 620 adiciona = true;
619 621 }
  622 + if(botoes.uniao===true){
  623 + button = new OpenLayers.Control.Button({
  624 + displayClass: "uniao",
  625 + trigger: function(){
  626 + i3GEO.editorOL.carregajts("i3GEO.editorOL.uniao()");
  627 + },
  628 + title: "Une geometrias"
  629 + });
  630 + controles.push(button);
  631 + adiciona = true;
  632 + }
620 633 //botao de seleção
621 634 if(botoes.selecao===true){
622 635 button = new OpenLayers.Control.SelectFeature(
... ... @@ -839,6 +852,63 @@ i3GEO.editorOL = {
839 852 if(temp.checked === true)
840 853 {i3GEOOLsplit.activate();}
841 854 },
  855 + uniao: function(){
  856 + var geosel = i3GEO.editorOL.layergrafico.selectedFeatures,
  857 + polis,linhas,pontos,uniaopolis,uniaolinhas,uniaopontos;
  858 + if(geosel.length > 1){
  859 + polis = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.Polygon");
  860 + linhas = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.LineString");
  861 + pontos = i3GEO.editorOL.retornaGeometriasTipo(geosel,"OpenLayers.Geometry.Point");
  862 + if(polis)
  863 + {uniaopolis = i3GEO.editorOL.uniaojts(polis);}
  864 + if(linhas)
  865 + {uniaolinhas = i3GEO.editorOL.uniaojts(linhas);}
  866 + if(pontos)
  867 + {uniaopontos = i3GEO.editorOL.uniaojts(pontos);}
  868 + if(uniaopolis)
  869 + {i3GEO.editorOL.layergrafico.addFeatures(uniaopolis);}
  870 + if(uniaolinhas)
  871 + {i3GEO.editorOL.layergrafico.addFeatures(uniaolinhas);}
  872 + if(uniaopontos)
  873 + {i3GEO.editorOL.layergrafico.addFeatures(uniaopontos);}
  874 + }
  875 + else
  876 + {alert("Selecione pelo menos dois elementos");}
  877 + },
  878 + uniaojts: function(geoms){
  879 + var n = geoms.length,
  880 + rwkt = new jsts.io.WKTReader(),
  881 + wwkt = new jsts.io.WKTWriter(),
  882 + fwkt = new OpenLayers.Format.WKT(),
  883 + wkt,
  884 + g,
  885 + i,uniao;
  886 + if(n > 1){
  887 + wkt = fwkt.write(geoms[0]);
  888 + alert(wkt)
  889 + uniao = rwkt.read(wkt);
  890 + for(i=1;i <= n;i++){
  891 + wkt = fwkt.write(geoms[i]);
  892 + g = readerwkt.read(wkt);
  893 + uniao = uniao.union(g);
  894 + }
  895 + uniao = wwkt.write(uniao);
  896 + return [fwkt.read(uniao)];
  897 + }
  898 + else
  899 + {return false;}
  900 + },
  901 + retornaGeometriasTipo: function(features,tipo){
  902 + var n = features.length,
  903 + lista = [],
  904 + i,temp;
  905 + for(i=0;i<n;i++){
  906 + temp = features[i].geometry;
  907 + if(temp.CLASS_NAME == tipo)
  908 + {lista.push(temp);}
  909 + }
  910 + return lista;
  911 + },
842 912 flashFeatures: function(features, index) {
843 913 if(!index) {
844 914 index = 0;
... ... @@ -855,5 +925,8 @@ i3GEO.editorOL = {
855 925 if(index <= features.length) {
856 926 window.setTimeout(function() {i3GEO.editorOL.flashFeatures(features, index);}, 75);
857 927 }
  928 + },
  929 + carregajts: function(funcao){
  930 + i3GEO.util.scriptTag(i3GEO.configura.locaplic+"/pacotes/jsts/jstsi3geo.js",funcao,"i3GEOjts",true);
858 931 }
859 932 };
860 933 \ No newline at end of file
... ...
mashups/openlayers.php
... ... @@ -65,6 +65,8 @@ if(isset($botoes)){
65 65 {$objBotoes[] = "'poligono':true";}
66 66 if(in_array("edita",$botoes))
67 67 {$objBotoes[] = "'edita':true";}
  68 + if(in_array("uniao",$botoes))
  69 + {$objBotoes[] = "'uniao':true";}
68 70 if(in_array("apaga",$botoes))
69 71 {$objBotoes[] = "'apaga':true";}
70 72 if(in_array("procura",$botoes))
... ... @@ -172,6 +174,7 @@ Parâmetros:
172 174 linha
173 175 poligono
174 176 edita
  177 + uniao
175 178 apaga
176 179 captura
177 180 procura
... ...
mashups/openlayers.png

19.9 KB | W: | H:

20.5 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
ms_criamapa.php
... ... @@ -159,6 +159,7 @@ include_once ($caminho.&quot;classesphp/pega_variaveis.php&quot;);
159 159 include_once ($caminho."classesphp/funcoes_gerais.php");
160 160 if(!isset($dir_tmp))
161 161 {include_once ($caminho."ms_configura.php");}
  162 +
162 163 if (!isset($debug))
163 164 {error_reporting(0);$debug="nao";}
164 165 else
... ...