Commit 823e969417b1788c24fddd5b1d0653f89e38c77d

Authored by Edmar Moretti
1 parent 207c9f35

Nova ferramenta que permite converter wkt em shapefile ou feature e adiciona ao mapa como camada

classesjs/classe_mapa.js
... ... @@ -595,6 +595,22 @@ i3GEO.mapa =
595 595 * Abre as telas de dialogo das opcoes de manipulacao do mapa atual
596 596 */
597 597 dialogo : {
  598 + /**
  599 + * Function: wkt2layer
  600 + *
  601 + * Janela de conversao de wkt em layer.
  602 + */
  603 + wkt2layer: function(wkt){
  604 + var temp = function(wkt){
  605 + i3GEOF.wkt2layer.iniciaJanelaFlutuante(wkt);
  606 + };
  607 + i3GEO.util.dialogoFerramenta("i3GEO.mapa.dialogo.wkt2layer()","wkt2layer","wkt2layer","dependencias.php",temp);
  608 + },
  609 + /**
  610 + * Function: atalhosedicao
  611 + *
  612 + * Janela com as principais opcoes de edicao de um layer. Utilizado pelo sistema de administracao.
  613 + */
598 614 atalhosedicao: function(idtema){
599 615 i3GEO.mapa.ativaTema(idtema);
600 616 i3GEO.util.dialogoFerramenta("i3GEO.mapa.dialogo.atalhosedicao()","atalhosedicao","atalhosedicao","dependencias.php","i3GEOF.atalhosedicao.iniciaJanelaFlutuante()");
... ...
classesphp/classe_temas.php
... ... @@ -673,8 +673,10 @@ $tamanho - Tamanho do texto.
673 673 $fonte - Fonte
674 674  
675 675 $wrap - caractere que indica quebra de linha
  676 +
  677 +$wkt - boolean indicando se $xy e um WKT
676 678 */
677   - function insereFeature($marca,$tipo,$xy,$texto,$position,$partials,$offsetx,$offsety,$minfeaturesize,$mindistance,$force,$shadowcolor,$shadowsizex,$shadowsizey,$outlinecolor,$cor,$sombray,$sombrax,$sombra,$fundo,$angulo,$tamanho,$fonte,$wrap)
  679 + function insereFeature($marca,$tipo,$xy,$texto,$position,$partials,$offsetx,$offsety,$minfeaturesize,$mindistance,$force,$shadowcolor,$shadowsizex,$shadowsizey,$outlinecolor,$cor,$sombray,$sombrax,$sombra,$fundo,$angulo,$tamanho,$fonte,$wrap,$wkt=false)
678 680 {
679 681 //verifica se j'a existe um layer criado anteriormente com o mesmo nome e apaga se existir
680 682 if ($tipo == "limpaponto")
... ... @@ -747,7 +749,6 @@ $wrap - caractere que indica quebra de linha
747 749 break;
748 750 }
749 751 }
750   - $apt = explode(" ",$xy);
751 752 switch ($tipo)
752 753 {
753 754 case "ANNOTATION":
... ... @@ -766,10 +767,17 @@ $wrap - caractere que indica quebra de linha
766 767 $shp = ms_newshapeobj(MS_SHAPE_POLYGON);
767 768 break;
768 769 }
769   - $lin = ms_newlineobj();
770   - for ($i = 0;$i < count($apt); $i = $i + 2)
771   - {$lin->addxy($apt[$i],$apt[$i + 1]);}
772   - $shp->add($lin);
  770 + if($wkt == false){
  771 + $apt = explode(" ",$xy);
  772 + $lin = ms_newlineobj();
  773 + for ($i = 0;$i < count($apt); $i = $i + 2){
  774 + $lin->addxy($apt[$i],$apt[$i + 1]);
  775 + }
  776 + $shp->add($lin);
  777 + }
  778 + else{
  779 + $shp = ms_shapeObjFromWkt($xy);
  780 + }
773 781 $pinlayer->addfeature($shp);
774 782 //$shp->free();
775 783 return("ok");
... ...
ferramentas/wkt2layer/dependencias.php 0 → 100755
... ... @@ -0,0 +1,30 @@
  1 +<?php
  2 +/**
  3 + * Carrega os programas javascript necessarios para a ferramenta
  4 + * Esse programa e usado na tag <script> ou com a funcao scripttag do i3Geo
  5 + * Alem de carregar os scripts, carrega tambem o template no formato MUSTACHE, definindo a variavel
  6 + * javascript i3GEOF.wkt2layer.MUSTACHE
  7 + * O template e substituido pelos valores definidos em index.js no momento da inicializacao da ferramenta
  8 + */
  9 +if(extension_loaded('zlib')){
  10 + ob_start('ob_gzhandler');
  11 +}
  12 +header("Content-type: text/javascript");
  13 +include("index.js");
  14 +include("dicionario.js");
  15 +echo "\n";
  16 +/**
  17 + * Inclui o template mustache do HTML usado para criar o conteudo da janela
  18 + */
  19 +echo 'i3GEOF.wkt2layer.MUSTACHE = "';
  20 +$texto = file_get_contents("template_mst.html");
  21 +$texto = str_replace("\n", "", $texto);
  22 +$texto = str_replace("\r", "", $texto);
  23 +$texto = str_replace("\t", "", $texto);
  24 +$texto = str_replace('"', "'", $texto);
  25 +echo $texto;
  26 +echo '";';
  27 +if(extension_loaded('zlib')){
  28 + ob_end_flush();
  29 +}
  30 +?>
0 31 \ No newline at end of file
... ...
ferramentas/wkt2layer/dicionario.js 0 → 100755
... ... @@ -0,0 +1,23 @@
  1 +//+$trad(1,i3GEOF.wkt2layer.dicionario)+
  2 +i3GEOF.wkt2layer.dicionario = {
  3 + 'wkt2layer' : [ {
  4 + pt : "WKT como nova camada",
  5 + en : "",
  6 + es : ""
  7 + } ],
  8 + 'shapefile' : [ {
  9 + pt : "Exporta o WKT em shape file e insere como uma nova camada, permitindo o download dos dados. N&atilde;o permite que os dados sejam recuperados quando o mapa &eacute; salvo.",
  10 + en : "",
  11 + es : ""
  12 + } ],
  13 + 'feature' : [ {
  14 + pt : "Cria uma nova camada no mapa atual e insere os dados. Permite que os dados sejam salvos no mapa para abertura posterior.",
  15 + en : "",
  16 + es : ""
  17 + } ],
  18 + 'mensagem' : [ {
  19 + pt : "WKT vazio",
  20 + en : "",
  21 + es : ""
  22 + } ]
  23 +};
... ...
ferramentas/wkt2layer/index.js 0 → 100755
... ... @@ -0,0 +1,102 @@
  1 +if (typeof (i3GEOF) === 'undefined') {
  2 + var i3GEOF = {};
  3 +}
  4 +/*
  5 + * Classe: i3GEOF.wkt2layer
  6 + */
  7 +i3GEOF.wkt2layer =
  8 +{
  9 + /**
  10 + * Template no formato mustache. E preenchido na carga do javascript com o programa dependencias.php
  11 + */
  12 + MUSTACHE : "",
  13 + /**
  14 + * Susbtitutos para o template
  15 + */
  16 + mustacheHash : function(wkt) {
  17 + var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.wkt2layer.dicionario);
  18 + dicionario["locaplic"] = i3GEO.configura.locaplic;
  19 + dicionario["wkt"] = wkt;
  20 + return dicionario;
  21 + },
  22 + /*
  23 + * Function: inicia
  24 + *
  25 + * Inicia a ferramenta. &Eacute; chamado por criaJanelaFlutuante
  26 + *
  27 + * Parametro:
  28 + *
  29 + * iddiv {String} - id do div que receber&aacute; o conteudo HTML da ferramenta
  30 + */
  31 + inicia : function(iddiv,wkt) {
  32 + $i(iddiv).innerHTML = i3GEOF.wkt2layer.html(wkt);
  33 + new YAHOO.widget.Button("i3GEOFwkt2layerShp", {
  34 + onclick : {
  35 + fn : function() {
  36 + var wkt = $i("i3GEOFwkt2layerWkt").value;
  37 + if(wkt.length < 5){
  38 + i3GEO.janela.tempoMsg($trad("mensagem",i3GEOF.wkt2layer.dicionario));
  39 + }
  40 + }
  41 + }
  42 + });
  43 + new YAHOO.widget.Button("i3GEOFwkt2layerInterno", {
  44 + onclick : {
  45 + fn : function() {
  46 + var wkt = $i("i3GEOFwkt2layerWkt").value;
  47 + if(wkt.length < 5){
  48 + i3GEO.janela.tempoMsg($trad("mensagem",i3GEOF.wkt2layer.dicionario));
  49 + }
  50 + }
  51 + }
  52 + });
  53 + },
  54 + /*
  55 + * Function: html
  56 + *
  57 + * Gera o c&oacute;digo html para apresenta&ccedil;&atilde;o das op&ccedil;&otilde;es da ferramenta
  58 + *
  59 + * Retorno:
  60 + *
  61 + * String com o c&oacute;digo html
  62 + */
  63 + html : function(wkt) {
  64 + var ins = Mustache.render(i3GEOF.wkt2layer.MUSTACHE, i3GEOF.wkt2layer.mustacheHash(wkt));
  65 + return ins;
  66 + },
  67 + /*
  68 + * Function: criaJanelaFlutuante
  69 + *
  70 + * Cria a janela flutuante para controle da ferramenta.
  71 + */
  72 + iniciaJanelaFlutuante : function(wkt) {
  73 + var minimiza, cabecalho, janela, divid, temp, titulo;
  74 +
  75 + cabecalho = function() {
  76 + };
  77 + minimiza = function() {
  78 + i3GEO.janela.minimiza("i3GEOFwkt2layer");
  79 + };
  80 + // cria a janela flutuante
  81 + titulo = $trad("wkt2layer",i3GEOF.wkt2layer.dicionario);
  82 + janela =
  83 + i3GEO.janela.cria(
  84 + "280px",
  85 + "180px",
  86 + "",
  87 + "",
  88 + "",
  89 + titulo,
  90 + "i3GEOF.wkt2layer",
  91 + false,
  92 + "hd",
  93 + cabecalho,
  94 + minimiza,
  95 + "",
  96 + true
  97 + );
  98 + divid = janela[2].id;
  99 + $i("i3GEOF.wkt2layer_corpo").style.backgroundColor = "white";
  100 + i3GEOF.wkt2layer.inicia(divid,wkt);
  101 + }
  102 +};
... ...
ferramentas/wkt2layer/template_mst.html 0 → 100755
... ... @@ -0,0 +1,31 @@
  1 +<style>
  2 +.yui-button#i3GEOFwkt2layerShp button {
  3 + background: url('../imagens/gisicons/shape.png') 5% 50% no-repeat;
  4 + width: 200px;
  5 +}
  6 +
  7 +.yui-button#i3GEOFwkt2layerInterno button {
  8 + background: url('../imagens/gisicons/layer-vector-create.png') 5% 50%
  9 + no-repeat;
  10 + width: 200px;
  11 +}
  12 +</style>
  13 +<div style='margin-left: 5px'>
  14 + <p class='paragrafo'>
  15 + <b>WKT: </b>
  16 + </p>
  17 + <p class='paragrafo'>
  18 + <textarea id='i3GEOFwkt2layerWkt' cols='30' rows='3'>
  19 + {{{wkt}}} </textarea>
  20 + </p>
  21 + <p class='paragrafo'>{{{shapefile}}}</p>
  22 + <br>
  23 + <p class='paragrafo'>
  24 + <input id='i3GEOFwkt2layerShp' type='button' value='Shape File' />
  25 + </p>
  26 + <p class='paragrafo'>{{{feature}}}</p>
  27 + <br>
  28 + <p class='paragrafo'>
  29 + <input id='i3GEOFwkt2layerInterno' type='button' value='Feature' />
  30 + </p>
  31 +</div>
... ...
temas/testeraster.map 0 → 100755
... ... @@ -0,0 +1,78 @@
  1 +MAP
  2 + FONTSET "../symbols/fontes.txt"
  3 + SYMBOLSET "../symbols/simbolosv6.sym"
  4 + LAYER
  5 +
  6 +#DATA "PG:host=localhost port=5432 dbname='siss' user='postgres' password='postgres' schema='public' table='modelagem' mode='2'"
  7 +DATA "/var/www/rasters/modelagem_ED1_ok.tif"
  8 +#PROCESSING "NODATA=0"
  9 +PROCESSING "SCALE=AUTO"
  10 +PROCESSING "LOAD_WHOLE_IMAGE=YES"
  11 +PROCESSING "SCALE=0,100"
  12 + PROCESSING "SCALE_BUCKETS=10"
  13 +
  14 + METADATA
  15 + "METAESTAT_ID_MEDIDA_VARIAVEL" ""
  16 + "cache" ""
  17 + "CLASSE" "SIM"
  18 + "METAESTAT_CODIGO_TIPO_REGIAO" ""
  19 + "metaestat" ""
  20 + "convcaracter" ""
  21 + "TEMA" "Raster"
  22 + "cortepixels" "0"
  23 + END # METADATA
  24 + NAME "testeraster"
  25 + STATUS OFF
  26 + TEMPLATE "none.htm"
  27 + TYPE RASTER
  28 + UNITS METERS
  29 +
  30 + CLASS
  31 + NAME ">= 1 e < que 20"
  32 + EXPRESSION (([pixel]>=1)and([pixel]<20))
  33 + STYLE
  34 + COLOR 32 92 148
  35 + OUTLINECOLOR 255 255 255
  36 + END # STYLE
  37 + TITLE "testeraster+0"
  38 + END # CLASS
  39 + CLASS
  40 + NAME ">= 20 e < que 40"
  41 + EXPRESSION (([pixel]>=20)and([pixel]<40))
  42 + STYLE
  43 + COLOR 187 188 5
  44 + OUTLINECOLOR 255 255 255
  45 + END # STYLE
  46 + TITLE "testeraster+1"
  47 + END # CLASS
  48 + CLASS
  49 + NAME ">= 40 e < que 60"
  50 + EXPRESSION (([pixel]>=40)and([pixel]<60))
  51 + STYLE
  52 + COLOR 242 92 238
  53 + OUTLINECOLOR 255 255 255
  54 + END # STYLE
  55 + TITLE "testeraster+2"
  56 + END # CLASS
  57 + CLASS
  58 + NAME ">= 60 e < que 80"
  59 + EXPRESSION (([pixel]>=60)and([pixel]<80))
  60 + STYLE
  61 + COLOR 36 224 102
  62 + OUTLINECOLOR 255 255 255
  63 + END # STYLE
  64 + TITLE "testeraster+3"
  65 + END # CLASS
  66 + CLASS
  67 + NAME ">= 80 e < que 100"
  68 + EXPRESSION (([pixel]>=80)and([pixel]<=100))
  69 + STYLE
  70 + COLOR 55 187 122
  71 + OUTLINECOLOR 255 255 255
  72 + END # STYLE
  73 + TITLE "testeraster+4"
  74 + END # CLASS
  75 +
  76 + END # LAYER
  77 +
  78 +END # MAP
... ...