Commit 9afefac0664274f28619f447e8f6b1b8148452d1

Authored by Edmar Moretti
1 parent 8ae9b14a
Exists in master and in 1 other branch unmaintened

Alteração nos parâmetros de geração de arquivos KML na ferramenta OGC

aplicmap/ogcwsv7.map
... ... @@ -47,6 +47,7 @@ MAP
47 47 FORMATOPTION "STORAGE=memory"
48 48 IMAGEMODE FEATURE
49 49 END
  50 +
50 51 OUTPUTFORMAT
51 52 NAME "geojson"
52 53 DRIVER "OGR/GEOJSON"
... ...
ms_configura.php
... ... @@ -314,7 +314,7 @@ Variable: $ogrOutput
314 314  
315 315 Indica se o OGR esta corretamente instalado, permitindo o seu uso nos servicos OGC de exportacao de dados
316 316 */
317   -$ogrOutput = true;
  317 +$ogrOutput = false;
318 318 /*
319 319 Variable: saikuUrl
320 320  
... ...
ogc.php
... ... @@ -262,11 +262,11 @@ ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo
262 262  
263 263 ";
264 264 exit;
265   -}
266   -
  265 +}
267 266 include(dirname(__FILE__)."/classesphp/sani_request.php");
268 267 include_once (dirname(__FILE__)."/classesphp/carrega_ext.php");
269 268 include(dirname(__FILE__)."/ms_configura.php");
  269 +error_reporting(0);
270 270 $_GET = array_merge($_GET,$_POST);
271 271 //error_log($_SERVER['QUERY_STRING']);
272 272 if(isset($_GET["BBOX"])){
... ... @@ -417,6 +417,9 @@ if(strpos(strtolower($OUTPUTFORMAT),"kml") !== false){
417 417 if(strpos(strtolower($OUTPUTFORMAT),"kmz") !== false){
418 418 $OUTPUTFORMAT = "kmz";
419 419 }
  420 +if(strpos(strtolower($OUTPUTFORMAT),"kmlwms") !== false){
  421 + $OUTPUTFORMAT = "kmlwms";
  422 +}
420 423 //
421 424 //verifica o OUTPUTFORMAT e o cache de arquivo
422 425 //
... ... @@ -428,16 +431,21 @@ if(!empty($OUTPUTFORMAT)){
428 431 //para o caso da requisicao kmz
429 432 //kmz nao funciona diretamente com mapserver
430 433 //
431   -if(strtolower($OUTPUTFORMAT) == "kmz"){
  434 +if(strtolower($OUTPUTFORMAT) == "kmz" && $ogrOutput == false){
432 435 $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema;
433 436 header("Location:".$urln);
434 437 exit;
435 438 }
436 439 if(strtolower($OUTPUTFORMAT) == "kml" && $ogrOutput == false){
437   - $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema;
  440 + $urln = "pacotes/kmlmapserver/kmlservice.php?request=kml&map=".$tema."&typename=".$tema;
438 441 header("Location:".$urln);
439 442 exit;
440 443 }
  444 +if(strtolower($OUTPUTFORMAT) == "kmlwms"){
  445 + $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmlwms&map=".$tema."&typename=".$tema;
  446 + header("Location:".$urln);
  447 + exit;
  448 +}
441 449 if(strtolower($OUTPUTFORMAT) == "shape-zip" && $ogrOutput == false){
442 450 $retorno = downloadTema2("",$tema,$locaplic,$dir_tmp,$postgis_mapa);
443 451 $zip = $retorno["shape-zip"];
... ... @@ -1543,6 +1551,14 @@ function processaOutputformatMapfile(){
1543 1551 $oMap->outputformat->setOption("FILENAME", $tema.".kml");
1544 1552 $l->setmetadata("wfs_getfeature_formatlist","kml");
1545 1553 }
  1554 + if(strtolower($OUTPUTFORMAT) == "kmz"){
  1555 + $l = $oMap->getlayer(0);
  1556 + $n = $l->name;
  1557 + $oMap->selectOutputFormat("kmz");
  1558 + $oMap->outputformat->setOption("STORAGE", "filesystem");
  1559 + $oMap->outputformat->setOption("FILENAME", $tema.".kmz");
  1560 + $l->setmetadata("wfs_getfeature_formatlist","kmz");
  1561 + }
1546 1562 if(strtolower($OUTPUTFORMAT) == "shape-zip"){
1547 1563 $l = $oMap->getlayer(0);
1548 1564 $n = $l->name;
... ...
ogc/dicionario.js
... ... @@ -52,14 +52,19 @@ ogc.dicionario =
52 52 es : "Descargar CSV a través de WFS pero sin geometría"
53 53 }],
54 54 "kmz" : [{
55   - pt : "Download KMZ",
  55 + pt : "Download KMZ (KML vetorial compactado)",
56 56 en : "Download KMZ",
57 57 es : "Descargar KMZ"
58 58 }],
  59 + "kmlwms" : [{
  60 + pt : "Download KML (com WMS embutido)",
  61 + en : "",
  62 + es : ""
  63 + }],
59 64 "kml" : [{
60   - pt : "Download KML",
61   - en : "Download KML",
62   - es : "Descargar KML"
  65 + pt : "Download KML (vetorial)",
  66 + en : "",
  67 + es : ""
63 68 }],
64 69 "explore" : [{
65 70 pt : "Explore a tabela de atributos",
... ...
ogc/templates/templatelinksdownload.php
... ... @@ -7,6 +7,7 @@
7 7 <p><a target=blank href="{{{servico}}}OUTPUTFORMAT=csv&bbox={{mapext}}&service=wfs&version=1.1.0&request=getfeature&layers={{{tema}}}&typeName={{{tema}}}&ows_geomtype=AS_WKT" >{{{downCgeo}}}</a>
8 8 <p><a target=blank href="{{{servico}}}OUTPUTFORMAT=csv&bbox={{mapext}}&service=wfs&version=1.1.0&request=getfeature&layers={{{tema}}}&typeName={{{tema}}}&ows_geomtype=none" >{{{downSgeo}}}</a>
9 9 <p><a target=blank href="{{{servico}}}OUTPUTFORMAT=kmz&bbox={{mapext}}&service=wfs&version=1.1.0&request=getfeature&layers={{{tema}}}&typeName={{{tema}}}" >{{{kmz}}}</a>
  10 +<p><a target=blank href="{{{servico}}}OUTPUTFORMAT=kmlwms&bbox={{mapext}}&service=wfs&version=1.1.0&request=getfeature&layers={{{tema}}}&typeName={{{tema}}}" >{{{kmlwms}}}</a>
10 11 <p><a target=blank href="{{{servico}}}OUTPUTFORMAT=kml&bbox={{mapext}}&service=wfs&version=1.1.0&request=getfeature&layers={{{tema}}}&typeName={{{tema}}}" >{{{kml}}}</a>
11 12 <p><a target=blank href="{{{servico}}}OUTPUTFORMAT=geojson&bbox={{mapext}}&service=wfs&version=1.1.0&request=getfeature&layers={{{tema}}}&typeName={{{tema}}}" >GeoJson</a>
12 13 <p><a target=blank href="{{{urli3geo}}}/ferramentas/recline/default.php?tema={{{tema}}}" >{{{explore}}}</a>
... ...
pacotes/kmlmapserver/classes/kmlserver.class.php
... ... @@ -70,6 +70,7 @@ class KmlServer {
70 70 $this->service->run();
71 71 } else {
72 72 include 'layerserver.class.php';
  73 + error_reporting(0);
73 74 $this->service = new LayerServer();
74 75 $this->service->run();
75 76 }
... ... @@ -81,7 +82,10 @@ class KmlServer {
81 82 function get_request(){
82 83 $this->service = $this->load_parm('service');
83 84 if(!$this->service){
84   - $this->service= 'kml';
  85 + $this->service= $this->load_parm('request');
  86 + }
  87 + if(!$this->service){
  88 + $this->service= "kml";
85 89 }
86 90 }
87 91  
... ...
pacotes/kmlmapserver/classes/layerserver.class.php
... ... @@ -153,7 +153,7 @@ class LayerServer
153 153 * wether folder should contain networklinks instead of real geometries
154 154 * it is automatically set when all layers are requested
155 155 */
156   - var $_networklink;
  156 + var $_networklink = false;
157 157 var $postgis_mapa;
158 158  
159 159 /**
... ... @@ -191,8 +191,6 @@ class LayerServer
191 191 if (! $this->typename) {
192 192 $this->_networklink = true;
193 193 $this->typename = $this->get_layer_list();
194   - } else {
195   - $this->_networklink = false;
196 194 }
197 195 if ($this->_networklink == false) {
198 196 // desliga todos os layers
... ... @@ -276,6 +274,11 @@ class LayerServer
276 274 $this->request = $this->load_parm('request', 'kml');
277 275 if ($this->request == 'kmz') {
278 276 $this->_zipped = true;
  277 + } else {
  278 + $this->_zipped = false;
  279 + }
  280 + if($this->request == "kmlwms"){
  281 + $this->_networklink = true;
279 282 }
280 283 if (! $this->map) {
281 284 $this->set_error('No mapfile specified');
... ... @@ -325,7 +328,6 @@ class LayerServer
325 328 }
326 329 } else {
327 330 foreach ($layers as $layer) {
328   - // echo "Oi";exit;
329 331 $this->process_layer_request($layer);
330 332 }
331 333 }
... ... @@ -684,6 +686,9 @@ class LayerServer
684 686 {
685 687 $ml = $element->addChild('MultiGeometry');
686 688 foreach (split('\), \(', $wkt) as $line) {
  689 + //$line = str_replace("MULTIPOLYGON (","POLYGON ",$line).")";
  690 + $line = str_replace(array("MULTIPOLYGON",")","("),"",$line);
  691 + //$line = "POLYGON ((".$line."))";
687 692 $this->add_polygon($line, $ml, $featurename);
688 693 }
689 694 }
... ... @@ -1107,7 +1112,7 @@ class LayerServer
1107 1112 for ($i = 0; $i < ($maptemp->numlayers); $i ++) {
1108 1113 $l = $maptemp->getlayer($i);
1109 1114 $l->set("status", MS_DEFAULT);
1110   - if (! $this->_zipped) {
  1115 + if ($this->_networklink == true || $l->type == MS_LAYER_RASTER ) {
1111 1116 $l->set("type", MS_LAYER_RASTER);
1112 1117 $l->setmetadata('wms_onlineresource', "../../ogc.php?tema=" . $temp . "&width=1500&height=1500&TRANSPARENT=true&FORMAT=image/png&");
1113 1118 $l->setmetadata("ows_enable_request", "*");
... ... @@ -1116,11 +1121,7 @@ class LayerServer
1116 1121 }
1117 1122 } else {
1118 1123 $this->map_object = ms_newMapObj($this->map);
1119   - // $w = $this->map_object->web;
1120   - // $w->set("template","none.htm");
1121   -
1122 1124 if (! $this->_zipped) {
1123   - // $this->map_object->setmetadata('wms_onlineresource',$servidor.":80".$locmapserv."?map=".$temp."&width=1500&height=1500&");
1124 1125 $this->map_object->setmetadata('wms_onlineresource', "../../ogc.php?tema=" . $temp . "&width=1500&height=1500&TRANSPARENT=true&FORMAT=image/png&");
1125 1126 $this->map_object->setmetadata("ows_enable_request", "*");
1126 1127 }
... ... @@ -1128,10 +1129,6 @@ class LayerServer
1128 1129 for ($i = 0; $i < $n; $i ++) {
1129 1130 $l = $this->map_object->getlayer($i);
1130 1131 $l->set("status", MS_DEFAULT);
1131   - if (! $this->_zipped)
1132   - $l->set("type", MS_LAYER_RASTER);
1133   - // $l->setmetadata('wms_onlineresource',"../../ogc.php?tema=".$temp."&width=500&height=500&");
1134   - // ms_newLayerObj($this->map_object, $l);
1135 1132 }
1136 1133 }
1137 1134 if (! $this->map_object) {
... ... @@ -1181,7 +1178,7 @@ class LayerServer
1181 1178 */
1182 1179 function send_header()
1183 1180 {
1184   - header('Content-Disposition: attachment; filename=kml.km' . ($this->_zipped ? 'z' : 'l'));
  1181 + header('Content-Disposition: attachment; filename='.$this->typename."_".$this->request .'.km' . ($this->_zipped ? 'z' : 'l'));
1185 1182 header('Content-type: application/vnd.google-earth.km' . ($this->_zipped ? 'z' : 'l') . '+XML');
1186 1183 }
1187 1184  
... ...