Commit 9289b7e937c559ddad6e49744c733de7ae3d70e0
1 parent
4da76dc9
Exists in
master
and in
7 other branches
validação dasopções de getlayrbyname e layer->open
Showing
13 changed files
with
191 additions
and
129 deletions
Show diff stats
classesphp/atlas_controle.php
... | ... | @@ -212,10 +212,10 @@ function gravaid() |
212 | 212 | $_SESSION["utilizacgi"] = "nao"; |
213 | 213 | $_SESSION["atlasxml"] = $atlasxmltemp; |
214 | 214 | $m = ms_newMapObj($tmpfname); |
215 | - $nomes = $m->getalllayernames(); | |
216 | - foreach($nomes as $n) | |
215 | + $c = $m->numlayers; | |
216 | + for ($i=0;$i < $c;++$i) | |
217 | 217 | { |
218 | - $l = $m->getlayerbyname($n); | |
218 | + $l = $m->getlayer($i); | |
219 | 219 | $l->setmetadata("ATLAS","nao"); |
220 | 220 | $l->setmetadata("TIP",""); |
221 | 221 | } | ... | ... |
classesphp/classe_alteraclasse.php
... | ... | @@ -83,7 +83,7 @@ $tema - nome do tema |
83 | 83 | $this->mapa = ms_newMapObj($map_file); |
84 | 84 | $this->arquivo = $map_file; |
85 | 85 | $this->layer = ""; |
86 | - if($tema != "") | |
86 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
87 | 87 | $this->layer = $this->mapa->getlayerbyname($tema); |
88 | 88 | $this->nome = $tema; |
89 | 89 | } |
... | ... | @@ -106,6 +106,7 @@ Todos os elementos passarão a ser desenhados conforme essa primeira classe, uma |
106 | 106 | */ |
107 | 107 | function simbolounico() |
108 | 108 | { |
109 | + if(!$this->layer){return "erro";} | |
109 | 110 | $numclasses = $this->layer->numclasses; |
110 | 111 | if ($numclasses > 0) |
111 | 112 | { |
... | ... | @@ -197,6 +198,7 @@ $ignorar - valor que será ignorado na listagem final |
197 | 198 | */ |
198 | 199 | function intervalosiguais($item,$nclasses,$ignorar) |
199 | 200 | { |
201 | + if(!$this->layer){return "erro";} | |
200 | 202 | $valores = pegaValores($this->mapa,$this->layer,$item,true,$ignorar); |
201 | 203 | if (count($valores) > 0) |
202 | 204 | { |
... | ... | @@ -257,6 +259,7 @@ Include: |
257 | 259 | */ |
258 | 260 | function quartis($item,$ignorar) |
259 | 261 | { |
262 | + if(!$this->layer){return "erro";} | |
260 | 263 | $valores = pegaValores($this->mapa,$this->layer,$item,true,$ignorar); |
261 | 264 | if (count($valores) > 0) |
262 | 265 | { |
... | ... | @@ -315,6 +318,7 @@ $ignorar - valor que será ignorado na listagem final |
315 | 318 | */ |
316 | 319 | function valorunico($item,$ignorar) |
317 | 320 | { |
321 | + if(!$this->layer){return "erro";} | |
318 | 322 | // pega valores |
319 | 323 | $valoresu = array_unique(pegaValores($this->mapa,$this->layer,$item,false,$ignorar)); |
320 | 324 | // processa array com os valores |
... | ... | @@ -367,6 +371,7 @@ A nova classe será uma cópia da classe 0. |
367 | 371 | */ |
368 | 372 | function adicionaclasse() |
369 | 373 | { |
374 | + if(!$this->layer){return "erro";} | |
370 | 375 | $classe = $this->layer->getclass(0); |
371 | 376 | $c = ms_newClassObj($this->layer, $classe); |
372 | 377 | //$classe = $this->layer->getclass(0); |
... | ... | @@ -388,6 +393,7 @@ Include: |
388 | 393 | */ |
389 | 394 | function alteraCoresClasses($cori,$corf) |
390 | 395 | { |
396 | + if(!$this->layer){return "erro";} | |
391 | 397 | if(file_exists($this->locaplic."/class.palette.php")) |
392 | 398 | include_once($this->locaplic."/class.palette.php"); |
393 | 399 | else |
... | ... | @@ -419,6 +425,7 @@ Inverte as cores da legenda de um tema. |
419 | 425 | */ |
420 | 426 | function inverteCoresClasses() |
421 | 427 | { |
428 | + if(!$this->layer){return "erro";} | |
422 | 429 | $numclasses = $this->layer->numclasses; |
423 | 430 | for($i=0;$i<$numclasses;++$i) |
424 | 431 | { |
... | ... | @@ -444,6 +451,7 @@ Calcula o tamanho dos estilos das classes, alterando o tamanho do símbolo. |
444 | 451 | */ |
445 | 452 | function calculaTamanhoClasses() |
446 | 453 | { |
454 | + if(!$this->layer){return "erro";} | |
447 | 455 | $numclasses = $this->layer->numclasses; |
448 | 456 | for($i=0;$i<$numclasses;++$i) |
449 | 457 | { |
... | ... | @@ -474,6 +482,7 @@ $classe - id da classe |
474 | 482 | */ |
475 | 483 | function statusClasse($classe) |
476 | 484 | { |
485 | + if(!$this->layer){return "erro";} | |
477 | 486 | $classe = $this->layer->getclass($classe); |
478 | 487 | $status = $classe->status; |
479 | 488 | if ($status == MS_OFF) | ... | ... |
classesphp/classe_analise.php
... | ... | @@ -85,7 +85,7 @@ $tema - Nome do tema que será processado |
85 | 85 | $this->locaplic = $locaplic; |
86 | 86 | $this->mapa = ms_newMapObj($map_file); |
87 | 87 | $this->arquivo = $map_file; |
88 | - if($tema != "") | |
88 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
89 | 89 | $this->layer = $this->mapa->getlayerbyname($tema); |
90 | 90 | $this->nome = $tema; |
91 | 91 | $this->diretorio = dirname($this->arquivo); |
... | ... | @@ -906,7 +906,8 @@ $locaplic - Localização do I3geo. |
906 | 906 | $res_count = $layerPt->getNumresults(); |
907 | 907 | $pontos = array(); |
908 | 908 | //pega um shape especifico |
909 | - $layerPt->open(); | |
909 | + $sopen = $layerPt->open(); | |
910 | + if($sopen == MS_FAILURE){return "erro";} | |
910 | 911 | for ($i = 0; $i < $res_count; ++$i) |
911 | 912 | { |
912 | 913 | $result = $layerPt->getResult($i); |
... | ... | @@ -947,7 +948,8 @@ $locaplic - Localização do I3geo. |
947 | 948 | $dbname = $nomeshp.".dbf"; |
948 | 949 | foreach($pontos as $ponto) |
949 | 950 | { |
950 | - $layerPt->open(); | |
951 | + $sopen = $layerPt->open(); | |
952 | + if($sopen == MS_FAILURE){return "erro";} | |
951 | 953 | foreach ($itemspt as $ni) |
952 | 954 | {$reg[] = $ponto->values[$ni];} |
953 | 955 | $layerPt->close(); |
... | ... | @@ -963,7 +965,8 @@ $locaplic - Localização do I3geo. |
963 | 965 | $ident = @$layer->queryByPoint($pt, 0, 0); |
964 | 966 | $itens = pegaItens($layer); |
965 | 967 | $res_count = $layer->getNumresults(); |
966 | - $layer->open(); | |
968 | + $sopen = $layer->open(); | |
969 | + if($sopen == MS_FAILURE){return "erro";} | |
967 | 970 | if ($res_count > 0) |
968 | 971 | { |
969 | 972 | $result = $layer->getResult(0); |
... | ... | @@ -1037,38 +1040,30 @@ function distanciaptpt($temaorigem,$temadestino,$temaoverlay,$locaplic,$itemorig |
1037 | 1040 | $layerorigem = $this->mapa->getlayerbyname($temaorigem); |
1038 | 1041 | $layerdestino = $this->mapa->getlayerbyname($temadestino); |
1039 | 1042 | $layeroverlay = $this->mapa->getlayerbyname($temaoverlay); |
1040 | - if (@$layerorigem->open() == MS_SUCCESS) | |
1043 | + $sopen = $layerorigem->open(); | |
1044 | + if($sopen == MS_FAILURE){return "erro";} | |
1045 | + $res_count = $layerorigem->getNumresults(); | |
1046 | + for ($i = 0; $i < $res_count; ++$i) | |
1041 | 1047 | { |
1042 | - $layerorigem->open(); | |
1043 | - $res_count = $layerorigem->getNumresults(); | |
1044 | - for ($i = 0; $i < $res_count; ++$i) | |
1045 | - { | |
1046 | - $result = $layerorigem->getResult($i); | |
1047 | - $shp_index = $result->shapeindex; | |
1048 | - $shapesorigem[] = $layerorigem->getshape(-1, $shp_index); | |
1049 | - } | |
1050 | - $layerorigem->close(); | |
1048 | + $result = $layerorigem->getResult($i); | |
1049 | + $shp_index = $result->shapeindex; | |
1050 | + $shapesorigem[] = $layerorigem->getshape(-1, $shp_index); | |
1051 | 1051 | } |
1052 | - else | |
1053 | - {return "erro";} | |
1052 | + $layerorigem->close(); | |
1054 | 1053 | $layeroverlay->set("tolerance",0); |
1055 | 1054 | $layerdestino->set("tolerance",0); |
1056 | 1055 | $layeroverlay->queryByrect($this->mapa->extent); |
1057 | 1056 | $layerdestino->queryByFeatures($layeroverlay->index); |
1058 | - if (@$layerdestino->open() == MS_SUCCESS) | |
1057 | + $sopen = $layerdestino->open(); | |
1058 | + if($sopen == MS_FAILURE){return "erro";} | |
1059 | + $res_count = $layerdestino->getNumresults(); | |
1060 | + for ($i = 0; $i < $res_count; ++$i) | |
1059 | 1061 | { |
1060 | - $layerdestino->open(); | |
1061 | - $res_count = $layerdestino->getNumresults(); | |
1062 | - for ($i = 0; $i < $res_count; ++$i) | |
1063 | - { | |
1064 | - $result = $layerdestino->getResult($i); | |
1065 | - $shp_index = $result->shapeindex; | |
1066 | - $shapesdestino[] = $layerdestino->getshape(-1, $shp_index); | |
1067 | - } | |
1068 | - $layerdestino->close(); | |
1062 | + $result = $layerdestino->getResult($i); | |
1063 | + $shp_index = $result->shapeindex; | |
1064 | + $shapesdestino[] = $layerdestino->getshape(-1, $shp_index); | |
1069 | 1065 | } |
1070 | - else | |
1071 | - {return "erro";} | |
1066 | + $layerdestino->close(); | |
1072 | 1067 | $rect = $this->mapa->extent; |
1073 | 1068 | $projInObj = $layerorigem->getProjection(); |
1074 | 1069 | if ($projInObj == "") |
... | ... | @@ -1148,6 +1143,7 @@ nome do layer criado com o buffer. |
1148 | 1143 | */ |
1149 | 1144 | function criaBuffer($distancia,$locaplic,$unir="nao") |
1150 | 1145 | { |
1146 | + if(!$this->layer){return "erro";} | |
1151 | 1147 | set_time_limit(180); |
1152 | 1148 | //para manipular dbf |
1153 | 1149 | if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) |
... | ... | @@ -1159,37 +1155,36 @@ nome do layer criado com o buffer. |
1159 | 1155 | //pega os shapes selecionados |
1160 | 1156 | if (file_exists(($this->arquivo)."qy")) |
1161 | 1157 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
1162 | - if (@$this->layer->open() == MS_SUCCESS) | |
1158 | + $sopen = $this->layer->open(); | |
1159 | + if($sopen == MS_FAILURE){return "erro";} | |
1160 | + $items = pegaItens($this->layer); | |
1161 | + $this->layer->open(); | |
1162 | + $res_count = $this->layer->getNumresults(); | |
1163 | + $buffers = array(); | |
1164 | + //pega um shape especifico | |
1165 | + for ($i = 0; $i < $res_count; ++$i) | |
1163 | 1166 | { |
1164 | - $items = pegaItens($this->layer); | |
1165 | - $this->layer->open(); | |
1166 | - $res_count = $this->layer->getNumresults(); | |
1167 | - $buffers = array(); | |
1168 | - //pega um shape especifico | |
1169 | - for ($i = 0; $i < $res_count; ++$i) | |
1170 | - { | |
1171 | - $result = $this->layer->getResult($i); | |
1172 | - $shp_index = $result->shapeindex; | |
1173 | - $shape = $this->layer->getshape(-1, $shp_index); | |
1174 | - //calcula a extensão geografica | |
1175 | - $rect = $shape->bounds; | |
1176 | - $projInObj = ms_newprojectionobj("proj=latlong"); | |
1177 | - $projOutObj = ms_newprojectionobj("proj=poly,ellps=GRS67,lat_0=".$rect->miny.",lon_0=".$rect->minx.",x_0=5000000,y_0=10000000"); | |
1178 | - $poPoint = ms_newpointobj(); | |
1179 | - $poPoint->setXY($rect->minx, $rect->miny); | |
1180 | - $dd1 = ms_newpointobj(); | |
1181 | - $dd1->setXY($rect->minx, $rect->miny); | |
1182 | - $poPoint->project($projInObj, $projOutObj); | |
1183 | - $dd2 = ms_newpointobj(); | |
1184 | - $dd2->setXY(($poPoint->x + $distancia), $poPoint->y); | |
1185 | - $dd2->project($projOutObj,$projInObj); | |
1186 | - $d = $dd1->distanceToPoint($dd2); | |
1187 | - if ($distancia < 0){$d = $d * -1;} | |
1188 | - //calcula a distancia 29100 | |
1189 | - //gera o buffer | |
1190 | - $buffers[] = $shape->buffer($d); | |
1191 | - $shapes[] = $shape; | |
1192 | - } | |
1167 | + $result = $this->layer->getResult($i); | |
1168 | + $shp_index = $result->shapeindex; | |
1169 | + $shape = $this->layer->getshape(-1, $shp_index); | |
1170 | + //calcula a extensão geografica | |
1171 | + $rect = $shape->bounds; | |
1172 | + $projInObj = ms_newprojectionobj("proj=latlong"); | |
1173 | + $projOutObj = ms_newprojectionobj("proj=poly,ellps=GRS67,lat_0=".$rect->miny.",lon_0=".$rect->minx.",x_0=5000000,y_0=10000000"); | |
1174 | + $poPoint = ms_newpointobj(); | |
1175 | + $poPoint->setXY($rect->minx, $rect->miny); | |
1176 | + $dd1 = ms_newpointobj(); | |
1177 | + $dd1->setXY($rect->minx, $rect->miny); | |
1178 | + $poPoint->project($projInObj, $projOutObj); | |
1179 | + $dd2 = ms_newpointobj(); | |
1180 | + $dd2->setXY(($poPoint->x + $distancia), $poPoint->y); | |
1181 | + $dd2->project($projOutObj,$projInObj); | |
1182 | + $d = $dd1->distanceToPoint($dd2); | |
1183 | + if ($distancia < 0){$d = $d * -1;} | |
1184 | + //calcula a distancia 29100 | |
1185 | + //gera o buffer | |
1186 | + $buffers[] = $shape->buffer($d); | |
1187 | + $shapes[] = $shape; | |
1193 | 1188 | } |
1194 | 1189 | //faz a união dos elementos se necessário |
1195 | 1190 | if($unir == "sim") |
... | ... | @@ -1241,7 +1236,6 @@ nome do layer criado com o buffer. |
1241 | 1236 | $cor->setrgb(255,0,0); |
1242 | 1237 | $coro = $estilo->outlinecolor; |
1243 | 1238 | $coro->setrgb(255,0,0); |
1244 | - | |
1245 | 1239 | return($novolayer->name); |
1246 | 1240 | } |
1247 | 1241 | /* |
... | ... | @@ -1257,6 +1251,7 @@ $locaplic - Localização do I3geo. |
1257 | 1251 | */ |
1258 | 1252 | function criaCentroide($locaplic) |
1259 | 1253 | { |
1254 | + if(!$this->layer){return "erro";} | |
1260 | 1255 | set_time_limit(180); |
1261 | 1256 | //para manipular dbf |
1262 | 1257 | if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) |
... | ... | @@ -1268,26 +1263,25 @@ $locaplic - Localização do I3geo. |
1268 | 1263 | //pega os shapes selecionados |
1269 | 1264 | if (file_exists(($this->arquivo)."qy")) |
1270 | 1265 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
1271 | - if (@$this->layer->open() == MS_SUCCESS) | |
1266 | + $sopen = $this->layer->open(); | |
1267 | + if($sopen == MS_FAILURE){return "erro";} | |
1268 | + $items = pegaItens($this->layer); | |
1269 | + $this->layer->open(); | |
1270 | + $res_count = $this->layer->getNumresults(); | |
1271 | + $centroides = array(); | |
1272 | + $shapes = array(); | |
1273 | + //pega um shape especifico | |
1274 | + for ($i = 0; $i < $res_count; ++$i) | |
1272 | 1275 | { |
1273 | - $items = pegaItens($this->layer); | |
1274 | - $this->layer->open(); | |
1275 | - $res_count = $this->layer->getNumresults(); | |
1276 | - $centroides = array(); | |
1277 | - $shapes = array(); | |
1278 | - //pega um shape especifico | |
1279 | - for ($i = 0; $i < $res_count; ++$i) | |
1280 | - { | |
1281 | - $result = $this->layer->getResult($i); | |
1282 | - $shp_index = $result->shapeindex; | |
1283 | - $shape = $this->layer->getshape(-1, $shp_index); | |
1284 | - $LineObj = ms_newLineObj(); | |
1285 | - $LineObj->add($shape->getCentroid()); | |
1286 | - $ShapeObj = ms_newShapeObj(MS_SHAPE_POINT); | |
1287 | - $ShapeObj->add($LineObj); | |
1288 | - $centroides[] = $ShapeObj; | |
1289 | - $shapes[] = $shape; | |
1290 | - } | |
1276 | + $result = $this->layer->getResult($i); | |
1277 | + $shp_index = $result->shapeindex; | |
1278 | + $shape = $this->layer->getshape(-1, $shp_index); | |
1279 | + $LineObj = ms_newLineObj(); | |
1280 | + $LineObj->add($shape->getCentroid()); | |
1281 | + $ShapeObj = ms_newShapeObj(MS_SHAPE_POINT); | |
1282 | + $ShapeObj->add($LineObj); | |
1283 | + $centroides[] = $ShapeObj; | |
1284 | + $shapes[] = $shape; | |
1291 | 1285 | } |
1292 | 1286 | $fechou = $this->layer->close(); |
1293 | 1287 | //gera o novo arquivo shape file |
... | ... | @@ -1763,7 +1757,8 @@ $locaplic - Localização do I3geo |
1763 | 1757 | $def[] = array("npontos","N","10","0"); |
1764 | 1758 | $db = xbase_create($nomeshp.".dbf", $def); |
1765 | 1759 | $dbname = $nomeshp.".dbf"; |
1766 | - $layerPo->open(); | |
1760 | + $sopen = $layerPo->open(); | |
1761 | + if($sopen == MS_FAILURE){return "erro";} | |
1767 | 1762 | $layerPo->whichShapes($this->mapa->extent); |
1768 | 1763 | while ($shape = $layerPo->nextShape()) |
1769 | 1764 | { |
... | ... | @@ -1796,6 +1791,7 @@ Salva o mapa acrescentando um novo layer com o resultado. |
1796 | 1791 | */ |
1797 | 1792 | function agrupaElementos($item,$locaplic) |
1798 | 1793 | { |
1794 | + if(!$this->layer){return "erro";} | |
1799 | 1795 | set_time_limit(180); |
1800 | 1796 | //para manipular dbf |
1801 | 1797 | if(!isset($item)){$item="";} |
... | ... | @@ -1806,7 +1802,8 @@ Salva o mapa acrescentando um novo layer com o resultado. |
1806 | 1802 | //define o nome do novo shapefile que será criado |
1807 | 1803 | if (file_exists(($this->arquivo)."qy")) |
1808 | 1804 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
1809 | - $this->layer->open(); | |
1805 | + $sopen = $this->layer->open(); | |
1806 | + if($sopen == MS_FAILURE){return "erro";} | |
1810 | 1807 | $res_count = $this->layer->getNumresults(); |
1811 | 1808 | // |
1812 | 1809 | //pega os indices dos poligonos por classe de atributo |
... | ... | @@ -1909,6 +1906,7 @@ $locaplic - Localização do I3geo |
1909 | 1906 | */ |
1910 | 1907 | function dissolvePoligono($item,$locaplic) |
1911 | 1908 | { |
1909 | + if(!$this->layer){return "erro";} | |
1912 | 1910 | set_time_limit(180); |
1913 | 1911 | //para manipular dbf |
1914 | 1912 | if(!isset($item)){$item="";} |
... | ... | @@ -1919,7 +1917,8 @@ $locaplic - Localização do I3geo |
1919 | 1917 | //define o nome do novo shapefile que será criado |
1920 | 1918 | if (file_exists(($this->arquivo)."qy")) |
1921 | 1919 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
1922 | - $this->layer->open(); | |
1920 | + $sopen = $this->layer->open(); | |
1921 | + if($sopen == MS_FAILURE){return "erro";} | |
1923 | 1922 | $res_count = $this->layer->getNumresults(); |
1924 | 1923 | // |
1925 | 1924 | //pega os indices dos poligonos por classe de atributo |
... | ... | @@ -2305,7 +2304,9 @@ function gravaCoordenadasPt($tema,$limitepontos="TRUE") |
2305 | 2304 | $res_count = $layerPt->getNumresults(); |
2306 | 2305 | $pontos = array(); |
2307 | 2306 | //pega um shape especifico |
2308 | - $layerPt->open(); | |
2307 | + $sopen = $layerPt->open(); | |
2308 | + if($sopen == MS_FAILURE){return "erro";} | |
2309 | + | |
2309 | 2310 | if (($prjTema != "") && ($prjMapa != $prjTema)) |
2310 | 2311 | { |
2311 | 2312 | $projInObj = ms_newprojectionobj($prjTema); | ... | ... |
classesphp/classe_atributos.php
... | ... | @@ -77,7 +77,7 @@ $tema - nome do tema |
77 | 77 | $this->locaplic = $locaplic; |
78 | 78 | $this->mapa = ms_newMapObj($map_file); |
79 | 79 | $this->arquivo = $map_file; |
80 | - if($tema != "") | |
80 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
81 | 81 | $this->layer = $this->mapa->getlayerbyname($tema); |
82 | 82 | $this->nome = $tema; |
83 | 83 | } |
... | ... | @@ -106,6 +106,7 @@ xmin ymin xmax ymax separados por espaço. |
106 | 106 | */ |
107 | 107 | function extensaoShape($shape) |
108 | 108 | { |
109 | + if(!$this->layer){return "erro";} | |
109 | 110 | $prjMapa = $this->mapa->getProjection(); |
110 | 111 | $prjTema = $this->layer->getProjection(); |
111 | 112 | $ret = $shape->bounds; |
... | ... | @@ -141,6 +142,7 @@ $registro - Índice do registro que será consultado. |
141 | 142 | */ |
142 | 143 | function extensaoRegistro($registro) |
143 | 144 | { |
145 | + if(!$this->layer){return "erro";} | |
144 | 146 | $this->layer->set("template","none.htm"); |
145 | 147 | $this->layer->setfilter(""); |
146 | 148 | $ext = ""; |
... | ... | @@ -201,6 +203,7 @@ $tipo - Tipo de busca brasil|null |
201 | 203 | */ |
202 | 204 | function itensTexto($tipo) |
203 | 205 | { |
206 | + if(!$this->layer){return "erro";} | |
204 | 207 | if ($tipo == "brasil") |
205 | 208 | {$this->mapa = extPadrao($this->mapa);} |
206 | 209 | $this->layer->set("template","none.htm"); |
... | ... | @@ -213,7 +216,8 @@ $tipo - Tipo de busca brasil|null |
213 | 216 | if ($this->layer->getNumresults() > 0){$existesel = "sim";} |
214 | 217 | if ($existesel == "nao") |
215 | 218 | {$this->layer->querybyrect($this->mapa->extent);} |
216 | - $this->layer->open(); | |
219 | + $sopen = $this->layer->open(); | |
220 | + if($sopen == MS_FAILURE){return "erro";} | |
217 | 221 | $registros[] = array(); |
218 | 222 | $res_count = $this->layer->getNumresults(); |
219 | 223 | for ($i = 0; $i < $res_count; ++$i) |
... | ... | @@ -256,6 +260,7 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona |
256 | 260 | */ |
257 | 261 | function listaRegistros($itemtema,$tipo,$unico,$inicio,$fim,$tipolista) |
258 | 262 | { |
263 | + if(!$this->layer){return "erro";} | |
259 | 264 | $resultadoFinal = array(); |
260 | 265 | if ((!isset($tipolista)) || ($tipolista=="")){$tipolista = "tudo";} |
261 | 266 | if (!isset($inicio)){$inicio = 0;} |
... | ... | @@ -276,7 +281,8 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona |
276 | 281 | if (file_exists($this->arquivo."qy")) |
277 | 282 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
278 | 283 | $indxlayer = $this->layer->index; |
279 | - $this->layer->open(); | |
284 | + $sopen = $this->layer->open(); | |
285 | + if($sopen == MS_FAILURE){return "erro";} | |
280 | 286 | $res_count = $this->layer->getNumresults(); |
281 | 287 | $registros = array(); |
282 | 288 | //lista apenas os selecionados |
... | ... | @@ -323,7 +329,8 @@ $tipolista - Indica se serão mostrados todos os registros ou apenas os seleciona |
323 | 329 | if (($res_count >= $fim) && ($fim < $res_count)) |
324 | 330 | {$res_count = $fim;} |
325 | 331 | } |
326 | - $this->layer->open(); | |
332 | + $sopen = $this->layer->open(); | |
333 | + if($sopen == MS_FAILURE){return "erro";} | |
327 | 334 | for ($i = $inicio; $i < $res_count; ++$i) |
328 | 335 | { |
329 | 336 | $valitem = array(); |
... | ... | @@ -406,7 +413,8 @@ $onde - Tipo de abrangência espacial (brasil ou mapa) |
406 | 413 | if ($filtro != ""){$l->setfilter("");} |
407 | 414 | $buscas = "ÁÃÓÕÔáàãâóòôõúûíéêç"; |
408 | 415 | $trocas = "AAOOOaaaaoooouuieec"; |
409 | - $l->open(); | |
416 | + $sopen = $l->open(); | |
417 | + if($sopen == MS_FAILURE){return "erro";} | |
410 | 418 | $l->whichShapes($this->mapa->extent); |
411 | 419 | $fr = array(); |
412 | 420 | while ($shape = $l->nextShape()) |
... | ... | @@ -465,6 +473,7 @@ Include: |
465 | 473 | */ |
466 | 474 | function estatDescritivas($item,$exclui) |
467 | 475 | { |
476 | + if(!$this->layer){return "erro";} | |
468 | 477 | $this->layer->set("template","none.htm"); |
469 | 478 | $items = pegaItens($this->layer); |
470 | 479 | $valores = array(); |
... | ... | @@ -477,7 +486,8 @@ Include: |
477 | 486 | if ($this->layer->getNumresults() > 0){$existesel = "sim";} |
478 | 487 | if ($existesel == "nao") |
479 | 488 | {$this->layer->queryByrect($this->mapa->extent);} |
480 | - $abriu = $this->layer->open(); | |
489 | + $sopen = $this->layer->open(); | |
490 | + if($sopen == MS_FAILURE){return "erro";} | |
481 | 491 | $res_count = $this->layer->getNumresults(); |
482 | 492 | //pega os valores |
483 | 493 | for ($i = 0; $i < $res_count; ++$i) |
... | ... | @@ -837,7 +847,8 @@ function identificaQBP($tema,$x,$y,$map_file,$resolucao,$item="",$tiporetorno="" |
837 | 847 | } |
838 | 848 | } |
839 | 849 | $res_count = $layer->getNumresults(); |
840 | - $layer->open(); | |
850 | + $sopen = $layer->open(); | |
851 | + if($sopen == MS_FAILURE){return "erro";} | |
841 | 852 | for ($i = 0; $i < $res_count; ++$i) |
842 | 853 | { |
843 | 854 | $valori = array(); | ... | ... |
classesphp/classe_legenda.php
... | ... | @@ -116,7 +116,7 @@ $template - nome do template para processar a legenda |
116 | 116 | $this->mapa = ms_newMapObj($map_file); |
117 | 117 | $this->arquivo = $map_file; |
118 | 118 | $this->localaplicacao = $locaplic; |
119 | - if ($tema != "") | |
119 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
120 | 120 | { |
121 | 121 | $this->layer = $this->mapa->getlayerbyname($tema); |
122 | 122 | $this->nome = $tema; |
... | ... | @@ -296,7 +296,8 @@ array |
296 | 296 | if (($totaliza=="sim") && ($nc > 1)) |
297 | 297 | { |
298 | 298 | $layer->set("template","none.htm"); |
299 | - $layer->open(); | |
299 | + $sopen = $layer->open(); | |
300 | + if($sopen == MS_FAILURE){return "erro";} | |
300 | 301 | $itens = $layer->getitems(); |
301 | 302 | $total = 0; |
302 | 303 | $nreg = array(); |
... | ... | @@ -354,6 +355,7 @@ Exclui um estilo de uma classe. |
354 | 355 | */ |
355 | 356 | function excluiEstilo($classe,$estilo) |
356 | 357 | { |
358 | + if(!$this->layer){return "erro";} | |
357 | 359 | $classe = $this->layer->getclass($classe); |
358 | 360 | $classe->deletestyle($estilo); |
359 | 361 | } |
... | ... | @@ -367,6 +369,7 @@ objeto estilo |
367 | 369 | */ |
368 | 370 | function adicionaEstilo($classe,$estilo) |
369 | 371 | { |
372 | + if(!$this->layer){return "erro";} | |
370 | 373 | $classe = $this->layer->getclass($classe); |
371 | 374 | $estilo = $classe->getstyle($estilo); |
372 | 375 | $e = ms_newStyleObj($classe,$estilo); |
... | ... | @@ -384,6 +387,7 @@ $estilo - Índice do estilo de uma classe que será clonado. |
384 | 387 | */ |
385 | 388 | function sobeEstilo($classe,$estilo) |
386 | 389 | { |
390 | + if(!$this->layer){return "erro";} | |
387 | 391 | $classe = $this->layer->getclass($classe); |
388 | 392 | $classe->movestyleup($estilo); |
389 | 393 | } |
... | ... | @@ -399,6 +403,7 @@ $estilo - Índice do estilo de uma classe que será clonado. |
399 | 403 | */ |
400 | 404 | function desceEstilo($classe,$estilo) |
401 | 405 | { |
406 | + if(!$this->layer){return "erro";} | |
402 | 407 | $classe = $this->layer->getclass($classe); |
403 | 408 | $classe->movestyledown($estilo); |
404 | 409 | } |
... | ... | @@ -480,6 +485,7 @@ string com o tipo do layer,id do estilo,outlinecolor,backgroundcolor,color,symbo |
480 | 485 | */ |
481 | 486 | function pegaParametros($classe) |
482 | 487 | { |
488 | + if(!$this->layer){return "erro";} | |
483 | 489 | $tipoLayer = $this->layer->type; |
484 | 490 | $classe = $this->layer->getclass($classe); |
485 | 491 | $numestilos = $classe->numstyles; |
... | ... | @@ -520,6 +526,7 @@ $size - Tamanho que será aplicado ao símbolo. |
520 | 526 | */ |
521 | 527 | function aplicaParametro($classe,$estilo,$outlinecolor,$backgroundcolor,$color,$symbolname,$size) |
522 | 528 | { |
529 | + if(!$this->layer){return "erro";} | |
523 | 530 | $classe = $this->layer->getclass($classe); |
524 | 531 | $estilo = $classe->getstyle($estilo); |
525 | 532 | if (isset($outlinecolor)) | ... | ... |
classesphp/classe_mapa.php
... | ... | @@ -142,10 +142,13 @@ string - javascript com os parametros |
142 | 142 | $sel = "nao"; |
143 | 143 | if ($qy) //verifica se existe alguma selecao no tema |
144 | 144 | { |
145 | - $oLayer->open(); | |
146 | - $res_count = $oLayer->getNumresults(); | |
147 | - $oLayer->close(); | |
148 | - if ($res_count > 0){$sel = "sim";$existesel = true;} | |
145 | + $sopen = $oLayer->open(); | |
146 | + if($sopen != MS_FAILURE) | |
147 | + { | |
148 | + $res_count = $oLayer->getNumresults(); | |
149 | + $oLayer->close(); | |
150 | + if ($res_count > 0){$sel = "sim";$existesel = true;} | |
151 | + } | |
149 | 152 | } |
150 | 153 | if ((strtoupper($oLayer->getmetadata("tema")) != "NAO") && ($oLayer->getmetadata("escondido") == "")) |
151 | 154 | { | ... | ... |
classesphp/classe_navegacao.php
... | ... | @@ -140,10 +140,10 @@ Desliga o status das camadas raster |
140 | 140 | */ |
141 | 141 | function desabilitaRASTER() |
142 | 142 | { |
143 | - $ls = $this->mapa->getalllayernames(); | |
144 | - foreach ($ls as $l) | |
145 | - { | |
146 | - $layer = $this->mapa->getlayerbyname($l); | |
143 | + $c = $this->mapa->numlayers; | |
144 | + for ($i=0;$i < $c;++$i) | |
145 | + { | |
146 | + $layer = $this->mapa->getlayer($i); | |
147 | 147 | if ($layer->type == MS_LAYER_RASTER) |
148 | 148 | {$layer->set("status",MS_OFF);} |
149 | 149 | } | ... | ... |
classesphp/classe_selecao.php
... | ... | @@ -76,6 +76,7 @@ $tema - nome do tema |
76 | 76 | //error_reporting(E_ALL); |
77 | 77 | $this->mapa = ms_newMapObj($map_file); |
78 | 78 | $this->arquivo = $map_file; |
79 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
79 | 80 | $this->layer = $this->mapa->getlayerbyname($tema); |
80 | 81 | $this->nome = $tema; |
81 | 82 | } |
... | ... | @@ -104,6 +105,7 @@ $ys - lista de coordenadas y separadas por virgula |
104 | 105 | */ |
105 | 106 | function selecaoPorPoligono($tipo,$xs,$ys) |
106 | 107 | { |
108 | + if(!$this->layer){return "erro";} | |
107 | 109 | $this->layer->set("tolerance",0); |
108 | 110 | if ($tipo == "limpa") |
109 | 111 | {return($this->selecaoLimpa());} |
... | ... | @@ -160,6 +162,7 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa |
160 | 162 | */ |
161 | 163 | function selecaoTema($temao,$tipo) |
162 | 164 | { |
165 | + if(!$this->layer){return "erro";} | |
163 | 166 | $this->layer->set("tolerance",0); |
164 | 167 | if ($tipo == "limpa") |
165 | 168 | {return($this->selecaoLimpa());} |
... | ... | @@ -191,7 +194,8 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa |
191 | 194 | $selecao = ""; |
192 | 195 | if (($selecao != "ok") && ($layero->data != "")) |
193 | 196 | { |
194 | - $layero->open(); | |
197 | + $sopen = $layero->open(); | |
198 | + if($sopen == MS_FAILURE){return "erro";} | |
195 | 199 | $res_count = $layero->getNumresults(); |
196 | 200 | for ($i = 0; $i < $res_count; ++$i) |
197 | 201 | { |
... | ... | @@ -245,7 +249,8 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa |
245 | 249 | if (($selecao != "ok") && ($layero->data == "")) |
246 | 250 | { |
247 | 251 | $layero->queryByRect($this->mapa->extent); |
248 | - $layero->open(); | |
252 | + $sopen = $layero->open(); | |
253 | + if($sopen == MS_FAILURE){return "erro";} | |
249 | 254 | $conta = $layero->getNumresults(); |
250 | 255 | for ($k = 0; $k < $conta; $k++) |
251 | 256 | { |
... | ... | @@ -319,6 +324,7 @@ $valor - Valor. |
319 | 324 | {return($this->selecaoLimpa());} |
320 | 325 | if ($tipo == "inverte") |
321 | 326 | {return($this->selecaoInverte());} |
327 | + if(!$this->layer){return "erro";} | |
322 | 328 | $operador = explode(",",$operador); |
323 | 329 | $operador = $operador[1]; |
324 | 330 | $this->layer->set("template","none.htm"); |
... | ... | @@ -373,6 +379,7 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa |
373 | 379 | {return ($this->selecaoLimpa());} |
374 | 380 | if ($tipo == "inverte") |
375 | 381 | {return ($this->selecaoInverte());} |
382 | + if(!$this->layer){return "erro";} | |
376 | 383 | $this->layer->set("template","none.htm"); |
377 | 384 | if (file_exists(($this->arquivo)."qy")) |
378 | 385 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
... | ... | @@ -449,6 +456,7 @@ Limpa a seleção do tema. |
449 | 456 | { |
450 | 457 | if ($this->nome != "") //limpa de um tema |
451 | 458 | { |
459 | + if(!$this->layer){return "erro";} | |
452 | 460 | if (file_exists(($this->arquivo)."qy")) |
453 | 461 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
454 | 462 | $indxlayer = $this->layer->index; |
... | ... | @@ -470,6 +478,7 @@ Inverte seleção do tema. |
470 | 478 | */ |
471 | 479 | function selecaoInverte() |
472 | 480 | { |
481 | + if(!$this->layer){return "erro";} | |
473 | 482 | $this->layer->set("template","none.htm"); |
474 | 483 | if (file_exists(($this->arquivo)."qy")) |
475 | 484 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
... | ... | @@ -513,6 +522,7 @@ $shp_atual - Indices dos elementos já selecionados. |
513 | 522 | */ |
514 | 523 | function selecaoAdiciona($shpi,$shp_atual) |
515 | 524 | { |
525 | + if(!$this->layer){return "erro";} | |
516 | 526 | $this->layer->set("template","none.htm"); |
517 | 527 | $indxlayer = $this->layer->index; |
518 | 528 | $shp = array_merge($shpi,$shp_atual); |
... | ... | @@ -536,6 +546,7 @@ $shp_atual - Indices dos elementos já selecionados. |
536 | 546 | */ |
537 | 547 | function selecaoRetira($shpi,$shp_atual) |
538 | 548 | { |
549 | + if(!$this->layer){return "erro";} | |
539 | 550 | $this->layer->set("template","none.htm"); |
540 | 551 | $indxlayer = $this->layer->index; |
541 | 552 | $this->mapa->freequery($indxlayer); |
... | ... | @@ -560,6 +571,7 @@ $ids - Ids separados por vírgula correspondendo aos registros. |
560 | 571 | */ |
561 | 572 | function incluiSel($ids) |
562 | 573 | { |
574 | + if(!$this->layer){return "erro";} | |
563 | 575 | $this->layer->set("template","none.htm"); |
564 | 576 | if (file_exists(($this->arquivo)."qy")) |
565 | 577 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
... | ... | @@ -583,6 +595,7 @@ $dir_tmp - localização do diretório temporário |
583 | 595 | */ |
584 | 596 | function selecao2tema($locaplic,$dir_tmp) |
585 | 597 | { |
598 | + if(!$this->layer){return "erro";} | |
586 | 599 | $this->layer->set("template","none.htm"); |
587 | 600 | $this->layer->setfilter(""); |
588 | 601 | $nomeshp = criaSHP($this->nome,$this->arquivo,$locaplic,$dir_tmp); |
... | ... | @@ -611,6 +624,7 @@ $tipo - Tipo de operação adiciona|retira|inverte|limpa |
611 | 624 | */ |
612 | 625 | function selecaoEXT($tipo) |
613 | 626 | { |
627 | + if(!$this->layer){return "erro";} | |
614 | 628 | $this->layer->set("tolerance",0); |
615 | 629 | if ($tipo == "limpa") |
616 | 630 | {return ($this->selecaoLimpa());} |
... | ... | @@ -659,6 +673,7 @@ $ext - coordenadas separadas por espaços no estilo xmin ymin xmax ymax |
659 | 673 | */ |
660 | 674 | function selecaoBOX($tipo,$ext) |
661 | 675 | { |
676 | + if(!$this->layer){return "erro";} | |
662 | 677 | $this->layer->set("tolerance",0); |
663 | 678 | if ($tipo == "limpa") |
664 | 679 | {return ($this->selecaoLimpa());} | ... | ... |
classesphp/classe_shp.php
... | ... | @@ -75,13 +75,11 @@ $tema - nome do tema |
75 | 75 | $this->mapa = ms_newMapObj($map_file); |
76 | 76 | $this->arquivo = $map_file; |
77 | 77 | $this->tema = $tema; |
78 | - if ($tema != "") | |
78 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
79 | 79 | { |
80 | 80 | $this->layer = $this->mapa->getlayerbyname($tema); |
81 | - $this->nome = $tema; | |
82 | 81 | } |
83 | - else | |
84 | - {$this->layer = "";} | |
82 | + $this->nome = $tema; | |
85 | 83 | } |
86 | 84 | /* |
87 | 85 | function: salva |
... | ... | @@ -146,8 +144,7 @@ $projecao - código epsg da projeção das coordenadas |
146 | 144 | */ |
147 | 145 | function insereSHP($xy,$projecao,$item="",$valor="") |
148 | 146 | { |
149 | - if($this->layer == "") | |
150 | - {return("erro");} | |
147 | + if(!$this->layer){return "erro";} | |
151 | 148 | if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) |
152 | 149 | include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); |
153 | 150 | else |
... | ... | @@ -287,9 +284,9 @@ string - xy |
287 | 284 | */ |
288 | 285 | function listaPontosShape() |
289 | 286 | { |
290 | - if($this->layer == "") | |
291 | - {return("erro");} | |
292 | - $this->layer->open(); | |
287 | + if(!$this->layer){return "erro";} | |
288 | + $sopen = $this->layer->open(); | |
289 | + if($sopen == MS_FAILURE){return "erro";} | |
293 | 290 | $this->layer->whichShapes($this->mapa->extent); |
294 | 291 | $xy = array(); |
295 | 292 | while ($shape = $this->layer->nextShape()) |
... | ... | @@ -318,8 +315,7 @@ $para - linha|poligono |
318 | 315 | include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); |
319 | 316 | else |
320 | 317 | include_once "../pacotes/phpxbase/api_conversion.php"; |
321 | - if($this->layer == "") | |
322 | - {return("erro");} | |
318 | + if(!$this->layer){return "erro";} | |
323 | 319 | $this->layer->set("template","none.htm"); |
324 | 320 | $diretorio = dirname($this->arquivo); |
325 | 321 | $tipol = MS_SHP_ARC; | ... | ... |
classesphp/classe_temas.php
... | ... | @@ -97,9 +97,9 @@ $tema - nome do tema que será processado |
97 | 97 | $this->locaplic = $locaplic; |
98 | 98 | $this->mapa = ms_newMapObj($map_file); |
99 | 99 | $this->arquivo = $map_file; |
100 | - if (isset($tema)) | |
100 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
101 | 101 | { |
102 | - $this->layer = @$this->mapa->getlayerbyname($tema); | |
102 | + $this->layer = $this->mapa->getlayerbyname($tema); | |
103 | 103 | $this->nome = $tema; |
104 | 104 | $vermultilayer = new vermultilayer(); |
105 | 105 | $vermultilayer->verifica($map_file,$tema); |
... | ... | @@ -136,6 +136,7 @@ $lista - lista de processos separados por | |
136 | 136 | */ |
137 | 137 | function aplicaProcessos($lista) |
138 | 138 | { |
139 | + if(!$this->layer){return "erro";} | |
139 | 140 | if ($this->layer->num_processing > 0) |
140 | 141 | {$this->layer->clearProcessing();} |
141 | 142 | $lista = str_replace('"',"",$lista); |
... | ... | @@ -342,6 +343,7 @@ Calcula a extensão geográfica de um tema e ajusta o mapa para essa extensão. |
342 | 343 | */ |
343 | 344 | function zoomTema() |
344 | 345 | { |
346 | + if(!$this->layer){return "erro";} | |
345 | 347 | $prjMapa = ""; |
346 | 348 | $prjTema = ""; |
347 | 349 | if($this->layer->type != MS_LAYER_RASTER) |
... | ... | @@ -382,6 +384,7 @@ string Filtro. |
382 | 384 | */ |
383 | 385 | function pegaFiltro() |
384 | 386 | { |
387 | + if(!$this->layer){return "erro";} | |
385 | 388 | $fil = $this->layer->getfilter(); |
386 | 389 | if ($this->layer->getfilter() == '"(null)"'){return " ";} |
387 | 390 | if (function_exists("mb_convert_encoding")) |
... | ... | @@ -402,6 +405,7 @@ $testa - Testa o filtro e retorna uma imagem. |
402 | 405 | */ |
403 | 406 | function insereFiltro($filtro,$testa="") |
404 | 407 | { |
408 | + if(!$this->layer){return "erro";} | |
405 | 409 | $fil = $this->layer->getfilter(); |
406 | 410 | $filtro = str_replace("|","'",$filtro); |
407 | 411 | if ($this->layer->connectiontype == MS_POSTGIS) |
... | ... | @@ -536,7 +540,7 @@ $fonte - Fonte. |
536 | 540 | //verifica se j'a existe um layer criado anteriormente com o mesmo nome e apaga se existir |
537 | 541 | if ($tipo == "limpaponto") |
538 | 542 | { |
539 | - if ($this->layer != "") | |
543 | + if ($this->layer) | |
540 | 544 | { |
541 | 545 | $this->layer->set("status",MS_DELETE); |
542 | 546 | $this->layer->set("name","pindelete"); |
... | ... | @@ -544,7 +548,7 @@ $fonte - Fonte. |
544 | 548 | } |
545 | 549 | } |
546 | 550 | //se o novo layer nao existir, cria um novo copiando o layer "pin" que ja deve existir no map file (no map file que iniciou a aplicacao) |
547 | - if ($this->layer == "") | |
551 | + if (!$this->layer) | |
548 | 552 | { |
549 | 553 | $pinlayer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,"Ins",$metaClasse="SIM"); |
550 | 554 | $c = $pinlayer->getclass(0); |
... | ... | @@ -674,6 +678,7 @@ $nome - nome que será dado a geometria |
674 | 678 | */ |
675 | 679 | function capturaGeometrias($dir_tmp,$imgdir,$nome="") |
676 | 680 | { |
681 | + if(!$this->layer){return "erro";} | |
677 | 682 | $this->mapa->setsize(30,30); |
678 | 683 | $ext = $this->mapa->extent; |
679 | 684 | $sb = $this->mapa->scalebar; |
... | ... | @@ -681,7 +686,9 @@ $nome - nome que será dado a geometria |
681 | 686 | if (file_exists($this->arquivo."qy")) |
682 | 687 | {$this->mapa->loadquery(($this->arquivo)."qy");} |
683 | 688 | $items = pegaItens($this->layer); |
684 | - $this->layer->open(); | |
689 | + $sopen = $this->layer->open(); | |
690 | + if($sopen == MS_FAILURE){return "erro";} | |
691 | + | |
685 | 692 | $res_count = $this->layer->getNumresults(); |
686 | 693 | $final["layer"] = pegaNome($this->layer); |
687 | 694 | $registros = array(); |
... | ... | @@ -791,6 +798,7 @@ lista - lista de item e cores de cada parte do grafico |
791 | 798 | */ |
792 | 799 | function graficotema($lista,$tamanho="50",$tipo="PIE",$outlinecolor="",$offset=0) |
793 | 800 | { |
801 | + if(!$this->layer){return "erro";} | |
794 | 802 | $nome = pegaNome($this->layer); |
795 | 803 | $novolayer = ms_newLayerObj($this->mapa, $this->layer); |
796 | 804 | $nomer = nomeRandomico(); | ... | ... |
classesphp/classe_toponimia.php
... | ... | @@ -81,6 +81,7 @@ $tema - nome do tema que será processado |
81 | 81 | include_once("funcoes_gerais.php"); |
82 | 82 | $this->mapa = ms_newMapObj($map_file); |
83 | 83 | $this->arquivo = $map_file; |
84 | + if($tema != "" && @$this->mapa->getlayerbyname($tema)) | |
84 | 85 | $this->layer = $this->mapa->getlayerbyname($tema); |
85 | 86 | $this->nome = $tema; |
86 | 87 | } |
... | ... | @@ -144,6 +145,7 @@ $tipo Tipo teste| |
144 | 145 | */ |
145 | 146 | function criaToponimia($item,$position,$partials,$offsetx,$offsety,$minfeaturesize,$mindistance,$force,$shadowcolor,$shadowsizex,$shadowsizey,$outlinecolor,$cor,$sombray,$sombrax,$sombra,$fundo,$angulo,$tamanho,$fonte,$tipo) |
146 | 147 | { |
148 | + if(!$this->layer){return "erro";} | |
147 | 149 | if (!isset($tipo)){$tipo = "";} |
148 | 150 | if ($item != "") //o layer nao tem tabela mas tem toponimia |
149 | 151 | { |
... | ... | @@ -230,6 +232,7 @@ $item Item que será utilizado. |
230 | 232 | */ |
231 | 233 | function ativaEtiquetas($item) |
232 | 234 | { |
235 | + if(!$this->layer){return "erro";} | |
233 | 236 | $this->layer->setmetadata("TIP",$item); |
234 | 237 | return("ok"); |
235 | 238 | } |
... | ... | @@ -241,6 +244,7 @@ remove a inclusão de etiquetas em um tema. |
241 | 244 | */ |
242 | 245 | function removeEtiquetas() |
243 | 246 | { |
247 | + if(!$this->layer){return "erro";} | |
244 | 248 | $this->layer->setmetadata("TIP",""); |
245 | 249 | return("ok"); |
246 | 250 | } | ... | ... |
classesphp/flamingoogc.php
... | ... | @@ -92,10 +92,10 @@ foreach(array_keys($_SESSION) as $k) |
92 | 92 | } |
93 | 93 | $postgis_mapa = $_SESSION["postgis_mapa"]; |
94 | 94 | $nmap = ms_newMapobj($map_file); |
95 | -$ts = $nmap->getalllayernames(); | |
96 | -foreach ($ts as $t) | |
95 | +$c = $nmap->numlayers; | |
96 | +for ($i=0;$i < $c;++$i) | |
97 | 97 | { |
98 | - $l = $nmap->getlayerbyname($t); | |
98 | + $l = $nmap->getlayer($i);} | |
99 | 99 | if($l->connectiontype != MS_WMS) |
100 | 100 | { |
101 | 101 | $l->setmetadata("ows_title",pegaNome($l)); | ... | ... |
classesphp/funcoes_gerais.php
... | ... | @@ -1020,7 +1020,8 @@ function pegaValores($mapa,$layer,$item,$numerico=false,$ignorar="") |
1020 | 1020 | $layer->setfilter(""); |
1021 | 1021 | if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) |
1022 | 1022 | { |
1023 | - $layer->open(); | |
1023 | + $sopen = $layer->open(); | |
1024 | + if($sopen == MS_FAILURE){return "erro";} | |
1024 | 1025 | $res_count = $layer->getNumresults(); |
1025 | 1026 | $valitem = array(); |
1026 | 1027 | for ($i=0;$i<$res_count;++$i) |
... | ... | @@ -1083,7 +1084,8 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao") |
1083 | 1084 | //pega os valores dos indices dos elementos selecionados para comparacao posterior |
1084 | 1085 | if ($selecionados == "sim") |
1085 | 1086 | { |
1086 | - $layer->open(); | |
1087 | + $sopen = $layer->open(); | |
1088 | + if($sopen == MS_FAILURE){return "erro";} | |
1087 | 1089 | $res_count = $layer->getNumresults(); |
1088 | 1090 | for ($i = 0; $i < $res_count; ++$i) |
1089 | 1091 | { |
... | ... | @@ -1095,7 +1097,9 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao") |
1095 | 1097 | $valores = array(); |
1096 | 1098 | if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) |
1097 | 1099 | { |
1098 | - $layer->open(); | |
1100 | + $sopen = $layer->open(); | |
1101 | + if($sopen == MS_FAILURE){return "erro";} | |
1102 | + | |
1099 | 1103 | $res_count = $layer->getNumresults(); |
1100 | 1104 | for ($i=0;$i<$res_count;++$i) |
1101 | 1105 | { |
... | ... | @@ -1616,7 +1620,9 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
1616 | 1620 | $res_count = $layer->getNumresults(); |
1617 | 1621 | if ($res_count > 0) |
1618 | 1622 | { |
1619 | - $abriu = $layer->open(); | |
1623 | + $sopen = $layer->open(); | |
1624 | + if($sopen == MS_FAILURE){return "erro";} | |
1625 | + | |
1620 | 1626 | for ($i = 0; $i < $res_count; ++$i) |
1621 | 1627 | { |
1622 | 1628 | $result = $layer->getResult($i); |
... | ... | @@ -1932,7 +1938,9 @@ function autoClasses(&$nlayer,$mapa) |
1932 | 1938 | $ret->setextent($temp[0],$temp[1],$temp[2],$temp[3]); |
1933 | 1939 | } |
1934 | 1940 | // |
1935 | - $nlayer->open(); | |
1941 | + $sopen = $nlayer->open(); | |
1942 | + if($sopen == MS_FAILURE){return "erro";} | |
1943 | + | |
1936 | 1944 | $status = $nlayer->whichShapes($ret); |
1937 | 1945 | $parametrosClasses = array(); |
1938 | 1946 | if ($status == 0) | ... | ... |