Commit 062f96ac075bd5d0ca59fc7403766a59d16404dd

Authored by Edmar Moretti
1 parent 32531454

Inclusão de uma opção para acesso aos dados no formato vetorial compactado (kmz)

Showing 1 changed file with 38 additions and 4 deletions   Show diff stats
kml.php
... ... @@ -109,7 +109,7 @@ if($menutemas == "")
109 109 kml_cabecalho($menu["nome_menu"],$menu["desc_menu"]);
110 110 $id_menu = $menu["id_menu"];
111 111 //raiz
112   - $sql = "select id_raiz,i3geoadmin_raiz.id_tema,nome_tema,tipoa_tema,codigo_tema FROM i3geoadmin_raiz LEFT JOIN i3geoadmin_temas ON i3geoadmin_temas.id_tema = i3geoadmin_raiz.id_tema where (lower(i3geoadmin_temas.tipoa_tema) != 'wms' or i3geoadmin_temas.tipoa_tema isnull) and (lower(i3geoadmin_temas.kml_tema) != 'nao' or i3geoadmin_temas.kml_tema isnull) and i3geoadmin_temas.tipoa_tema != 'WMS' and i3geoadmin_temas.kml_tema != 'nao' and i3geoadmin_raiz.id_menu='$id_menu' and i3geoadmin_raiz.nivel = 0 and i3geoadmin_raiz.id_nivel = 0 order by ordem";
  112 + $sql = "select id_raiz,i3geoadmin_raiz.id_tema,nome_tema,tipoa_tema,codigo_tema,kmz_tema FROM i3geoadmin_raiz LEFT JOIN i3geoadmin_temas ON i3geoadmin_temas.id_tema = i3geoadmin_raiz.id_tema where (lower(i3geoadmin_temas.tipoa_tema) != 'wms' or i3geoadmin_temas.tipoa_tema isnull) and (lower(i3geoadmin_temas.kml_tema) != 'nao' or i3geoadmin_temas.kml_tema isnull) and i3geoadmin_temas.tipoa_tema != 'WMS' and i3geoadmin_temas.kml_tema != 'nao' and i3geoadmin_raiz.id_menu='$id_menu' and i3geoadmin_raiz.nivel = 0 and i3geoadmin_raiz.id_nivel = 0 order by ordem";
113 113 $temas = pegaDados($sql);
114 114 if(count($temas) > 0)
115 115 {
... ... @@ -122,7 +122,7 @@ if($menutemas == "")
122 122 kml_cabecalho($grupo["nome_grupo"],$grupo["desc_grupo"]);
123 123 $id_grupo = $grupo["id_grupo"];
124 124 //raiz
125   - $sql = "select id_raiz,i3geoadmin_raiz.id_tema,nome_tema,tipoa_tema,kml_tema,codigo_tema FROM i3geoadmin_raiz LEFT JOIN i3geoadmin_temas ON i3geoadmin_temas.id_tema = i3geoadmin_raiz.id_tema where lower(i3geoadmin_temas.tipoa_tema) != 'wms' and lower(i3geoadmin_temas.kml_tema) != 'nao' and i3geoadmin_temas.tipoa_tema != 'WMS' and i3geoadmin_temas.kml_tema != 'nao' and i3geoadmin_raiz.id_menu='$id_menu' and i3geoadmin_raiz.nivel = 1 and i3geoadmin_raiz.id_nivel = ".$grupo["id_n1"]." order by ordem";
  125 + $sql = "select id_raiz,i3geoadmin_raiz.id_tema,nome_tema,tipoa_tema,kml_tema,kmz_tema,codigo_tema FROM i3geoadmin_raiz LEFT JOIN i3geoadmin_temas ON i3geoadmin_temas.id_tema = i3geoadmin_raiz.id_tema where lower(i3geoadmin_temas.tipoa_tema) != 'wms' and lower(i3geoadmin_temas.kml_tema) != 'nao' and i3geoadmin_temas.tipoa_tema != 'WMS' and i3geoadmin_temas.kml_tema != 'nao' and i3geoadmin_raiz.id_menu='$id_menu' and i3geoadmin_raiz.nivel = 1 and i3geoadmin_raiz.id_nivel = ".$grupo["id_n1"]." order by ordem";
126 126 $temas = pegaDados($sql);
127 127 if(count($temas) > 0)
128 128 {
... ... @@ -139,7 +139,7 @@ if($menutemas == "")
139 139 foreach ($subgrupos as $subgrupo)
140 140 {
141 141 $id_n2 = $subgrupo["id_n2"];
142   - $sql = "select t.codigo_tema,t.nome_tema,t.link_tema, t.desc_tema from i3geoadmin_n3 as n3,i3geoadmin_temas as t where ";
  142 + $sql = "select t.codigo_tema,t.nome_tema,t.link_tema, t.desc_tema, t.kmz_tema from i3geoadmin_n3 as n3,i3geoadmin_temas as t where ";
143 143 $sql .= "n3.id_n2='$id_n2' ";
144 144 $sql .= "and n3.id_tema = t.id_tema ";
145 145 $sql .= "and n3_perfil = '' ";
... ... @@ -164,14 +164,31 @@ echo "</Document></kml>\n";
164 164 function kml_tema_bd($tema)
165 165 {
166 166 global $urli3geo;
  167 + $teste = array_keys($tema);
  168 + if(in_array("link_tema",$teste))
167 169 $fonte = $tema["link_tema"];
  170 + else
  171 + $fonte = "";
  172 +
168 173 $nome = $tema["nome_tema"];
169 174 $id = $tema["codigo_tema"];
  175 +
  176 + if(in_array("desc_tema",$teste))
170 177 $desc = $tema["desc_tema"];
  178 + else
  179 + $desc = "";
  180 +
171 181 $fonte = "<a href='$fonte' >Fonte </a>";
172 182 $legenda = "<a href='$urli3geo/ogc.php?tema=$id&layer=$id&request=getlegendgraphic&service=wms&format=image/jpeg' >Legenda </a>";
  183 +
173 184 $href = "$urli3geo/ogc.php?tema=$id&amp;width=800&amp;height=800&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;SRS=EPSG:4326&amp;STYLES=&amp;BGCOLOR=0xFFFFFF&amp;FORMAT=image/png&amp;TRANSPARENT=TRUE&amp;layers=$id";
174 185 kml_servico($nome,$fonte,$legenda,$desc,$href);
  186 +
  187 + if(strtolower($tema["kmz_tema"]) != "nao")
  188 + {
  189 + $href = "$urli3geo/pacotes/kmlmapserver/kmlservice.php?request=kmz&amp;map=$id&amp;typename=$id";
  190 + kml_networklink($nome." (vetorial)",$fonte,$legenda,$desc,$href);
  191 + }
175 192 }
176 193 function kml_cabecalho($nome,$desc)
177 194 {
... ... @@ -202,8 +219,12 @@ function kml_tema($tema)
202 219 {$kml = mb_convert_encoding($tema->KML,"auto","auto");}
203 220 if(strtolower($kml) != "nao" && strtolower($tipoa) != "wms")
204 221 {
  222 + if($fonte != "")
205 223 $fonte = "<a href='$fonte' >Fonte </a>";
206   - $legenda = "<a href='$urli3geo/ogc.php?tema=$id&layer=$id&request=getlegendgraphic&service=wms&format=image/jpeg' >Legenda </a>";
  224 + else
  225 + $fonte = "";
  226 +
  227 + $legenda = "<a href='$urli3geo/ogc.php?tema=$id&layer=$id&request=getlegendgraphic&service=wms&format=image/png' >Legenda </a>";
207 228 $href = "$urli3geo/ogc.php?tema=$id&amp;width=800&amp;height=800&amp;VERSION=1.1.1&amp;REQUEST=GetMap&amp;SRS=EPSG:4326&amp;STYLES=&amp;BGCOLOR=0xFFFFFF&amp;FORMAT=image/png&amp;TRANSPARENT=TRUE&amp;layers=$id";
208 229 kml_servico($nome,$fonte,$legenda,$desc,$href);
209 230 }
... ... @@ -221,4 +242,17 @@ function kml_servico($nome,$fonte,$legenda,$desc,$href)
221 242 echo " <LatLonBox><north>9.49014618085</north><south>-39.3925604735</south><east>-29.5851853</east><west>-76.5125927</west></LatLonBox>\n";
222 243 echo " </GroundOverlay>\n";
223 244 }
  245 +function kml_networklink($nome,$fonte,$legenda,$desc,$href)
  246 +{
  247 + echo " <NetworkLink>\n";
  248 + echo " <name>".str_replace("&","&amp;",$nome)."</name>\n";
  249 + echo " <description><![CDATA[".$fonte.$legenda.$desc."]]></description>\n";
  250 + echo " <visibility>0</visibility>\n";
  251 + echo " <Link>\n";
  252 + echo " <viewRefreshMode>never</viewRefreshMode>\n";
  253 + echo " <href>$href</href>\n";
  254 + echo " </Link>\n";
  255 + echo " </NetworkLink>\n";
  256 +}
  257 +
224 258 ?>
225 259 \ No newline at end of file
... ...