Commit 8d154fcd481f4d3091ea0af12c4e7ac8f2ad2494
1 parent
99a23c5f
Exists in
master
Correção na geração de serviços kml, kmz e datadownload
Showing
3 changed files
with
55 additions
and
27 deletions
Show diff stats
classesphp/mapa_controle.php
... | ... | @@ -119,7 +119,7 @@ $interfaceTemp = $interface; |
119 | 119 | //TEMA2SLD e usado por datadownload.htm |
120 | 120 | //PEGAMAPAS e utilizado em varias funcoes |
121 | 121 | // |
122 | -if ($funcao != "listainterfaces" && $funcao != "pegalistadetemas" && $funcao != "pegalistadeSubgrupos" && $funcao != "procurartemasestrela" && $funcao != "pegalistadegrupos" && $funcao != "pegalistademenus" && $funcao != "criaMapa" && strtoupper($funcao) != "TEMA2SLD" && strtoupper($funcao) != "PEGAMAPAS"){ | |
122 | +if ($funcao != "download3" && $funcao != "listainterfaces" && $funcao != "pegalistadetemas" && $funcao != "pegalistadeSubgrupos" && $funcao != "procurartemasestrela" && $funcao != "pegalistadegrupos" && $funcao != "pegalistademenus" && $funcao != "criaMapa" && strtoupper($funcao) != "TEMA2SLD" && strtoupper($funcao) != "PEGAMAPAS"){ | |
123 | 123 | session_name("i3GeoPHP"); |
124 | 124 | if (isset($g_sid) && $g_sid != "") |
125 | 125 | { | ... | ... |
ogc.php
... | ... | @@ -175,10 +175,10 @@ if(!file_exists($tema)){ |
175 | 175 | |
176 | 176 | $layers = $tema; |
177 | 177 | //ajusta o OUTPUTFORMAT |
178 | -if(strpos(strtolower($OUTPUTFORMAT),"kml") === true || strpos(strtolower($OUTPUTFORMAT),"kml") === 0){ | |
178 | +if(strpos(strtolower($OUTPUTFORMAT),"kml") !== false){ | |
179 | 179 | $OUTPUTFORMAT = "kml"; |
180 | 180 | } |
181 | -if(strpos(strtolower($OUTPUTFORMAT),"kmz") === true || strpos(strtolower($OUTPUTFORMAT),"kmz") === 0){ | |
181 | +if(strpos(strtolower($OUTPUTFORMAT),"kmz") !== false){ | |
182 | 182 | $OUTPUTFORMAT = "kmz"; |
183 | 183 | } |
184 | 184 | // |
... | ... | @@ -191,11 +191,29 @@ if(!empty($OUTPUTFORMAT)){ |
191 | 191 | //para o caso da requisicao kmz |
192 | 192 | //kmz nao funciona diretamente com mapserver |
193 | 193 | // |
194 | -if(strtolower($OUTPUTFORMAT) == "xkml" || strtolower($OUTPUTFORMAT) == "kmz"){ | |
194 | +if(strtolower($OUTPUTFORMAT) == "kmz"){ | |
195 | 195 | $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema; |
196 | 196 | header("Location:".$urln); |
197 | 197 | exit; |
198 | 198 | } |
199 | +if(strtolower($OUTPUTFORMAT) == "kml" && $ogrOutput == false){ | |
200 | + $urln = "pacotes/kmlmapserver/kmlservice.php?request=kmz&map=".$tema."&typename=".$tema; | |
201 | + header("Location:".$urln); | |
202 | + exit; | |
203 | +} | |
204 | +// | |
205 | +//caso seja uma requisição WMS com format | |
206 | +// | |
207 | +if(strpos(strtolower($format),"kml") !== false){ | |
208 | + $urln = "pacotes/kmlmapserver/kmlservice.php?request=kml&map=".$tema."&typename=".$tema; | |
209 | + header("Location:".$urln); | |
210 | + exit; | |
211 | +} | |
212 | +if(strpos(strtolower($format),"kmz") !== false){ | |
213 | + $urln = "pacotes/kmlmapserver/kmlservice.php?request=kml&map=".$tema."&typename=".$tema; | |
214 | + header("Location:".$urln); | |
215 | + exit; | |
216 | +} | |
199 | 217 | // |
200 | 218 | //usa o epsg correto ao inves do apelido inventado pelo Google |
201 | 219 | // | ... | ... |
pacotes/kmlmapserver/classes/layerserver.class.php
... | ... | @@ -143,32 +143,38 @@ class LayerServer { |
143 | 143 | function run(){ |
144 | 144 | // Check cache |
145 | 145 | if(ENABLE_CACHE){ |
146 | - $cache_file = $this->get_cache_file_name(); | |
147 | - if(file_exists($cache_file)){ | |
148 | - $this->send_header(); | |
149 | - readfile($cache_file); | |
150 | - exit; | |
151 | - } | |
146 | + $cache_file = $this->get_cache_file_name(); | |
147 | + if(file_exists($cache_file)){ | |
148 | + $this->send_header(); | |
149 | + readfile($cache_file); | |
150 | + exit; | |
151 | + } | |
152 | 152 | } |
153 | 153 | // If not layer are requested, send all as networklinks |
154 | 154 | if(!$this->typename){ |
155 | - $this->_networklink = true; | |
156 | - $this->typename = $this->get_layer_list(); | |
155 | + $this->_networklink = true; | |
156 | + $this->typename = $this->get_layer_list(); | |
157 | 157 | } else { |
158 | - $this->_networklink = false; | |
158 | + $this->_networklink = false; | |
159 | 159 | } |
160 | - //ajusta a legenda | |
161 | - $numlayers = $this->map_object->numlayers; | |
162 | - for ($i=0;$i < $numlayers;++$i){ | |
163 | - $layer = $this->map_object->getlayer($i); | |
164 | - if (($layer->data != "") && (strtoupper($layer->getmetadata("escondido")) != "SIM") && (strtoupper($layer->getmetadata("tema")) != "NAO")){ | |
165 | - if ($layer->numclasses > 0){ | |
166 | - $classe = $layer->getclass(0); | |
167 | - if (($classe->name == "") || ($classe->name == " ")){ | |
168 | - $classe->set("name",$layer->getmetadata("tema")); | |
169 | - } | |
170 | - //corrige o titulo da legenda | |
171 | - if($layer->type != 3 && $layer->type != 4){ | |
160 | + if($this->_networklink == false){ | |
161 | + //desliga todos os layers | |
162 | + for($i = 0; $i < $this->map_object->numlayers; $i++){ | |
163 | + $l = $this->map_object->getLayer($i); | |
164 | + $l->set("status",MS_OFF); | |
165 | + } | |
166 | + //ajusta a legenda | |
167 | + $nomesl = explode(',', $this->typename); | |
168 | + foreach ($nomesl as $nomel){ | |
169 | + $layer = $this->map_object->getlayerbyname($nomel); | |
170 | + if($layer){ | |
171 | + $layer->set("status",MS_DEFAULT); | |
172 | + if ($layer->numclasses > 0){ | |
173 | + $classe = $layer->getclass(0); | |
174 | + if (($classe->name == "") || ($classe->name == " ")){ | |
175 | + $classe->set("name",$layer->getmetadata("tema")); | |
176 | + } | |
177 | + //corrige o titulo da legenda | |
172 | 178 | $nclass = $layer->numclasses; |
173 | 179 | for($j=0;$j<$nclass;$j++){ |
174 | 180 | $classe = $layer->getclass($j); |
... | ... | @@ -193,8 +199,12 @@ class LayerServer { |
193 | 199 | . " <screenXY x='0.01' y='0.14' xunits='fraction' yunits='fraction'/>" . PHP_EOL |
194 | 200 | . " <size x='-1' y='-1' xunits='pixels' yunits='pixels'/>" . PHP_EOL |
195 | 201 | . " </ScreenOverlay>" . PHP_EOL; |
196 | - | |
197 | - $this->_xml = new SimpleXMLElement('<kml xmlns="http://earth.google.com/kml/2.0"><Document >'.$legenda.'</Document></kml>'); | |
202 | + if($this->_networklink == false){ | |
203 | + $this->_xml = new SimpleXMLElement('<kml xmlns="http://earth.google.com/kml/2.0"><Document >'.$legenda.'</Document></kml>'); | |
204 | + } | |
205 | + else{ | |
206 | + $this->_xml = new SimpleXMLElement('<kml xmlns="http://earth.google.com/kml/2.0"><Document ></Document></kml>'); | |
207 | + } | |
198 | 208 | // Prepare projection |
199 | 209 | $this->in_proj = ms_newProjectionObj($this->map_object->getProjection()); |
200 | 210 | // Set projection to GOOGLE earth's projection | ... | ... |