Commit 0c4f6bda0581cc5351ddb67a641ba5a443ac865d

Authored by Edmar Moretti
1 parent 42e2d92d

--no commit message

classesjs/classe_editorol.js
  1 +/*
  2 +Title: Editor vetorial para OpenLayers
  3 +
  4 +i3GEO.editorOL
  5 +
  6 +Funções utilizadas pelo OpenLayers nas opções de edição de dados vetoriais.
  7 +É utilizado também pelo mashup com navegação via OpenLayers e com OSM.
  8 +
  9 +Arquivo: i3geo/classesjs/classe_editorol.js
  10 +
  11 +Licença:
  12 +
  13 +GPL2
  14 +
  15 +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
  16 +
  17 +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
  18 +Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
  19 +
  20 +Este programa é software livre; você pode redistribuí-lo
  21 +e/ou modificá-lo sob os termos da Licença Pública Geral
  22 +GNU conforme publicada pela Free Software Foundation;
  23 +
  24 +Este programa é distribuído na expectativa de que seja útil,
  25 +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
  26 +de COMERCIABILIDADE OU ADEQUACAtilde;O A UMA FINALIDADE ESPECÍFICA.
  27 +Consulte a Licença Pública Geral do GNU para mais detalhes.
  28 +Você deve ter recebido uma cópia da Licença Pública Geral do
  29 +GNU junto com este programa; se não, escreva para a
  30 +Free Software Foundation, Inc., no endereço
  31 +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  32 +*/
  33 +
1 34 if(!i3GEO || typeof(i3GEO) === 'undefined'){
2 35 var i3GEO = {
3 36 };
... ... @@ -246,7 +279,8 @@ i3GEO.editorOL = {
246 279 });
247 280 }
248 281 if(i3GEO.editorOL.mapext != ""){
249   - i3GEO.editorOL.mapa.zoomToExtent(i3GEO.editorOL.mapext);
  282 + var m = i3GEO.util.extGeo2OSM(i3GEO.editorOL.mapext);
  283 + i3GEO.editorOL.mapa.zoomToExtent(m);
250 284 }
251 285 else{
252 286 i3GEO.editorOL.mapa.zoomToMaxExtent();
... ... @@ -325,6 +359,7 @@ i3GEO.editorOL = {
325 359 {p = e.xy;}
326 360 //altera o indicador de localizacao
327 361 lonlat = i3GEO.editorOL.mapa.getLonLatFromPixel(p);
  362 + lonlat = i3GEO.util.projOSM2Geo(lonlat);
328 363 d = i3GEO.calculo.dd2dms(lonlat.lon,lonlat.lat);
329 364 try{
330 365 $i(idcoord[0].id).innerHTML = "Long: "+d[0]+"<br>Lat: "+d[1];
... ... @@ -1447,7 +1482,8 @@ i3GEO.editorOL = {
1447 1482 adicionaMarcas: function(){
1448 1483 if(i3GEO.editorOL.pontos.length === 0)
1449 1484 {return;}
1450   - var SHADOW_Z_INDEX = 10,
  1485 + var f,
  1486 + SHADOW_Z_INDEX = 10,
1451 1487 MARKER_Z_INDEX = 11,
1452 1488 layer = new OpenLayers.Layer.Vector(
1453 1489 "pontos",
... ... @@ -1476,10 +1512,13 @@ i3GEO.editorOL = {
1476 1512 y.push(i3GEO.editorOL.pontos[index+1]);
1477 1513 }
1478 1514 for (index = 0; index < x.length; index++) {
  1515 + f = new OpenLayers.Geometry.Point(x[index], y[index]);
  1516 + f = i3GEO.util.projGeo2OSM(f);
  1517 + f = new OpenLayers.Feature.Vector(
  1518 + f
  1519 + );
1479 1520 features.push(
1480   - new OpenLayers.Feature.Vector(
1481   - new OpenLayers.Geometry.Point(x[index], y[index])
1482   - )
  1521 + f
1483 1522 );
1484 1523 }
1485 1524 layer.addFeatures(features);
... ...
classesjs/classe_util.js
... ... @@ -2952,23 +2952,32 @@ i3GEO.util = {
2952 2952 Converte string 'xmin ymin xmax ymax' ou 'xmin ymin' de geo para a projecao OSM
2953 2953 */
2954 2954 extGeo2OSM: function(ext,retornaArray){
  2955 + var metrica,point,proj900913,projWGS84,temp,sep;
  2956 + sep = " ";
  2957 + if(typeof ext == "object"){
  2958 + return i3GEO.util.projGeo2OSM(ext);
  2959 + }
2955 2960 if(i3GEO.Interface.openlayers.googleLike === true){
2956   - var metrica,point,proj900913,projWGS84,temp = ext.split(" ");
  2961 + temp = ext.split(sep);
  2962 + if(temp === 1){
  2963 + sep = ",";
  2964 + temp = ext.split(sep);
  2965 + }
2957 2966 if(temp[0]*1 <= 180 && temp[0]*1 >= -180){
2958 2967 projWGS84 = new OpenLayers.Projection("EPSG:4326");
2959 2968 proj900913 = new OpenLayers.Projection("EPSG:900913");
2960 2969 point = new OpenLayers.LonLat(temp[0], temp[1]);
2961 2970 metrica = point.transform(projWGS84,proj900913);
2962   - ext = metrica.lon+" "+metrica.lat;
  2971 + ext = metrica.lon+sep+metrica.lat;
2963 2972 if(temp.length > 2){
2964 2973 point = new OpenLayers.LonLat(temp[2], temp[3]);
2965 2974 metrica = point.transform(projWGS84,proj900913);
2966   - ext += " "+metrica.lon+" "+metrica.lat;
  2975 + ext += sep+metrica.lon+sep+metrica.lat;
2967 2976 }
2968 2977 }
2969 2978 }
2970 2979 if(retornaArray){
2971   - return ext.split(" ");
  2980 + return ext.split(sep);
2972 2981 }
2973 2982 else{
2974 2983 return ext;
... ... @@ -2980,23 +2989,32 @@ i3GEO.util = {
2980 2989 Converte string 'xmin ymin xmax ymax' ou 'xmin ymin' de geo para a projecao OSM
2981 2990 */
2982 2991 extOSM2Geo: function(ext,retornaArray){
  2992 + var metrica,point,proj900913,projWGS84,temp,sep;
  2993 + sep = " ";
  2994 + if(typeof ext == "object"){
  2995 + return i3GEO.util.projOSM2Geo(ext);
  2996 + }
2983 2997 if(i3GEO.Interface.openlayers.googleLike === true){
2984   - var metrica,point,proj900913,projWGS84,temp = ext.split(" ");
  2998 + temp = ext.split(sep);
  2999 + if(temp === 1){
  3000 + sep = ",";
  3001 + temp = ext.split(sep);
  3002 + }
2985 3003 if(temp[0]*1 >= 180 || temp[0]*1 <= -180){
2986 3004 projWGS84 = new OpenLayers.Projection("EPSG:4326");
2987 3005 proj900913 = new OpenLayers.Projection("EPSG:900913");
2988 3006 point = new OpenLayers.LonLat(temp[0], temp[1]);
2989 3007 metrica = point.transform(proj900913,projWGS84);
2990   - ext = metrica.lon+" "+metrica.lat;
  3008 + ext = metrica.lon+sep+metrica.lat;
2991 3009 if(temp.length > 2){
2992 3010 point = new OpenLayers.LonLat(temp[2], temp[3]);
2993 3011 metrica = point.transform(proj900913,projWGS84);
2994   - ext += " "+metrica.lon+" "+metrica.lat;
  3012 + ext += sep+metrica.lon+sep+metrica.lat;
2995 3013 }
2996 3014 }
2997 3015 }
2998 3016 if(retornaArray){
2999   - return ext.split(" ");
  3017 + return ext.split(sep);
3000 3018 }
3001 3019 else{
3002 3020 return ext;
... ... @@ -3016,6 +3034,19 @@ i3GEO.util = {
3016 3034 return obj;
3017 3035 },
3018 3036 /*
  3037 + Function: projGeo2OSM
  3038 +
  3039 + Projeta um objeto OpenLayers de GEO para OSM
  3040 + */
  3041 + projGeo2OSM: function(obj){
  3042 + if(i3GEO.Interface.openlayers.googleLike === true){
  3043 + projWGS84 = new OpenLayers.Projection("EPSG:4326");
  3044 + proj900913 = new OpenLayers.Projection("EPSG:900913");
  3045 + obj = obj.transform(projWGS84,proj900913);
  3046 + }
  3047 + return obj;
  3048 + },
  3049 + /*
3019 3050 Function: navegadorDir
3020 3051  
3021 3052 Abre o navegador de arquivos localizados no servidor
... ...
mashups/index.html
... ... @@ -70,8 +70,13 @@ body,td {
70 70 </fieldset>
71 71 <fieldset>
72 72 <p>
73   - Duas camadas mas com apenas uma vis&iacute;vel na inicializa&ccedil;&atilde;o do mapa <a target=_blank
74   - href="openlayers.php?temas=_wbiomashp,_lbiomashp,_wlocali,_llocali&largura=800&altura=500&visiveis=_wbiomashp,_lbiomashp">openlayers.php?temas=_wbiomashp,_lbiomashp,locali&amp;largura=800&amp;altura=500&amp;visiveis=_wbiomashp,_lbiomashp</a>
  73 + Duas camadas mas com apenas uma vis&iacute;vel na inicializa&ccedil;&atilde;o do mapa
  74 + </p>
  75 + <p class="m">
  76 + Windows: <a target=_blank href="openlayers.php?temas=_wbiomashp,_wlocali&largura=800&altura=500&visiveis=_wbiomashp">openlayers.php?temas=_wbiomashp,_wlocali&amp;largura=800&amp;altura=500&amp;visiveis=_wbiomashp</a>
  77 + </p>
  78 + <p class="m">
  79 + Linux: <a target=_blank href="openlayers.php?temas=_lbiomashp,_llocali&largura=800&altura=500&visiveis=_lbiomashp">openlayers.php?temas=_lbiomashp,_llocali&amp;largura=800&amp;altura=500&amp;visiveis=_lbiomashp</a>
75 80 </p>
76 81 </fieldset>
77 82 <fieldset>
... ...
mashups/openlayers.php
... ... @@ -271,8 +271,7 @@ if($temas != &quot;&quot;){
271 271 }
272 272 }
273 273 $visivel = "false";
274   - if(in_array($tema,$visiveis))
275   - {
  274 + if(in_array($tema,$visiveis)){
276 275 $visivel = "true";
277 276 }
278 277 // echo $visivel;exit;
... ... @@ -285,16 +284,11 @@ if($temas != &quot;&quot;){
285 284 $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{cloneTMS:"'.$nomeLayer.'",layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,singleTile:true,visibility:false,isBaseLayer:false})';
286 285 }
287 286 else{
288   - // $objOpenLayers[] = 'new OpenLayers.Layer.WMS(
289   - // "'.$tituloLayer.'",
290   - // "../ogc.php?tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent:
291   - // "true", format:
292   - // "image/png"},{singleTile:true,visibility:'.$visivel.',isBaseLayer:'.$ebase.'})';
293 287 foreach($layers as $l){
294 288 $tituloLayer = $l->getmetadata("tema");
295 289 $nomeLayer = $l->name;
296 290 $visivel = "false";
297   - if($l->status == MS_DEFAULT || $nlayers == 1){
  291 + if($l->status == MS_DEFAULT || in_array($tema,$visiveis)){
298 292 $visivel = "true";
299 293 }
300 294 if($tituloLayer != ""){
... ...
mashups/osm.php
... ... @@ -289,7 +289,7 @@ if($temas != &quot;&quot;){
289 289 $tituloLayer = $l->getmetadata("tema");
290 290 $nomeLayer = $l->name;
291 291 $visivel = "false";
292   - if($l->status == MS_DEFAULT || $nlayers == 1){
  292 + if($l->status == MS_DEFAULT || in_array($tema,$visiveis)){
293 293 $visivel = "true";
294 294 }
295 295 if($tituloLayer != ""){
... ... @@ -397,18 +397,18 @@ function ajuda(){
397 397 <head>
398 398 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
399 399  
400   -<script type="text/javascript" src="openlayers_compacto.js.php"></script>
401   -<!-- para debug
  400 +<!--<script type="text/javascript" src="openlayers_compacto.js.php"></script>-->
  401 +<!-- para debug -->
402 402 <script type="text/javascript" src="../pacotes/yui290/build/yahoo-dom-event/yahoo-dom-event.js"></script>
403 403 <script type="text/javascript" src="../pacotes/yui290/build/dragdrop/dragdrop-min.js"></script>
404 404 <script type="text/javascript" src="../pacotes/yui290/build/container/container-min.js"></script>
405 405 <script type="text/javascript" src="../classesjs/compactados/classe_calculo_compacto.js"></script>
406   -<script type="text/javascript" src="../classesjs/compactados/classe_util_compacto.js"></script>
  406 +<script type="text/javascript" src="../classesjs/classe_util.js"></script>
407 407 <script type="text/javascript" src="../classesjs/compactados/classe_janela_compacto.js"></script>
408 408 <script type="text/javascript" src="../pacotes/openlayers/OpenLayers2131.js"></script>
409 409 <script type="text/javascript" src="../classesjs/compactados/classe_desenho_compacto.js"></script>
410 410 <script type="text/javascript" src="../classesjs/classe_editorol.js"></script>
411   --->
  411 +
412 412 <?php
413 413 //carrega o script para layers do tipo plugin
414 414 if(count($temasPluginI3Geo) > 0){
... ... @@ -532,16 +532,17 @@ if(isset($mapext)){
532 532 }
533 533 else{
534 534 echo "i3GEO.editorOL.mapext = new OpenLayers.Bounds('-15125970.651191 -5205055.877383 15125970.651191 5205055.877383');\n";
535   -}
  535 +}
536 536 if(empty($fundo)){
537 537 // echo "i3GEO.editorOL.mapa.allOverlays = true;";
538 538 }
539 539 ?>
  540 +i3GEO.Interface = {openlayers:{googleLike:true}};
540 541 i3GEO.editorOL.fundo = "osm";
541 542  
542 543 var temp = i3GEO.editorOL.minresolution,
543 544 r = [ i3GEO.editorOL.minresolution ];
544   -for (j = 0; j < (i3GEO.editorOL.numzoom - 1); j++) {
  545 +for (var j = 0; j < (i3GEO.editorOL.numzoom - 1); j++) {
545 546 temp = temp / 2;
546 547 r.push(temp);
547 548 }
... ... @@ -562,7 +563,7 @@ i3GEO.editorOL.inicia();
562 563 if(!i3GEO.configura){
563 564 i3GEO.configura = {"locaplic": "../"};
564 565 }
565   -i3GEO.Interface = {openlayers:{googleLike:true}};
  566 +
566 567 <?php
567 568 //camadas plugin
568 569  
... ...