Commit 51c4251337f0c63b21924a976458b64b49b7dde9

Authored by Edmar Moretti
1 parent 079f9da3

Opção para escolher os símbolos de uma lista e desativação de elementos de formu…

…lário conforme contexto de outros elementos
admin/js/core.js
... ... @@ -1215,6 +1215,20 @@ function core_abreCor(janela,elemento)
1215 1215 $i("i3geo_janelaCori").style.height = "290px";
1216 1216 //i3GEO.janela.cria("350px","250px","../../ferramentas/colorpicker/index.htm?doc=&elemento="+elemento+"&tipo=rgb","","","Cor","i3geo_janelaCor",true);
1217 1217 }
  1218 +function core_desativaforms(lista){
  1219 + var n = lista.length,
  1220 + i;
  1221 + for (i=0;i<n;i++){
  1222 + $i(lista[i]).style.background = "pink";
  1223 + }
  1224 +}
  1225 +function core_ativaforms(lista){
  1226 + var n = lista.length,
  1227 + i;
  1228 + for (i=0;i<n;i++){
  1229 + $i(lista[i]).style.background = "white";
  1230 + }
  1231 +}
1218 1232 //
1219 1233 //carregador de javascript
1220 1234 //
... ...
admin/js/editormapfile.js
... ... @@ -43,7 +43,6 @@ objcontype = [
43 43 {texto:"MS_ORACLESPATIAL",valor:"8"},
44 44 {texto:"MS_WFS",valor:"9"},
45 45 {texto:"MS_GRATICULE",valor:"10"},
46   - {texto:"MS_MYGIS",valor:"11"},
47 46 {texto:"MS_RASTER",valor:"12"},
48 47 {texto:"MS_PLUGIN",valor:"13"}
49 48 ];
... ... @@ -884,7 +883,7 @@ Abre o editor de conexões
884 883 */
885 884 function editorConexao(codigoMap,codigoLayer)
886 885 {
887   - core_montaEditor("","600px","500px")
  886 + core_montaEditor("","450px","650px")
888 887 var sUrl = "../php/editormapfile.php?funcao=pegaConexao&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer;
889 888 core_pegaDados("Obtendo dados...",sUrl,"montaEditorConexao")
890 889 }
... ... @@ -897,7 +896,7 @@ Abre o editor de metadados
897 896 */
898 897 function editorMetadados(codigoMap,codigoLayer)
899 898 {
900   - core_montaEditor("","600px","500px")
  899 + core_montaEditor("","450px","500px")
901 900 var sUrl = "../php/editormapfile.php?funcao=pegaMetadados&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer;
902 901 core_pegaDados("Obtendo dados...",sUrl,"montaEditorMetadados")
903 902 }
... ... @@ -910,7 +909,7 @@ Abre o editor de dados gerais de um layer
910 909 */
911 910 function editorGeral(codigoMap,codigoLayer)
912 911 {
913   - core_montaEditor("","600px","500px")
  912 + core_montaEditor("","450px","500px")
914 913 var sUrl = "../php/editormapfile.php?funcao=pegaGeral&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer;
915 914 core_pegaDados("Obtendo dados...",sUrl,"montaEditorGeral")
916 915 }
... ... @@ -923,7 +922,7 @@ Abre o editor de dados gerais de uma classe
923 922 */
924 923 function editorClasseGeral(codigoMap,codigoLayer,indiceClasse)
925 924 {
926   - core_montaEditor("","600px","500px")
  925 + core_montaEditor("","450px","500px")
927 926 var sUrl = "../php/editormapfile.php?funcao=pegaClasseGeral&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer+"&indiceClasse="+indiceClasse;
928 927 core_pegaDados("Obtendo dados...",sUrl,"montaEditorClasseGeral")
929 928 }
... ... @@ -936,7 +935,7 @@ Abre o editor dos labels de um layer
936 935 */
937 936 function editorClasseLabel(codigoMap,codigoLayer,indiceClasse)
938 937 {
939   - core_montaEditor("","600px","500px")
  938 + core_montaEditor("","450px","500px")
940 939 var sUrl = "../php/editormapfile.php?funcao=pegaClasseLabel&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer+"&indiceClasse="+indiceClasse;
941 940 core_pegaDados("Obtendo dados...",sUrl,"montaEditorClasseLabel")
942 941 }
... ... @@ -949,12 +948,13 @@ Abre o editor de dados gerais de um estilo
949 948 */
950 949 function editorEstilo(codigoMap,codigoLayer,indiceClasse,indiceEstilo)
951 950 {
952   - core_montaEditor("","600px","500px")
  951 + core_montaEditor("","450px","500px")
953 952 var sUrl = "../php/editormapfile.php?funcao=pegaEstilo&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer+"&indiceClasse="+indiceClasse+"&indiceEstilo="+indiceEstilo;
954 953 core_pegaDados("Obtendo dados...",sUrl,"montaEditorEstilo")
955 954 }
956 955 function montaEditorConexao(dados)
957 956 {
  957 + var idsForms = ["connection","data","tileitem","tileindex","type"];
958 958 var param = {
959 959 "linhas":[
960 960 {ajuda:"Type of connection. Default is local.",
... ... @@ -963,6 +963,8 @@ function montaEditorConexao(dados)
963 963 titulo:"Connection",id:"connection",value:dados.connection,tipo:"text"},
964 964 {ajuda:"Full filename of the spatial data to process. No file extension is necessary for shapefiles. Can be specified relative to the SHAPEPATH option from the Map Object.If this is an SDE layer, the parameter should include the name of the layer as well as the geometry column, i.e. 'mylayer,shape,myversion'.If this is a PostGIS layer, the parameter should be in the form of '<columnname> from <tablename>', where 'columnname' is the name of the column containing the geometry objects and 'tablename' is the name of the table from which the geometry data will be read.For Oracle, use 'shape FROM table' or 'shape FROM (SELECT statement)' or even more complex Oracle compliant queries! Note that there are important performance impacts when using spatial subqueries however. Try using MapServer's FILTER whenever possible instead. You can also see the SQL submitted by forcing an error, for instance by submitting a DATA parameter you know won't work, using for example a bad column name. Exemplo postgis: the_geom FROM (select * FROM biomas) as foo USING UNIQUE gid USING SRID=4291 . Exemplo shapefile: c://ms4w/Apache/htdocs/geodados/brasil/limitespol/localidades.shp",
965 965 titulo:"Data",id:"data",value:dados.data,tipo:"text"},
  966 + {ajuda:"Specifies how the data should be drawn. Need not be the same as the shapefile type. For example, a polygon shapefile may be drawn as a point layer, but a point shapefile may not be drawn as a polygon layer. Common sense rules. Annotation means that a label point will be calculated for the features, but the feature itself will not be drawn although a marker symbol can be optionally drawn. this allows for advanced labeling like numbered highway shields. Points are labeled at that point. Polygons are labeled first using a centroid, and if that doesn't fall in the polygon a scanline approach is used to guarantee the label falls within the feature. Lines are labeled at the middle of the longest arc in the visible portion of the line. Query only means the layer can be queried but not drawn.In order to differentiate between POLYGONs and POLYLINEs (which do not exist as a type), simply respectively use or ommit the COLOR keyword when classifying. If you use it, it's a polygon with a fill color, otherwise it's a polyline with only an OUTLINECOLOR.For CHART layers, see the Dynamic Charting howto.A circle must be defined by a a minimum bounding rectangle. That is, 2 points that define the smallest square that can contain it. These 2 points are the two opposite corners of said box",
  967 + titulo:"Type",id:"",value:dados.type,tipo:"text",div:"<div id=cType ></div>"},
966 968 {ajuda:"Item that contains the location of an individual tile, default is 'location'.",
967 969 titulo:"tileitem",id:"tileitem",value:dados.tileitem,tipo:"text"},
968 970 {ajuda:"Name of the tileindex file or layer. A tileindex is similar to an ArcInfo library index. The tileindex contains polygon features for each tile. The item that contains the location of the tiled data is given using the TILEITEM parameter. When a file is used as the tileindex for shapefile or raster layers, the tileindex should be a shapefile. For CONNECTIONTYPE OGR layers, any OGR supported datasource can be a tileindex. Normally the location should contain the path to the tile file relative to the shapepath, not relative to the tileindex itself. If the DATA parameter contains a value then it is added to the end of the location. When a tileindex layer is used, it works similarly to directly referring to a file, but any supported feature source can be used (ie. postgres, oracle).NOTE: All files in the tileindex should have the same coordinate system, and for vector files the same set of attributes in the same order.",
... ... @@ -970,20 +972,29 @@ function montaEditorConexao(dados)
970 972 ]
971 973 }
972 974 var ins = "<input type=button title='Salvar' value='Salvar' id=salvarEditor />"
  975 + ins += "&nbsp;<input type=button title='Testar' value='Testar' id=testarEditor />"
  976 +
973 977 if(dados.postgis_mapa.length > 0)
974 978 {
975   - ins += "<p>Os seguintes 'alias' estão disponíveis para uso na opção 'connection': ";
976   - ins += dados.postgis_mapa+"</p>"
  979 + ins += "<p>Os seguintes 'alias' estão definidos no metadata 'ITENS': ";
  980 + ins += dados.postgis_mapa;
  981 + ins += "<br>Os campos em cores não são compatíveis com o tipo de conexão.</p>";
977 982 }
978   - ins += "<input type=button title='Testar' value='Testar' id=testarEditor />"
979 983 ins += core_geraLinhas(param)
980 984 ins += "<br><br><br>"
981 985 $i("editor_bd").innerHTML = ins
  986 +
982 987 temp = "<select id='connectiontype' >"
983 988 temp += core_comboObjeto(objcontype,"valor","texto",dados.connectiontype)
984 989 temp += "</select>"
985 990 $i("cConnectiontype").innerHTML = temp
986   -
  991 +
  992 + temp = "<select id='type' >"
  993 + temp += core_comboObjeto(objlayertypes,"valor","texto",dados.type)
  994 + temp += "</select>"
  995 + $i("cType").innerHTML = temp
  996 +
  997 +
987 998 var temp = function()
988 999 {salvarDadosEditor('conexao',dados.codigoMap,dados.codigoLayer,false)}
989 1000 new YAHOO.widget.Button("salvarEditor",{ onclick: { fn: temp }});
... ... @@ -991,6 +1002,27 @@ function montaEditorConexao(dados)
991 1002 var temp = function()
992 1003 {salvarDadosEditor('conexao',dados.codigoMap,dados.codigoLayer,"","",true)}
993 1004 new YAHOO.widget.Button("testarEditor",{ onclick: { fn: temp }});
  1005 + core_desativaforms(idsForms);
  1006 + $i("connectiontype").onchange = function(){
  1007 + core_desativaforms(idsForms);
  1008 + var valor = $i("connectiontype").value,
  1009 + d = [];
  1010 + //["connection","data","tileitem","tileindex"]
  1011 + if(valor == 0 || valor == 10)
  1012 + {d = [];}
  1013 + if(valor == 1 || valor == 12)
  1014 + {d = ["data","type"];}
  1015 + if(valor == 2)
  1016 + {d = ["tileitem","tileindex","type"];}
  1017 + if(valor == 3 || valor == 4 || valor == 6 || valor == 8 || valor == 13)
  1018 + {d = idsForms;}
  1019 + if(valor == 5)
  1020 + {d = ["connection","tileitem","tileindex","type"];}
  1021 + if(valor == 7 || valor == 9)
  1022 + {d = ["connection","type"];}
  1023 + core_ativaforms(d);
  1024 + };
  1025 + $i("connectiontype").onchange.call();
994 1026 }
995 1027 function montaEditorMetadados(dados)
996 1028 {
... ... @@ -1169,10 +1201,12 @@ function montaEditorGeral(dados)
1169 1201 temp += core_comboObjeto(objstatus,"valor","texto",dados.status)
1170 1202 temp += "</select>"
1171 1203 $i("cStatus").innerHTML = temp
  1204 +
1172 1205 temp = "<select id='type' >"
1173 1206 temp += core_comboObjeto(objlayertypes,"valor","texto",dados.type)
1174 1207 temp += "</select>"
1175   - $i("cType").innerHTML = temp
  1208 + $i("cType").innerHTML = temp
  1209 +
1176 1210 temp = "<select id='sizeunits' >"
1177 1211 temp += core_comboObjeto(objmapunits,"valor","texto",dados.sizeunits)
1178 1212 temp += "</select>"
... ... @@ -1315,7 +1349,7 @@ function montaEditorClasseLabel(dados)
1315 1349 temp += core_comboObjeto(objfonttypes,"valor","texto",dados.type)
1316 1350 temp += "</select>"
1317 1351 $i("cType").innerHTML = temp
1318   -
  1352 +
1319 1353 temp = "<select id='partials' >"
1320 1354 temp += core_comboObjeto(objbool_tf,"valor","texto",dados.partials)
1321 1355 temp += "</select>"
... ... @@ -1340,11 +1374,11 @@ function montaEditorEstilo(dados)
1340 1374 var param = {
1341 1375 "linhas":[
1342 1376 {ajuda:"The symbol name or number to use for all features if attribute tables are not used. The number is the index of the symbol in the symbol file, starting at 1, the 5th symbol in the file is therefore symbol number 5. You can also give your symbols names using the NAME keyword in the symbol definition file, and use those to refer to them. Default is 0, which results in a single pixel, single width line, or solid polygon fill, depending on layer type.You can also specify a gif or png filename. The path is relative to the location of the mapfile.",
1343   - titulo:"Symbolname",id:"symbolname",value:dados.symbolname,tipo:"text"},
  1377 + titulo:"Symbolname",id:"",value:dados.symbolname,tipo:"text",div:"<div id=cSymbolname ></div>"},
1344 1378 {ajuda:"Color to use for drawing features.",
1345 1379 titulo:"Color",id:"color",value:dados.color,tipo:"cor"},
1346 1380 {ajuda:"Background-color to use for drawing features.",
1347   - titulo:"Backgroundcolo",id:"backgroundcolor",value:dados.backgroundcolor,tipo:"cor"},
  1381 + titulo:"Backgroundcolor",id:"backgroundcolor",value:dados.backgroundcolor,tipo:"cor"},
1348 1382 {ajuda:"Height, in pixels, of the symbol/pattern to be used. Only useful with scalable symbols. Default is 1. For symbols of Type HATCH, the SIZE is the distance between hatched lines. For its use with hatched lines, see Example#8 in the SYMBOL examples.",
1349 1383 titulo:"Size",id:"size",value:dados.size,tipo:"text"},
1350 1384 {ajuda:"Color to use for outlining polygons and certain marker symbols. Line symbols do not support outline colors.",
... ... @@ -1374,9 +1408,33 @@ function montaEditorEstilo(dados)
1374 1408 ins += "<br><br><br>"
1375 1409 $i("editor_bd").innerHTML = ins
1376 1410  
  1411 + temp = "<input type='text' value='"+dados.symbolname+"' id='symbolname' size='50'>";
  1412 + temp += "<div id='listaSimbolos' style='overflow:auto;width:400px;height:50px;'></div>";
  1413 + $i("cSymbolname").innerHTML = temp
  1414 +
1377 1415 var temp = function()
1378 1416 {salvarDadosEditor('estilo',dados.codigoMap,dados.codigoLayer,dados.indiceClasse,dados.indiceEstilo)}
1379   - new YAHOO.widget.Button("salvarEditor",{ onclick: { fn: temp }});
  1417 + new YAHOO.widget.Button("salvarEditor",{ onclick: { fn: temp }});
  1418 +
  1419 + escolheSimbolo = function(nome){
  1420 + $i("symbolname").value = nome;
  1421 + };
  1422 + //lista os simbolos
  1423 + var sUrl = "../php/editormapfile.php?funcao=editasimbolo&tipo="+dados.type+"&opcao=listaSimbolos&onclick=escolheSimbolo(this.title)";
  1424 + var callback =
  1425 + {
  1426 + success:function(o)
  1427 + {
  1428 + try
  1429 + {
  1430 + $i("listaSimbolos").innerHTML = o.responseText;
  1431 + }
  1432 + catch(e){}
  1433 + },
  1434 + failure:core_handleFailure,
  1435 + argument: { foo:"foo", bar:"bar" }
  1436 + };
  1437 + core_makeRequest(sUrl,callback,'POST')
1380 1438 }
1381 1439 /*
1382 1440 Function: salvarDadosEditor
... ... @@ -1398,7 +1456,7 @@ function salvarDadosEditor(tipo,codigoMap,codigoLayer,indiceClasse,indiceEstilo,
1398 1456 if(arguments.length < 6){var testar = false;}
1399 1457 if(tipo == "conexao")
1400 1458 {
1401   - var campos = new Array("connection","data","connectiontype","tileitem","tileindex")
  1459 + var campos = new Array("type","connection","data","connectiontype","tileitem","tileindex")
1402 1460 var par = "&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer
1403 1461 var prog = "../php/editormapfile.php?funcao=alterarConexao"
1404 1462 }
... ... @@ -1462,8 +1520,8 @@ function salvarDadosEditor(tipo,codigoMap,codigoLayer,indiceClasse,indiceEstilo,
1462 1520 }
1463 1521 prog += "&testar="+testar;
1464 1522 try{
1465   - for (i=0;i<campos.length;i++)
1466   - {par += "&"+campos[i]+"="+($i(campos[i]).value)}
  1523 + for (i=0;i<campos.length;i++)
  1524 + {par += "&"+campos[i]+"="+($i(campos[i]).value)}
1467 1525 }catch(e){alert(e)}
1468 1526 core_carregando("ativa");
1469 1527 core_carregando(" gravando o registro do layer= "+codigoLayer);
... ...
admin/php/editormapfile.php
... ... @@ -77,6 +77,31 @@ switch (strtoupper($funcao))
77 77 exit;
78 78 break;
79 79 /*
  80 + Valor: EDITASIMBOLO
  81 +
  82 + Lista os símbolos de um determinado tipo
  83 +
  84 + Parametros:
  85 +
  86 + tipo {string} - tipo de layer
  87 +
  88 + onclick {string} - função javascript que será executada ao se clicar no símbilo
  89 +
  90 + Retorno:
  91 +
  92 + {JSON}
  93 + */
  94 + case "EDITASIMBOLO":
  95 + include_once("../../classesphp/classe_legenda.php");
  96 + if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN'))
  97 + {$map_file = $locaplic."/aplicmap/geral1windows.map";}
  98 + else
  99 + {$map_file = $locaplic."/aplicmap/geral1.map";}
  100 + $m = new Legenda($map_file,$locaplic);
  101 + retornaJSON($m->listaSimbolos($tipo,$dir_tmp,"",$onclick));
  102 + exit;
  103 + break;
  104 + /*
80 105 Valor: PEGALAYERS
81 106  
82 107 Lista os layers existentes em um mapfile
... ... @@ -471,6 +496,8 @@ switch (strtoupper($funcao))
471 496  
472 497 tileindex
473 498  
  499 + type
  500 +
474 501 Retorno:
475 502  
476 503 {JSON}
... ... @@ -1112,11 +1139,12 @@ function pegaConexao()
1112 1139 $dados["postgis_mapa"] = $postgis_mapa;
1113 1140 $dados["codigoMap"] = $codigoMap;
1114 1141 $dados["codigoLayer"] = $codigoLayer;
  1142 + $dados["type"] = $layer->type;
1115 1143 return $dados;
1116 1144 }
1117 1145 function alterarConexao()
1118 1146 {
1119   - global $dir_tmp,$testar,$codigoMap,$codigoLayer,$locaplic,$connection,$connectiontype,$data,$tileitem,$tileindex;
  1147 + global $type,$dir_tmp,$testar,$codigoMap,$codigoLayer,$locaplic,$connection,$connectiontype,$data,$tileitem,$tileindex;
1120 1148 $mapfile = $locaplic."/temas/".$codigoMap.".map";
1121 1149 $mapa = ms_newMapObj($mapfile);
1122 1150 $layer = $mapa->getlayerbyname($codigoLayer);
... ... @@ -1128,6 +1156,7 @@ function alterarConexao()
1128 1156 $layer->set("data",$data);
1129 1157 $layer->set("tileitem",$tileitem);
1130 1158 $layer->set("tileindex",$tileindex);
  1159 + $layer->set("type",$type);
1131 1160 if($testar == "true")
1132 1161 {
1133 1162 $nome = $dir_tmp."/".$codigoMap.".map";
... ... @@ -1509,6 +1538,7 @@ function pegaEstilo()
1509 1538 $dados["indiceClasse"] = $indiceClasse;
1510 1539 $dados["indiceEstilo"] = $indiceEstilo;
1511 1540 //$dados["opacity"] = $estilo->opacity;
  1541 + $dados["type"] = $layer->type;
1512 1542 return $dados;
1513 1543 }
1514 1544 function alterarEstilo()
... ...