Commit 9372abe2b86cc7b397ea44f3a9cd69f540ffc559
1 parent
0697c0de
Exists in
master
and in
7 other branches
--no commit message
Showing
2 changed files
with
6 additions
and
178 deletions
Show diff stats
admin/php/arvore.php
| ... | ... | @@ -696,7 +696,7 @@ function movimentaNo() |
| 696 | 696 | if ($ordematual > 1) |
| 697 | 697 | { |
| 698 | 698 | $menos = $ordematual - 1; |
| 699 | - echo "UPDATE i3geoadmin_$tabela SET 'ordem' = $ordematual where $where and ordem = '$menos'"; | |
| 699 | + //echo "UPDATE i3geoadmin_$tabela SET 'ordem' = $ordematual where $where and ordem = '$menos'"; | |
| 700 | 700 | $dbhw->query("UPDATE i3geoadmin_$tabela SET ordem = $ordematual where $where and ordem = '$menos'"); |
| 701 | 701 | $dbhw->query("UPDATE i3geoadmin_$tabela SET ordem = $menos where id_$posfixo = '$id'"); |
| 702 | 702 | } | ... | ... |
classesphp/funcoes_gerais.php
| ... | ... | @@ -1915,7 +1915,12 @@ function criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand=TRUE) |
| 1915 | 1915 | $db = dbase_open($nomeshp.".dbf", 0); |
| 1916 | 1916 | else |
| 1917 | 1917 | $db = xbase_open($nomeshp.".dbf", 0); |
| 1918 | + | |
| 1919 | + if(function_exists("dbase_numrecords")) | |
| 1918 | 1920 | $record_numbers = dbase_numrecords($db); |
| 1921 | + else | |
| 1922 | + $record_numbers = xbase_numrecords($db); | |
| 1923 | + | |
| 1919 | 1924 | if(function_exists("dbase_close")) |
| 1920 | 1925 | dbase_close($db); |
| 1921 | 1926 | else |
| ... | ... | @@ -2185,183 +2190,6 @@ function downloadTema2($map_file,$tema,$locaplic,$dir_tmp,$postgis_mapa) |
| 2185 | 2190 | } |
| 2186 | 2191 | return array("arquivos"=>implode(",",$resultado),"nreg"=>$nreg); |
| 2187 | 2192 | |
| 2188 | - | |
| 2189 | - | |
| 2190 | - | |
| 2191 | - | |
| 2192 | - // | |
| 2193 | - //verifica se o tema existe no mapfile | |
| 2194 | - //se não existir, tenta inserir com base no mapfile existente no diretório temas | |
| 2195 | - //o tema pode existir se a função estiver sendo chamada da árvore de temas de um mapa já aberto | |
| 2196 | - // | |
| 2197 | - $temasdir = $locaplic."/temas"; | |
| 2198 | - $map = ms_newMapObj($map_file); | |
| 2199 | - $teste = @$map->getlayerbyname($tema); | |
| 2200 | - if ($teste == "") | |
| 2201 | - { | |
| 2202 | - $maptemp = ms_newMapObj($temasdir."/".$tema.".map"); | |
| 2203 | - $temastemp = $maptemp->getalllayernames(); | |
| 2204 | - foreach ($temastemp as $tt) | |
| 2205 | - { | |
| 2206 | - $ll = $maptemp->getlayerbyname($tt); | |
| 2207 | - $permite = $ll->getmetadata("permitedownload"); | |
| 2208 | - if($permite != "nao") | |
| 2209 | - {ms_newLayerObj($map, $ll);} | |
| 2210 | - } | |
| 2211 | - $teste = @$map->getlayerbyname($tema); | |
| 2212 | - if ($teste == "") | |
| 2213 | - {return "erro";} | |
| 2214 | - } | |
| 2215 | - else | |
| 2216 | - { | |
| 2217 | - //remove o metadata com um nome de arquivo opcional, pois a função de download pode estar sendo executada da árvore de camadas | |
| 2218 | - $teste = $map->getlayerbyname($tema); | |
| 2219 | - $teste->setmetadata("arquivodownload",""); | |
| 2220 | - } | |
| 2221 | - // | |
| 2222 | - //salva o mapfile com um outro nome para evitar que o mapa atual, se estiver aberto, seja modificado | |
| 2223 | - // | |
| 2224 | - $map_file = str_replace(".map","tmp.map",$map_file); | |
| 2225 | - $map->save($map_file); | |
| 2226 | - substituiCon($map_file,$postgis_mapa); | |
| 2227 | - $map = ms_newMapObj($map_file); | |
| 2228 | - // | |
| 2229 | - //verifica se existe mais de um tema (grupo) montando o array com os temas | |
| 2230 | - //os grupos podem ter o nome do layer em GROUP ao invés de NAME | |
| 2231 | - // | |
| 2232 | - $multilayer = 0; | |
| 2233 | - $grupos = $map->getAllGroupNames(); | |
| 2234 | - foreach ($grupos as $grupo) | |
| 2235 | - { | |
| 2236 | - if ($grupo == $tema) | |
| 2237 | - {$multilayer = 1;} | |
| 2238 | - } | |
| 2239 | - if ($multilayer == 1) | |
| 2240 | - { | |
| 2241 | - $temasnx = $map->getAllLayerNames(); | |
| 2242 | - foreach ($temasnx as $l) | |
| 2243 | - { | |
| 2244 | - $gl = $map->getlayerbyname($l); | |
| 2245 | - $g = $gl->group; | |
| 2246 | - if (($g == $tema) || ($l == $tema)) | |
| 2247 | - {$temas[] = $l;} | |
| 2248 | - } | |
| 2249 | - } | |
| 2250 | - if ($multilayer == 0) | |
| 2251 | - {$temas[] = $tema;} | |
| 2252 | - $radtmp = dirname($dir_tmp); | |
| 2253 | - foreach ($temas as $tema) | |
| 2254 | - { | |
| 2255 | - $l = $map->getlayerbyname($tema); | |
| 2256 | - $novonomelayer = $tema; | |
| 2257 | - $nomeshp = $dir_tmp."/".$novonomelayer; | |
| 2258 | - if(file_exists($nomeshp.".dbf")){ | |
| 2259 | - // | |
| 2260 | - //verifica se o arquivo está vazio ou não | |
| 2261 | - // | |
| 2262 | - $verificaDBF = verificaDBF($nomeshp.".dbf"); | |
| 2263 | - if($verificaDBF == false){ | |
| 2264 | - unlink($nomeshp.".dbf"); | |
| 2265 | - unlink($nomeshp.".shp"); | |
| 2266 | - unlink($nomeshp.".shx"); | |
| 2267 | - } | |
| 2268 | - } | |
| 2269 | - // | |
| 2270 | - //se existir um arquivo já pronto, definido no metadata arquivodownload, irá ser utilizado | |
| 2271 | - // | |
| 2272 | - $meta = $l->getmetadata("arquivodownload"); | |
| 2273 | - if($meta != "") | |
| 2274 | - { | |
| 2275 | - // | |
| 2276 | - //se o arquivo não tiver sido copiado | |
| 2277 | - // | |
| 2278 | - $nomecopia = $dir_tmp."/".basename($meta); | |
| 2279 | - if(file_exists($meta)) | |
| 2280 | - { | |
| 2281 | - if(!file_exists($nomecopia)) | |
| 2282 | - {copy($meta,$nomecopia);} | |
| 2283 | - } | |
| 2284 | - $resultado[] = basename($dir_tmp)."/".basename($nomecopia); | |
| 2285 | - } | |
| 2286 | - else //se não existir arquivo definido | |
| 2287 | - { | |
| 2288 | - $dados = $l->data; | |
| 2289 | - // | |
| 2290 | - //se for imagem, copia o arquivo | |
| 2291 | - // | |
| 2292 | - if($l->type == MS_LAYER_RASTER) | |
| 2293 | - { | |
| 2294 | - if (file_exists($dados)) | |
| 2295 | - { | |
| 2296 | - $dir = dirname($dados); | |
| 2297 | - $arq = explode(".",basename($dados)); | |
| 2298 | - $nomecopia = $dir_tmp."/".$arq[0]; | |
| 2299 | - $exts = array("jpg","jpw","tif","tifw","tfw","png","pngw","jpgw","wld","img"); | |
| 2300 | - foreach($exts as $ext) | |
| 2301 | - { | |
| 2302 | - $copia = $nomecopia.".".$ext; | |
| 2303 | - if(!file_exists($copia) && file_exists($dir."/".$arq[0].".".$ext)) | |
| 2304 | - {copy($dir."/".$arq[0].".".$ext,$copia);} | |
| 2305 | - if(file_exists($copia)) | |
| 2306 | - $resultado[] = basename($dir_tmp)."/".basename($copia); | |
| 2307 | - } | |
| 2308 | - } | |
| 2309 | - else | |
| 2310 | - {return "erro";} | |
| 2311 | - } | |
| 2312 | - else //se for vetorial, extrai o arquivo | |
| 2313 | - { | |
| 2314 | - //define o nome correto do arquivo final | |
| 2315 | - $sp = $map->shapepath; | |
| 2316 | - $arq = ""; | |
| 2317 | - if (file_exists($dados)) | |
| 2318 | - {$arq = $dados;} | |
| 2319 | - if (file_exists($dados.".shp")) | |
| 2320 | - {$arq = $dados.".shp";} | |
| 2321 | - if (file_exists($sp.$dados.".shp")) | |
| 2322 | - {$arq = $sp.$dados.".shp";} | |
| 2323 | - if (file_exists($sp.$dados)) | |
| 2324 | - {$arq = $sp.$dados;} | |
| 2325 | - // | |
| 2326 | - //se o tema usa um arquivo shapefile, apenas faz a cópia | |
| 2327 | - // | |
| 2328 | - /* | |
| 2329 | - if ($arq != "") | |
| 2330 | - { | |
| 2331 | - $arq = explode(".shp",$arq); | |
| 2332 | - if(!file_exists($nomeshp.".shp")) | |
| 2333 | - { | |
| 2334 | - copy($arq[0].".shp",$nomeshp.".shp"); | |
| 2335 | - copy($arq[0].".shx",$nomeshp.".shx"); | |
| 2336 | - copy($arq[0].".dbf",$nomeshp.".dbf"); | |
| 2337 | - } | |
| 2338 | - $resultado[] = basename($dir_tmp)."/".$novonomelayer.".shp"; | |
| 2339 | - $resultado[] = basename($dir_tmp)."/".$novonomelayer.".dbf"; | |
| 2340 | - $resultado[] = basename($dir_tmp)."/".$novonomelayer.".shx"; | |
| 2341 | - } | |
| 2342 | - */ | |
| 2343 | - $nomeshp = criaSHP($tema,$map_file,$locaplic,$dir_tmp,$nomeRand); | |
| 2344 | - if($nomeshp == false) | |
| 2345 | - {return array("arquivos"=>"<span style=color:red >Ocorreu um erro, tente novamente","nreg"=>0);} | |
| 2346 | - $resultado[] = str_replace($radtmp."/","",$nomeshp).".shp"; | |
| 2347 | - $resultado[] = str_replace($radtmp."/","",$nomeshp).".shx"; | |
| 2348 | - $resultado[] = str_replace($radtmp."/","",$nomeshp).".dbf"; | |
| 2349 | - } | |
| 2350 | - } | |
| 2351 | - } | |
| 2352 | - $nreg = ""; | |
| 2353 | - if(count($resultado) == 3){ | |
| 2354 | - $arq = $radtmp."/".$resultado[2]; | |
| 2355 | - if(function_exists("dbase_open")){ | |
| 2356 | - $db = dbase_open($arq, 0); | |
| 2357 | - if($db){$nreg = dbase_numrecords($db);} | |
| 2358 | - } | |
| 2359 | - else{ | |
| 2360 | - $db = xbase_open($arq, 0); | |
| 2361 | - if($db){$nreg = xbase_numrecords($db);} | |
| 2362 | - } | |
| 2363 | - } | |
| 2364 | - return array("arquivos"=>implode(",",$resultado),"nreg"=>$nreg); | |
| 2365 | 2193 | } |
| 2366 | 2194 | |
| 2367 | 2195 | /* | ... | ... |