Commit d393e8303bf4171d6494c3f8412979c854a5eb81
1 parent
6a1b7c86
Exists in
master
and in
7 other branches
Alteração nas funções de cálculo de área e perímetro na operação de análise de g…
…eometrias. Esses cálculos agora são feitos via phpmapscript, não sendo mais necessário uma conexão com o Postgis.
Showing
2 changed files
with
34 additions
and
35 deletions
Show diff stats
classesphp/classe_analise.php
| @@ -1327,75 +1327,70 @@ $operacao - Tipo de análise. | @@ -1327,75 +1327,70 @@ $operacao - Tipo de análise. | ||
| 1327 | { | 1327 | { |
| 1328 | $lista = explode(",",$lista); | 1328 | $lista = explode(",",$lista); |
| 1329 | $dir = $dir_tmp."/".$imgdir."/"; | 1329 | $dir = $dir_tmp."/".$imgdir."/"; |
| 1330 | - if ($postgis_con == "") | ||
| 1331 | - {return ("erro. Nao foi definida a conexao com o Postgis.");} | 1330 | + //if ($postgis_con == "") |
| 1331 | + //{return ("erro. Nao foi definida a conexao com o Postgis.");} | ||
| 1332 | foreach ($lista as $l) | 1332 | foreach ($lista as $l) |
| 1333 | { | 1333 | { |
| 1334 | $geos = &$this->unserializeGeo($dir.$l); | 1334 | $geos = &$this->unserializeGeo($dir.$l); |
| 1335 | foreach ($geos["dados"] as &$geo) | 1335 | foreach ($geos["dados"] as &$geo) |
| 1336 | { | 1336 | { |
| 1337 | $g = $geo["wkt"]; | 1337 | $g = $geo["wkt"]; |
| 1338 | - $pgconn = pg_connect($postgis_con); | 1338 | + //$pgconn = pg_connect($postgis_con); |
| 1339 | switch ($operacao) | 1339 | switch ($operacao) |
| 1340 | { | 1340 | { |
| 1341 | case "perimetro": | 1341 | case "perimetro": |
| 1342 | + /* | ||
| 1342 | $sql = "select perimeter(transform( GeomFromText('$g',4291),$srid_area))::float as perim"; | 1343 | $sql = "select perimeter(transform( GeomFromText('$g',4291),$srid_area))::float as perim"; |
| 1343 | $result=pg_query($pgconn, $sql); | 1344 | $result=pg_query($pgconn, $sql); |
| 1344 | pg_close($pgconn); | 1345 | pg_close($pgconn); |
| 1345 | $calculo = pg_fetch_all($result); | 1346 | $calculo = pg_fetch_all($result); |
| 1346 | $geo["valores"][] = array("item"=>"P_perim_metros","valor"=>$calculo[0]["perim"]); | 1347 | $geo["valores"][] = array("item"=>"P_perim_metros","valor"=>$calculo[0]["perim"]); |
| 1348 | + */ | ||
| 1349 | + $shape = ms_shapeObjFromWkt($g); | ||
| 1350 | + $area = $shape->getArea(); | ||
| 1351 | + $rect = $shape->bounds; | ||
| 1352 | + $projInObj = ms_newprojectionobj("proj=latlong"); | ||
| 1353 | + $projOutObj = ms_newprojectionobj("proj=poly,ellps=GRS67,lat_0=0,lon_0=".$rect->miny.",x_0=5000000,y_0=10000000"); | ||
| 1354 | + $shape->project($projInObj, $projOutObj); | ||
| 1355 | + $s = $shape->towkt(); | ||
| 1356 | + $shape = ms_shapeObjFromWkt($s); | ||
| 1357 | + $area = $shape->getLength(); | ||
| 1358 | + $geo["valores"][] = array("item"=>"P_perim_metros","valor"=>$area); | ||
| 1359 | + | ||
| 1347 | break; | 1360 | break; |
| 1348 | case "area": | 1361 | case "area": |
| 1362 | + /* | ||
| 1349 | $sql = "select area(transform( GeomFromText('$g',4291),$srid_area))::float as aream"; | 1363 | $sql = "select area(transform( GeomFromText('$g',4291),$srid_area))::float as aream"; |
| 1350 | $result=pg_query($pgconn, $sql); | 1364 | $result=pg_query($pgconn, $sql); |
| 1351 | pg_close($pgconn); | 1365 | pg_close($pgconn); |
| 1352 | $calculo = pg_fetch_all($result); | 1366 | $calculo = pg_fetch_all($result); |
| 1353 | $geo["valores"][] = array("item"=>"P_area_metros","valor"=>$calculo[0]["aream"]); | 1367 | $geo["valores"][] = array("item"=>"P_area_metros","valor"=>$calculo[0]["aream"]); |
| 1368 | + */ | ||
| 1369 | + $shape = ms_shapeObjFromWkt($g); | ||
| 1370 | + $area = $shape->getArea(); | ||
| 1371 | + $rect = $shape->bounds; | ||
| 1372 | + $projInObj = ms_newprojectionobj("proj=latlong"); | ||
| 1373 | + $projOutObj = ms_newprojectionobj("proj=poly,ellps=GRS67,lat_0=0,lon_0=".$rect->miny.",x_0=5000000,y_0=10000000"); | ||
| 1374 | + $shape->project($projInObj, $projOutObj); | ||
| 1375 | + $s = $shape->towkt(); | ||
| 1376 | + $shape = ms_shapeObjFromWkt($s); | ||
| 1377 | + $area = $shape->getArea(); | ||
| 1378 | + $geo["valores"][] = array("item"=>"P_area_metros","valor"=>$area); | ||
| 1354 | break; | 1379 | break; |
| 1355 | case "comprimento": | 1380 | case "comprimento": |
| 1381 | + /* | ||
| 1356 | $sql = "select length(transform( GeomFromText('$g',4291),$srid_area))::float as compm"; | 1382 | $sql = "select length(transform( GeomFromText('$g',4291),$srid_area))::float as compm"; |
| 1357 | $result=pg_query($pgconn, $sql); | 1383 | $result=pg_query($pgconn, $sql); |
| 1358 | pg_close($pgconn); | 1384 | pg_close($pgconn); |
| 1359 | $calculo = pg_fetch_all($result); | 1385 | $calculo = pg_fetch_all($result); |
| 1360 | $geo["valores"][] = array("item"=>"P_compr_metros","valor"=>$calculo[0]["compm"]); | 1386 | $geo["valores"][] = array("item"=>"P_compr_metros","valor"=>$calculo[0]["compm"]); |
| 1387 | + */ | ||
| 1361 | break; | 1388 | break; |
| 1362 | } | 1389 | } |
| 1363 | } | 1390 | } |
| 1364 | $this->serializeGeo($dir.$l,$geos); | 1391 | $this->serializeGeo($dir.$l,$geos); |
| 1365 | } | 1392 | } |
| 1366 | return("ok"); | 1393 | return("ok"); |
| 1367 | - | ||
| 1368 | - | ||
| 1369 | - | ||
| 1370 | - /* utiliza o geos | ||
| 1371 | - $lista = explode(",",$lista); | ||
| 1372 | - $dir = $dir_tmp."/".$imgdir."/"; | ||
| 1373 | - foreach ($lista as $l) | ||
| 1374 | - { | ||
| 1375 | - $geos = &$this->unserializeGeo($dir.$l); | ||
| 1376 | - foreach ($geos["dados"] as &$geo) | ||
| 1377 | - { | ||
| 1378 | - //cria objeto projecao | ||
| 1379 | - $projInObj = ms_newprojectionobj("proj=latlong,ellps=GRS67"); | ||
| 1380 | - $projOutObj = ms_newprojectionobj("proj=laea,ellps=GRS67,lat_0=-12,lon_0=-52,x_0=500000,y_0=10000000,units=m"); | ||
| 1381 | - $g = ms_shapeObjFromWkt($geo["wkt"]); | ||
| 1382 | - $p = $g->project($projInObj,$projOutObj); | ||
| 1383 | - switch ($operacao) | ||
| 1384 | - { | ||
| 1385 | - case "comprimento": | ||
| 1386 | - $valor = $g->getLength(); | ||
| 1387 | - $geo["valores"][] = array("item"=>"P_perim_metros","valor"=>$valor); | ||
| 1388 | - break; | ||
| 1389 | - case "area": | ||
| 1390 | - $valor = $g->getArea(); | ||
| 1391 | - $geo["valores"][] = array("item"=>"P_area_metros","valor"=>$valor); | ||
| 1392 | - break; | ||
| 1393 | - } | ||
| 1394 | - } | ||
| 1395 | - $this->serializeGeo($dir.$l,$geos); | ||
| 1396 | - } | ||
| 1397 | - return("ok"); | ||
| 1398 | - */ | ||
| 1399 | } | 1394 | } |
| 1400 | /* | 1395 | /* |
| 1401 | function: incmapageometrias | 1396 | function: incmapageometrias |
ms_configura.php
| @@ -113,6 +113,8 @@ if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) | @@ -113,6 +113,8 @@ if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) | ||
| 113 | /* | 113 | /* |
| 114 | Variable: $postgis_con | 114 | Variable: $postgis_con |
| 115 | 115 | ||
| 116 | + Depreciado - não é mais necessário | ||
| 117 | + | ||
| 116 | string de conexão com o banco de dados postgis utilizada para reallização de cálculos | 118 | string de conexão com o banco de dados postgis utilizada para reallização de cálculos |
| 117 | 119 | ||
| 118 | se não existir, deixe em branco | 120 | se não existir, deixe em branco |
| @@ -121,6 +123,8 @@ if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) | @@ -121,6 +123,8 @@ if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) | ||
| 121 | /* | 123 | /* |
| 122 | Variable: $srid_area | 124 | Variable: $srid_area |
| 123 | 125 | ||
| 126 | + Depreciado - não é mais necessário | ||
| 127 | + | ||
| 124 | srid utilizado nos cálculos que exigem projeção equivalente | 128 | srid utilizado nos cálculos que exigem projeção equivalente |
| 125 | */ | 129 | */ |
| 126 | $srid_area = 1; | 130 | $srid_area = 1; |