Commit 9087fa1f3b8af9dfd7ca2403d32c7c189ea59627

Authored by Edmar Moretti
1 parent 69d94d50

Inclusão de info_format json em ogc.php

Showing 2 changed files with 63 additions and 14 deletions   Show diff stats
.project
... ... @@ -25,6 +25,13 @@
25 25 <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
26 26 <nature>org.eclipse.php.core.PHPNature</nature>
27 27 </natures>
  28 + <linkedResources>
  29 + <link>
  30 + <name>cesium</name>
  31 + <type>2</type>
  32 + <location>/var/www/i3geo/pacotes/cesium</location>
  33 + </link>
  34 + </linkedResources>
28 35 <filteredResources>
29 36 <filter>
30 37 <id>1431135588159</id>
... ...
ogc.php
1 1 <?php
2 2 /*
3   -Title: Gerador de servi&ccedil;os OGC
  3 + Title: Gerador de servi&ccedil;os OGC
4 4  
5 5 Gera web services nos padr&otilde;es OGC para os temas existentes na pasta i3geo/temas
6 6  
... ... @@ -45,13 +45,13 @@ legenda - (opcional) mostra a legenda no corpo do mapa sim|nao
45 45 perfil - (opcional) perfil utilizado para restringir os temas que ser&atilde;o mostrados
46 46  
47 47 format - (opcional) pode ser utilizado a op&ccedil;&atilde;o &format=application/openlayers para
48   - abrir o mashup do OpenLayers com as camadas definida em temas.
49   - Na gera&ccedil;&atilde;o da legenda pode ser utilizado text/html para gerar no formato html.
  48 +abrir o mashup do OpenLayers com as camadas definida em temas.
  49 +Na gera&ccedil;&atilde;o da legenda pode ser utilizado text/html para gerar no formato html.
50 50  
51 51 OUTPUTFORMAT - em getfeature, aceita tamb&eacute;m shape-zip para download de shapefile e csv para download de csv compactado
52 52  
53 53 id_medida_variavel - id da medida de variavel - utilizado apenas quando a fonte para definicao do layer for o sistema de metadados estatisticos
54   - nao deve ser utilizado junto com tema
  54 +nao deve ser utilizado junto com tema
55 55  
56 56 restauramapa - ID de um mapa salvo no sistema de administracao. O mapa e restaurado e tratado como WMS
57 57  
... ... @@ -59,11 +59,11 @@ DESLIGACACHE (opcional) {sim|nao} - forca a nao usar o cache de imagens qd defin
59 59  
60 60 filtros - filtros podem ser adicionados incluindo o parametro da seguinte forma: &map_layer_<nomedotema>_filter=
61 61  
62   - Exemplo de filtro
  62 +Exemplo de filtro
63 63  
64   - http://localhost/i3geo/ogc.php?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&tema=_lbiomashp&SRS=EPSG:4618&WIDTH=500&HEIGHT=500&BBOX=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&FORMAT=image/png&service=wms&version=1.1.0&request=getmap&layers=_lbiomashp
  64 +http://localhost/i3geo/ogc.php?map_layer__lbiomashp_filter=(('[CD_LEGENDA]'='CAATINGA'))&tema=_lbiomashp&SRS=EPSG:4618&WIDTH=500&HEIGHT=500&BBOX=-76.5125927,-39.3925675209,-29.5851853,9.49014852081&FORMAT=image/png&service=wms&version=1.1.0&request=getmap&layers=_lbiomashp
65 65  
66   - no caso de camadas Postgis basta usar map_layer__lbiomashp_filter=cd_legenda='CAATINGA'
  66 +no caso de camadas Postgis basta usar map_layer__lbiomashp_filter=cd_legenda='CAATINGA'
67 67  
68 68 Exemplos:
69 69  
... ... @@ -392,8 +392,8 @@ else{
392 392 $l->set("status",MS_OFF);
393 393 }
394 394 /*
395   - if($cache == true && strtolower($l->getmetadata('cache')) == 'sim' && $tipo == '' && count($tema) == 1){
396   - carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir);
  395 + if($cache == true && strtolower($l->getmetadata('cache')) == 'sim' && $tipo == '' && count($tema) == 1){
  396 + carregaCacheImagem($_GET['BBOX'],$tx,$_GET['WIDTH'],$_GET['HEIGHT'],$cachedir);
397 397 }
398 398 */
399 399 $l->setmetadata("ows_title",pegaNome($l));
... ... @@ -455,7 +455,7 @@ else{
455 455 if(!in_array("POLYLINE_NO_CLIP=True",$pr)){
456 456 $l->setprocessing("POLYLINE_NO_CLIP=True");
457 457 }
458   - }
  458 + }
459 459 //
460 460 //verifica se existem parametros de substituicao passados via url
461 461 //
... ... @@ -871,11 +871,50 @@ if(isset($OUTPUTFORMAT)){
871 871 }
872 872 }
873 873 ms_ioinstallstdouttobuffer();
  874 +
874 875 //verifica parametro outputformat
875 876 if(strtolower($req->getValueByName("REQUEST")) == "getmap" && $req->getValueByName("format") == ""){
876 877 $req->setParameter("format","image/png");
877 878 }
878   -$oMap->owsdispatch($req);
  879 +
  880 +if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo" && $_GET["info_format"] == "application/json"){
  881 + $req->setParameter("info_format","text/plain");
  882 + $oMap->owsdispatch($req);
  883 + ms_iostripstdoutbuffercontentheaders();
  884 + ob_clean();
  885 + $r = ms_iogetstdoutbufferstring();
  886 + $t = explode("=",$r);
  887 + $n = array();
  888 + if(count($t) > 1){
  889 + $v = str_replace("\\n","",$t[1]);
  890 + $v = str_replace("\\r","",$v);
  891 + if(trim($v) != ""){
  892 + $va = trim($v);
  893 + $coluna = trim(explode(":",$t[0])[2]);
  894 + $valor = str_replace("'","",$va);
  895 + $n[] = array (
  896 + "type" => "FeatureCollection",
  897 + "features" => array(
  898 + array(
  899 + "type"=>"Feature",
  900 + "id" => "",
  901 + "geometry" => array(),
  902 + "properties" => array(
  903 + $coluna => $valor
  904 + ),
  905 + "geometry_name" => ""
  906 + )
  907 + )
  908 + );
  909 + }
  910 + }
  911 + header("Content-type: application/json");
  912 + echo json_encode($n[0]);
  913 + exit;
  914 +}
  915 +
  916 +$oMap->owsdispatch($req);
  917 +
879 918 $contenttype = ms_iostripstdoutbuffercontenttype();
880 919 if(strtolower($request) == "getcapabilities"){
881 920 header('Content-Disposition: attachment; filename=getcapabilities.xml');
... ... @@ -887,7 +926,8 @@ if(!isset($OUTPUTFORMAT)){
887 926 if(strtolower($OUTPUTFORMAT) == "geojson"){
888 927 ms_iostripstdoutbuffercontentheaders();
889 928 header("Content-type: application/json; subtype=geojson");
890   -}
  929 +}
  930 +
891 931 $buffer = ms_iogetStdoutBufferBytes();
892 932 ms_ioresethandlers();
893 933 //
... ... @@ -1059,7 +1099,9 @@ function nomeRand($n=10)
1059 1099 $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ';
1060 1100 $max = 51;
1061 1101 for($i=0; $i < $n; ++$i)
1062   - {$nomes .= $a{mt_rand(0, $max)};}
  1102 + {
  1103 + $nomes .= $a{mt_rand(0, $max)};
  1104 + }
1063 1105 return $nomes;
1064 1106 }
1065 1107 function renderNocacheTms(){
... ... @@ -1101,4 +1143,4 @@ function renderNocacheTms(){
1101 1143 header("Content-type: image/png");
1102 1144 }
1103 1145 }
1104   -?>
  1146 +?>
... ...