[Mapbender-commits] r7666 - in trunk/mapbender/http: classes
javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Mar 2 08:14:13 EST 2011
Author: armin11
Date: 2011-03-02 05:14:13 -0800 (Wed, 02 Mar 2011)
New Revision: 7666
Modified:
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/javascripts/initWmcObj.php
Log:
Fix problem with exchanging urls of wmc documents with urls from database and owsproxy while loading them.
Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php 2011-03-02 11:40:20 UTC (rev 7665)
+++ trunk/mapbender/http/classes/class_wmc.php 2011-03-02 13:14:13 UTC (rev 7666)
@@ -521,9 +521,9 @@
$WMSIdList = $xpath->query($query_mbWMSId);
foreach($WMSIdList as $WMSId) {
$id = $WMSId->nodeValue;
- $sql = "SELECT wms_timestamp,wms_getmap,wms_getlegendurl " .
- "FROM wms WHERE wms_id = $1 AND " .
- "wms_owsproxy <> NULL AND wms_owsproxy <> ''";
+ $sql = "SELECT wms_timestamp,wms_getmap,wms_getlegendurl, wms_owsproxy " .
+ "FROM wms WHERE wms_id = $1";// AND " .
+ //"wms_owsproxy <> NULL AND wms_owsproxy <> ''";
$v = array($id);
$t = array("t");
@@ -533,24 +533,59 @@
} //FIMXE: PROPER ERROR MESSAGE
if($row = db_fetch_array($res)) {
- $wms_timestamp = $row["wms_timestamp"];
- if ($this->timestamp < $wms_timestamp) {
- // wmc is fresh, life is good
- }
- else {
+ //check if ows_proxy is set
+ if (isset($row["wms_owsproxy"]) && $row["wms_owsproxy"] != '') {
+ //set relevant wms urls to owsproxy urls
+ $wmsowsproxy = $row["wms_owsproxy"];
+ $owsproxyurl = OWSPROXY."/".session_id()."/".$wmsowsproxy."?";
+ $wmsGetMapUrl = $owsproxyurl;
+ $wmsGetLegendUrl = $owsproxyurl;
+ //in the case of owsproxy the urls should be exchanged every time!
$MapResources = $xpath->query("../../wmc:Server/wmc:OnlineResource",$WMSId);
foreach($MapResources as $MapResource) {
- $MapResource->setAttribute("xlink:href",$row["wms_getmap"]);
+ $MapResource->setAttribute("xlink:href",$wmsGetMapUrl);
}
$LegendResources = $xpath->query("../../wmc:StyleList/wmc:Style/wmc:LegendURL/wmc:OnlineResource",$WMSId);
foreach ($LegendResources as $LegendResource) {
- $base = $row["wms_getlegendurl"];
- $origurl = explode('&', $LegendResource->getAttribute("xlink:href"),2);
- $url = $base . $origurl[1];
- $LegendResource->setAttribute("xlink:href",$url);
+ $e = new mb_notice("class_wmc.php: old getlegendurl (WMC): ".$LegendResource->getAttribute("xlink:href"));
+ $e = new mb_notice("class_wmc.php: new getlegendurl (OWSPROXY): ".$wmsGetLegendUrl);
+ //get param part of getlegend url from xml
+ $arURL = parse_url($LegendResource->getAttribute("xlink:href"));
+ $query = $arURL["query"];
+ $url = $wmsGetLegendUrl . $query;
+ $LegendResource->setAttribute("xlink:href",$url);
}
+ } else { //service is not secured - exchange urls only when they may have changed
+ $wmsGetMapUrl = $row["wms_getmap"];
+ $wmsGetLegendUrl = $row["wms_getlegendurl"];
+ //in cases when no owsproxy is defined exchange only if timestamp are not in sync
+ $wms_timestamp = $row["wms_timestamp"];
+ //if ($this->timestamp < $wms_timestamp) {//TODO: check if such a distiction is really needful - the timestamp of a wmc changes if some metadata changes - therefor it is needed - exchange all urls by default!
+ if (false) {
+ // wmc is fresh, life is good
+ $e = new mb_notice("class_wmc.php: the wms metadata has not been changed - no url will be exchanged!");
+ }
+ else {
+ $MapResources = $xpath->query("../../wmc:Server/wmc:OnlineResource",$WMSId);
+ $e = new mb_notice("class_wmc.php: the wms is newer than the wmc -urls will be exchanged!");
+ foreach($MapResources as $MapResource) {
+ $MapResource->setAttribute("xlink:href",$wmsGetMapUrl);
+ }
+
+ $LegendResources = $xpath->query("../../wmc:StyleList/wmc:Style/wmc:LegendURL/wmc:OnlineResource",$WMSId);
+ foreach ($LegendResources as $LegendResource) {
+ $e = new mb_notice("class_wmc.php: old getlegendurl (WMC): ".$LegendResource->getAttribute("xlink:href"));
+ $e = new mb_notice("class_wmc.php: new getlegendurl (DB): ".$wmsGetLegendUrl);
+ //get param part of getlegend url from xml
+ $arURL = parse_url($LegendResource->getAttribute("xlink:href"));
+ $query = $arURL["query"];
+ $url = $wmsGetLegendUrl . $query;
+ $LegendResource->setAttribute("xlink:href",$url);
+ }
+ }
}
+
}
}
$updatedWMC = $WMCDoc->saveXML();
Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php 2011-03-02 11:40:20 UTC (rev 7665)
+++ trunk/mapbender/http/javascripts/initWmcObj.php 2011-03-02 13:14:13 UTC (rev 7666)
@@ -120,6 +120,9 @@
// just make it work for a single Wmc
try {
$wmcGetApi = WmcFactory::createFromDb($input["id"]);
+ //update urls from wmc with urls from database if id is given
+ $updatedWMC = $wmcGetApi->updateUrlsFromDb();
+ $wmcGetApi->createFromXml($updatedWMC);
//increment load count
$wmcGetApi->incrementWmcLoadCount();
}
@@ -327,6 +330,7 @@
$xml = $wmcGetApi->toXml();
$wmcGetApi = new wmc();
+//new Object with merged layers and other features
$wmcGetApi->createFromXml($xml);
More information about the Mapbender_commits
mailing list