Commit 161cda39821200df19c501940f229ddbd37951db

Authored by Edmar Moretti
1 parent 45d6c874

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 108 */
109 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 111 $diretorio = dirname($this->arquivo);
116   - $tipol = MS_SHP_POINT;
117 112 $novonomelayer = nomeRandomico();
118 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 114 $def[] = array("ID","C","50");
123 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 120 $db = xbase_create($nomeshp.".dbf", $def);
125 121 xbase_close($db);
126 122 }
127   - else{
  123 + else
  124 + {
128 125 $db = dbase_create($nomeshp.".dbf", $def);
129 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 132 $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2);
132 133 $novoshpf->free();
133 134 if($tituloTema == "")
... ... @@ -365,11 +366,6 @@ $para - linha|poligono
365 366 */
366 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 369 if(!$this->layer){return "erro";}
374 370 $this->layer->set("template","none.htm");
375 371 $diretorio = dirname($this->arquivo);
... ... @@ -390,7 +386,17 @@ $para - linha|poligono
390 386 $temp = strtoupper($ni);
391 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 400 $dbname = $nomeshp.".dbf";
395 401 $reg = array();
396 402 $novoshpf = ms_newShapefileObj($nomeshp.".shp", $tipol);
... ... @@ -412,10 +418,18 @@ $para - linha|poligono
412 418 foreach ($items as $ni)
413 419 {$reg[] = "-";}
414 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 431 $novoshpf->free();
417 432 $this->layer->close();
418   - xbase_close($db);
419 433 //cria o novo layer
420 434 $layer = criaLayer($this->mapa,MS_LAYER_LINE,MS_DEFAULT,"",$metaClasse="SIM");
421 435 $layer->set("data",$nomeshp);
... ...