Commit f565b5b512c3fa2457fb9e4c516af4ca0646f2ab
1 parent
745a043c
Exists in
master
and in
7 other branches
Inclusão do parâmetro wkt
Showing
1 changed file
with
84 additions
and
9 deletions
Show diff stats
ms_criamapa.php
| ... | ... | @@ -75,21 +75,16 @@ poligonos - lista de coordenadas x e y que serão adicionadas como polígonos no m |
| 75 | 75 | |
| 76 | 76 | nometemapoligonos - nome do tema de polígonos |
| 77 | 77 | |
| 78 | +wkt - insere elementos no mapa com coordenadas definidas em wkt | |
| 79 | + | |
| 80 | +nometemawkt - nome do tema em wkt | |
| 81 | + | |
| 78 | 82 | debug - ativa o retorno de mensagens de erro do PHP sim|nao |
| 79 | 83 | */ |
| 80 | 84 | /* |
| 81 | 85 | Section: Fluxo do código |
| 82 | 86 | */ |
| 83 | -/* | |
| 84 | -Note: Verifica a variável $debug | |
| 85 | - | |
| 86 | -Verifica se o debug deve ser ativado, checando a variável $debug | |
| 87 | -*/ | |
| 88 | 87 | $tempo = microtime(1); |
| 89 | -if (!isset($debug)) | |
| 90 | -{error_reporting(0);$debug="nao";} | |
| 91 | -else | |
| 92 | -{error_reporting(E_ALL);$debug="sim";} | |
| 93 | 88 | /* |
| 94 | 89 | Note: Verifica a variável $caminho |
| 95 | 90 | |
| ... | ... | @@ -118,6 +113,11 @@ Inclui os programas php com funções utilizadas pelo ms_criamapa.php |
| 118 | 113 | require_once ($caminho."classesphp/pega_variaveis.php"); |
| 119 | 114 | require_once ($caminho."classesphp/funcoes_gerais.php"); |
| 120 | 115 | require_once ($caminho."ms_configura.php"); |
| 116 | + | |
| 117 | +if (!isset($debug)) | |
| 118 | +{error_reporting(0);$debug="nao";} | |
| 119 | +else | |
| 120 | +{error_reporting(E_ALL);$debug="sim";} | |
| 121 | 121 | /* |
| 122 | 122 | Note: Prepara as variáveis que serão incluidas na seção |
| 123 | 123 | |
| ... | ... | @@ -379,6 +379,15 @@ ms_ResetErrorList(); |
| 379 | 379 | /* |
| 380 | 380 | Note: Inclui uma camada de pontos utilizando os parâmetros passados pela URL |
| 381 | 381 | */ |
| 382 | +if (isset($wkt)) | |
| 383 | +{insereWKTUrl();} | |
| 384 | +$error = ms_GetErrorObj(); | |
| 385 | +while($error && $error->code != MS_NOERR) | |
| 386 | +{ | |
| 387 | + printf("<br>Error in %s: %s<br>\n", $error->routine, $error->message); | |
| 388 | + $error = $error->next(); | |
| 389 | +} | |
| 390 | +ms_ResetErrorList(); | |
| 382 | 391 | if (isset($pontos)) |
| 383 | 392 | {inserePontosUrl();} |
| 384 | 393 | $error = ms_GetErrorObj(); |
| ... | ... | @@ -625,6 +634,72 @@ function mostraAguarde() |
| 625 | 634 | } |
| 626 | 635 | } |
| 627 | 636 | /* |
| 637 | +Function: insereWKTUrl | |
| 638 | + | |
| 639 | +Insere elementos no mapa a partir de uma string definida em wkt | |
| 640 | +*/ | |
| 641 | +function insereWKTUrl() | |
| 642 | +{ | |
| 643 | + global $wkt,$nometemawkt,$dir_tmp,$imgdir,$tmpfname,$locaplic; | |
| 644 | + require_once "pacotes/phpxbase/api_conversion.php"; | |
| 645 | + if (!isset($nometemapontos)) | |
| 646 | + {$nometemapontos="WKT";} | |
| 647 | + if ($nometemapontos == "") | |
| 648 | + {$nometemapontos="WKT";} | |
| 649 | + // | |
| 650 | + //cria o shape file | |
| 651 | + // | |
| 652 | + $shape = ms_shapeObjFromWkt($wkt); | |
| 653 | + $tipol = $shape->type; | |
| 654 | + if($tipol == 0){$tipol = 3;} | |
| 655 | + $nomeshp = $dir_tmp."/".$imgdir."/wkts"; | |
| 656 | + // cria o dbf | |
| 657 | + $def = array(); | |
| 658 | + $items = array("COORD"); | |
| 659 | + foreach ($items as $ni) | |
| 660 | + {$def[] = array($ni,"C","254");} | |
| 661 | + xbase_create($nomeshp.".dbf", $def); | |
| 662 | + $dbname = $nomeshp.".dbf"; | |
| 663 | + $db=xbase_open($dbname,2); | |
| 664 | + if ($tipol == 1) | |
| 665 | + {$novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_ARC);} | |
| 666 | + if ($tipol == 3) | |
| 667 | + {$novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_MULTIPOINT);} | |
| 668 | + if ($tipol == 2) | |
| 669 | + {$novoshpf = ms_newShapefileObj($nomeshp, MS_SHP_POLYGON);} | |
| 670 | + $reg[] = ""; | |
| 671 | + $novoshpf->addShape($shape); | |
| 672 | + xbase_add_record($db,$reg); | |
| 673 | + $novoshpf->free(); | |
| 674 | + xbase_close($db); | |
| 675 | + //adiciona o layer | |
| 676 | + $mapa = ms_newMapObj($tmpfname); | |
| 677 | + $layer = ms_newLayerObj($mapa); | |
| 678 | + $layer->set("name","wktins"); | |
| 679 | + $layer->set("data",$nomeshp); | |
| 680 | + $layer->setmetadata("tema",$nometemawkt); | |
| 681 | + $layer->setmetadata("classe","sim"); | |
| 682 | + $layer->set("type",$shape->type); | |
| 683 | + $layer->set("status",MS_DEFAULT); | |
| 684 | + $classe = ms_newClassObj($layer); | |
| 685 | + $estilo = ms_newStyleObj($classe); | |
| 686 | + if($shape->type == 0) | |
| 687 | + { | |
| 688 | + $estilo->set("symbolname","ponto"); | |
| 689 | + $estilo->set("size",6); | |
| 690 | + } | |
| 691 | + if($shape->type == 1) | |
| 692 | + { | |
| 693 | + $estilo->set("symbolname","linha"); | |
| 694 | + $estilo->set("size",3); | |
| 695 | + } | |
| 696 | + if($shape->type == 2) | |
| 697 | + {$layer->set("transparency","50");} | |
| 698 | + $cor = $estilo->color; | |
| 699 | + $cor->setRGB(255,0,0); | |
| 700 | + $salvo = $mapa->save($tmpfname); | |
| 701 | +} | |
| 702 | +/* | |
| 628 | 703 | Function: inserePontosUrl |
| 629 | 704 | |
| 630 | 705 | Insere um novo tema com os pontos definidos na variável $pontos | ... | ... |