Commit 161cda39821200df19c501940f229ddbd37951db
1 parent
45d6c874
Exists in
master
and in
7 other branches
Crítica no uso da função xdbase passando a usar a função dbase quando a extensão…
… dbase estiver instalada no PHP.
Showing
1 changed file
with
31 additions
and
17 deletions
Show diff stats
classesphp/classe_shp.php
@@ -108,26 +108,27 @@ Nome do tema criado. | @@ -108,26 +108,27 @@ Nome do tema criado. | ||
108 | */ | 108 | */ |
109 | function criaSHPvazio($tituloTema="") | 109 | function criaSHPvazio($tituloTema="") |
110 | { | 110 | { |
111 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | ||
112 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | ||
113 | - else | ||
114 | - include_once "../pacotes/phpxbase/api_conversion.php"; | ||
115 | $diretorio = dirname($this->arquivo); | 111 | $diretorio = dirname($this->arquivo); |
116 | - $tipol = MS_SHP_POINT; | ||
117 | $novonomelayer = nomeRandomico(); | 112 | $novonomelayer = nomeRandomico(); |
118 | $nomeshp = $diretorio."/".$novonomelayer; | 113 | $nomeshp = $diretorio."/".$novonomelayer; |
119 | - $l = criaLayer($this->mapa,MS_LAYER_POINT,MS_DEFAULT,"Ins","SIM"); | ||
120 | - $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | ||
121 | - $novoshpf->free(); | ||
122 | $def[] = array("ID","C","50"); | 114 | $def[] = array("ID","C","50"); |
123 | if(!function_exists("dbase_create")){ | 115 | if(!function_exists("dbase_create")){ |
116 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | ||
117 | + {include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php");} | ||
118 | + else | ||
119 | + {include_once "../pacotes/phpxbase/api_conversion.php";} | ||
124 | $db = xbase_create($nomeshp.".dbf", $def); | 120 | $db = xbase_create($nomeshp.".dbf", $def); |
125 | xbase_close($db); | 121 | xbase_close($db); |
126 | } | 122 | } |
127 | - else{ | 123 | + else |
124 | + { | ||
128 | $db = dbase_create($nomeshp.".dbf", $def); | 125 | $db = dbase_create($nomeshp.".dbf", $def); |
129 | dbase_close($db); | 126 | dbase_close($db); |
130 | } | 127 | } |
128 | + $tipol = MS_SHP_POINT; | ||
129 | + $l = criaLayer($this->mapa,MS_LAYER_POINT,MS_DEFAULT,"Ins","SIM"); | ||
130 | + $novoshpf = ms_newShapefileObj($nomeshp, $tipol); | ||
131 | + $novoshpf->free(); | ||
131 | $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); | 132 | $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); |
132 | $novoshpf->free(); | 133 | $novoshpf->free(); |
133 | if($tituloTema == "") | 134 | if($tituloTema == "") |
@@ -365,11 +366,6 @@ $para - linha|poligono | @@ -365,11 +366,6 @@ $para - linha|poligono | ||
365 | */ | 366 | */ |
366 | function shpPT2shp($locaplic,$para) | 367 | function shpPT2shp($locaplic,$para) |
367 | { | 368 | { |
368 | - //para manipular dbf | ||
369 | - if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | ||
370 | - include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | ||
371 | - else | ||
372 | - include_once "../pacotes/phpxbase/api_conversion.php"; | ||
373 | if(!$this->layer){return "erro";} | 369 | if(!$this->layer){return "erro";} |
374 | $this->layer->set("template","none.htm"); | 370 | $this->layer->set("template","none.htm"); |
375 | $diretorio = dirname($this->arquivo); | 371 | $diretorio = dirname($this->arquivo); |
@@ -390,7 +386,17 @@ $para - linha|poligono | @@ -390,7 +386,17 @@ $para - linha|poligono | ||
390 | $temp = strtoupper($ni); | 386 | $temp = strtoupper($ni); |
391 | $def[] = array($temp,"C","254"); | 387 | $def[] = array($temp,"C","254"); |
392 | } | 388 | } |
393 | - $db = xbase_create($nomeshp.".dbf", $def); | 389 | + //para manipular dbf |
390 | + if(!function_exists("dbase_create")) | ||
391 | + { | ||
392 | + if(file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | ||
393 | + {include_once($this->locaplic."/pacotes/phpxbase/api_conversion.php");} | ||
394 | + else | ||
395 | + {include_once "../pacotes/phpxbase/api_conversion.php";} | ||
396 | + $db = xbase_create($nomeshp.".dbf", $def); | ||
397 | + } | ||
398 | + else | ||
399 | + {$db = dbase_create($nomeshp.".dbf", $def);} | ||
394 | $dbname = $nomeshp.".dbf"; | 400 | $dbname = $nomeshp.".dbf"; |
395 | $reg = array(); | 401 | $reg = array(); |
396 | $novoshpf = ms_newShapefileObj($nomeshp.".shp", $tipol); | 402 | $novoshpf = ms_newShapefileObj($nomeshp.".shp", $tipol); |
@@ -412,10 +418,18 @@ $para - linha|poligono | @@ -412,10 +418,18 @@ $para - linha|poligono | ||
412 | foreach ($items as $ni) | 418 | foreach ($items as $ni) |
413 | {$reg[] = "-";} | 419 | {$reg[] = "-";} |
414 | $novoshpf->addShape($shape); | 420 | $novoshpf->addShape($shape); |
415 | - xbase_add_record($db,$reg); | 421 | + if(!function_exists("dbase_create")) |
422 | + { | ||
423 | + xbase_add_record($db,$reg); | ||
424 | + xbase_close($db); | ||
425 | + } | ||
426 | + else | ||
427 | + { | ||
428 | + dbase_add_record($db,$reg); | ||
429 | + dbase_close($db); | ||
430 | + } | ||
416 | $novoshpf->free(); | 431 | $novoshpf->free(); |
417 | $this->layer->close(); | 432 | $this->layer->close(); |
418 | - xbase_close($db); | ||
419 | //cria o novo layer | 433 | //cria o novo layer |
420 | $layer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,"",$metaClasse="SIM"); | 434 | $layer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,"",$metaClasse="SIM"); |
421 | $layer->set("data",$nomeshp); | 435 | $layer->set("data",$nomeshp); |