Commit 5ddcd23c4d3948b7f817196b6048e61bce49f04d
1 parent
c67d1b81
Exists in
master
and in
7 other branches
Inclusão da ferramenta de identificação na versão mobile
Showing
5 changed files
with
122 additions
and
8 deletions
Show diff stats
classesphp/classe_atributos.php
| ... | ... | @@ -75,6 +75,7 @@ $tema - nome do tema |
| 75 | 75 | { |
| 76 | 76 | $this->mapa = ms_newMapObj($map_file); |
| 77 | 77 | $this->arquivo = $map_file; |
| 78 | + if($tema != "") | |
| 78 | 79 | $this->layer = $this->mapa->getlayerbyname($tema); |
| 79 | 80 | $this->nome = $tema; |
| 80 | 81 | } |
| ... | ... | @@ -587,7 +588,12 @@ $resolucao - Resolucao de busca. |
| 587 | 588 | if ($opcao == "ligados") |
| 588 | 589 | { |
| 589 | 590 | foreach ($listatemas as $tema) |
| 590 | - {$resultados[$tema] = $this->identificaQBP($tema,$xyarray[0],$xyarray[1],$this->arquivo,$resolucao);} | |
| 591 | + { | |
| 592 | + $l = $this->mapa->getlayerbyname($tema); | |
| 593 | + if($l->status == MS_DEFAULT) | |
| 594 | + $resultados[$tema] = $this->identificaQBP($tema,$xyarray[0],$xyarray[1],$this->arquivo,$resolucao); | |
| 595 | + | |
| 596 | + } | |
| 591 | 597 | } |
| 592 | 598 | //pesquisa apenas os temas com tip |
| 593 | 599 | if ($opcao == "tip") |
| ... | ... | @@ -680,7 +686,7 @@ $item - Item único que será identificado. |
| 680 | 686 | |
| 681 | 687 | $tiporetorno - Tipo de retorno dos dados. Se for vazio, o retorno é formatado como string, se for shape, retorna o objeto shape |
| 682 | 688 | */ |
| 683 | -function identificaQBP($tema,$x,$y,$map_file,$resolucao,$item,$tiporetorno="") | |
| 689 | +function identificaQBP($tema,$x,$y,$map_file,$resolucao,$item="",$tiporetorno="") | |
| 684 | 690 | { |
| 685 | 691 | $mapa = ms_newMapObj($map_file); |
| 686 | 692 | $layer = $mapa->getLayerByName($tema); |
| ... | ... | @@ -768,7 +774,7 @@ function identificaQBP($tema,$x,$y,$map_file,$resolucao,$item,$tiporetorno="") |
| 768 | 774 | } |
| 769 | 775 | if ($layer->type == MS_LAYER_POLYGON) |
| 770 | 776 | { |
| 771 | - $layer->set("toleranceunits",MS_PIXEL); | |
| 777 | + $layer->set("toleranceunits",'MS_PIXEL'); | |
| 772 | 778 | $layer->set("tolerance",1); |
| 773 | 779 | $ident = @$layer->queryByPoint($pt, 1, 0); |
| 774 | 780 | } | ... | ... |
classesphp/classe_vermultilayer.php
| ... | ... | @@ -88,6 +88,11 @@ class vermultilayer |
| 88 | 88 | $escala = $map->scale; |
| 89 | 89 | $todoslayers = $map->getAlllayernames(); |
| 90 | 90 | $multilayer = 0; |
| 91 | + $temas = array(); | |
| 92 | + $layers = array(); | |
| 93 | + $nomes = array(); | |
| 94 | + $nomesvisiveis = array(); | |
| 95 | + $temasvisiveis = array(); | |
| 91 | 96 | foreach ($todoslayers as $temai) |
| 92 | 97 | { |
| 93 | 98 | $layer = $map->getlayerbyname($temai); | ... | ... |
classesphp/funcoes_gerais.php
| ... | ... | @@ -900,10 +900,10 @@ Objeto map alterado. |
| 900 | 900 | */ |
| 901 | 901 | function desligaTemas($objMapa) |
| 902 | 902 | { |
| 903 | - $numlayers = $objMap->numlayers; | |
| 903 | + $numlayers = $objMapa->numlayers; | |
| 904 | 904 | for ($i=0;$i < $numlayers;$i++) |
| 905 | 905 | { |
| 906 | - $layer = $objMap->getlayer($i); | |
| 906 | + $layer = $objMapa->getlayer($i); | |
| 907 | 907 | $layer->set("status",MS_OFF); |
| 908 | 908 | } |
| 909 | 909 | return $objMapa; |
| ... | ... | @@ -1231,6 +1231,32 @@ function xy2imagem($map_file,$xy) |
| 1231 | 1231 | return $pt; |
| 1232 | 1232 | } |
| 1233 | 1233 | /* |
| 1234 | +function: imagem2xy | |
| 1235 | + | |
| 1236 | +Converte coordenadas de imagem em coordenadas geográficas. | |
| 1237 | + | |
| 1238 | +parameters: | |
| 1239 | + | |
| 1240 | +$map_file - Arquivo map file. | |
| 1241 | + | |
| 1242 | +$xy - XY com as coordenadas (separado por espaço no caso de string) | |
| 1243 | +*/ | |
| 1244 | +function imagem2xy($map_file,$xy) | |
| 1245 | +{ | |
| 1246 | + if (!is_array($xy)) | |
| 1247 | + {$xy = explode(" ",$xy);} | |
| 1248 | + $map = ms_newMapObj($map_file); | |
| 1249 | + $map = desligatemas($map); | |
| 1250 | + $map = desligamargem($map); | |
| 1251 | + $imgo = $map->draw(); | |
| 1252 | + $e = $map->extent; | |
| 1253 | + $c = $map->cellsize; | |
| 1254 | + $x = ($e->minx) + $xy[0] * $c; | |
| 1255 | + $y = ($e->maxy) + $xy[1] * $c; | |
| 1256 | + return array($x,$y); | |
| 1257 | +} | |
| 1258 | + | |
| 1259 | +/* | |
| 1234 | 1260 | function: xy2wkt |
| 1235 | 1261 | |
| 1236 | 1262 | Converte coordenadas em wkt. | ... | ... |
mobile/mobile.php
| ... | ... | @@ -145,6 +145,13 @@ if ($tipo=="localizar") |
| 145 | 145 | include("localizar.php"); |
| 146 | 146 | exit; |
| 147 | 147 | } |
| 148 | +if ($tipo =="autopan") | |
| 149 | +{ | |
| 150 | + include("../classesphp/classe_navegacao.php"); | |
| 151 | + $m = new Navegacao($tmpfname); | |
| 152 | + $m->pan($x,$y,"",""); | |
| 153 | + $m->salva(); | |
| 154 | +} | |
| 148 | 155 | $mapa = ms_newMapObj($tmpfname); |
| 149 | 156 | $w = $mapa->width; |
| 150 | 157 | $h = $mapa->height; |
| ... | ... | @@ -163,10 +170,9 @@ $hsrc = imagesy($ims); |
| 163 | 170 | $xdst = abs(($wdst - $wsrc) / 2); |
| 164 | 171 | $ydst = abs(($hdst - $hsrc) / 2); |
| 165 | 172 | $branco = imagecolorresolve($ims,255,255,255); |
| 166 | -//imagecolortransparent($ims,$branco); | |
| 167 | -//imageSaveAlpha($ims, true); | |
| 168 | 173 | imagecopymerge($img,$ims,0,0,0,0,$wsrc,$hsrc,80); |
| 169 | 174 | ImagePNG($img, $nome); |
| 175 | +if(!isset($maparef)){$maparef = "";} | |
| 170 | 176 | ?> |
| 171 | 177 | <div id='botoes' style="position:relative;top:1px;left:1px" > |
| 172 | 178 | <select id='op' name='op' onchange='op(this.value)'> |
| ... | ... | @@ -182,6 +188,9 @@ ImagePNG($img, $nome); |
| 182 | 188 | <form id='f' action='mobile.php?' method='get'> |
| 183 | 189 | <input type='hidden' name='tmpfname' value='<?php echo $tmpfname;?>' /> |
| 184 | 190 | <input id='tipo' type=hidden name='tipo' value='' /> |
| 191 | + <input id='x' type=hidden name='x' value='' /> | |
| 192 | + <input id='y' type=hidden name='y' value='' /> | |
| 193 | + <input id='referencia' type=hidden name='maparef' value='<?php echo $maparef;?>' /> | |
| 185 | 194 | </form> |
| 186 | 195 | <map name="sample"> |
| 187 | 196 | <area shape="rect" coords="0,0,40,23" onclick='zoommais()'> |
| ... | ... | @@ -195,10 +204,28 @@ ImagePNG($img, $nome); |
| 195 | 204 | <area shape="rect" coords="22,91,40,104" onclick='leste()'> |
| 196 | 205 | <area shape="rect" coords="0,106,40,119" onclick='sul()'> |
| 197 | 206 | <area shape="rect" coords="0,91,18,105" onclick='oeste()'> |
| 207 | +<area shape="rect" coords="0,120,40,150" onclick='identifica()'> | |
| 198 | 208 | </map> |
| 199 | -<img id='mapa' style="position:relative;top:1px;left:1px" src='<?php echo $nomeimagem; ?>' usemap="#sample" /> | |
| 209 | +<img id='mapa' onclick='autopan(event)' style="position:relative;top:1px;left:1px" src='<?php echo $nomeimagem; ?>' usemap="#sample" /> | |
| 210 | +<br> | |
| 211 | +<a href=# onclick="maparef()">Ativar/desativar mapa de referência</a> | |
| 212 | +<?php | |
| 213 | +if ((isset($maparef)) && ($maparef == "sim")) | |
| 214 | +{ | |
| 215 | + //$ref = $mapa->reference; | |
| 216 | + $imgo = $mapa->drawreferencemap(); | |
| 217 | + $nome = ($imgo->imagepath).nomeRandomico().".png"; | |
| 218 | + $imgo->saveImage($nome); | |
| 219 | + $nomeimagem = ($imgo->imageurl).basename($nome); | |
| 220 | + echo "<br><img style=position:relative;top:1px;left:1px src='".$nomeimagem."' />"; | |
| 221 | + | |
| 222 | +} | |
| 223 | +?> | |
| 200 | 224 | </body> |
| 201 | 225 | <script> |
| 226 | +modooperacao = "" | |
| 227 | +navn = false | |
| 228 | +navm = false | |
| 202 | 229 | var app = navigator.appName.substring(0,1); |
| 203 | 230 | if (app=='N') navn=true; else navm=true; |
| 204 | 231 | pan = "" |
| ... | ... | @@ -271,5 +298,55 @@ function op(valor) |
| 271 | 298 | {document.getElementById('f').action = "index.php?"} |
| 272 | 299 | document.getElementById('f').submit(); |
| 273 | 300 | } |
| 301 | +function maparef() | |
| 302 | +{ | |
| 303 | + var temp = document.getElementById("referencia").value; | |
| 304 | + if (temp == "sim") | |
| 305 | + {document.getElementById("referencia").value = "";} | |
| 306 | + else | |
| 307 | + {document.getElementById("referencia").value = "sim";} | |
| 308 | + document.getElementById('tipo').value = ""; | |
| 309 | + document.getElementById('f').submit(); | |
| 310 | +} | |
| 311 | +function autopan(exy) | |
| 312 | +{ | |
| 313 | + var xy = capturaposicao(exy) | |
| 314 | + if((xy[0] > 40) || (xy[1] > 150) ) | |
| 315 | + { | |
| 316 | + document.getElementById('x').value = xy[0] | |
| 317 | + document.getElementById('y').value = xy[1] | |
| 318 | + document.getElementById('tipo').value = "autopan"; | |
| 319 | + document.getElementById('f').action = "mobile.php" | |
| 320 | + if (modooperacao == "identifica") | |
| 321 | + {document.getElementById('f').action = "identifica.php?"} | |
| 322 | + document.getElementById('f').submit(); | |
| 323 | + } | |
| 324 | +} | |
| 325 | +function identifica() | |
| 326 | +{ | |
| 327 | + modooperacao = "identifica" | |
| 328 | + document.getElementById("botoes").innerHTML = "Clique no mapa" | |
| 329 | +} | |
| 330 | +function capturaposicao(exy) | |
| 331 | +{ | |
| 332 | + var e = (navn) ? exy : window.event; | |
| 333 | + var xfig = e.clientX; | |
| 334 | + var yfig = e.clientY; | |
| 335 | + var obj = document.getElementById("mapa") | |
| 336 | + var pos = findPos(obj) | |
| 337 | + var xfig = xfig - pos[0] | |
| 338 | + var yfig = yfig - pos[1] | |
| 339 | + return [xfig,yfig] | |
| 340 | +} | |
| 341 | +function findPos(obj) { | |
| 342 | + var curleft = curtop = 0; | |
| 343 | + if (obj.offsetParent) { | |
| 344 | + do { | |
| 345 | + curleft += obj.offsetLeft; | |
| 346 | + curtop += obj.offsetTop; | |
| 347 | + } while (obj = obj.offsetParent); | |
| 348 | + } | |
| 349 | + return [curleft,curtop]; | |
| 350 | +} | |
| 274 | 351 | </script> |
| 275 | 352 | </html> | ... | ... |
mobile/navegacao.png