Commit ee55328ecd387588a061ead4467d62e3a7d7f64c

Authored by Edmar Moretti
1 parent fca2731b

Inclusão do OUTPUTFORMAT shape-zip em ogc.php

Showing 2 changed files with 35 additions and 7 deletions   Show diff stats
aplicmap/ogcwsv6.map
... ... @@ -4,7 +4,7 @@ MAP
4 4 SYMBOLSET "../symbols/simbolosv6.sym"
5 5 IMAGECOLOR 255 255 255
6 6 IMAGETYPE png
7   -MAXSIZE 10000
  7 + MAXSIZE 10000
8 8 SHAPEPATH "/opt/www/html/geodados"
9 9 SIZE 450 450
10 10 STATUS ON
... ... @@ -26,6 +26,11 @@ MAXSIZE 10000
26 26 FORMATOPTION "INTERLACE=OFF"
27 27 TRANSPARENT TRUE
28 28 END
  29 + OUTPUTFORMAT
  30 + NAME 'shape-zip'
  31 + DRIVER 'OGR/ESRI Shapefile'
  32 + IMAGEMODE FEATURE
  33 + END
29 34 PROJECTION
30 35 "+proj=longlat +ellps=GRS67 +no_defs"
31 36 END
... ...
ogc.php
... ... @@ -223,6 +223,12 @@ if(isset($_GET["tms"])){
223 223 if(isset($_GET["Z"]) && isset($_GET["X"])){
224 224 $agora .= "google";
225 225 }
  226 +//
  227 +//se o outputformat for definido, evita o cahce de arquivo
  228 +//
  229 +if(isset($_GET["OUTPUTFORMAT"])){
  230 + $_GET["DESLIGACACHE"] = "sim";
  231 +}
226 232 if(isset($_GET["DESLIGACACHE"]) && $_GET["DESLIGACACHE"] == "sim"){
227 233 $agora = time();
228 234 $cache = false;
... ... @@ -331,7 +337,7 @@ else{
331 337 carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir);
332 338 }
333 339 */
334   - $l->setmetadata("ows_title",pegaNome($l));
  340 + $l->setmetadata("ows_title",pegaNome($l));
335 341 $l->setmetadata("ows_srs",$listaepsg);
336 342 $l->set("group","");
337 343 //essa linha é necessária pq as vezes no mapfile não tem nenhum layer com o nome igual ao nome do mapfile
... ... @@ -502,8 +508,7 @@ else{
502 508 $l->setmetadata("gml_include_items","all");
503 509 $l->set("dump",MS_TRUE);
504 510 $l->setmetadata("WMS_INCLUDE_ITEMS","all");
505   - $l->setmetadata("WFS_INCLUDE_ITEMS","all");
506   -
  511 + $l->setmetadata("WFS_INCLUDE_ITEMS","all");
507 512 if($l->getmetadata("ows_metadataurl_href") == ""){
508 513 $l->setmetadata("ows_metadataurl_href",$c["fonte"]);
509 514 $l->setmetadata("ows_metadataurl_type","TC211");
... ... @@ -585,7 +590,7 @@ if(isset($_GET["tms"])){
585 590 //echo $lon1." ".$lat1." ".$lon2." ".$lat2;exit;
586 591 $oMap->setsize(256,256);
587 592 $oMap->setExtent($lon1,$lat1,$lon2,$lat2);
588   -
  593 +
589 594 $layer0->set("status",MS_DEFAULT);
590 595 //
591 596 //se o layer foi marcado para corte altera os parametros para ampliar o mapa
... ... @@ -648,7 +653,7 @@ if(isset($_GET["Z"]) && isset($_GET["X"])){
648 653 $poPoint2->project($projInObj, $projOutObj);
649 654 $oMap->setsize(256,256);
650 655 $oMap->setExtent($poPoint1->x,$poPoint1->y,$poPoint2->x,$poPoint2->y);
651   -
  656 +
652 657 $oMap->getlayer(0)->set("status",MS_DEFAULT);
653 658 $oMap->setProjection("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m");
654 659 $layer0->setProjection("proj=latlong,a=6378137,b=6378137");
... ... @@ -716,6 +721,24 @@ if(strtolower($req->getValueByName("REQUEST")) == "getfeature"){
716 721 if((isset($legenda)) && (strtolower($legenda) == "sim")){
717 722 $leg = $oMap->legend;
718 723 $leg->set("status",MS_EMBED);
  724 +}
  725 +//
  726 +//altera o outputformat
  727 +//
  728 +if(isset($OUTPUTFORMAT)){
  729 + if(strtolower($OUTPUTFORMAT) == "shape-zip"){
  730 + $l = $oMap->getlayer(0);
  731 + $n = $l->name.time();
  732 + $oMap->selectOutputFormat("shape-zip");
  733 + $oMap->outputformat->setOption("STORAGE", "memory");
  734 + $oMap->outputformat->setOption("FORM", "zip");
  735 + $oMap->outputformat->setOption("FILENAME", $n.".zip");
  736 + $l->setmetadata("wfs_getfeature_formatlist","shape-zip");
  737 + $oMap->save($nomeMapfileTmp);
  738 + if(strtolower($request) != "getcapabilities"){
  739 + header('Content-Disposition: attachment; filename='.$n.'.zip');
  740 + }
  741 + }
719 742 }
720 743 ms_ioinstallstdouttobuffer();
721 744 $oMap->owsdispatch($req);
... ... @@ -870,7 +893,7 @@ function salvaCacheImagem($cachedir,$map,$tms){
870 893 // Fill the image with transparent color
871 894 $color = imagecolorallocatealpha($imgc,0x00,0x00,0x00,127);
872 895 imagefill($imgc, 0, 0, $color);
873   -
  896 +
874 897 imagecopy($imgc, $img, 0 , 0 , $cortePixels , $cortePixels , 256, 256);
875 898 imagepng($imgc,$nome);
876 899 }
... ...