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