Commit c30565e25e1610ca22e5cdd043f0f19db17b974c
1 parent
76627213
Exists in
master
and in
7 other branches
Ajustes para funcionar no preview do editor de mapfiles
Showing
1 changed file
with
102 additions
and
99 deletions
Show diff stats
mashups/openlayers.php
| ... | ... | @@ -211,6 +211,10 @@ if($temas != ""){ |
| 211 | 211 | $visiveis = explode(",",$visiveis); |
| 212 | 212 | } |
| 213 | 213 | $objOpenLayers = array(); |
| 214 | + if(!isset($servidor)){ | |
| 215 | + $servidor = "../ogc.php"; | |
| 216 | + } | |
| 217 | + /* | |
| 214 | 218 | if(isset($servidor) && $servidor != "../ogc.php"){ |
| 215 | 219 | $layers = $temas; |
| 216 | 220 | foreach($temas as $tema){ |
| ... | ... | @@ -219,128 +223,127 @@ if($temas != ""){ |
| 219 | 223 | $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tema.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{isBaseLayer:false})'; |
| 220 | 224 | } |
| 221 | 225 | } |
| 222 | - else{ | |
| 223 | - foreach($temas as $tema){ | |
| 224 | - if(file_exists($locaplic."/temas/".$tema.".gvp")){ | |
| 225 | - include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); | |
| 226 | - $gm = new gvsig2mapfile($locaplic."/temas/".$tema.".gvp"); | |
| 227 | - $gvsigview = $gm->getViewsNames(); | |
| 228 | - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$gvsigview[0].'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{singleTile:false,visibility:true,isBaseLayer:false})'; | |
| 226 | + */ | |
| 227 | + foreach($temas as $tema){ | |
| 228 | + if(file_exists($locaplic."/temas/".$tema.".gvp")){ | |
| 229 | + include_once($locaplic."/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php"); | |
| 230 | + $gm = new gvsig2mapfile($locaplic."/temas/".$tema.".gvp"); | |
| 231 | + $gvsigview = $gm->getViewsNames(); | |
| 232 | + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$gvsigview[0].'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{layers:"'.$tema.'",transparent: "true", format: "image/png"},{singleTile:false,visibility:true,isBaseLayer:false})'; | |
| 233 | + } | |
| 234 | + else{ | |
| 235 | + $nomeMap = ""; | |
| 236 | + if(file_exists($locaplic."/temas/".$tema.".map")){ | |
| 237 | + $nomeMap = $locaplic."/temas/".$tema.".map"; | |
| 229 | 238 | } |
| 230 | 239 | else{ |
| 231 | - $nomeMap = ""; | |
| 232 | - if(file_exists($locaplic."/temas/".$tema.".map")){ | |
| 233 | - $nomeMap = $locaplic."/temas/".$tema.".map"; | |
| 240 | + if(file_exists($tema)){ | |
| 241 | + $nomeMap = $tema; | |
| 234 | 242 | } |
| 235 | 243 | else{ |
| 236 | - if(file_exists($tema)){ | |
| 237 | - $nomeMap = $tema; | |
| 244 | + // acontece caso o mapfile tenha sido gerado na pasta | |
| 245 | + // temporaria por algum sistema | |
| 246 | + if(file_exists($dir_tmp."/".$tema.".map")){ | |
| 247 | + $nomeMap = $dir_tmp."/".$tema.".map"; | |
| 238 | 248 | } |
| 239 | - else{ | |
| 240 | - // acontece caso o mapfile tenha sido gerado na pasta | |
| 241 | - // temporaria por algum sistema | |
| 242 | - if(file_exists($dir_tmp."/".$tema.".map")){ | |
| 243 | - $nomeMap = $dir_tmp."/".$tema.".map"; | |
| 249 | + } | |
| 250 | + } | |
| 251 | + if($nomeMap != ""){ | |
| 252 | + $layersNomes = array(); | |
| 253 | + $layers = array(); | |
| 254 | + $maptemp = @ms_newMapObj($nomeMap); | |
| 255 | + if($maptemp){ | |
| 256 | + $nlayers = $maptemp->numlayers; | |
| 257 | + for($i=0;$i<($nlayers);++$i) { | |
| 258 | + $layern = $maptemp->getLayer($i); | |
| 259 | + if($layern->getmetadata("PLUGINI3GEO") != ""){ | |
| 260 | + //obtem os dados necessarios para iniciar o plugin | |
| 261 | + $temasPluginI3Geo[] = array( | |
| 262 | + "name"=>$layern->name, | |
| 263 | + "tema"=>$layern->getmetadata("tema"), | |
| 264 | + "plugin"=>$layern->getmetadata("PLUGINI3GEO"), | |
| 265 | + "cache"=>strtoupper($layern->getmetadata("cache")), | |
| 266 | + "transitioneffect"=>strtoupper($layern->getmetadata("transitioneffect")) | |
| 267 | + ); | |
| 268 | + } | |
| 269 | + else{ | |
| 270 | + $layersNomes[] = $layern->name; | |
| 271 | + $layers[] = $layern; | |
| 244 | 272 | } |
| 245 | 273 | } |
| 246 | - } | |
| 247 | - if($nomeMap != ""){ | |
| 248 | - $layersNomes = array(); | |
| 249 | - $layers = array(); | |
| 250 | - $maptemp = @ms_newMapObj($nomeMap); | |
| 251 | - if($maptemp){ | |
| 252 | - $nlayers = $maptemp->numlayers; | |
| 253 | - for($i=0;$i<($nlayers);++$i) { | |
| 254 | - $layern = $maptemp->getLayer($i); | |
| 255 | - if($layern->getmetadata("PLUGINI3GEO") != ""){ | |
| 256 | - //obtem os dados necessarios para iniciar o plugin | |
| 257 | - $temasPluginI3Geo[] = array( | |
| 258 | - "name"=>$layern->name, | |
| 259 | - "tema"=>$layern->getmetadata("tema"), | |
| 260 | - "plugin"=>$layern->getmetadata("PLUGINI3GEO"), | |
| 261 | - "cache"=>strtoupper($layern->getmetadata("cache")), | |
| 262 | - "transitioneffect"=>strtoupper($layern->getmetadata("transitioneffect")) | |
| 263 | - ); | |
| 264 | - } | |
| 265 | - else{ | |
| 266 | - $layersNomes[] = $layern->name; | |
| 267 | - $layers[] = $layern; | |
| 268 | - } | |
| 274 | + $nomeLayer = implode(",",$layersNomes); | |
| 275 | + $tituloLayer = $layern->getmetadata("tema"); | |
| 276 | + $ebase = "false"; | |
| 277 | + if(isset($fundo) && $fundo != ""){ | |
| 278 | + if(in_array($tema,$fundo)){ | |
| 279 | + $ebase = "true"; | |
| 269 | 280 | } |
| 270 | - $nomeLayer = implode(",",$layersNomes); | |
| 271 | - $tituloLayer = $layern->getmetadata("tema"); | |
| 272 | - $ebase = "false"; | |
| 273 | - if(isset($fundo) && $fundo != ""){ | |
| 274 | - if(in_array($tema,$fundo)){ | |
| 275 | - $ebase = "true"; | |
| 276 | - } | |
| 281 | + } | |
| 282 | + $visivel = "false"; | |
| 283 | + if(in_array($tema,$visiveis)){ | |
| 284 | + $visivel = "true"; | |
| 285 | + } | |
| 286 | + if($nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM" && $layern->getmetadata("PLUGINI3GEO") == ""){ | |
| 287 | + if($layern->type != 2 && $layern->type != 3){ | |
| 288 | + $opacidade = 1; | |
| 289 | + } | |
| 290 | + // | |
| 291 | + //verifica se deve aplicar filtro | |
| 292 | + // | |
| 293 | + $filtro = $_GET["map_layer_".$layern->name."_filter"]; | |
| 294 | + if(!empty($filtro)){ | |
| 295 | + $DESLIGACACHE = "sim"; | |
| 296 | + $nocache = "map_layer_".$layern->name."_filter=".$filtro."&".$nocache; | |
| 277 | 297 | } |
| 278 | - $visivel = "false"; | |
| 279 | - if(in_array($tema,$visiveis)){ | |
| 280 | - $visivel = "true"; | |
| 298 | + $teffect = 'transitionEffect: "resize",'; | |
| 299 | + if(strtoupper($layern->getmetadata("transitioneffect")) == "NAO"){ | |
| 300 | + $teffect = 'transitionEffect: null,'; | |
| 281 | 301 | } |
| 282 | - if($nlayers == 1 && strtoupper($layern->getmetadata("cache")) == "SIM" && $layern->getmetadata("PLUGINI3GEO") == ""){ | |
| 283 | - if($layern->type != 2 && $layern->type != 3){ | |
| 302 | + // nesse caso o layer e adicionado como TMS | |
| 303 | + // tms leva os parametros do TMS | |
| 304 | + $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'",{'.$teffect.' tileOrigin: new OpenLayers.LonLat(-180, -90),opacity:'.$opacidade.',serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png"})'; | |
| 305 | + // cria um clone WMS para efeitos de getfeatureinfo | |
| 306 | + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{cloneTMS:"'.$nomeLayer.'",layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,transitionEffect : null,singleTile:true,visibility:false,isBaseLayer:false})'; | |
| 307 | + } | |
| 308 | + else{ | |
| 309 | + foreach($layers as $l){ | |
| 310 | + $singleTile = "false"; | |
| 311 | + if(strtoupper($l->getmetadata("TILES")) == "NAO"){ | |
| 312 | + $singleTile = "true"; | |
| 313 | + } | |
| 314 | + $tituloLayer = $l->getmetadata("tema"); | |
| 315 | + $nomeLayer = $l->name; | |
| 316 | + $visivel = "false"; | |
| 317 | + if($l->status == MS_DEFAULT || in_array($tema,$visiveis)){ | |
| 318 | + $visivel = "true"; | |
| 319 | + } | |
| 320 | + if($l->type != 2 && $l->type != 3){ | |
| 284 | 321 | $opacidade = 1; |
| 285 | 322 | } |
| 286 | 323 | // |
| 287 | 324 | //verifica se deve aplicar filtro |
| 288 | 325 | // |
| 289 | - $filtro = $_GET["map_layer_".$layern->name."_filter"]; | |
| 326 | + $filtro = $_GET["map_layer_".$l->name."_filter"]; | |
| 290 | 327 | if(!empty($filtro)){ |
| 291 | 328 | $DESLIGACACHE = "sim"; |
| 292 | - $nocache = "map_layer_".$layern->name."_filter=".$filtro."&".$nocache; | |
| 329 | + $nocache = "map_layer_".$l->name."_filter=".$filtro."&".$nocache; | |
| 293 | 330 | } |
| 294 | - $teffect = 'transitionEffect: "resize",'; | |
| 295 | - if(strtoupper($layern->getmetadata("transitioneffect")) == "NAO"){ | |
| 296 | - $teffect = 'transitionEffect: null,'; | |
| 331 | + $teffect = 'transitionEffect: "resize",'; | |
| 332 | + if(strtoupper($l->getmetadata("transitioneffect")) == "NAO"){ | |
| 333 | + $teffect = 'transitionEffect: null,'; | |
| 297 | 334 | } |
| 298 | - // nesse caso o layer e adicionado como TMS | |
| 299 | - // tms leva os parametros do TMS | |
| 300 | - $objOpenLayers[] = 'new OpenLayers.Layer.TMS("'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'",{'.$teffect.' tileOrigin: new OpenLayers.LonLat(-180, -90),opacity:'.$opacidade.',serviceVersion:"&tms=",visibility:'.$visivel.',isBaseLayer:'.$ebase.',layername:"'.$nomeLayer.'",type:"png"})'; | |
| 301 | - // cria um clone WMS para efeitos de getfeatureinfo | |
| 302 | - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{cloneTMS:"'.$nomeLayer.'",layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{displayInLayerSwitcher:false,transitionEffect : null,singleTile:true,visibility:false,isBaseLayer:false})'; | |
| 303 | - } | |
| 304 | - else{ | |
| 305 | - foreach($layers as $l){ | |
| 306 | - $singleTile = "false"; | |
| 307 | - if(strtoupper($l->getmetadata("TILES")) == "NAO"){ | |
| 308 | - $singleTile = "true"; | |
| 309 | - } | |
| 310 | - $tituloLayer = $l->getmetadata("tema"); | |
| 311 | - $nomeLayer = $l->name; | |
| 312 | - $visivel = "false"; | |
| 313 | - if($l->status == MS_DEFAULT || in_array($tema,$visiveis)){ | |
| 314 | - $visivel = "true"; | |
| 315 | - } | |
| 316 | - if($l->type != 2 && $l->type != 3){ | |
| 317 | - $opacidade = 1; | |
| 318 | - } | |
| 319 | - // | |
| 320 | - //verifica se deve aplicar filtro | |
| 321 | - // | |
| 322 | - $filtro = $_GET["map_layer_".$l->name."_filter"]; | |
| 323 | - if(!empty($filtro)){ | |
| 324 | - $DESLIGACACHE = "sim"; | |
| 325 | - $nocache = "map_layer_".$l->name."_filter=".$filtro."&".$nocache; | |
| 326 | - } | |
| 327 | - $teffect = 'transitionEffect: "resize",'; | |
| 328 | - if(strtoupper($l->getmetadata("transitioneffect")) == "NAO"){ | |
| 329 | - $teffect = 'transitionEffect: null,'; | |
| 330 | - } | |
| 331 | - if($tituloLayer != ""){ | |
| 332 | - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{'.$teffect.' singleTile:'.$singleTile.',visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; | |
| 333 | - } | |
| 334 | - else{ | |
| 335 | - $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "../ogc.php?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{'.$teffect.' displayInLayerSwitcher:false,singleTile:'.$singleTile.',visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; | |
| 336 | - } | |
| 335 | + if($tituloLayer != ""){ | |
| 336 | + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{'.$teffect.' singleTile:'.$singleTile.',visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; | |
| 337 | + } | |
| 338 | + else{ | |
| 339 | + $objOpenLayers[] = 'new OpenLayers.Layer.WMS( "'.$tituloLayer.'", "'.$servidor.'?'.$nocache.'tema='.$tema.'&DESLIGACACHE='.$DESLIGACACHE.'&",{opacity:'.$opacidade.',layers:"'.$nomeLayer.'",transparent: "true", format: "image/png"},{'.$teffect.' displayInLayerSwitcher:false,singleTile:'.$singleTile.',visibility:'.$visivel.',isBaseLayer:'.$ebase.'})'; | |
| 337 | 340 | } |
| 338 | 341 | } |
| 339 | 342 | } |
| 340 | 343 | } |
| 341 | - else{ | |
| 342 | - echo $tema." não foi encontrado.<br>"; | |
| 343 | - } | |
| 344 | + } | |
| 345 | + else{ | |
| 346 | + echo $tema." não foi encontrado.<br>"; | |
| 344 | 347 | } |
| 345 | 348 | } |
| 346 | 349 | } | ... | ... |