Esempio n. 1
0
 function zoomPonto($xy)
 {
     $apt = explode(" ", $xy);
     $pt = ms_newPointObj();
     $e = $this->mapa->extent;
     $pt = xy2imagem($this->arquivo, $xy);
     $this->mapa->zoompoint(1, $pt, $this->mapa->width, $this->mapa->height, $e);
 }
Esempio n. 2
0
 function identificaQBP3($tema = "", $x = 0, $y = 0, $map_file = "", $resolucao = 0, $item = "", $tiporetorno = "", $etip = false, $ext = "", $wkt = "nao")
 {
     if ($map_file == "") {
         $mapa = $this->mapa;
         $map_file = $this->arquivo;
     } else {
         $mapa = ms_newMapObj($map_file);
     }
     if ($ext != "") {
         $extmapa = $mapa->extent;
         $e = explode(" ", $ext);
         $extmapa->setextent(min($e[0], $e[2]), min($e[1], $e[3]), max($e[0], $e[2]), max($e[1], $e[3]));
         //$mapa->save($this->arquivo);
     }
     if ($tema == "") {
         $layer = $this->layer;
     } else {
         $layer = $mapa->getLayerByName($tema);
     }
     $layer->set("status", MS_DEFAULT);
     $layer->set("template", "none.htm");
     $pt = ms_newPointObj();
     $pt->setXY($x, $y);
     if (strtoupper($layer->getmetadata("convcaracter")) == "NAO") {
         $convC = false;
     } else {
         $convC = true;
     }
     //
     //operação especial para o caso de wms
     //
     if ($layer->connectiontype == MS_WMS) {
         $wkt = "nao";
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $mapa = desligatemas($mapa);
         $mapa = desligamargem($mapa);
         $imgo = $mapa->draw();
         $ptimg = xy2imagem($map_file, array($x, $y), $mapa);
         //$formatoinfo = "MIME";
         $formatosinfo = $layer->getmetadata("formatosinfo");
         if ($formatosinfo != "") {
             $formatosinfo = explode(",", $formatosinfo);
             if ($formatosinfo[0] != "") {
                 $formatoinfo = $formatosinfo[0];
             }
             foreach ($formatosinfo as $f) {
                 if (strtoupper($f) == "TEXT/PLAIN") {
                     $formatoinfo = "text/plain";
                 }
             }
         } else {
             $formatoinfo = $layer->getmetadata("wms_feature_info_type");
             if ($formatoinfo == "") {
                 $formatoinfo = $layer->getmetadata("wms_feature_info_mime_type");
             }
             if ($formatoinfo == "") {
                 $formatoinfo = "text/plain";
             }
         }
         $res = $layer->getWMSFeatureInfoURL($ptimg->x, $ptimg->y, 1, $formatoinfo);
         $res = str_replace("INFOFORMAT", "INFO_FORMAT", $res);
         $res2 = $layer->getWMSFeatureInfoURL($ptimg->x, $ptimg->y, 1, "MIME");
         $res2 = str_replace("INFOFORMAT", "INFO_FORMAT", $res2);
         //echo $res." ".$res2;exit;
         $resposta = file($res);
         //var_dump($resposta);exit;
         $n = array();
         if (strtoupper($formatoinfo) != "TEXT/HTML" && strtoupper($formatoinfo) != "MIME") {
             foreach ($resposta as $r) {
                 $t = explode("=", $r);
                 if (count($t) > 1) {
                     $v = str_replace("\\n", "", $t[1]);
                     $v = str_replace("\\r", "", $v);
                     if (trim($v) != "") {
                         $va = trim($v);
                         if ($convC == true) {
                             $va = $this->converte($va);
                         }
                         $n[] = array("alias" => trim($t[0]), "valor" => $va, "link" => "", "img" => "");
                     }
                 }
             }
             //caso esri
             if (count($n) > 0 && $n[0] == "") {
                 //error_reporting(0);
                 $resposta = file($res);
                 $cabecalho = str_replace('"   "', '"|"', $resposta[0]);
                 $cabecalho = explode("|", $cabecalho);
                 $linha = str_replace('"  "', '"|"', $resposta[1]);
                 $linha = explode("|", $linha);
                 for ($i = 0; $i < count($cabecalho); ++$i) {
                     if ($convC == true) {
                         $va = $this->converte($linha[$i]);
                     } else {
                         $va = $linha[$i];
                     }
                     $n[] = array("alias" => $cabecalho[$i], "valor" => $va, "link" => "", "img" => "");
                 }
             }
         }
         //var_dump($n);exit;
         $id = nomeRandomico();
         if (count($n) == 0 && strtoupper($formatoinfo) != "TEXT/HTML") {
             $formatoinfo = "MIME";
         }
         if (strtoupper($formatoinfo) == "TEXT/HTML" && $res != "") {
             $n[] = array("alias" => "", "valor" => "<iframe width=250px id='" . $id . "' name='" . $id . "' src='" . $res . "'></iframe>", "link" => "", "img" => "");
         }
         if (strtoupper($formatoinfo) == "MIME" && $res2 != "") {
             $n[] = array("alias" => "", "valor" => "<iframe width=250px id='" . $id . "' name='" . $id . "' src='" . $res2 . "'></iframe>", "link" => "", "img" => "");
         }
         if ($res != "") {
             $n[] = array("alias" => "Link WMS", "valor" => "getfeatureinfo " . $formatoinfo, "link" => $res, "img" => "", "idIframe" => $id);
         }
         if ($res2 != "") {
             $n[] = array("alias" => "Link WMS", "valor" => "getfeatureinfo padr&atilde;o do servi&ccedil;o", "link" => $res2, "img" => "", "idIframe" => $id);
         }
         if ($res == "" && $res2 == "") {
             $n[] = array("alias" => "Ocorreu um erro", "valor" => "", "link" => "", "img" => "");
         }
         return array($n);
     }
     //se o usuario estiver logado e o tema for editavel, a lista de itens
     //nao usa os alias para permitir a edicao dos dados
     if (!empty($_COOKIE["i3geocodigologin"]) && $layer->getmetadata("EDITAVEL") == "SIM") {
         $itens = "";
         $itensdesc = "";
         $lks = "";
         $itemimg = "";
         $locimg = "";
     } else {
         $itens = $layer->getmetadata("ITENS");
         // itens
         $itensdesc = $layer->getmetadata("ITENSDESC");
         // descri&ccedil;&atilde;o dos itens
         $lks = $layer->getmetadata("ITENSLINK");
         // link dos itens
         $itemimg = $layer->getmetadata("ITEMIMG");
         //indica um item que ser&aacute; utilizado para colocar um &iacute;cone
         $locimg = $layer->getmetadata("IMGLOC");
         //indica o local onde est&atilde;o os &iacute;cones
     }
     $tips = $layer->getmetadata("TIP");
     $itensLayer = pegaItens($layer, $mapa);
     $nitens = count($itensLayer);
     if ($itens == "") {
         $itens = $itensLayer;
     } else {
         $itens = explode(",", $itens);
     }
     if ($itensdesc == "") {
         $itensdesc = $itensLayer;
     } else {
         $itensdesc = explode(",", $itensdesc);
     }
     if ($lks == "") {
         $lks = array_fill(0, $nitens - 1, '');
     } else {
         $lks = explode(",", $lks);
     }
     if ($itemimg == "") {
         $itemimg = array_fill(0, $nitens - 1, '');
     } else {
         $itemimg = explode(",", $itemimg);
     }
     if ($locimg == "") {
         $locimg = array_fill(0, $nitens - 1, '');
     } else {
         $locimg = explode(",", $locimg);
     }
     $tips = str_replace(" ", ",", $tips);
     $tips = explode(",", $tips);
     //o retorno deve ser do tipo TIP
     if ($etip == true) {
         $temp = array_combine($itens, $itensdesc);
         $templ = array_combine($itens, $lks);
         $tempimg = array_combine($itens, $itemimg);
         $temploc = array_combine($itens, $locimg);
         $itensdesc = array();
         $itens = array();
         $lks = array();
         $itemimg = array();
         $locimg = array();
         //foreach($tips as $t){
         foreach ($itensLayer as $t) {
             $itens[] = $t;
             if ($temp[$t] != "") {
                 $itensdesc[] = $temp[$t];
             } else {
                 $itensdesc[] = $t;
             }
             if ($templ[$t] != "") {
                 $lks[] = $templ[$t];
             } else {
                 $lks[] = "";
             }
             if ($tempimg[$t] != "") {
                 $itemimg[] = $tempimg[$t];
             } else {
                 $itemimg[] = "";
             }
             if ($temploc[$t] != "") {
                 $locimg[] = $temploc[$t];
             } else {
                 $locimg[] = "";
             }
         }
     }
     if ($layer->connectiontype != MS_WMS && $layer->type == MS_LAYER_RASTER) {
         $wkt = "nao";
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $ident = @$layer->queryByPoint($pt, 0, 0);
         //0.01);
     }
     if ($layer->type == MS_LAYER_POINT || $layer->type == MS_LAYER_LINE || $layer->type == MS_LAYER_CHART) {
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $ident = @$layer->queryByPoint($pt, 1, -1);
         //0.01);
     }
     if ($layer->type == MS_LAYER_POLYGON) {
         $layer->set("toleranceunits", MS_PIXELS);
         $layer->set("tolerance", $resolucao);
         $ident = @$layer->queryByPoint($pt, 1, -1);
     }
     if ($ident == MS_SUCCESS) {
         //$ident = @$layer->queryByPoint($pt, 1, -1);
         //verifica se o layer e editavel no sistema METAESTAT
         $editavel = "nao";
         //
         $sopen = $layer->open();
         $res_count = $layer->getNumresults();
         if (strtoupper($layer->getmetadata("convcaracter")) == "NAO") {
             $convC = false;
         } else {
             $convC = true;
         }
         if ($sopen == MS_FAILURE) {
             return "erro";
         }
         for ($i = 0; $i < $res_count; ++$i) {
             $valori = array();
             if ($this->v >= 6) {
                 $shape = $layer->getShape($layer->getResult($i));
             } else {
                 $result = $layer->getResult($i);
                 $shp_index = $result->shapeindex;
                 $shape = $layer->getfeature($shp_index, -1);
             }
             $conta = 0;
             //var_dump($itens);exit;
             if ($tiporetorno == "shape" || $tiporetorno == "googlerelevo") {
                 if ($tiporetorno == "shape") {
                     $resultado[] = $shape;
                 }
                 if ($tiporetorno == "googlerelevo") {
                     $lin = $shape->line(0);
                     $p = $lin->point(0);
                     $resultado = array("elevation" => $shape->values[$item], "location" => array("lat" => $p->x, "lng" => $p->y));
                 }
             } else {
                 if ($etip == false && $item != "") {
                     $resultado[] = $shape->values[$item];
                 } else {
                     //var_dump($itens);exit;
                     foreach ($itens as $it) {
                         $val = $shape->values[$it];
                         if ($convC == true) {
                             $val = $this->converte($val);
                         }
                         $link = $lks[$conta];
                         foreach ($itens as $t) {
                             $valtemp = $shape->values[$t];
                             $busca = '[' . $t . ']';
                             $link = str_replace($busca, $valtemp, $link);
                         }
                         $img = "";
                         if ($locimg[$conta] != "" && $itemimg[$conta] != "") {
                             $img = "<img src='" . $locimg[$conta] . "//" . $shape->values[$itemimg[$conta]] . "' //>";
                         } else {
                             if ($itemimg[$conta] != "") {
                                 $img = "<img src='" . $shape->values[$itemimg[$conta]] . "' //>";
                             }
                         }
                         //indica se o item &eacute; tbm uma etiqueta
                         $etiqueta = "nao";
                         if (in_array($it, $tips)) {
                             $etiqueta = "sim";
                         }
                         $arraytemp = array("item" => $it, "alias" => $this->converte($itensdesc[$conta]), "valor" => $val, "link" => $link, "img" => $img, "tip" => $etiqueta);
                         if ($etip == false) {
                             $valori[] = $arraytemp;
                         } else {
                             $valori[$it] = $arraytemp;
                         }
                         $conta = $conta + 1;
                     }
                     if ($wkt == "sim") {
                         $arraytemp = array("alias" => "wkt", "valor" => $shape->towkt(), "link" => "", "img" => "", "tip" => "");
                         $valori[] = $arraytemp;
                     }
                     $resultado[] = $valori;
                 }
             }
         }
         $layer->close();
     } else {
         $resultado[] = " ";
     }
     if ($etip == true) {
         return array("resultado" => $resultado, "itensLayer" => $itensLayer);
     } else {
         return $resultado;
     }
 }