[fusion-commits] r1799 - trunk/layers/MapServer/php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri Feb 20 14:15:33 EST 2009
Author: pdeschamps
Date: 2009-02-20 14:15:33 -0500 (Fri, 20 Feb 2009)
New Revision: 1799
Modified:
trunk/layers/MapServer/php/Maptip.php
Log:
Trapped possible bug with an invalid layername specified.
Modified: trunk/layers/MapServer/php/Maptip.php
===================================================================
--- trunk/layers/MapServer/php/Maptip.php 2009-02-20 19:03:59 UTC (rev 1798)
+++ trunk/layers/MapServer/php/Maptip.php 2009-02-20 19:15:33 UTC (rev 1799)
@@ -84,49 +84,44 @@
foreach($aLayer as $key=>$layer){
$oLayer = @$oMap->GetLayerByName($layer);
- if(!is_object($oLayer)){
- echo "{'maptips':'','url':'','label':'','error':' The layer [".$layer."] was not found'}";
- die();
- }
+ // make sure the layer exists in the map.
+ if(is_object($oLayer)){
+ $oLayer->set('tolerance', 0);
- $oLayer->set('tolerance', 0);
+ if ($oLayer->type == MS_LAYER_RASTER || $oLayer->type == MS_LAYER_QUERY ||
+ $oLayer->type == MS_LAYER_CIRCLE || $oLayer->type == MS_LAYER_CHART) {
+ die("{'error':'maptips are only valid for vector layers'}");
+ }
- if ($oLayer->type == MS_LAYER_RASTER || $oLayer->type == MS_LAYER_QUERY ||
- $oLayer->type == MS_LAYER_CIRCLE || $oLayer->type == MS_LAYER_CHART) {
- die("{'error':'maptips are only valid for vector layers'}");
- }
+ if (@$oLayer->queryByShape($oSpatialFilter) == MS_SUCCESS) {
- if (@$oLayer->queryByShape($oSpatialFilter) == MS_SUCCESS) {
+ $oRes = $oLayer->getResult(0);
+ $oLayer->open();
- $oRes = $oLayer->getResult(0);
- $oLayer->open();
+ $oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);
- $oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);
+ $szMapTipText .= $oLayer->name." : ".$oShape->values[$aMapTipTextField[$key]].$szBreak;
- $szMapTipText .= $oLayer->name." : ".$oShape->values[$aMapTipTextField[$key]].$szBreak;
+ $szLabels = $aLabel[$key];
- $szLabels = $aLabel[$key];
+ $szMapTip = $oShape->values[$aMapTipTextField[$key]];
+ $szURL = buildCustonUrl($oShape->values,$aMapTipURL[$key]);
- $szMapTip = $oShape->values[$aMapTipTextField[$key]];
- $szURL = buildCustonUrl($oShape->values,$aMapTipURL[$key]);
+ $szMapTip = $szMapTip != "undefined" ? $szMapTip : "";
+ $szURL = $szURL != "undefined" ? $szURL : "";
+ $szLabels = $szLabels != "undefined" ? $szLabels : "";
- $szMapTip = $szMapTip != "undefined" ? $szMapTip : "";
- $szURL = $szURL != "undefined" ? $szURL : "";
- $szLabels = $szLabels != "undefined" ? $szLabels : "";
+ array_push($aMapTips, $szMapTip);
+ array_push($aURL, $szURL);
+ array_push($aTipLabel,$szLabels);
- array_push($aMapTips, $szMapTip);
- array_push($aURL, $szURL);
- array_push($aTipLabel,$szLabels);
-
- $oLayer->close();
+ $oLayer->close();
+ }
}
}
-
-echo "{'maptips':".var2json($aMapTips).",'url':".var2json($aURL).",'label':".var2json($aTipLabel)."}";
-
-
+ echo "{'maptips':".var2json($aMapTips).",'url':".var2json($aURL).",'label':".var2json($aTipLabel)."}";
}
else
{
More information about the fusion-commits
mailing list