[fusion-commits] r2319 - in trunk/layers: . MapServer MapServer/php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Jan 17 15:15:35 EST 2011
Author: madair
Date: 2011-01-17 12:15:35 -0800 (Mon, 17 Jan 2011)
New Revision: 2319
Modified:
trunk/layers/Layers.js
trunk/layers/MapServer/MapServer.js
trunk/layers/MapServer/php/LoadMap.php
Log:
re #79: adjusting for uniqueness of lower level groups with same name but different parents
Modified: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js 2011-01-14 05:33:47 UTC (rev 2318)
+++ trunk/layers/Layers.js 2011-01-17 20:15:35 UTC (rev 2319)
@@ -415,7 +415,7 @@
},
findGroup: function(name) {
- return this.findGroupByAttribute('name', name);
+ return this.findGroupByAttribute('uniqueId', name);
},
findGroupByAttribute: function(attribute, value) {
Modified: trunk/layers/MapServer/MapServer.js
===================================================================
--- trunk/layers/MapServer/MapServer.js 2011-01-14 05:33:47 UTC (rev 2318)
+++ trunk/layers/MapServer/MapServer.js 2011-01-17 20:15:35 UTC (rev 2319)
@@ -272,6 +272,7 @@
this.layerRoot.displayInLegend = true;
this.layerRoot.expandInLegend = true;
+ o.groups.sort(function(a,b) {return a.depth-b.depth} );
this.parseMapLayersAndGroups(o);
var minScale = 1.0e10;
@@ -377,12 +378,11 @@
loadScaleRanges: function() {
var sl = Fusion.getScriptLanguage();
var loadmapScript = 'layers/' + this.arch + '/' + sl + '/LoadScaleRanges.' + sl;
-
- var sessionid = this.getSessionID();
-
var params = {'mapname': this._sMapname, "session": this.getSessionID()};
- var options = {onSuccess: OpenLayers.Function.bind(this.scaleRangesLoaded, this),
- parameters:params};
+ var options = {
+ onSuccess: OpenLayers.Function.bind(this.scaleRangesLoaded, this),
+ parameters: params
+ };
Fusion.ajaxRequest(loadmapScript, options);
},
@@ -503,20 +503,6 @@
}
},
- parseLayers: function() {
- //this.layerRoot.clear();
- for (var i=0; i<this.aLayers.length; i++) {
- var layer = this.aLayers[i];
- var parent;
- if (layer.parentGroup != '') {
- parent = this.layerRoot.findGroup(layer.parentGroup.name);
- } else {
- parent = this.layerRoot;
- }
- parent.addLayer(layer, this.bLayersReversed);
- }
- },
-
updateLayer: function() { //to be fleshed out, add query file to layer if selection, call this before draw
if (this.hasSelection()) {
this.oLayerOL.addOptions({queryfile: this._sQueryfile});
Modified: trunk/layers/MapServer/php/LoadMap.php
===================================================================
--- trunk/layers/MapServer/php/LoadMap.php 2011-01-14 05:33:47 UTC (rev 2318)
+++ trunk/layers/MapServer/php/LoadMap.php 2011-01-17 20:15:35 UTC (rev 2319)
@@ -406,31 +406,40 @@
$layerObj->minScale = min($layerObj->minScale, $aScaleRanges[$j]->minScale);
$layerObj->maxScale = max($layerObj->maxScale, $aScaleRanges[$j]->maxScale);
}
- array_push($mapObj->layers, $layerObj);
//allow for nested groups using a "parentGroup" piece of metadata
//nesting of groups is accomplished by using the | as a separator
$parentStr = $layer->getMetaData('parentGroup');
- $nestedParents = explode('|',$parentStr);
- $parentParent = '';
- foreach($nestedParents as $parent) {
- //echo "testing:".$parent;
- if (strlen($parent)>0) {
+ $nestedParents = array();
+ if (strlen($parentStr)>0) {
+ $nestedParents = explode('|',$parentStr);
+ }
+ if (strlen($layer->group)>0) {
+ array_push($nestedParents, $layer->group);
+ $layerObj->parentGroup = implode("|",$nestedParents);
+ }
+ //echo "/*";
+ //print_r($nestedParents);
+ while (count($nestedParents)>0) {
$alreadyListed = false;
- foreach($mapObj->groups as $pGroup){
- if ($pGroup->groupName == $parent) {
+ $parentId = implode("|",$nestedParents);
+ $parent = array_pop($nestedParents);
+ //echo "-testing:".$parent." from:".$parentId."\n";
+ foreach($mapObj->groups as $pGroup) {
+ if ($pGroup->uniqueId == $parentId) {
$alreadyListed = true;
break;
}
}
if (!$alreadyListed) {
- array_push($mapObj->groups, getParentGroupObject($layer, $parent, $parentParent));
+ array_push($mapObj->groups, getGroupObject($layer, $parentId));
}
- }
- $parentParent = $parent;
}
+ //echo "*/";
+ array_push($mapObj->layers, $layerObj);
}
+ /*
$aGroups = $oMap->getAllGroupNames();
if (is_array($aGroups)) {
foreach($aGroups as $groupName) {
@@ -440,31 +449,32 @@
}
}
}
-
+ */
echo var2json($mapObj);
}
-function getGroupObject($layer) {
+function getGroupObject($layer, $parentId) {
$group = NULL;
- $group->groupName = $layer->group;
+
+ /* parent group for nested groups */
+ $group->uniqueId = $parentId;
+ $nestedParents = explode('|',$parentId);
+ $parent = array_pop($nestedParents);
+ $group->groupName = $parent;
+ $group->parentUniqueId = implode('|',$nestedParents);
+ $group->parent = $group->parentUniqueId;
+ $group->depth = count($nestedParents);
+
$ll = $layer->getMetaData('groupLegendLabel');
$group->legendLabel = $ll != '' ? $ll : $group->groupName;
- $group->uniqueId = $group->groupName;
$b = $layer->getMetaData('groupDisplayInLegend');
$group->displayInLegend = ($b == 'false') ? false : true;
$b = $layer->getMetaData('groupExpandInLegend');
$group->expandInLegend = ($b == 'false') ? false : true;
$group->layerGroupType = '';
- /* parent group for nested groups */
- $parentStr = $layer->getMetaData('parentGroup');
- $nestedParents = explode('|',$parentStr);
- $parent = array_pop($nestedParents);
- $group->parentUniqueId = $parent;
- $group->parent = $parent;
$b = $layer->getMetaData('groupVisible');
$group->visible = ($b == 'false') ? false : true;
$group->actuallyVisible = $layer->isVisible();
- $group->groupParent = $layer->getMetaData('groupParent');
return $group;
}
@@ -482,12 +492,11 @@
$group->expandInLegend = ($b == 'false') ? false : true;
$group->layerGroupType = '';
/* maybe do some parsing of the metadata to get parents of paretns? */
- $group->parentUniqueId = $parent;
+ $group->parentUniqueId = $parentGroup;
$group->parent = $parent;
$b = $layer->getMetaData('groupVisible');
$group->visible = ($b == 'false') ? false : true;
$group->actuallyVisible = $layer->isVisible();
- $group->groupParent = $layer->getMetaData('groupParent');
return $group;
}
More information about the fusion-commits
mailing list