Commit acf33bfa9365216e2fca1f78c08fe25f36dd098e

Authored by Edmar Moretti
1 parent 808d9f76

Inclusão de opção para gerar arquivo CSV sem a geometria

Showing 3 changed files with 17 additions and 12 deletions   Show diff stats
admin/admin.db
No preview for this file type
ogc.htm
... ... @@ -201,6 +201,8 @@ A:hover {
201 201 ins +=
202 202 "<p><a target=blank href='"+servico+"OUTPUTFORMAT=csv&bbox=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&service=wfs&version=1.1.0&request=getfeature&layers="+tema+"&typeName="+tema+"' />download CSV via WFS</a>";
203 203 ins +=
  204 + "<p><a target=blank href='"+servico+"OUTPUTFORMAT=csv&bbox=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&service=wfs&version=1.1.0&request=getfeature&layers="+tema+"&typeName="+tema+"&ows_geomtype=none' />download CSV via WFS mas sem a geometria</a>";
  205 + ins +=
204 206 "<p><a target=blank href='"+servico+"OUTPUTFORMAT=kmz&bbox=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&service=wfs&version=1.1.0&request=getfeature&layers="+tema+"&typeName="+tema+"' />download KMZ</a>";
205 207 ins +=
206 208 "<p><a target=blank href='"+servico+"OUTPUTFORMAT=geojson&bbox=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&service=wfs&version=1.1.0&request=getfeature&layers="+tema+"&typeName="+tema+"' />GeoJson</a>";
... ...
ogc.php
... ... @@ -38,8 +38,6 @@ ajuda - (opcional) mostra uma ajuda ao usu&amp;aacute;rio
38 38  
39 39 tema - (opcional) nome do tema que ser&aacute; mostrado no servi&ccedil;o. Se for definido, o web service conter&aacute; apenas esse tema. O tema &eacute; o nome do mapfile existente em i3geo/temas, mas pode ser especificado um mapfile existente em outra pasta. Nesse caso, deve-se especificar o caminho completo para o arquivo. Se n&atilde;o for definido, ser&atilde;o considerados todos os temas
40 40  
41   -intervalo - (opcional) valor inicial e final com o n&uacute;mero de temas que ser&atilde;o mostrados no servi&ccedil;o
42   -
43 41 legenda - (opcional) mostra a legenda no corpo do mapa sim|nao
44 42  
45 43 perfil - (opcional) perfil utilizado para restringir os temas que ser&atilde;o mostrados
... ... @@ -50,6 +48,9 @@ Na gera&amp;ccedil;&amp;atilde;o da legenda pode ser utilizado text/html para gerar no f
50 48  
51 49 OUTPUTFORMAT - em getfeature, aceita tamb&eacute;m shape-zip para download de shapefile e csv para download de csv compactado
52 50  
  51 +ows_geomtype - permite definir o tipo de geometria conforme utilizado pelo parametro GEOMETRY do OGR (veja http://gdal.org/drv_csv.html)
  52 +afeta o OUTPUTFORMAT csv. Utilize &ows_geomtype=none para obter um csv sem a coluna geometry
  53 +
53 54 id_medida_variavel - id da medida de variavel - utilizado apenas quando a fonte para definicao do layer for o sistema de metadados estatisticos
54 55 nao deve ser utilizado junto com tema
55 56  
... ... @@ -75,7 +76,6 @@ ogc.php?tema=bioma
75 76  
76 77 ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo
77 78  
78   -ogc.php?intervalo=0,50
79 79 */
80 80 $_GET = array_merge($_GET,$_POST);
81 81 //
... ... @@ -854,12 +854,13 @@ if(strtolower($OUTPUTFORMAT) == &quot;shape-zip&quot;){
854 854 exit;
855 855 }
856 856 if(strtolower($OUTPUTFORMAT) == "csv"){
  857 + ms_iostripstdoutbuffercontentheaders();
857 858 //grava em disco
858   - $arq = $dir_tmp."/".$tema.".csv";
  859 + $arq = $dir_tmp."/".$tema.$ows_geomtype.".csv";
859 860 $contents = ms_iogetstdoutbufferstring();
860 861 file_put_contents($arq,$contents);
861 862 //envia para download
862   - header('Content-Disposition: attachment; filename='.$tema.'.csv');
  863 + header('Content-Disposition: attachment; filename='.$tema.$ows_geomtype.'.csv');
863 864 header("Content-type: text/csv");
864 865 ms_iogetStdoutBufferBytes();
865 866 ms_ioresethandlers();
... ... @@ -1066,7 +1067,6 @@ function renderNocacheTms(){
1066 1067 imagepng($imgc,$nomer);
1067 1068 }
1068 1069 if($i3georendermode == 0 || !isset($i3georendermode)){
1069   -
1070 1070 header('Content-Length: '.filesize($nomer));
1071 1071 header('Content-Type: image/png');
1072 1072 header('Cache-Control: max-age=3600, must-revalidate');
... ... @@ -1128,7 +1128,7 @@ function getfeatureinfoJson(){
1128 1128 echo $json;
1129 1129 }
1130 1130 function processaOutputformatMapfile(){
1131   - global $OUTPUTFORMAT, $oMap, $tema;
  1131 + global $OUTPUTFORMAT, $oMap, $tema, $ows_geomtype;
1132 1132 if(strtolower($OUTPUTFORMAT) == "shape-zip"){
1133 1133 $l = $oMap->getlayer(0);
1134 1134 $n = $l->name;
... ... @@ -1143,8 +1143,11 @@ function processaOutputformatMapfile(){
1143 1143 $n = $l->name."-csv";
1144 1144 $oMap->selectOutputFormat("csv");
1145 1145 $oMap->outputformat->setOption("STORAGE", "filesystem");
1146   - $oMap->outputformat->setOption("FILENAME", $tema.".csv");
1147   - $oMap->outputformat->setOption("FORM", "simple");
  1146 + $oMap->outputformat->setOption("FILENAME", $tema.$ows_geomtype.".csv");
  1147 + $oMap->outputformat->setOption("FORM", "simple");
  1148 + if(isset($ows_geomtype) && $ows_geomtype != ""){
  1149 + $oMap->outputformat->setOption("LCO:GEOMETRY", $ows_geomtype);
  1150 + }
1148 1151 $l->setmetadata("wfs_getfeature_formatlist","csv");
1149 1152 }
1150 1153 if(strtolower($OUTPUTFORMAT) == "geojson" || strtolower($OUTPUTFORMAT) == "json"){
... ... @@ -1154,7 +1157,7 @@ function processaOutputformatMapfile(){
1154 1157 }
1155 1158 }
1156 1159 function carregaCacheArquivo(){
1157   - global $dir_tmp, $tema, $OUTPUTFORMAT;
  1160 + global $dir_tmp, $tema, $OUTPUTFORMAT, $ows_geomtype;
1158 1161 if(strtolower($OUTPUTFORMAT) == "shape-zip"){
1159 1162 $arq = $dir_tmp."/".$tema."_shapefile.zip";
1160 1163 if(file_exists($arq)){
... ... @@ -1164,9 +1167,9 @@ function carregaCacheArquivo(){
1164 1167 }
1165 1168 }
1166 1169 if(strtolower($OUTPUTFORMAT) == "csv"){
1167   - $arq = $dir_tmp."/".$tema.".csv";
  1170 + $arq = $dir_tmp."/".$tema.$ows_geomtype.".csv";
1168 1171 if(file_exists($arq)){
1169   - header('Content-Disposition: attachment; filename='.$tema.'.csv');
  1172 + header('Content-Disposition: attachment; filename='.$tema.$ows_geomtype.'.csv');
1170 1173 header("Content-type: text/csv");
1171 1174 readfile($arq);
1172 1175 exit;
... ...