Commit 4e6b5831a7253cf78294146592ba0c3c0ef06ced

Authored by Edmar Moretti
1 parent ee8dd0a6

Adicionada opção de definição da projeção das coordenadas digitadas na ferramenta de inserir pontos

classesphp/classe_shp.php
... ... @@ -133,8 +133,10 @@ Insere um ponto em um shape file no diretório local
133 133  
134 134 parameters:
135 135 $xy - X e y do novo ponto, separados por espaços. Pode ser mais de um ponto.
  136 +
  137 +$projecao - código epsg da projeção das coordenadas
136 138 */
137   - function insereSHP($xy)
  139 + function insereSHP($xy,$projecao)
138 140 {
139 141 require_once "../pacotes/phpxbase/api_conversion.php";
140 142 $xy = explode(" ",$xy);
... ... @@ -158,6 +160,12 @@ $xy - X e y do novo ponto, separados por espaços. Pode ser mais de um ponto.
158 160 {
159 161 $poPoint = ms_newpointobj();
160 162 $poPoint->setXY($xy[$i],$xy[$i+1]);
  163 + if($projecao != "")
  164 + {
  165 + $projOutObj = ms_newprojectionobj("proj=latlong");
  166 + $projInObj = ms_newprojectionobj("init=epsg:".$projecao);
  167 + $poPoint->project($projInObj, $projOutObj);
  168 + }
161 169 $shapefileObj->addpoint($poPoint);
162 170 }
163 171 $shapefileObj->free();
... ...
classesphp/mapa_controle.php
... ... @@ -1210,7 +1210,8 @@ Include:
1210 1210 case "insereSHP":
1211 1211 include("classe_shp.php");
1212 1212 $m = new SHP($map_file,$tema);
1213   - $m->insereSHP($xy);
  1213 + if (!isset($projecao)){$projecao = "";}
  1214 + $m->insereSHP($xy,$projecao);
1214 1215 redesenhaMapa();
1215 1216 break;
1216 1217 /*
... ...
ferramentas/inserexy2/index.htm
... ... @@ -14,6 +14,11 @@
14 14 <div id=guia5 >Coordenadas</div>
15 15 </div>
16 16 <span id=geral style="left:0px;top:0px;">
  17 + <div id=projecao style='left:0px;display:none'>
  18 + Proje&ccedil;&atilde;o:
  19 + <div onclick='verificaproj()' id="listaepsg" style="border:1px solid gray;width:300px;overflow:auto;height:60px;display:block;left:1px" >
  20 + </div>
  21 + </div>
17 22 <div class=guiaobj id="guia1obj" style="display:block;left:1px" >
18 23 <div id=opc1 style=left:0px;top:5px;text-align:left; >
19 24 Escolha o tema para inserir os pontos:
... ... @@ -27,28 +32,46 @@
27 32 </div>
28 33 </div>
29 34 <div class=guiaobj id="guia2obj" style="display:none;;left:1px" >
30   - <div id=opc2 style="display:block;top:5px;left:0px">
  35 + <div id=tipodig style="display:block;top:5px;left:0px">
  36 + Tipo de entrada:
  37 + <table class=lista >
  38 + <tr>
  39 + <td><input title='DMS' onclick='escolhedig("digmascara")' name=tipodig type=radio id='tipodigmascara' checked /></td>
  40 + <td>Máscara</td>
  41 + <td><input title='DMS' onclick='escolhedig("digcampo")' name=tipodig type=radio id='tipodigcampo' /></td>
  42 + <td>Campo &uacute;nico</td>
  43 + </tr>
  44 + </table><br>
  45 + </div>
  46 + <div id=digmascara style="display:block;top:10px;left:0px">
31 47 X:<input class=digitar id='xg' title='grau' type=text size=3 value='-00'/>
32 48 <input class=digitar id='xm' title='minuto' type=text size=3 value='00'/>
33 49 <input class=digitar id='xs' title='segundo' type=text size=3 value='0.0'/>
34   - ou <input class=digitar id='longitude' title='dms' type=text size=16 value=''/><br>
35   - Y:<input class=digitar id='yg' title='grau' type=text size=3 value='-00'/>
  50 + &nbsp;Y:<input class=digitar id='yg' title='grau' type=text size=3 value='-00'/>
36 51 <input class=digitar id='ym' title='minuto' type=text size=3 value='00'/>
37   - <input class=digitar id='ys' title='segundo' type=text size=3 value='0.0'/>
38   - ou <input class=digitar id='latitude' title='dms' type=text size=16 value=''/><br><br>
  52 + <input class=digitar id='ys' title='segundo' type=text size=3 value='0.0'/><br><br>
  53 + </div>
  54 + <div id=digcampo style="display:none;top:10px;left:0px">
  55 + X: <input class=digitar id='longitude' title='dms' type=text size=16 value=''/>
  56 + Y: <input class=digitar id='latitude' title='dms' type=text size=16 value=''/><br><br>
  57 + </div>
  58 + <div id=opc2 style="display:block;top:15px;left:0px">
39 59 <div style=top:0px;left:0px;text-align:left onclick='inserir()' >
40 60 <input id=botao2 type='button' size=14 value='Insere' />
41 61 </div>
42 62 </div>
43   - <div id=men2 style="display:block;position:relative;left:0px;top:10px">
44   - Digite as coordenadas do ponto desejado e clique em "Insere" para incluir o ponto.
  63 +
  64 + <div id=men2 style="display:block;position:relative;left:0px;top:20px">
  65 + Digite as coordenadas do ponto desejado e clique em "Insere".
45 66 <br>A coordenada X corresponde a longitude (leste-oeste) e a coordenada Y corresponde a latitude (norte-sul).
46   - <br>Os valores devem sempre estar no formato Grau, Minuto e Segundo. Caso as coordenadas estejam em d&eacute;cimos de grau, utilize a guia "Colar".
  67 + <br>Os valores devem sempre estar no formato Grau, Minuto e Segundo, sendo que no caso da opção de campo &uacute;nico, os valores devem estar separados por espaços. Caso as coordenadas estejam em d&eacute;cimos de grau, utilize a guia "Colar".
47 68 <br>O valor correspondente ao Grau deve receber o sinal de negativo("-") nos casos de longitude oeste (todo o Brasil est&aacute; nesse caso) e nos casos de latitude Sul.<br><br><br>
48 69 </div>
49 70 </div>
50 71 <div class=guiaobj id="guia3obj" style="display:none;left:1px;top:5px" >
  72 +
51 73 <div id=opc3 style="top:0px;left:0px;text-align:left;">
  74 + Cole ou digite a lista de coordenadas:
52 75 <input class=digitar id='colar' title='pares' type=text size=50 value=''/>
53 76 </div>
54 77 <div style=top:10px;left:0px;text-align:left onclick='colar()' >
... ...
ferramentas/inserexy2/index.js
... ... @@ -26,20 +26,30 @@ ativaGuias(&quot;&quot;)
26 26 mostraGuia("guia1")
27 27 //eventos das guias
28 28 $i("guia1").onclick = function()
29   -{mostraGuia("guia1");}
  29 +{mostraGuia("guia1");$i("projecao").style.display="none";}
30 30 $i("guia2").onclick = function()
31   -{mostraGuia("guia2");}
  31 +{mostraGuia("guia2");$i("projecao").style.display="block";}
32 32 $i("guia3").onclick = function()
33   -{mostraGuia("guia3");}
  33 +{mostraGuia("guia3");$i("projecao").style.display="block";}
34 34 $i("guia4").onclick = function()
35   -{mostraGuia("guia4");}
  35 +{mostraGuia("guia4");$i("projecao").style.display="none";}
36 36 $i("guia5").onclick = function()
37   -{mostraGuia("guia5");}
  37 +{mostraGuia("guia5");$i("projecao").style.display="none";}
38 38  
39 39 window.parent.g_nomepin = ""
40 40 mensagemAjuda("men1",$i("men1").innerHTML)
41 41 mensagemAjuda("men2",$i("men2").innerHTML)
42 42 mensagemAjuda("men3",$i("men3").innerHTML)
  43 +
  44 +radioepsg
  45 +(
  46 + function(retorno)
  47 + {
  48 + $i("listaepsg").innerHTML = retorno.dados
  49 + },
  50 + "listaepsg"
  51 +)
  52 +
43 53 //pega a lista de temas editaveis
44 54 function montaComboLocal()
45 55 {
... ... @@ -190,40 +200,37 @@ function inserir()
190 200 aguarde("block")
191 201 var reg = new RegExp("w|W|l|L|o|O|'|G|r", "g");
192 202 var regv = new RegExp(",", "g");
193   - if (!$i("longitude").value == "")
  203 + if($i("tipodigcampo").checked)
194 204 {
195   - var v = $i("longitude").value + " 0" + " 0"
196   - v = v.replace(reg,"");
197   - v = v.replace(regv,".");
198   - v = v.split(" ");
199   - $i("xg").value = v[0]
200   - $i("xm").value = v[1]
201   - $i("xs").value = v[2]
202   - var xgv = v[0]
203   - var xmv = v[1]
204   - var xsv = v[2]
205   - var xsv = xsv.replace(",",".");
  205 + if (!$i("longitude").value == "")
  206 + {
  207 + var v = $i("longitude").value + " 0" + " 0"
  208 + v = v.replace(reg,"");
  209 + v = v.replace(regv,".");
  210 + v = v.split(" ");
  211 + var xgv = v[0]
  212 + var xmv = v[1]
  213 + var xsv = v[2]
  214 + var xsv = xsv.replace(",",".");
  215 + }
  216 + if (!$i("latitude").value == "")
  217 + {
  218 + var vv = $i("latitude").value + " 0" + " 0"
  219 + vv = vv.replace(reg,"");
  220 + vv = vv.replace(regv,".");
  221 + vv = vv.split(" ");
  222 + var ygv = vv[0]
  223 + var ymv = vv[1]
  224 + var ysv = vv[2]
  225 + var ysv = ysv.replace(regv,".");
  226 + }
206 227 }
207   - else
208   - {
  228 + if($i("tipodigmascara").checked)
  229 + {
209 230 var xgv = $i("xg").value;
210 231 var xmv = $i("xm").value;
211 232 var xsv = $i("xs").value;
212 233 var xsv = xsv.replace(regv,".");
213   - }
214   - if (!$i("latitude").value == "")
215   - {
216   - var vv = $i("latitude").value + " 0" + " 0"
217   - vv = vv.replace(reg,"");
218   - vv = vv.replace(regv,".");
219   - vv = vv.split(" ");
220   - var ygv = vv[0]
221   - var ymv = vv[1]
222   - var ysv = vv[2]
223   - var ysv = ysv.replace(regv,".");
224   - }
225   - else
226   - {
227 234 var ygv = $i("yg").value;
228 235 var ymv = $i("ym").value;
229 236 var ysv = $i("ys").value;
... ... @@ -236,14 +243,42 @@ function inserir()
236 243 $i("resultado").innerHTML = ins
237 244 var fim = function()
238 245 {aguarde("none");window.parent.ajaxredesenha("");}
239   - var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&"+window.parent.objmapa.sid+"&funcao=insereSHP&tema="+window.parent.g_nomepin+"&xy="+xxx+" "+yyy;
  246 +
  247 + var inputs = $i("listaepsg").getElementsByTagName("input")
  248 + var listai = new Array;
  249 + for (i=0;i<inputs.length; i++)
  250 + {
  251 + if (inputs[i].checked == true)
  252 + {var projecao = inputs[i].value}
  253 + }
  254 + var projecao = pegaProj()
  255 + var p = g_locaplic+"/classesphp/mapa_controle.php?g_sid="+g_sid+"&"+window.parent.objmapa.sid+"&funcao=insereSHP&tema="+window.parent.g_nomepin+"&xy="+xxx+" "+yyy+"&projecao="+projecao;
240 256 var cp = new cpaint();
241 257 //cp.set_debug(2)
242 258 cp.set_response_type("JSON");
243 259 cp.call(p,"insereSHP",fim);
244 260 $i("longitude").value = ""
245 261 $i("latitude").value = ""
246   -
  262 +}
  263 +function verificaproj()
  264 +{
  265 + var p = pegaProj()
  266 + if (p != "")
  267 + {
  268 + escolhedig("digcampo")
  269 + $i("tipodigcampo").checked = true;
  270 + }
  271 +}
  272 +function pegaProj()
  273 +{
  274 + var inputs = $i("listaepsg").getElementsByTagName("input")
  275 + var listai = new Array;
  276 + for (i=0;i<inputs.length; i++)
  277 + {
  278 + if (inputs[i].checked == true)
  279 + {var projecao = inputs[i].value}
  280 + }
  281 + return (projecao)
247 282 }
248 283 function colar()
249 284 {
... ... @@ -264,4 +299,10 @@ function colar()
264 299 ins = ins + "<div style='font-size:12px'>" + n[i] +" " + n[i+1] + "</div><br>"
265 300 }
266 301 $i("resultado").innerHTML = ins
  302 +}
  303 +function escolhedig(q)
  304 +{
  305 + $i("digmascara").style.display="none";
  306 + $i("digcampo").style.display="none";
  307 + $i(q).style.display="block";
267 308 }
268 309 \ No newline at end of file
... ...