Commit 89f0378266ab26c1cbae64969f14130efc733a87

Authored by Edmar Moretti
1 parent 82d249d6

Incluído método para obtenção das coordenadas do íltimo ponto em um layer

Showing 1 changed file with 38 additions and 0 deletions   Show diff stats
classesphp/classe_shp.php
... ... @@ -301,6 +301,44 @@ string - xy
301 301 return $xy;
302 302 }
303 303 /*
  304 +function: ultimoXY
  305 +
  306 +Obtém as coordenadas xy do último ponto existente no layer. O último ponto é considerado entre aqueles que estão visíveis no mapa atual
  307 +
  308 +return:
  309 +array("layerprj"=>$xylayer,"mapprj"=>$xymapa)
  310 +*/
  311 + function ultimoXY()
  312 + {
  313 + if(!$this->layer){return "erro";}
  314 + $this->layer->queryByrect($this->mapa->extent);
  315 + $res_count = $this->layer->getNumresults();
  316 + $sopen = $this->layer->open();
  317 + if($sopen == MS_FAILURE){return "erro";}
  318 + $xy = array();
  319 +
  320 + $result = $this->layer->getResult($res_count - 1);
  321 + $shp_index = $result->shapeindex;
  322 + $shape = $this->layer->getshape(-1,$shp_index);
  323 + $lin = $shape->line(0);
  324 + $pt = $lin->point(0);
  325 + $this->layer->close();
  326 + $xylayer = array("x"=>$pt->x,"y"=>$pt->y);
  327 + $prjMapa = $this->mapa->getProjection();
  328 + $prjTema = $this->layer->getProjection();
  329 + if (($prjTema != "") && ($prjMapa != $prjTema))
  330 + {
  331 + $projInObj = ms_newprojectionobj($prjTema);
  332 + $projOutObj = ms_newprojectionobj($prjMapa);
  333 + $pt->project($projInObj, $projOutObj);
  334 + $xymapa = array("x"=>$pt->x,"y"=>$pt->y);
  335 + }
  336 + else
  337 + {$xymapa = $xylayer;}
  338 + return array("layerprj"=>$xylayer,"mapprj"=>$xymapa);
  339 + }
  340 +
  341 +/*
304 342 function: shpPT2shp
305 343  
306 344 Cria um tema linear ou poligonal com base em pontos de um tema pontual.
... ...