diff --git a/classesjs/classe_mapa.js b/classesjs/classe_mapa.js index 96b3f9e..3b2cb56 100644 --- a/classesjs/classe_mapa.js +++ b/classesjs/classe_mapa.js @@ -595,6 +595,22 @@ i3GEO.mapa = * Abre as telas de dialogo das opcoes de manipulacao do mapa atual */ dialogo : { + /** + * Function: wkt2layer + * + * Janela de conversao de wkt em layer. + */ + wkt2layer: function(wkt){ + var temp = function(wkt){ + i3GEOF.wkt2layer.iniciaJanelaFlutuante(wkt); + }; + i3GEO.util.dialogoFerramenta("i3GEO.mapa.dialogo.wkt2layer()","wkt2layer","wkt2layer","dependencias.php",temp); + }, + /** + * Function: atalhosedicao + * + * Janela com as principais opcoes de edicao de um layer. Utilizado pelo sistema de administracao. + */ atalhosedicao: function(idtema){ i3GEO.mapa.ativaTema(idtema); i3GEO.util.dialogoFerramenta("i3GEO.mapa.dialogo.atalhosedicao()","atalhosedicao","atalhosedicao","dependencias.php","i3GEOF.atalhosedicao.iniciaJanelaFlutuante()"); diff --git a/classesphp/classe_temas.php b/classesphp/classe_temas.php index e7f4630..c0a5844 100644 --- a/classesphp/classe_temas.php +++ b/classesphp/classe_temas.php @@ -673,8 +673,10 @@ $tamanho - Tamanho do texto. $fonte - Fonte $wrap - caractere que indica quebra de linha + +$wkt - boolean indicando se $xy e um WKT */ - 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) + 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) { //verifica se j'a existe um layer criado anteriormente com o mesmo nome e apaga se existir if ($tipo == "limpaponto") @@ -747,7 +749,6 @@ $wrap - caractere que indica quebra de linha break; } } - $apt = explode(" ",$xy); switch ($tipo) { case "ANNOTATION": @@ -766,10 +767,17 @@ $wrap - caractere que indica quebra de linha $shp = ms_newshapeobj(MS_SHAPE_POLYGON); break; } - $lin = ms_newlineobj(); - for ($i = 0;$i < count($apt); $i = $i + 2) - {$lin->addxy($apt[$i],$apt[$i + 1]);} - $shp->add($lin); + if($wkt == false){ + $apt = explode(" ",$xy); + $lin = ms_newlineobj(); + for ($i = 0;$i < count($apt); $i = $i + 2){ + $lin->addxy($apt[$i],$apt[$i + 1]); + } + $shp->add($lin); + } + else{ + $shp = ms_shapeObjFromWkt($xy); + } $pinlayer->addfeature($shp); //$shp->free(); return("ok"); diff --git a/ferramentas/wkt2layer/dependencias.php b/ferramentas/wkt2layer/dependencias.php new file mode 100755 index 0000000..071eddc --- /dev/null +++ b/ferramentas/wkt2layer/dependencias.php @@ -0,0 +1,30 @@ + ou com a funcao scripttag do i3Geo + * Alem de carregar os scripts, carrega tambem o template no formato MUSTACHE, definindo a variavel + * javascript i3GEOF.wkt2layer.MUSTACHE + * O template e substituido pelos valores definidos em index.js no momento da inicializacao da ferramenta + */ +if(extension_loaded('zlib')){ + ob_start('ob_gzhandler'); +} +header("Content-type: text/javascript"); +include("index.js"); +include("dicionario.js"); +echo "\n"; +/** + * Inclui o template mustache do HTML usado para criar o conteudo da janela + */ +echo 'i3GEOF.wkt2layer.MUSTACHE = "'; +$texto = file_get_contents("template_mst.html"); +$texto = str_replace("\n", "", $texto); +$texto = str_replace("\r", "", $texto); +$texto = str_replace("\t", "", $texto); +$texto = str_replace('"', "'", $texto); +echo $texto; +echo '";'; +if(extension_loaded('zlib')){ + ob_end_flush(); +} +?> \ No newline at end of file diff --git a/ferramentas/wkt2layer/dicionario.js b/ferramentas/wkt2layer/dicionario.js new file mode 100755 index 0000000..8158a6e --- /dev/null +++ b/ferramentas/wkt2layer/dicionario.js @@ -0,0 +1,23 @@ +//+$trad(1,i3GEOF.wkt2layer.dicionario)+ +i3GEOF.wkt2layer.dicionario = { + 'wkt2layer' : [ { + pt : "WKT como nova camada", + en : "", + es : "" + } ], + 'shapefile' : [ { + pt : "Exporta o WKT em shape file e insere como uma nova camada, permitindo o download dos dados. Não permite que os dados sejam recuperados quando o mapa é salvo.", + en : "", + es : "" + } ], + 'feature' : [ { + pt : "Cria uma nova camada no mapa atual e insere os dados. Permite que os dados sejam salvos no mapa para abertura posterior.", + en : "", + es : "" + } ], + 'mensagem' : [ { + pt : "WKT vazio", + en : "", + es : "" + } ] +}; diff --git a/ferramentas/wkt2layer/index.js b/ferramentas/wkt2layer/index.js new file mode 100755 index 0000000..118b943 --- /dev/null +++ b/ferramentas/wkt2layer/index.js @@ -0,0 +1,102 @@ +if (typeof (i3GEOF) === 'undefined') { + var i3GEOF = {}; +} +/* + * Classe: i3GEOF.wkt2layer + */ +i3GEOF.wkt2layer = +{ + /** + * Template no formato mustache. E preenchido na carga do javascript com o programa dependencias.php + */ + MUSTACHE : "", + /** + * Susbtitutos para o template + */ + mustacheHash : function(wkt) { + var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.wkt2layer.dicionario); + dicionario["locaplic"] = i3GEO.configura.locaplic; + dicionario["wkt"] = wkt; + return dicionario; + }, + /* + * Function: inicia + * + * Inicia a ferramenta. É chamado por criaJanelaFlutuante + * + * Parametro: + * + * iddiv {String} - id do div que receberá o conteudo HTML da ferramenta + */ + inicia : function(iddiv,wkt) { + $i(iddiv).innerHTML = i3GEOF.wkt2layer.html(wkt); + new YAHOO.widget.Button("i3GEOFwkt2layerShp", { + onclick : { + fn : function() { + var wkt = $i("i3GEOFwkt2layerWkt").value; + if(wkt.length < 5){ + i3GEO.janela.tempoMsg($trad("mensagem",i3GEOF.wkt2layer.dicionario)); + } + } + } + }); + new YAHOO.widget.Button("i3GEOFwkt2layerInterno", { + onclick : { + fn : function() { + var wkt = $i("i3GEOFwkt2layerWkt").value; + if(wkt.length < 5){ + i3GEO.janela.tempoMsg($trad("mensagem",i3GEOF.wkt2layer.dicionario)); + } + } + } + }); + }, + /* + * Function: html + * + * Gera o código html para apresentação das opções da ferramenta + * + * Retorno: + * + * String com o código html + */ + html : function(wkt) { + var ins = Mustache.render(i3GEOF.wkt2layer.MUSTACHE, i3GEOF.wkt2layer.mustacheHash(wkt)); + return ins; + }, + /* + * Function: criaJanelaFlutuante + * + * Cria a janela flutuante para controle da ferramenta. + */ + iniciaJanelaFlutuante : function(wkt) { + var minimiza, cabecalho, janela, divid, temp, titulo; + + cabecalho = function() { + }; + minimiza = function() { + i3GEO.janela.minimiza("i3GEOFwkt2layer"); + }; + // cria a janela flutuante + titulo = $trad("wkt2layer",i3GEOF.wkt2layer.dicionario); + janela = + i3GEO.janela.cria( + "280px", + "180px", + "", + "", + "", + titulo, + "i3GEOF.wkt2layer", + false, + "hd", + cabecalho, + minimiza, + "", + true + ); + divid = janela[2].id; + $i("i3GEOF.wkt2layer_corpo").style.backgroundColor = "white"; + i3GEOF.wkt2layer.inicia(divid,wkt); + } +}; diff --git a/ferramentas/wkt2layer/template_mst.html b/ferramentas/wkt2layer/template_mst.html new file mode 100755 index 0000000..2efd643 --- /dev/null +++ b/ferramentas/wkt2layer/template_mst.html @@ -0,0 +1,31 @@ + +
+

+ WKT: +

+

+ +

+

{{{shapefile}}}

+
+

+ +

+

{{{feature}}}

+
+

+ +

+
diff --git a/temas/testeraster.map b/temas/testeraster.map new file mode 100755 index 0000000..ec64b93 --- /dev/null +++ b/temas/testeraster.map @@ -0,0 +1,78 @@ +MAP + FONTSET "../symbols/fontes.txt" + SYMBOLSET "../symbols/simbolosv6.sym" + LAYER + +#DATA "PG:host=localhost port=5432 dbname='siss' user='postgres' password='postgres' schema='public' table='modelagem' mode='2'" +DATA "/var/www/rasters/modelagem_ED1_ok.tif" +#PROCESSING "NODATA=0" +PROCESSING "SCALE=AUTO" +PROCESSING "LOAD_WHOLE_IMAGE=YES" +PROCESSING "SCALE=0,100" + PROCESSING "SCALE_BUCKETS=10" + + METADATA + "METAESTAT_ID_MEDIDA_VARIAVEL" "" + "cache" "" + "CLASSE" "SIM" + "METAESTAT_CODIGO_TIPO_REGIAO" "" + "metaestat" "" + "convcaracter" "" + "TEMA" "Raster" + "cortepixels" "0" + END # METADATA + NAME "testeraster" + STATUS OFF + TEMPLATE "none.htm" + TYPE RASTER + UNITS METERS + + CLASS + NAME ">= 1 e < que 20" + EXPRESSION (([pixel]>=1)and([pixel]<20)) + STYLE + COLOR 32 92 148 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "testeraster+0" + END # CLASS + CLASS + NAME ">= 20 e < que 40" + EXPRESSION (([pixel]>=20)and([pixel]<40)) + STYLE + COLOR 187 188 5 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "testeraster+1" + END # CLASS + CLASS + NAME ">= 40 e < que 60" + EXPRESSION (([pixel]>=40)and([pixel]<60)) + STYLE + COLOR 242 92 238 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "testeraster+2" + END # CLASS + CLASS + NAME ">= 60 e < que 80" + EXPRESSION (([pixel]>=60)and([pixel]<80)) + STYLE + COLOR 36 224 102 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "testeraster+3" + END # CLASS + CLASS + NAME ">= 80 e < que 100" + EXPRESSION (([pixel]>=80)and([pixel]<=100)) + STYLE + COLOR 55 187 122 + OUTLINECOLOR 255 255 255 + END # STYLE + TITLE "testeraster+4" + END # CLASS + + END # LAYER + +END # MAP -- libgit2 0.21.2