Commit 276b1fedc50072c1e357eb0ef3bfea72809efe4b
1 parent
e0b4c979
Exists in
master
and in
7 other branches
--no commit message
Showing
2 changed files
with
264 additions
and
87 deletions
Show diff stats
classesphp/classe_analise.php
| ... | ... | @@ -73,6 +73,12 @@ class Analise |
| 73 | 73 | Nome do arquivo de seleção (.qy) |
| 74 | 74 | */ |
| 75 | 75 | public $qyfile; |
| 76 | + /* | |
| 77 | + Variavel: $dbaseExiste | |
| 78 | + | |
| 79 | + Indica se a biblioteca dbase está carregada | |
| 80 | + */ | |
| 81 | + protected $dbaseExiste; | |
| 76 | 82 | /* |
| 77 | 83 | Function: __construct |
| 78 | 84 | |
| ... | ... | @@ -94,6 +100,9 @@ $ext - Extensão geográfica do mapa |
| 94 | 100 | include_once($locaplic."/funcoes_gerais.php"); |
| 95 | 101 | else |
| 96 | 102 | include_once("funcoes_gerais.php"); |
| 103 | + $this->dbaseExiste = false; | |
| 104 | + if(function_exists("dbase_create")) | |
| 105 | + {$this->dbaseExiste = true;} | |
| 97 | 106 | $this->locaplic = $locaplic; |
| 98 | 107 | $this->mapa = ms_newMapObj($map_file); |
| 99 | 108 | $this->arquivo = $map_file; |
| ... | ... | @@ -710,10 +719,12 @@ $locaplic - diretório da aplicação i3geo |
| 710 | 719 | { |
| 711 | 720 | if (file_exists($nomearq)) |
| 712 | 721 | { |
| 713 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 714 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 715 | - else | |
| 716 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 722 | + if($this->dbaseExiste == false){ | |
| 723 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 724 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 725 | + else | |
| 726 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 727 | + } | |
| 717 | 728 | //define o nome do novo shapefile que será criado |
| 718 | 729 | $nomefinal = nomeRandomico(); |
| 719 | 730 | $nomeshp = $this->diretorio."/".$nomefinal; |
| ... | ... | @@ -726,7 +737,7 @@ $locaplic - diretório da aplicação i3geo |
| 726 | 737 | $def[] = array("y2","N","12","5"); |
| 727 | 738 | $def[] = array("ind1","N","5","0"); |
| 728 | 739 | $def[] = array("ind2","N","5","0"); |
| 729 | - if(!function_exists(dbase_create)) | |
| 740 | + if($this->dbaseExiste == false) | |
| 730 | 741 | {$db = xbase_create($nomeshp.".dbf", $def);} |
| 731 | 742 | else |
| 732 | 743 | {$db = dbase_create($nomeshp.".dbf", $def);} |
| ... | ... | @@ -759,7 +770,7 @@ $locaplic - diretório da aplicação i3geo |
| 759 | 770 | $ShapeObj->add($linha); |
| 760 | 771 | $novoshpf->addShape($ShapeObj); |
| 761 | 772 | $registro = array($i1,$i2,$i3,$i4,$i5,$i6); |
| 762 | - if(!function_exists(dbase_create)) | |
| 773 | + if($this->dbaseExiste == false) | |
| 763 | 774 | xbase_add_record($db,$registro); |
| 764 | 775 | else |
| 765 | 776 | dbase_add_record($db,$registro); |
| ... | ... | @@ -768,7 +779,7 @@ $locaplic - diretório da aplicação i3geo |
| 768 | 779 | } |
| 769 | 780 | } |
| 770 | 781 | $novoshpf->free(); |
| 771 | - if(!function_exists(dbase_create)) | |
| 782 | + if($this->dbaseExiste == false) | |
| 772 | 783 | xbase_close($db); |
| 773 | 784 | else |
| 774 | 785 | dbase_close($db); |
| ... | ... | @@ -805,10 +816,12 @@ $locaplic - diretório da aplicação i3geo |
| 805 | 816 | { |
| 806 | 817 | if (file_exists($nomearq)) |
| 807 | 818 | { |
| 808 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 809 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 810 | - else | |
| 811 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 819 | + if($this->dbaseExiste == false){ | |
| 820 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 821 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 822 | + else | |
| 823 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 824 | + } | |
| 812 | 825 | // |
| 813 | 826 | //define os nomes dos novos shapefiles que serão criados |
| 814 | 827 | // |
| ... | ... | @@ -830,7 +843,7 @@ $locaplic - diretório da aplicação i3geo |
| 830 | 843 | $def[] = array("ind2","N","5","0"); |
| 831 | 844 | $def[] = array("b1","C","6"); |
| 832 | 845 | $def[] = array("b2","C","6"); |
| 833 | - if(!function_exists(dbase_create)) | |
| 846 | + if($this->dbaseExiste == false) | |
| 834 | 847 | {$dbLinhas = xbase_create($nomeshpLinhas.".dbf", $def);} |
| 835 | 848 | else |
| 836 | 849 | {$dbLinhas = dbase_create($nomeshpLinhas.".dbf", $def);} |
| ... | ... | @@ -840,7 +853,7 @@ $locaplic - diretório da aplicação i3geo |
| 840 | 853 | // |
| 841 | 854 | $def = array(); |
| 842 | 855 | $def[] = array("area","N","12","5"); |
| 843 | - if(!function_exists(dbase_create)) | |
| 856 | + if($this->dbaseExiste == false) | |
| 844 | 857 | {$dbPoligonos = xbase_create($nomeshpPoligonos.".dbf", $def);} |
| 845 | 858 | else |
| 846 | 859 | {$dbPoligonos = dbase_create($nomeshpPoligonos.".dbf", $def);} |
| ... | ... | @@ -891,7 +904,7 @@ $locaplic - diretório da aplicação i3geo |
| 891 | 904 | $ShapeObj->add($linha); |
| 892 | 905 | $novoshpLinhas->addShape($ShapeObj); |
| 893 | 906 | $registro = array($i1,$i2,$i3,$i4,$i5,$i6,$i[7],$i[8]); |
| 894 | - if(!function_exists(dbase_create)) | |
| 907 | + if($this->dbaseExiste == false) | |
| 895 | 908 | xbase_add_record($dbLinhas,$registro); |
| 896 | 909 | else |
| 897 | 910 | dbase_add_record($dbLinhas,$registro); |
| ... | ... | @@ -909,14 +922,14 @@ $locaplic - diretório da aplicação i3geo |
| 909 | 922 | $ns = $ShapeObjp->convexhull(); |
| 910 | 923 | $novoshpPoligonos->addShape($ns); |
| 911 | 924 | $registro = array($ns->getArea()); |
| 912 | - if(!function_exists(dbase_create)) | |
| 925 | + if($this->dbaseExiste == false) | |
| 913 | 926 | xbase_add_record($dbPoligonos,$registro); |
| 914 | 927 | else |
| 915 | 928 | dbase_add_record($dbPoligonos,$registro); |
| 916 | 929 | $ShapeObjp->free(); |
| 917 | 930 | } |
| 918 | 931 | $novoshpPoligonos->free(); |
| 919 | - if(!function_exists(dbase_create)) | |
| 932 | + if($this->dbaseExiste == false) | |
| 920 | 933 | xbase_close($dbPoligonos); |
| 921 | 934 | else |
| 922 | 935 | dbase_close($dbPoligonos); |
| ... | ... | @@ -945,7 +958,7 @@ $locaplic - diretório da aplicação i3geo |
| 945 | 958 | $ShapeObj->add($linha); |
| 946 | 959 | $novoshpLinhas->addShape($ShapeObj->convexhull()); |
| 947 | 960 | $registro = array(0,0,0,0,0,0,0,0); |
| 948 | - if(!function_exists(dbase_create)) | |
| 961 | + if($this->dbaseExiste == false) | |
| 949 | 962 | xbase_add_record($dbLinhas,$registro); |
| 950 | 963 | else |
| 951 | 964 | dbase_add_record($dbLinhas,$registro); |
| ... | ... | @@ -953,7 +966,7 @@ $locaplic - diretório da aplicação i3geo |
| 953 | 966 | $ShapeObj->free(); |
| 954 | 967 | } |
| 955 | 968 | $novoshpLinhas->free(); |
| 956 | - if(!function_exists(dbase_create)) | |
| 969 | + if($this->dbaseExiste == false) | |
| 957 | 970 | xbase_close($dbLinhas); |
| 958 | 971 | else |
| 959 | 972 | dbase_close($dbLinhas); |
| ... | ... | @@ -988,10 +1001,12 @@ $locaplic - Localização do I3geo. |
| 988 | 1001 | function pontoEmPoligono($temaPt,$temasPo,$locaplic) |
| 989 | 1002 | { |
| 990 | 1003 | set_time_limit(3000); |
| 991 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 992 | - {include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php");} | |
| 993 | - else | |
| 994 | - {include_once "../pacotes/phpxbase/api_conversion.php";} | |
| 1004 | + if($this->dbaseExiste == false){ | |
| 1005 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1006 | + {include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php");} | |
| 1007 | + else | |
| 1008 | + {include_once "../pacotes/phpxbase/api_conversion.php";} | |
| 1009 | + } | |
| 995 | 1010 | $layerPt = $this->mapa->getlayerbyname($temaPt); |
| 996 | 1011 | $layerPt->set("template","none.htm"); |
| 997 | 1012 | $layerPt->set("tolerance",0); |
| ... | ... | @@ -1050,13 +1065,16 @@ $locaplic - Localização do I3geo. |
| 1050 | 1065 | $conta = $conta + 1; |
| 1051 | 1066 | } |
| 1052 | 1067 | } |
| 1053 | - if(!function_exists("dbase_create")) | |
| 1068 | + if($this->dbaseExiste == false) | |
| 1054 | 1069 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1055 | 1070 | else |
| 1056 | 1071 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1057 | 1072 | //acrescenta os pontos no novo shapefile |
| 1058 | 1073 | $dbname = $nomeshp.".dbf"; |
| 1074 | + if($this->dbaseExiste == false) | |
| 1059 | 1075 | $db=xbase_open($dbname,2); |
| 1076 | + else | |
| 1077 | + $db=dbase_open($dbname,2); | |
| 1060 | 1078 | // cria o shapefile |
| 1061 | 1079 | $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POINT); |
| 1062 | 1080 | foreach($spts as $spt) |
| ... | ... | @@ -1095,11 +1113,17 @@ $locaplic - Localização do I3geo. |
| 1095 | 1113 | } |
| 1096 | 1114 | $layer->close(); |
| 1097 | 1115 | } |
| 1116 | + if($this->dbaseExiste == false) | |
| 1098 | 1117 | xbase_add_record($db,$reg); |
| 1118 | + else | |
| 1119 | + dbase_add_record($db,$reg); | |
| 1099 | 1120 | $reg = array(); |
| 1100 | 1121 | } |
| 1101 | 1122 | $novoshpf->free(); |
| 1123 | + if($this->dbaseExiste == false) | |
| 1102 | 1124 | xbase_close($db); |
| 1125 | + else | |
| 1126 | + dbase_close($db); | |
| 1103 | 1127 | |
| 1104 | 1128 | $novolayer = ms_newLayerObj($this->mapa, $layerPt); |
| 1105 | 1129 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1146,10 +1170,12 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig |
| 1146 | 1170 | { |
| 1147 | 1171 | set_time_limit(180); |
| 1148 | 1172 | //para manipular dbf |
| 1149 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1150 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1151 | - else | |
| 1152 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1173 | + if($this->dbaseExiste == false){ | |
| 1174 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1175 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1176 | + else | |
| 1177 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1178 | + } | |
| 1153 | 1179 | //define o nome do novo shapefile que será criado |
| 1154 | 1180 | $nomefinal = nomeRandomico(); |
| 1155 | 1181 | $nomeshp = $this->diretorio."/".$nomefinal; |
| ... | ... | @@ -1204,13 +1230,16 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig |
| 1204 | 1230 | $def[] = array("dist_m","N","10","2"); |
| 1205 | 1231 | $def[] = array("origem","C","255"); |
| 1206 | 1232 | $def[] = array("destino","C","255"); |
| 1207 | - if(!function_exists(dbase_create)) | |
| 1233 | + if($this->dbaseExiste == false) | |
| 1208 | 1234 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1209 | 1235 | else |
| 1210 | 1236 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1211 | 1237 | //acrescenta os pontos no novo shapefile |
| 1212 | 1238 | $dbname = $nomeshp.".dbf"; |
| 1239 | + if($this->dbaseExiste == false) | |
| 1213 | 1240 | $db=xbase_open($dbname,2); |
| 1241 | + else | |
| 1242 | + $db=dbase_open($dbname,2); | |
| 1214 | 1243 | foreach ($shapesorigem as $sorigem) |
| 1215 | 1244 | { |
| 1216 | 1245 | $valororigem = $sorigem->values[$itemorigem]; |
| ... | ... | @@ -1226,13 +1255,19 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig |
| 1226 | 1255 | $ShapeObj->project($projInObj, $projOutObj); |
| 1227 | 1256 | $distancia = $ShapeObj->getLength(); |
| 1228 | 1257 | $registro = array($distancia,$valororigem,$valordestino); |
| 1258 | + if($this->dbaseExiste == false) | |
| 1229 | 1259 | xbase_add_record($db,$registro); |
| 1260 | + else | |
| 1261 | + dbase_add_record($db,$registro); | |
| 1230 | 1262 | $linha->free(); |
| 1231 | 1263 | $ShapeObj->free(); |
| 1232 | 1264 | } |
| 1233 | 1265 | } |
| 1234 | 1266 | $novoshpf->free(); |
| 1267 | + if($this->dbaseExiste == false) | |
| 1235 | 1268 | xbase_close($db); |
| 1269 | + else | |
| 1270 | + dbase_close($db); | |
| 1236 | 1271 | //adiciona no mapa atual o novo tema |
| 1237 | 1272 | $novolayer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,("Distancias (".$nomefinal.")"),$metaClasse="SIM"); |
| 1238 | 1273 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1276,10 +1311,12 @@ nome do layer criado com o buffer. |
| 1276 | 1311 | set_time_limit(180); |
| 1277 | 1312 | //error_reporting(E_ALL); |
| 1278 | 1313 | //para manipular dbf |
| 1279 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1280 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1281 | - else | |
| 1282 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1314 | + if($this->dbaseExiste == false){ | |
| 1315 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1316 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1317 | + else | |
| 1318 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1319 | + } | |
| 1283 | 1320 | $nomebuffer = nomeRandomico(); |
| 1284 | 1321 | $nomeshp = $this->diretorio."/".$nomebuffer; |
| 1285 | 1322 | $listaShapes = array(); |
| ... | ... | @@ -1342,24 +1379,33 @@ nome do layer criado com o buffer. |
| 1342 | 1379 | // cria o dbf |
| 1343 | 1380 | $def = $this->criaDefDb($items); |
| 1344 | 1381 | $def[] = array("i3geo","C","254"); |
| 1345 | - if(!function_exists(dbase_create)) | |
| 1382 | + if($this->dbaseExiste == false) | |
| 1346 | 1383 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1347 | 1384 | else |
| 1348 | 1385 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1349 | 1386 | //acrescenta os pontos no novo shapefile |
| 1350 | 1387 | $dbname = $nomeshp.".dbf"; |
| 1388 | + if($this->dbaseExiste == false) | |
| 1351 | 1389 | $db=xbase_open($dbname,2); |
| 1390 | + else | |
| 1391 | + $db=dbase_open($dbname,2); | |
| 1352 | 1392 | for($i = 0;$i < count($buffers);++$i) |
| 1353 | 1393 | { |
| 1354 | 1394 | foreach ($items as $ni) |
| 1355 | 1395 | {$reg[] = $this->truncaS($shapes[$i]->values[$ni]);} |
| 1356 | 1396 | $reg[] = $i; |
| 1357 | 1397 | $novoshpf->addShape($buffers[$i]); |
| 1398 | + if($this->dbaseExiste == false) | |
| 1358 | 1399 | xbase_add_record($db,$reg); |
| 1400 | + else | |
| 1401 | + dbase_add_record($db,$reg); | |
| 1359 | 1402 | $reg = array(); |
| 1360 | 1403 | } |
| 1361 | 1404 | $novoshpf->free(); |
| 1405 | + if($this->dbaseExiste == false) | |
| 1362 | 1406 | xbase_close($db); |
| 1407 | + else | |
| 1408 | + dbase_close($db); | |
| 1363 | 1409 | //adiciona no mapa atual o novo tema |
| 1364 | 1410 | $novolayer = criaLayer($this->mapa,MS_LAYER_POLYGON,MS_DEFAULT,("Buffer (".$nomebuffer.")"),$metaClasse="SIM"); |
| 1365 | 1411 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1391,10 +1437,12 @@ $item {string} - (opcional) Item q será utilizado para ponderar os valores. |
| 1391 | 1437 | if(!$this->layer){return "erro";} |
| 1392 | 1438 | set_time_limit(180); |
| 1393 | 1439 | //para manipular dbf |
| 1394 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1395 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1396 | - else | |
| 1397 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1440 | + if($this->dbaseExiste == false){ | |
| 1441 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1442 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1443 | + else | |
| 1444 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1445 | + } | |
| 1398 | 1446 | error_reporting(E_ALL); |
| 1399 | 1447 | $nomeCentro = nomeRandomico(); |
| 1400 | 1448 | $nomeshp = $this->diretorio."/".$nomeCentro; |
| ... | ... | @@ -1427,13 +1475,16 @@ $item {string} - (opcional) Item q será utilizado para ponderar os valores. |
| 1427 | 1475 | $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POINT); |
| 1428 | 1476 | // cria o dbf |
| 1429 | 1477 | $def[] = array("id","C","254"); |
| 1430 | - if(!function_exists("dbase_create")) | |
| 1478 | + if($this->dbaseExiste == false) | |
| 1431 | 1479 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1432 | 1480 | else |
| 1433 | 1481 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1434 | 1482 | //acrescenta os pontos no novo shapefile |
| 1435 | 1483 | $dbname = $nomeshp.".dbf"; |
| 1484 | + if($this->dbaseExiste == false) | |
| 1436 | 1485 | $db=xbase_open($dbname,2); |
| 1486 | + else | |
| 1487 | + $db=dbase_open($dbname,2); | |
| 1437 | 1488 | $reg[] = ""; |
| 1438 | 1489 | |
| 1439 | 1490 | $shp = ms_newShapeObj(MS_SHP_POINT); |
| ... | ... | @@ -1441,10 +1492,15 @@ $item {string} - (opcional) Item q será utilizado para ponderar os valores. |
| 1441 | 1492 | $linha->addXY(($xs / $res_count),($ys / $res_count)); |
| 1442 | 1493 | $shp->add($linha); |
| 1443 | 1494 | $novoshpf->addShape($shp); |
| 1444 | - | |
| 1495 | + if($this->dbaseExiste == false) | |
| 1445 | 1496 | xbase_add_record($db,$reg); |
| 1497 | + else | |
| 1498 | + dbase_add_record($db,$reg); | |
| 1446 | 1499 | $novoshpf->free(); |
| 1500 | + if($this->dbaseExiste == false) | |
| 1447 | 1501 | xbase_close($db); |
| 1502 | + else | |
| 1503 | + dbase_close($db); | |
| 1448 | 1504 | //adiciona no mapa atual o novo tema |
| 1449 | 1505 | $novolayer = criaLayer($this->mapa,MS_LAYER_POINT,MS_DEFAULT,("Centróide (".$nomeCentro.")"),$metaClasse="SIM"); |
| 1450 | 1506 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1475,10 +1531,12 @@ $locaplic - Localização do I3geo. |
| 1475 | 1531 | if(!$this->layer){return "erro";} |
| 1476 | 1532 | set_time_limit(180); |
| 1477 | 1533 | //para manipular dbf |
| 1478 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1479 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1480 | - else | |
| 1481 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1534 | + if($this->dbaseExiste == false){ | |
| 1535 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1536 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1537 | + else | |
| 1538 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1539 | + } | |
| 1482 | 1540 | $nomeCentroides = nomeRandomico(); |
| 1483 | 1541 | $nomeshp = $this->diretorio."/".$nomeCentroides; |
| 1484 | 1542 | //pega os shapes selecionados |
| ... | ... | @@ -1510,23 +1568,32 @@ $locaplic - Localização do I3geo. |
| 1510 | 1568 | $items = pegaItens($this->layer); |
| 1511 | 1569 | // cria o dbf |
| 1512 | 1570 | $def = $this->criaDefDb($items); |
| 1513 | - if(!function_exists(dbase_create)) | |
| 1571 | + if($this->dbaseExiste == false) | |
| 1514 | 1572 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1515 | 1573 | else |
| 1516 | 1574 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1517 | 1575 | //acrescenta os pontos no novo shapefile |
| 1518 | 1576 | $dbname = $nomeshp.".dbf"; |
| 1577 | + if($this->dbaseExiste == false) | |
| 1519 | 1578 | $db=xbase_open($dbname,2); |
| 1579 | + else | |
| 1580 | + $db=dbase_open($dbname,2); | |
| 1520 | 1581 | for($i = 0;$i < count($centroides);++$i) |
| 1521 | 1582 | { |
| 1522 | 1583 | foreach ($items as $ni) |
| 1523 | 1584 | {$reg[] = $this->truncaS($shapes[$i]->values[$ni]);} |
| 1524 | 1585 | $novoshpf->addShape($centroides[$i]); |
| 1586 | + if($this->dbaseExiste == false) | |
| 1525 | 1587 | xbase_add_record($db,$reg); |
| 1588 | + else | |
| 1589 | + dbase_add_record($db,$reg); | |
| 1526 | 1590 | $reg = array(); |
| 1527 | 1591 | } |
| 1528 | 1592 | $novoshpf->free(); |
| 1593 | + if($this->dbaseExiste == false) | |
| 1529 | 1594 | xbase_close($db); |
| 1595 | + else | |
| 1596 | + dbase_close($db); | |
| 1530 | 1597 | //adiciona no mapa atual o novo tema |
| 1531 | 1598 | $novolayer = criaLayer($this->mapa,MS_LAYER_POINT,MS_DEFAULT,("Centróide (".$nomeCentroides.")"),$metaClasse="SIM"); |
| 1532 | 1599 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1564,10 +1631,12 @@ $npty - Número de pontos em Y (opcional) |
| 1564 | 1631 | { |
| 1565 | 1632 | set_time_limit(180); |
| 1566 | 1633 | //para manipular dbf |
| 1567 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1568 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1569 | - else | |
| 1570 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1634 | + if($this->dbaseExiste == false){ | |
| 1635 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1636 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1637 | + else | |
| 1638 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1639 | + } | |
| 1571 | 1640 | $nomegrade = nomeRandomico(); |
| 1572 | 1641 | $nomeshp = $this->diretorio."/".$nomegrade; |
| 1573 | 1642 | $this->mapa->preparequery(); |
| ... | ... | @@ -1588,13 +1657,16 @@ $npty - Número de pontos em Y (opcional) |
| 1588 | 1657 | $def = array(); |
| 1589 | 1658 | $def[] = array("x","C","20"); |
| 1590 | 1659 | $def[] = array("y","C","20"); |
| 1591 | - if(!function_exists(dbase_create)) | |
| 1660 | + if($this->dbaseExiste == false) | |
| 1592 | 1661 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1593 | 1662 | else |
| 1594 | 1663 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1595 | 1664 | //acrescenta os pontos no novo shapefile |
| 1596 | 1665 | $dbname = $nomeshp.".dbf"; |
| 1666 | + if($this->dbaseExiste == false) | |
| 1597 | 1667 | $db=xbase_open($dbname,2); |
| 1668 | + else | |
| 1669 | + $db=dbase_open($dbname,2); | |
| 1598 | 1670 | $reg = array(); |
| 1599 | 1671 | $w = $this->mapa->width; |
| 1600 | 1672 | $h = $this->mapa->height; |
| ... | ... | @@ -1614,7 +1686,10 @@ $npty - Número de pontos em Y (opcional) |
| 1614 | 1686 | $novoshpf->addpoint($poPoint); |
| 1615 | 1687 | $reg[] = $x; |
| 1616 | 1688 | $reg[] = $y; |
| 1689 | + if($this->dbaseExiste == false) | |
| 1617 | 1690 | xbase_add_record($db,$reg); |
| 1691 | + else | |
| 1692 | + dbase_add_record($db,$reg); | |
| 1618 | 1693 | $reg = array(); |
| 1619 | 1694 | } |
| 1620 | 1695 | $valorlinha = $valorlinha - $ydd; |
| ... | ... | @@ -1636,14 +1711,20 @@ $npty - Número de pontos em Y (opcional) |
| 1636 | 1711 | $novoshpf->addpoint($poPoint); |
| 1637 | 1712 | $reg[] = $x; |
| 1638 | 1713 | $reg[] = $y; |
| 1714 | + if($this->dbaseExiste == false) | |
| 1639 | 1715 | xbase_add_record($db,$reg); |
| 1716 | + else | |
| 1717 | + dbase_add_record($db,$reg); | |
| 1640 | 1718 | $reg = array(); |
| 1641 | 1719 | } |
| 1642 | 1720 | $valorcoluna = $valorcoluna + $xdd; |
| 1643 | 1721 | } |
| 1644 | 1722 | } |
| 1645 | 1723 | $novoshpf->free(); |
| 1724 | + if($this->dbaseExiste == false) | |
| 1646 | 1725 | xbase_close($db); |
| 1726 | + else | |
| 1727 | + dbase_close($db); | |
| 1647 | 1728 | //adiciona o novo tema no mapa |
| 1648 | 1729 | $novolayer = criaLayer($this->mapa,MS_LAYER_POINT,MS_DEFAULT,("Grade (".$nomegrade.")"),$metaClasse="SIM"); |
| 1649 | 1730 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1680,10 +1761,12 @@ $npty - Número de pontos em Y (opcional) |
| 1680 | 1761 | { |
| 1681 | 1762 | set_time_limit(180); |
| 1682 | 1763 | //para manipular dbf |
| 1683 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1684 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1685 | - else | |
| 1686 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1764 | + if($this->dbaseExiste == false){ | |
| 1765 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1766 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1767 | + else | |
| 1768 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1769 | + } | |
| 1687 | 1770 | $nomegrade = nomeRandomico(); |
| 1688 | 1771 | $nomeshp = $this->diretorio."/".$nomegrade; |
| 1689 | 1772 | //pega a extensão geográfica do mapa |
| ... | ... | @@ -1704,13 +1787,16 @@ $npty - Número de pontos em Y (opcional) |
| 1704 | 1787 | $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON); |
| 1705 | 1788 | $def = array(); |
| 1706 | 1789 | $def[] = array("id","C","20"); |
| 1707 | - if(!function_exists(dbase_create)) | |
| 1790 | + if($this->dbaseExiste == false) | |
| 1708 | 1791 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1709 | 1792 | else |
| 1710 | 1793 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1711 | 1794 | //acrescenta os pontos no novo shapefile |
| 1712 | 1795 | $dbname = $nomeshp.".dbf"; |
| 1796 | + if($this->dbaseExiste == false) | |
| 1713 | 1797 | $db=xbase_open($dbname,2); |
| 1798 | + else | |
| 1799 | + $db=dbase_open($dbname,2); | |
| 1714 | 1800 | $reg = array(); |
| 1715 | 1801 | $w = $this->mapa->width; |
| 1716 | 1802 | $h = $this->mapa->height; |
| ... | ... | @@ -1743,7 +1829,10 @@ $npty - Número de pontos em Y (opcional) |
| 1743 | 1829 | $shapen->add($linhas); |
| 1744 | 1830 | $novoshpf->addShape($shapen); |
| 1745 | 1831 | $reg[] = $linha."-".$coluna; |
| 1832 | + if($this->dbaseExiste == false) | |
| 1746 | 1833 | xbase_add_record($db,$reg); |
| 1834 | + else | |
| 1835 | + dbase_add_record($db,$reg); | |
| 1747 | 1836 | $reg = array(); |
| 1748 | 1837 | } |
| 1749 | 1838 | $valorlinha = $valorlinha - $ydd; |
| ... | ... | @@ -1778,14 +1867,20 @@ $npty - Número de pontos em Y (opcional) |
| 1778 | 1867 | $shapen->add($linhas); |
| 1779 | 1868 | $novoshpf->addShape($shapen); |
| 1780 | 1869 | $reg[] = $linha."-".$coluna; |
| 1870 | + if($this->dbaseExiste == false) | |
| 1781 | 1871 | xbase_add_record($db,$reg); |
| 1872 | + else | |
| 1873 | + dbase_add_record($db,$reg); | |
| 1782 | 1874 | $reg = array(); |
| 1783 | 1875 | } |
| 1784 | 1876 | $valorcoluna = $valorcoluna + $xdd; |
| 1785 | 1877 | } |
| 1786 | 1878 | } |
| 1787 | 1879 | $novoshpf->free(); |
| 1880 | + if($this->dbaseExiste == false) | |
| 1788 | 1881 | xbase_close($db); |
| 1882 | + else | |
| 1883 | + dbase_close($db); | |
| 1789 | 1884 | //adiciona o novo tema no mapa |
| 1790 | 1885 | $novolayer = criaLayer($this->mapa,MS_LAYER_POLYGON,MS_DEFAULT,("Grade (".$nomegrade.")"),$metaClasse="SIM"); |
| 1791 | 1886 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1822,10 +1917,12 @@ $npty - Número de pontos em Y (opcional) |
| 1822 | 1917 | { |
| 1823 | 1918 | set_time_limit(180); |
| 1824 | 1919 | //para manipular dbf |
| 1825 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1826 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1827 | - else | |
| 1828 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1920 | + if($this->dbaseExiste == false){ | |
| 1921 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1922 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1923 | + else | |
| 1924 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 1925 | + } | |
| 1829 | 1926 | $nomegrade = nomeRandomico(); |
| 1830 | 1927 | $nomeshp = $this->diretorio."/".$nomegrade; |
| 1831 | 1928 | //pega a extensão geográfica do mapa |
| ... | ... | @@ -1846,13 +1943,16 @@ $npty - Número de pontos em Y (opcional) |
| 1846 | 1943 | $novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON); |
| 1847 | 1944 | $def = array(); |
| 1848 | 1945 | $def[] = array("id","C","20"); |
| 1849 | - if(!function_exists(dbase_create)) | |
| 1946 | + if($this->dbaseExiste == false) | |
| 1850 | 1947 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1851 | 1948 | else |
| 1852 | 1949 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 1853 | 1950 | //acrescenta os pontos no novo shapefile |
| 1854 | 1951 | $dbname = $nomeshp.".dbf"; |
| 1952 | + if($this->dbaseExiste == false) | |
| 1855 | 1953 | $db=xbase_open($dbname,2); |
| 1954 | + else | |
| 1955 | + $db=dbase_open($dbname,2); | |
| 1856 | 1956 | $reg = array(); |
| 1857 | 1957 | $w = $this->mapa->width; |
| 1858 | 1958 | $h = $this->mapa->height; |
| ... | ... | @@ -1885,7 +1985,10 @@ $npty - Número de pontos em Y (opcional) |
| 1885 | 1985 | $shapen->add($linhas); |
| 1886 | 1986 | $novoshpf->addShape($shapen); |
| 1887 | 1987 | $reg[] = $linha."-".$coluna; |
| 1988 | + if($this->dbaseExiste == false) | |
| 1888 | 1989 | xbase_add_record($db,$reg); |
| 1990 | + else | |
| 1991 | + dbase_add_record($db,$reg); | |
| 1889 | 1992 | $reg = array(); |
| 1890 | 1993 | } |
| 1891 | 1994 | $valorlinha = $valorlinha - $ydd; |
| ... | ... | @@ -1927,7 +2030,10 @@ $npty - Número de pontos em Y (opcional) |
| 1927 | 2030 | $shapen->add($linhas); |
| 1928 | 2031 | $novoshpf->addShape($shapen); |
| 1929 | 2032 | $reg[] = $linha."-".$coluna; |
| 2033 | + if($this->dbaseExiste == false) | |
| 1930 | 2034 | xbase_add_record($db,$reg); |
| 2035 | + else | |
| 2036 | + dbase_add_record($db,$reg); | |
| 1931 | 2037 | $reg = array(); |
| 1932 | 2038 | if ($par) |
| 1933 | 2039 | {$x=$x+($xdd/2);$par=false;} |
| ... | ... | @@ -1938,7 +2044,10 @@ $npty - Número de pontos em Y (opcional) |
| 1938 | 2044 | } |
| 1939 | 2045 | } |
| 1940 | 2046 | $novoshpf->free(); |
| 2047 | + if($this->dbaseExiste == false) | |
| 1941 | 2048 | xbase_close($db); |
| 2049 | + else | |
| 2050 | + dbase_close($db); | |
| 1942 | 2051 | //adiciona o novo tema no mapa |
| 1943 | 2052 | $novolayer = criaLayer($this->mapa,MS_LAYER_POLYGON,MS_DEFAULT,("Grade (".$nomegrade.")"),$metaClasse="SIM"); |
| 1944 | 2053 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -1967,10 +2076,12 @@ $locaplic - Localização do I3geo |
| 1967 | 2076 | { |
| 1968 | 2077 | set_time_limit(180); |
| 1969 | 2078 | //para manipular dbf |
| 1970 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1971 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1972 | - else | |
| 1973 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2079 | + if($this->dbaseExiste == false){ | |
| 2080 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 2081 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 2082 | + else | |
| 2083 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2084 | + } | |
| 1974 | 2085 | $layerPt = $this->mapa->getlayerbyname($temaPt); |
| 1975 | 2086 | $layerPt->set("template","none.htm"); |
| 1976 | 2087 | $layerPt->set("tolerance",0); |
| ... | ... | @@ -1986,7 +2097,7 @@ $locaplic - Localização do I3geo |
| 1986 | 2097 | foreach ($itenspo as $ni) |
| 1987 | 2098 | {$def[] = array(substr($ni, 0, 10),"C","254");} |
| 1988 | 2099 | $def[] = array("npontos","N","10","0"); |
| 1989 | - if(!function_exists(dbase_create)) | |
| 2100 | + if($this->dbaseExiste == false) | |
| 1990 | 2101 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 1991 | 2102 | else |
| 1992 | 2103 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| ... | ... | @@ -1998,7 +2109,10 @@ $locaplic - Localização do I3geo |
| 1998 | 2109 | |
| 1999 | 2110 | //acrescenta os pontos no novo shapefile |
| 2000 | 2111 | $dbname = $nomeshp.".dbf"; |
| 2112 | + if($this->dbaseExiste == false) | |
| 2001 | 2113 | $db=xbase_open($dbname,2); |
| 2114 | + else | |
| 2115 | + $db=dbase_open($dbname,2); | |
| 2002 | 2116 | $sopen = $layerPo->open(); |
| 2003 | 2117 | if($sopen == MS_FAILURE){return "erro";} |
| 2004 | 2118 | |
| ... | ... | @@ -2017,11 +2131,17 @@ $locaplic - Localização do I3geo |
| 2017 | 2131 | //echo $layerPt->getNumresults(); |
| 2018 | 2132 | $novoreg[] = $layerPt->getNumresults(); |
| 2019 | 2133 | $novoshpf->addShape($shape); |
| 2134 | + if($this->dbaseExiste == false) | |
| 2020 | 2135 | xbase_add_record($db,$novoreg); |
| 2136 | + else | |
| 2137 | + dbase_add_record($db,$novoreg); | |
| 2021 | 2138 | } |
| 2022 | 2139 | $fechou = $layerPo->close(); |
| 2023 | 2140 | $novoshpf->free(); |
| 2141 | + if($this->dbaseExiste == false) | |
| 2024 | 2142 | xbase_close($db); |
| 2143 | + else | |
| 2144 | + dbase_close($db); | |
| 2025 | 2145 | //adiciona o novo tema no mapa |
| 2026 | 2146 | $novolayer = criaLayer($this->mapa,MS_LAYER_POLYGON,MS_DEFAULT,"N pontos",$metaClasse="SIM"); |
| 2027 | 2147 | $novolayer->set("data",$nomeshp.".shp"); |
| ... | ... | @@ -2045,10 +2165,12 @@ Salva o mapa acrescentando um novo layer com o resultado. |
| 2045 | 2165 | set_time_limit(180); |
| 2046 | 2166 | //para manipular dbf |
| 2047 | 2167 | if(!isset($item)){$item="";} |
| 2048 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 2049 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 2050 | - else | |
| 2051 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2168 | + if($this->dbaseExiste == false){ | |
| 2169 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 2170 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 2171 | + else | |
| 2172 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2173 | + } | |
| 2052 | 2174 | //define o nome do novo shapefile que será criado |
| 2053 | 2175 | carregaquery($this->arquivo,&$this->layer,&$this->mapa); |
| 2054 | 2176 | $sopen = $this->layer->open(); |
| ... | ... | @@ -2118,21 +2240,30 @@ Salva o mapa acrescentando um novo layer com o resultado. |
| 2118 | 2240 | $def = array(); |
| 2119 | 2241 | if($item==""){$item="nenhum";} |
| 2120 | 2242 | $def[] = array($item,"C","254"); |
| 2121 | - if(!function_exists(dbase_create)) | |
| 2243 | + if($this->dbaseExiste == false) | |
| 2122 | 2244 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 2123 | 2245 | else |
| 2124 | 2246 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 2125 | 2247 | //acrescenta os pontos no novo shapefile |
| 2126 | 2248 | $dbname = $nomeshp.".dbf"; |
| 2249 | + if($this->dbaseExiste == false) | |
| 2127 | 2250 | $db=xbase_open($dbname,2); |
| 2251 | + else | |
| 2252 | + $db=dbase_open($dbname,2); | |
| 2128 | 2253 | $classes = array_keys($dissolve); |
| 2129 | 2254 | foreach ($classes as $classe) |
| 2130 | 2255 | { |
| 2131 | 2256 | $novoshpf->addShape($dissolve[$classe]->convexhull()); |
| 2257 | + if($this->dbaseExiste == false) | |
| 2132 | 2258 | xbase_add_record($db,array($classe)); |
| 2259 | + else | |
| 2260 | + dbase_add_record($db,array($classe)); | |
| 2133 | 2261 | } |
| 2134 | 2262 | $novoshpf->free(); |
| 2263 | + if($this->dbaseExiste == false) | |
| 2135 | 2264 | xbase_close($db); |
| 2265 | + else | |
| 2266 | + dbase_close($db); | |
| 2136 | 2267 | // |
| 2137 | 2268 | //adiciona o novo layer no mapa |
| 2138 | 2269 | // |
| ... | ... | @@ -2164,10 +2295,12 @@ $locaplic - Localização do I3geo |
| 2164 | 2295 | set_time_limit(180); |
| 2165 | 2296 | //para manipular dbf |
| 2166 | 2297 | if(!isset($item)){$item="";} |
| 2167 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 2168 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 2169 | - else | |
| 2170 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2298 | + if($this->dbaseExiste == false){ | |
| 2299 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 2300 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 2301 | + else | |
| 2302 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2303 | + } | |
| 2171 | 2304 | //define o nome do novo shapefile que será criado |
| 2172 | 2305 | carregaquery($this->arquivo,&$this->layer,&$this->mapa); |
| 2173 | 2306 | $sopen = $this->layer->open(); |
| ... | ... | @@ -2226,21 +2359,30 @@ $locaplic - Localização do I3geo |
| 2226 | 2359 | $def = array(); |
| 2227 | 2360 | if($item==""){$item="nenhum";} |
| 2228 | 2361 | $def[] = array($item,"C","254"); |
| 2229 | - if(!function_exists(dbase_create)) | |
| 2362 | + if($this->dbaseExiste == false) | |
| 2230 | 2363 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 2231 | 2364 | else |
| 2232 | 2365 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 2233 | 2366 | //acrescenta os pontos no novo shapefile |
| 2234 | 2367 | $dbname = $nomeshp.".dbf"; |
| 2368 | + if($this->dbaseExiste == false) | |
| 2235 | 2369 | $db=xbase_open($dbname,2); |
| 2370 | + else | |
| 2371 | + $db=dbase_open($dbname,2); | |
| 2236 | 2372 | $classes = array_keys($dissolve); |
| 2237 | 2373 | foreach ($classes as $classe) |
| 2238 | 2374 | { |
| 2239 | 2375 | $novoshpf->addShape($dissolve[$classe]); |
| 2376 | + if($this->dbaseExiste == false) | |
| 2240 | 2377 | xbase_add_record($db,array($classe)); |
| 2378 | + else | |
| 2379 | + dbase_add_record($db,array($classe)); | |
| 2241 | 2380 | } |
| 2242 | 2381 | $novoshpf->free(); |
| 2382 | + if($this->dbaseExiste == false) | |
| 2243 | 2383 | xbase_close($db); |
| 2384 | + else | |
| 2385 | + dbase_close($db); | |
| 2244 | 2386 | // |
| 2245 | 2387 | //adiciona o novo layer no mapa |
| 2246 | 2388 | // |
| ... | ... | @@ -2490,33 +2632,44 @@ $tipoLista - tipo de valores que são passados em $lista stringArquivos|arraywkt. |
| 2490 | 2632 | if ($tiposhape == 0){$tiposhapefile = MS_SHP_MULTIPOINT;} |
| 2491 | 2633 | if ($tiposhape == 1){$tiposhapefile = MS_SHP_ARC;} |
| 2492 | 2634 | //cria o shapefile |
| 2493 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 2494 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 2495 | - else | |
| 2496 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2635 | + if($this->dbaseExiste == false){ | |
| 2636 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 2637 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 2638 | + else | |
| 2639 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 2640 | + } | |
| 2497 | 2641 | $diretorio = dirname($this->arquivo); |
| 2498 | 2642 | $novonomelayer = nomeRandomico(); |
| 2499 | 2643 | $nomeshp = $diretorio."/".$novonomelayer; |
| 2500 | 2644 | $l = criaLayer($this->mapa,$tiposhape,MS_DEFAULT,"Ins","SIM"); |
| 2501 | 2645 | $novoshpf = ms_newShapefileObj($nomeshp, $tiposhapefile); |
| 2502 | 2646 | $def[] = array("ID","C","250"); |
| 2503 | - if(!function_exists(dbase_create)) | |
| 2647 | + if($this->dbaseExiste == false) | |
| 2504 | 2648 | {$db = xbase_create($nomeshp.".dbf", $def);xbase_close($db);} |
| 2505 | 2649 | else |
| 2506 | 2650 | {$db = dbase_create($nomeshp.".dbf", $def);dbase_close($db);} |
| 2507 | 2651 | //acrescenta os pontos no novo shapefile |
| 2508 | 2652 | $dbname = $nomeshp.".dbf"; |
| 2653 | + if($this->dbaseExiste == false) | |
| 2509 | 2654 | $db=xbase_open($dbname,2); |
| 2655 | + else | |
| 2656 | + $db=dbase_open($dbname,2); | |
| 2510 | 2657 | $conta = 0; |
| 2511 | 2658 | foreach ($shapes as $s) |
| 2512 | 2659 | { |
| 2513 | 2660 | $reg = array(); |
| 2514 | 2661 | $reg[] = $valoresoriginais[$conta]; |
| 2662 | + if($this->dbaseExiste == false) | |
| 2515 | 2663 | xbase_add_record($db,$reg); |
| 2664 | + else | |
| 2665 | + dbase_add_record($db,$reg); | |
| 2516 | 2666 | $novoshpf->addshape($s); |
| 2517 | 2667 | $conta = $conta + 1; |
| 2518 | 2668 | } |
| 2669 | + if($this->dbaseExiste == false) | |
| 2519 | 2670 | xbase_close($db); |
| 2671 | + else | |
| 2672 | + dbase_close($db); | |
| 2520 | 2673 | $novoshpf->free(); |
| 2521 | 2674 | $l->setmetadata("tema",$novonomelayer." geometria"); |
| 2522 | 2675 | $l->setmetadata("TEMALOCAL","SIM"); | ... | ... |
classesphp/classe_shp.php
| ... | ... | @@ -60,6 +60,13 @@ class SHP |
| 60 | 60 | Nome do layer |
| 61 | 61 | */ |
| 62 | 62 | protected $nome; |
| 63 | + /* | |
| 64 | + Variavel: $dbaseExiste | |
| 65 | + | |
| 66 | + Indica se a biblioteca dbase está carregada | |
| 67 | + */ | |
| 68 | + protected $dbaseExiste; | |
| 69 | + | |
| 63 | 70 | /* |
| 64 | 71 | function: __construct |
| 65 | 72 | |
| ... | ... | @@ -75,7 +82,11 @@ $ext - extensao geográfica que será aplicada ao mapa |
| 75 | 82 | */ |
| 76 | 83 | function __construct($map_file,$tema="",$locaplic="",$ext="") |
| 77 | 84 | { |
| 78 | - //error_reporting(E_ALL); | |
| 85 | + //error_reporting(E_ALL); | |
| 86 | + $this->dbaseExiste = false; | |
| 87 | + if(function_exists("dbase_create")) | |
| 88 | + {$this->dbaseExiste = true;} | |
| 89 | + | |
| 79 | 90 | $this->locaplic = $locaplic; |
| 80 | 91 | $this->mapa = ms_newMapObj($map_file); |
| 81 | 92 | $this->arquivo = $map_file; |
| ... | ... | @@ -119,7 +130,7 @@ Nome do tema criado. |
| 119 | 130 | $novonomelayer = nomeRandomico(); |
| 120 | 131 | $nomeshp = $diretorio."/".$novonomelayer; |
| 121 | 132 | $def[] = array("ID","C","50"); |
| 122 | - if(!function_exists("dbase_create")){ | |
| 133 | + if($this->dbaseExiste == false){ | |
| 123 | 134 | if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) |
| 124 | 135 | {include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php");} |
| 125 | 136 | else |
| ... | ... | @@ -168,17 +179,24 @@ $projecao - código epsg da projeção das coordenadas |
| 168 | 179 | function insereSHP($xy,$projecao,$item="",$valor="") |
| 169 | 180 | { |
| 170 | 181 | if(!$this->layer){return "erro";} |
| 171 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 172 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 173 | - else | |
| 174 | - include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 182 | + if($this->dbaseExiste == false){ | |
| 183 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 184 | + include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 185 | + else | |
| 186 | + include_once "../pacotes/phpxbase/api_conversion.php"; | |
| 187 | + } | |
| 175 | 188 | $xy = explode(" ",$xy); |
| 176 | 189 | $data = $this->layer->data; |
| 177 | 190 | $data = explode(".shp",$data); |
| 178 | 191 | $data = $data[0]; |
| 179 | 192 | $items = pegaItens($this->layer); |
| 180 | 193 | $dbname = $data.".dbf"; |
| 194 | + | |
| 195 | + if($this->dbaseExiste == false) | |
| 181 | 196 | $db=xbase_open($dbname,2); |
| 197 | + else | |
| 198 | + $db=dbase_open($dbname,2); | |
| 199 | + | |
| 182 | 200 | for($i=0;$i<(count($xy) / 2);++$i) |
| 183 | 201 | { |
| 184 | 202 | $reg = array(); |
| ... | ... | @@ -190,9 +208,15 @@ $projecao - código epsg da projeção das coordenadas |
| 190 | 208 | else |
| 191 | 209 | $reg[] = "-"; |
| 192 | 210 | } |
| 211 | + if($this->dbaseExiste == false) | |
| 193 | 212 | xbase_add_record($db,$reg); |
| 213 | + else | |
| 214 | + dbase_add_record($db,$reg); | |
| 194 | 215 | } |
| 216 | + if($this->dbaseExiste == false) | |
| 195 | 217 | xbase_close($db); |
| 218 | + else | |
| 219 | + dbase_close($db); | |
| 196 | 220 | if (@$shapefileObj = ms_newShapefileObj($data,-2)) |
| 197 | 221 | { |
| 198 | 222 | for($i=0;$i<(count($xy));$i=$i+2) |
| ... | ... | @@ -446,7 +470,7 @@ $para - linha|poligono |
| 446 | 470 | $def[] = array($temp,"C","254"); |
| 447 | 471 | } |
| 448 | 472 | //para manipular dbf |
| 449 | - if(!function_exists("dbase_create")) | |
| 473 | + if($this->dbaseExiste == false) | |
| 450 | 474 | { |
| 451 | 475 | if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) |
| 452 | 476 | {include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php");} |
| ... | ... | @@ -495,7 +519,7 @@ $para - linha|poligono |
| 495 | 519 | foreach ($items as $ni) |
| 496 | 520 | {$reg[] = "-";} |
| 497 | 521 | $novoshpf->addShape($shape); |
| 498 | - if(!function_exists("dbase_create")) | |
| 522 | + if($this->dbaseExiste == false) | |
| 499 | 523 | { |
| 500 | 524 | xbase_add_record($db,$reg); |
| 501 | 525 | xbase_close($db); | ... | ... |