[fusion-commits] r1380 - in sandbox/olcore: . layers layers/MapGuide layers/MapGuide/php layers/MapServer layers/MapServer/php

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Apr 18 10:33:05 EDT 2008


Author: madair
Date: 2008-04-18 10:33:05 -0400 (Fri, 18 Apr 2008)
New Revision: 1380

Added:
   sandbox/olcore/layers/MapGuide/
   sandbox/olcore/layers/MapServer/
Removed:
   sandbox/olcore/MapGuide/
   sandbox/olcore/MapServer/
Modified:
   sandbox/olcore/layers/MapGuide/MapGuide.js
   sandbox/olcore/layers/MapGuide/php/Common.php
   sandbox/olcore/layers/MapGuide/php/CreateSession.php
   sandbox/olcore/layers/MapGuide/php/LoadMap.php
   sandbox/olcore/layers/MapServer/MapServer.js
   sandbox/olcore/layers/MapServer/php/CreateSession.php
   sandbox/olcore/layers/MapServer/php/LoadMap.php
   sandbox/olcore/layers/MapServer/php/Measure.php
   sandbox/olcore/layers/MapServer/php/Query.php
   sandbox/olcore/layers/MapServer/php/Selection.php
Log:
initial cut  at refactoring Map classes - missing files

Copied: sandbox/olcore/layers/MapGuide (from rev 1378, sandbox/olcore/MapGuide)

Modified: sandbox/olcore/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/olcore/MapGuide/MapGuide.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapGuide/MapGuide.js	2008-04-18 14:33:05 UTC (rev 1380)
@@ -1,5 +1,5 @@
 /**
- * Fusion.Maps.MapGuide
+ * Fusion.Layers.MapGuide
  *
  * $Id$
  *
@@ -24,56 +24,30 @@
  */
 
 /***************************************************************************
-* Class: Fusion.Maps.MapGuide
+* Class: Fusion.Layers.MapGuide
 *
 * Implements the map widget for MapGuide Open Source services.
 */
 
-Fusion.Maps.MapGuide = OpenLayers.Class(Fusion.Lib.EventMgr, {
-    arch: 'MapGuide',
-    session: [null],
-    bSingleTile: null,
-    aShowLayers: null,
-    aHideLayers: null,
-    aShowGroups: null,
-    aHideGroups: null,
-    aRefreshLayers: null,
-    sActiveLayer: null,
-    selectionType: 'INTERSECTS',
-    bSelectionOn: false,
-    oSelection: null,
-    bDisplayInLegend: true,   //TODO: set this in AppDef?
-    bExpandInLegend: true,   //TODO: set this in AppDef?
-    bMapLoaded : false,
-    bIsMapWidgetLayer : true,  //Setthis to false for overview map layers
-    bLayersReversed: false,     //MGOS returns layers top-most layer first
-
+Fusion.Layers.MapGuide = OpenLayers.Class(Fusion.Layers, {
     //the resource id of the current MapDefinition
     _sResourceId: null,
+    arch: 'MapGuide',
     
+    WKT: {                    //lookup table of MGOS WKT to EPSG codes
+      "GEOGCS[\"WGS84 Lat/Long's, Degrees, -180 ==> +180\",DATUM[\"D_WGS_1984\",SPHEROID[\"World_Geodetic_System_of_1984\",6378137,298.257222932867]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]": 'WGS84'    //used in Sheboygan example
+    },
+
     initialize : function(map, mapTag, isMapWidgetLayer) {
         // console.log('MapGuide.initialize');
+        Fusion.Layers.prototype.initialize.apply(this, arguments);
                 
-        this.registerEventID(Fusion.Event.MAP_SESSION_CREATED);
-        this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
-        this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
-        this.registerEventID(Fusion.Event.MAP_LOADED);
-        this.registerEventID(Fusion.Event.MAP_LOADING);
-
-        this.mapWidget = map;
-        this.oSelection = null;
-        if (isMapWidgetLayer != null) {
-            this.bIsMapWidgetLayer = isMapWidgetLayer;
-        }
         this.mapInfo = mapTag.mapInfo;
-        var extension = mapTag.extension; //TBD: this belongs in layer tag?
-        this.selectionType = extension.SelectionType ? extension.SelectionType[0] : 'INTERSECTS';
-        this.ratio = extension.MapRatio ? extension.MapRatio[0] : 1.0;
         
         //add in the handler for CTRL-click actions for the map, not an overviewmap
         if (this.bIsMapWidgetLayer) {
           var ctrlClickEnabled = true;
-          if (extension.DisableCtrlClick && extension.DisableCtrlClick[0] == 'true') {
+          if (this.extension.DisableCtrlClick && this.extension.DisableCtrlClick[0] == 'true') {
               ctrlClickEnabled = false;
           }
           if (ctrlClickEnabled) {
@@ -88,322 +62,23 @@
        
         this.sMapResourceId = mapTag.resourceId ? mapTag.resourceId : '';
         
-        rootOpts = {
-          displayInLegend: this.bDisplayInLegend,
-          expandInLegend: this.bExpandInLegend,
-          legendLabel: this._sMapname,
-          groupName: 'layerRoot'
-          //TODO: set other opts for group initialization as required
-        };
-        this.layerRoot = new Fusion.Maps.MapGuide.Group(rootOpts,this);
-        
-        this.bSingleTile = mapTag.singleTile; //this is set in thhe AppDef.Map class
-
-        this.keepAliveInterval = parseInt(extension.KeepAliveInterval ? extension.KeepAliveInterval[0] : 300);
-        
-        var sid = Fusion.sessionId;
-        if (sid) {
-            this.session[0] = sid;
-            this.mapSessionCreated();
-        } else {
-            this.createSession();
-        }
-        
-        
     },
 
-    createSession: function() {
-        if (!this.session[0]) {
-            this.session[0] = this;
-            var sl = Fusion.getScriptLanguage();
-            var scriptURL = this.arch + '/' + sl + '/CreateSession.' + sl;
-            var options = {onSuccess: OpenLayers.Function.bind(this.createSessionCB, this)};
-            Fusion.ajaxRequest(scriptURL,options);  
-        }
-        if (this.session[0] instanceof Fusion.Maps.MapGuide) {
-            // console.log('register for event');
-            this.session[0].registerForEvent(Fusion.Event.MAP_SESSION_CREATED, 
-                OpenLayers.Function.bind(this.mapSessionCreated, this));
-        } else {
-            this.mapSessionCreated();
-        }
+    loadMapParams: function() {
+        return {'mapid': this.sMapResourceId, "session": this.getSessionID()};
     },
     
-    createSessionCB : function(xhr) {
-        if (xhr.status == 200) {
-            var o;
-            eval('o='+xhr.responseText);
-            this.session[0] = o.sessionId;
-            this.triggerEvent(Fusion.Event.MAP_SESSION_CREATED);
-        }
-    },
-
-    mapSessionCreated: function() {
-        if (this.sMapResourceId != '') {
-            this.loadMap(this.sMapResourceId);
-        }
-        window.setInterval(OpenLayers.Function.bind(this.pingServer, this), this.keepAliveInterval * 1000);
-    },
-
-    sessionReady: function() {
-        return (typeof this.session[0] == 'string');
-    },
-
-    getSessionID: function() {
-        return this.session[0];
-    },
-    
-    getMapName: function() {
-        return this._sMapname;
-    },
-    
-    getMapTitle: function() {
-        return this._sMapTitle;
-    },
-    
-    loadMap: function(resourceId, options) {
-        this.bMapLoaded = false;
-
-        /* don't do anything if the map is already loaded? */
-        if (this._sResourceId == resourceId) {
-            return;
-        }
-
-        if (!this.sessionReady()) {
-            this.sMapResourceId = resourceId;
-            return;
-        }
-        
-        if (this.bIsMapWidgetLayer) {
-            this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADING);
-        } else {
-          this.triggerEvent(Fusion.Event.MAP_LOADING);
-        }
-        this.mapWidget._addWorker();
-        
-        this._fScale = -1;
-        this._nDpi = 96;
-        
-        options = options || {};
-        
-        this._oMaxExtent = null;
-        this.aShowLayers = options.showlayers || [];
-        this.aHideLayers = options.hidelayers || [];
-        this.aShowGroups = options.showgroups || [];
-        this.aHideGroups = options.hidegroups || [];
-        this.aRefreshLayers = options.refreshlayers || [];
-        this.aLayers = [];
-
-        this.oSelection = null;
-        this.aSelectionCallbacks = [];
-        this._bSelectionIsLoading = false;
-
-        var sl = Fusion.getScriptLanguage();
-        var loadmapScript = this.arch + '/' + sl  + '/LoadMap.' + sl;
-        
-        var sessionid = this.getSessionID();
-        
-        var params = {'mapid': resourceId, "session": sessionid};
-        var options = {onSuccess: OpenLayers.Function.bind(this.mapLoaded,this), 
-                       parameters:params};
-        Fusion.ajaxRequest(loadmapScript, options);
-    },
-    
-    mapLoaded: function(r) {
-        if (r.status == 200) {
-            var o;
-            eval('o='+r.responseText);
-            this._sResourceId = o.mapId;
-            this._sMapname = o.mapName;
-            this._sMapTitle = o.mapTitle;
-            this._fMetersperunit = o.metersPerUnit;
-            this.mapWidget._fMetersperunit = this._fMetersperunit;
-
-            this._oMaxExtent = OpenLayers.Bounds.fromArray(o.extent); 
-
-            this.layerRoot.clear();
-            this.layerRoot.legendLabel = this._sMapTitle;
-            
-            this.parseMapLayersAndGroups(o);
-            
-            this.minScale = 1.0e10;
-            this.maxScale = 0;
-            for (var i=0; i<this.aLayers.length; i++) {
-              this.minScale = Math.min(this.minScale, this.aLayers[i].minScale);
-              this.maxScale = Math.max(this.maxScale, this.aLayers[i].maxScale);
-            }
-            //a scale value of 0 is undefined
-            if (this.minScale <= 0) {
-              this.minScale = 1.0;
-            }
-            
-            for (var i=0; i<this.aShowLayers.length; i++) {
-                var layer =  this.layerRoot.findLayerByAttribute('layerName', this.aShowLayers[i]);
-                if (layer) {
-                    this.aShowLayers[i] = layer.uniqueId;
-                } else {
-                    this.aShowLayers[i] = '';
-                }
-            }
-            for (var i=0; i<this.aHideLayers.length; i++) {
-                var layer =  this.layerRoot.findLayerByAttribute('layerName', this.aHideLayers[i]);
-                if (layer) {
-                    this.aHideLayers[i] = layer.uniqueId;
-                } else {
-                    this.aHideLayers[i] = '';
-                }
-            }
-            
-            for (var i=0; i<this.aShowGroups.length; i++) {
-                var group =  this.layerRoot.findGroupByAttribute('groupName', this.aShowGroups[i]);
-                if (group) {
-                    this.aShowGroups[i] = group.uniqueId;
-                } else {
-                    this.aShowGroups[i] = '';
-                }
-            }
-            
-            for (var i=0; i<this.aHideGroups.length; i++) {
-                var group =  this.layerRoot.findGroupByAttribute('groupName', this.aHideGroups[i]);
-                if (group) {
-                    this.aHideGroups[i] = group.uniqueId;
-                } else {
-                    this.aHideGroups[i] = '';
-                }
-            }
-            
-            if (!this.bSingleTile) {
-              if (o.groups.length >0) {
-                this.bSingleTile = false;
-                this.groupName = o.groups[0].groupName  //assumes only one group for now
-              } else {
-                this.bSingleTile = true;
-              }
-            }
-
-            //set projection units and code if supplied
-            //TODO: consider passing the metersPerUnit value into the framework
-            //to allow for scaling that doesn't match any of the pre-canned units
-            this.units = this.getClosestUnits(o.metersPerUnit);
-            
-            //add in scales array if supplied
-            if (o.FiniteDisplayScales && o.FiniteDisplayScales.length>0) {
-              this.scales = o.FiniteDisplayScales;
-            }
-            
-            //remove this layer if it was already created
-            if (this.oLayerOL) {
-                this.oLayerOL.events.unregister("loadstart", this, this.loadStart);
-                this.oLayerOL.events.unregister("loadend", this, this.loadEnd);
-                this.oLayerOL.events.unregister("loadcancel", this, this.loadEnd);
-                this.oLayerOL.destroy();
-            }
-
-            this.oLayerOL = this.createOLLayer(this._sMapname, true, this.bSingleTile);
-            this.oLayerOL.events.register("loadstart", this, this.loadStart);
-            this.oLayerOL.events.register("loadend", this, this.loadEnd);
-            this.oLayerOL.events.register("loadcancel", this, this.loadEnd);
-            
-            //this is to distinguish between a regular map and an overview map
-            if (this.bIsMapWidgetLayer) {
-              this.mapWidget.addMap(this);
-              this.mapWidget.oMapOL.setBaseLayer(this.oLayerOL);
-              this.mapWidget._oInitialExtents = null;
-              this.mapWidget.fullExtents();
-              this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADED);
-            } else {
-              this.triggerEvent(Fusion.Event.MAP_LOADED);
-            }
-            this.bMapLoaded = true;
-        }
-        this.mapWidget._removeWorker();
-    },
-    
-    getClosestUnits: function(metrsPerUnit) {
-        
-        var units = "degrees";
-        var minDiff = 100000000;
-        for (var key in OpenLayers.INCHES_PER_UNIT)        
-        {
-            var newDiff = Math.abs((metrsPerUnit * 39.3701) - OpenLayers.INCHES_PER_UNIT[key]);
-            if(newDiff < minDiff)
-            {
-                minDiff = newDiff;
-                units = key;
-            }
-        }
-        return units;
-    },
-
 //TBD: this function not yet converted for OL    
-    reloadMap: function() {
-        
-        this.mapWidget._addWorker();
-        //console.log('loadMap: ' + resourceId);
-        this.aShowLayers = [];
-        this.aHideLayers = [];
-        this.aShowGroups = [];
-        this.aHideGroups = [];
-        this.aRefreshLayers = [];
-        this.layerRoot.clear();
-        this.oldLayers = this.aLayers.clone();
-        this.aLayers = [];
-        
-        var sl = Fusion.getScriptLanguage();
-        var loadmapScript = this.arch + '/' + sl  + '/LoadMap.' + sl;
-        
-        var sessionid = this.getSessionID();
-        
-        var params = {'mapname': this._sMapname, 'session': sessionid};
-        var options = {
-              onSuccess: OpenLayers.Function.bind(this.mapReloaded,this), 
-              onException: OpenLayers.Function.bind(this.reloadFailed, this),
-              parameters: params};
-        Fusion.ajaxRequest(loadmapScript, options);
+    reloadMapParams: function() {
+        return {'mapname': this._sMapname, 'session': this.getSessionID()};
     },
 
-    reloadFailed: function(r) {
-      Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL, 
-        OpenLayers.i18n('mapLoadError', {'error':r.transport.responseText})));
-      this.mapWidget._removeWorker();
-    },
-
-//TBD: this function not yet converted for OL    
-    mapReloaded: function(r) {
-        if (r.status == 200) {
-            var o;
-            eval('o='+r.responseText);
-            this.parseMapLayersAndGroups(o);
-            for (var i=0; i<this.aLayers.length; ++i) {
-              var newLayer = this.aLayers[i];
-              for (var j=0; j<this.oldLayers.length; ++j){
-                if (this.oldLayers[j].uniqueId == newLayer.uniqueId) {
-                  newLayer.selectedFeatureCount = this.oldLayers[j].selectedFeatureCount;
-                  break;
-                }
-              }
-            }
-            this.oldLayers = null;
-            this.mapWidget.triggerEvent(Fusion.Event.MAP_RELOADED);
-            this.drawMap();
-        }
-        this.mapWidget._removeWorker();
-    },
-    
-    reorderLayers: function(aLayerIndex) {
-        var sl = Fusion.getScriptLanguage();
-        var loadmapScript = this.arch + '/' + sl  + '/SetLayers.' + sl;
-        
-        var params = {
+    reorderLayersParams: function(aLayerIndex) {
+        return {
             'mapname': this._sMapname, 
             'session': this.getSessionID(),
             'layerindex': aLayerIndex.join()
         };
-        
-        var options = {
-            onSuccess: OpenLayers.Function.bind(this.mapLayersReset, this, aLayerIndex), 
-            parameters: params};
-        Fusion.ajaxRequest(loadmapScript, options);
     },
     
     mapLayersReset: function(aLayerIndex,r) {  
@@ -429,62 +104,15 @@
         }
     },
             
-    parseMapLayersAndGroups: function(o) {
-        for (var i=0; i<o.groups.length; i++) {
-            var group = new Fusion.Maps.MapGuide.Group(o.groups[i], this);
-            var parent;
-            if (group.parentUniqueId != '') {
-                parent = this.layerRoot.findGroupByAttribute('uniqueId', group.parentUniqueId);
-            } else {
-                parent = this.layerRoot;
-            }
-            parent.addGroup(group, this.bLayersReversed);
-        }
-
-        for (var i=0; i<o.layers.length; i++) {
-            var layer = new Fusion.Maps.MapGuide.Layer(o.layers[i], this);
-            var parent;
-            if (layer.parentGroup != '') {
-                parent = this.layerRoot.findGroupByAttribute('uniqueId', layer.parentGroup);
-            } else {
-                parent = this.layerRoot;
-            }
-            parent.addLayer(layer, this.bLayersReversed);
-            this.aLayers.push(layer);
-        }
-    },
-    
-    drawMap: function() {
-        if (!this.bMapLoaded) {
-            return;
-        }
-        
-        var params = {
-          ts : (new Date()).getTime(),  //add a timestamp to prevent caching on the server
-          showLayers : this.aShowLayers.length > 0 ? this.aShowLayers.toString() : null,
-          hideLayers : this.aHideLayers.length > 0 ? this.aHideLayers.toString() : null,
-          showGroups : this.aShowGroups.length > 0 ? this.aShowGroups.toString() : null,
-          hideGroups : this.aHideGroups.length > 0 ? this.aHideGroups.toString() : null,
-          refreshLayers : this.aRefreshLayers.length > 0 ? this.aRefreshLayers.toString() : null
-        };
-        this.aShowLayers = [];
-        this.aHideLayers = [];
-        this.aShowGroups = [];
-        this.aHideGroups = [];
-        this.aRefreshLayers = [];
-
-        this.oLayerOL.mergeNewParams(params);
-        if (this.queryLayer) this.queryLayer.redraw();
-    },
-
     /**
      * Function: createOLLayer
      * 
      * Returns an OpenLayers MapGuide layer object
      */
-    createOLLayer: function(layerName, bIsBaseLayer, bSingleTile, bFractionalZoom) {
+    createOLLayer: function(layerName, projCode, bIsBaseLayer, bSingleTile, bFractionalZoom) {
       var layerOptions = {
         units : this.units,
+        projection: projCode,
         isBaseLayer : bIsBaseLayer,
         maxExtent : this._oMaxExtent,
         maxResolution : 'auto',
@@ -530,112 +158,6 @@
       return oLayerOL;
     },
             
-    /**
-     * Function: getLayerByName
-     * 
-     * Returns the MapGuide layer object as identified by the layer name
-     */
-    getLayerByName : function(name)
-    {
-        var oLayer = null;
-        for (var i=0; i<this.aLayers.length; i++)
-        {
-            if (this.aLayers[i].layerName == name)
-            {
-                oLayer = this.aLayers[i];
-                break;
-            }
-        }
-        return oLayer;
-    },
-
-    /**
-     * Function: isMapLoaded
-     * 
-     * Returns true if the Map has been laoded succesfully form the server
-     */
-    isMapLoaded: function() {
-        return this.bMapLoaded;
-    },
-
-    hasSelection: function() { return this.bSelectionOn; },
-    
-    getSelectionCB : function(userFunc, layers, startend, r) {
-      if (r.status == 200) 
-      {
-          var o;
-          eval("o="+r.responseText);
-
-          var oSelection = new GxSelectionObject(o);
-          userFunc(oSelection);
-      }
-      
-    },
-    
-    /**
-     * advertise a new selection is available and redraw the map
-     */
-    newSelection: function() {
-        if (this.oSelection) {
-            this.oSelection = null;
-        }
-        this.bSelectionOn = true;
-        this.drawMap();
-        this.triggerEvent(Fusion.Event.MAP_SELECTION_ON);
-    },
-
-    /**
-     * Returns the number of features selected for this map layer
-     */
-    getSelectedFeatureCount : function() {
-      var total = 0;
-      for (var j=0; j<this.aLayers.length; ++j) {
-        total += this.aLayers[j].selectedFeatureCount;
-      }
-      return total;
-    },
-
-    /**
-     * Returns the number of features selected for this map layer
-     */
-    getSelectedLayers : function() {
-      var layers = [];
-      for (var j=0; j<this.aLayers.length; ++j) {
-        if (this.aLayers[j].selectedFeatureCount>0) {
-          layers.push(this.aLayers[j]);
-        }
-      }
-      return layers;
-    },
-
-    /**
-     * Returns the number of features selected for this map layer
-     */
-    getSelectableLayers : function() {
-      var layers = [];
-      for (var j=0; j<this.aLayers.length; ++j) {
-        if (this.aLayers[j].selectable) {
-          layers.push(this.aLayers[j]);
-        }
-      }
-      return layers;
-    },
-
-     /**
-      * Function: zoomToSelection
-      *
-      * sets a Selection XML back to the server
-      */
-    zoomToSelection: function(extent) {
-      var center = extent.getCenterPixel();
-      var size = extent.getSize();
-      extent.left = center.x - 2*size.w;
-      extent.right = center.x + 2*size.w;
-      extent.bottom = center.y - 2*size.h;
-      extent.top = center.y + 2*size.h;
-      this.mapWidget.setExtents(extent);
-    },  
-
     setSelection: function (selText, zoomTo) {
       this.mapWidget._addWorker();
       var sl = Fusion.getScriptLanguage();
@@ -752,7 +274,7 @@
             if (oNode.hasSelection) {
               if (!this.bSingleTile) {
                 if (!this.queryLayer) {
-                  this.queryLayer = this.createOLLayer("query layer", false, true);
+                  this.queryLayer = this.createOLLayer("query layer", this.projectionCode, false, true);
                   this.mapWidget.oMapOL.addLayer(this.queryLayer);
                   this.mapWidget.registerForEvent(Fusion.Event.MAP_LOADING, 
                         OpenLayers.Function.bind(this.removeQueryLayer, this));
@@ -986,7 +508,7 @@
     },
     
     pingServer: function() {
-        var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
+        var s = 'maps/' + this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
         var params = {};
         params.parameters = {'session': this.getSessionID()};
         Fusion.ajaxRequest(s, params);
@@ -1016,12 +538,12 @@
 });
     
 /***************************************************************************
-* Class: Fusion.Maps.MapGuide.Group
+* Class: Fusion.Layers.MapGuide.Group
 *
 * Implements the map layer groups for MapGuide services
 */
 
-Fusion.Maps.MapGuide.Group = OpenLayers.Class(Fusion.Widget.Map.Group, {
+Fusion.Layers.MapGuide.Group = OpenLayers.Class(Fusion.Widget.Map.Group, {
     oMap: null,
     initialize: function(o, oMap) {
         this.uniqueId = o.uniqueId;
@@ -1065,12 +587,12 @@
 });
 
 /***************************************************************************
-* Class: Fusion.Maps.MapGuide
+* Class: Fusion.Layers.MapGuide
 *
 * Implements individual map legend layers for MapGuide services
 */
 
-Fusion.Maps.MapGuide.Layer = OpenLayers.Class(Fusion.Widget.Map.Layer, {
+Fusion.Layers.MapGuide.Layer = OpenLayers.Class(Fusion.Widget.Map.Layer, {
     
     scaleRanges: null,
     oMap: null,
@@ -1105,7 +627,7 @@
         this.minScale = 1.0e10;
         this.maxScale = 0;
         for (var i=0; i<o.scaleRanges.length; i++) {
-          var scaleRange = new Fusion.Maps.MapGuide.ScaleRange(o.scaleRanges[i], 
+          var scaleRange = new Fusion.Layers.MapGuide.ScaleRange(o.scaleRanges[i], 
                                 this.layerType);
           this.scaleRanges.push(scaleRange);
           this.minScale = Math.min(this.minScale, scaleRange.minScale);
@@ -1159,12 +681,12 @@
 });
 
 /***************************************************************************
-* Class: Fusion.Maps.MapGuide
+* Class: Fusion.Layers.MapGuide
 *
 * Implements a scale range object for MapGuide services
 */
 
-Fusion.Maps.MapGuide.ScaleRange = OpenLayers.Class({
+Fusion.Layers.MapGuide.ScaleRange = OpenLayers.Class({
     styles: null,
     initialize: function(o, layerType) {
         this.minScale = o.minScale;
@@ -1174,13 +696,13 @@
         }
         this.styles = [];
         if (!o.styles) {
-          var styleItem = new Fusion.Maps.MapGuide.StyleItem({legendLabel:'DWF'}, layerType);
+          var styleItem = new Fusion.Layers.MapGuide.StyleItem({legendLabel:'DWF'}, layerType);
           this.styles.push(styleItem);
           return;
         }
         var staticIcon = o.styles.length>1 ? false : layerType;
         for (var i=0; i<o.styles.length; i++) {
-            var styleItem = new Fusion.Maps.MapGuide.StyleItem(o.styles[i], staticIcon);
+            var styleItem = new Fusion.Layers.MapGuide.StyleItem(o.styles[i], staticIcon);
             this.styles.push(styleItem);
         }
     },
@@ -1190,12 +712,12 @@
 });
 
 /***************************************************************************
-* Class: Fusion.Maps.MapGuide
+* Class: Fusion.Layers.MapGuide
 *
 * Implements the legend style items to get a legend icon from the server
 */
 
-Fusion.Maps.MapGuide.StyleItem = OpenLayers.Class({
+Fusion.Layers.MapGuide.StyleItem = OpenLayers.Class({
     initialize: function(o, staticIcon) {
         this.legendLabel = o.legendLabel;
         this.filter = o.filter;

Modified: sandbox/olcore/layers/MapGuide/php/Common.php
===================================================================
--- sandbox/olcore/MapGuide/php/Common.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapGuide/php/Common.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -36,7 +36,7 @@
  * this file to configure Fusion.
  */
 
-$defaultInstallDir = dirname(__FILE__)."/../../../../../";
+$defaultInstallDir = dirname(__FILE__)."/../../../../../../";
 $defaultExtensionDir = realpath($defaultInstallDir . "webserverextensions/www/");
 
 /**

Modified: sandbox/olcore/layers/MapGuide/php/CreateSession.php
===================================================================
--- sandbox/olcore/MapGuide/php/CreateSession.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapGuide/php/CreateSession.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -29,7 +29,7 @@
  *****************************************************************************/
 
 include('Common.php');
-include('../../common/php/Utilities.php');
+include('../../../common/php/Utilities.php');
 
 try {
     $site = $siteConnection->GetSite();

Modified: sandbox/olcore/layers/MapGuide/php/LoadMap.php
===================================================================
--- sandbox/olcore/MapGuide/php/LoadMap.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapGuide/php/LoadMap.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -78,6 +78,7 @@
       @$csFactory = new MgCoordinateSystemFactory();
       @$cs = $csFactory->Create($srs);
       @$metersPerUnit = $cs->ConvertCoordinateSystemUnitsToMeters(1.0);
+      //@$projectionCode = $csFactory->ConvertWktToEpsgCode($srs);
       //  $unitsType = $cs->GetUnits();
     }
     else
@@ -92,6 +93,7 @@
     echo "{";
     echo "sessionId:'$sessionID',";
     echo "mapId:'$mapid',";
+    echo "projectionWKT:'".addslashes($srs)."',";
     echo "metersPerUnit:$metersPerUnit,";
     //echo "mapTitle:'".addslashes(htmlentities($mapTitle))."',";
     //echo "mapName:'".addslashes(htmlentities($mapName))."',";

Copied: sandbox/olcore/layers/MapServer (from rev 1378, sandbox/olcore/MapServer)

Modified: sandbox/olcore/layers/MapServer/MapServer.js
===================================================================
--- sandbox/olcore/MapServer/MapServer.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapServer/MapServer.js	2008-04-18 14:33:05 UTC (rev 1380)
@@ -1,5 +1,5 @@
 /**
- * Fusion.Maps.MapServer
+ * Fusion.Layers.MapServer
  *
  * $Id$
  *
@@ -24,369 +24,79 @@
  */
 
 /******************************************************************************
- * Class: Fusion.Maps.MapServer
+ * Class: Fusion.Layers.MapServer
  *
  * Implementation of the map widget for MapServer CGI interface services
 */
 Fusion.Event.MAP_LAYER_ORDER_CHANGED = Fusion.Event.lastEventId++;
 
-Fusion.Maps.MapServer = OpenLayers.Class(Fusion.Lib.EventMgr, {
+Fusion.Layers.MapServer = OpenLayers.Class(Fusion.Layers, {
     arch: 'MapServer',
-    session: [null],
-    aShowLayers: null,
-    aHideLayers: null,
-    aShowGroups: null,
-    aHideGroups: null,
-    aRefreshLayers: null,
-    sActiveLayer: null,
-    selectionType: 'INTERSECTS',
-    bSelectionOn: false,
-    bDisplayInLegend: true,   //TODO: set this in AppDef?
-    bExpandInLegend: true,   //TODO: set this in AppDef?
-    oSelection: null,
-    bMapLoaded : false,
-    bIsMapWidgetLayer : true,  //Setthis to false for overview map layers
-    bLayersReversed: true,     //MS returns layers bottom-most layer first, we treat layer order in reverse sense
     mapMetadataKeys: null,
     layerMetadataKeys: null,
+    aVisibleLayers: null,
+    aVisibleGroups: null,
 
-    //the map file
-    sMapFile: null,
-
-    //imagetype
-    _sImageType : 'png',
-
     initialize : function(map, mapTag, isMapWidgetLayer) {
-        //console.log('Fusion.Maps.MapServer.initialize');
-        /*
-        //Object.inheritFrom(this, Fusion.Lib.EventMgr, []);
+        //console.log('Fusion.Layers.MapServer.initialize');
+        Fusion.Layers.prototype.initialize.apply(this, arguments);
         
-        prototype is not yet defined when this is called now omitting. 
-
-        Fusion.Lib.EventMgr.prototype.initialize.apply(this, []);
-        */
-
-        this.registerEventID(Fusion.Event.MAP_SESSION_CREATED);
-        this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
-        this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
-        this.registerEventID(Fusion.Event.MAP_LOADED);
-        this.registerEventID(Fusion.Event.MAP_LOADING);
-        this.registerEventID(Fusion.Event.MAP_LAYER_ORDER_CHANGED);
-
-        this.mapWidget = map;
-        this.oSelection = null;
-        if (isMapWidgetLayer != null) {
-            this.bIsMapWidgetLayer = isMapWidgetLayer;
-        }
-
-        var extension = mapTag.extension;
-        this.ratio = extension.MapRatio ? extension.MapRatio[0] : '1.0';
-        //this.selectionType = extension.SelectionType ? extension.SelectionType[0] : 'INTERSECTS';
-
-        rootOpts = {
-          displayInLegend: this.bDisplayInLegend,
-          expandInLegend: this.bExpandInLegend,
-          legendLabel: this._sMapname,
-          uniqueId: 'layerRoot',
-          groupName: 'layerRoot',
-          visible: true,
-          actuallyVisible: true
-          //TODO: set other opts for group initialization as required
-        };
-        this.layerRoot = new Fusion.Maps.MapServer.Group(rootOpts,this);
-
-        this.sMapFile = extension.MapFile ? extension.MapFile[0] : '';
-
-        this.mapMetadataKeys = extension.MapMetadata ? extension.MapMetadata[0] : null;
-        this.layerMetadataKeys = extension.LayerMetadata ? extension.LayerMetadata[0] : null;
-
-        this.bSingleTile = mapTag.singleTile;// this is set by the AppDef.Map object
-
-        this.keepAliveInterval = parseInt(extension.KeepAliveInterval ? extension.KeepAliveInterval[0] : 300);
-
-        if (mapTag.sid) {
-            this.session[0] = mapTag.sid;
-            this.mapSessionCreated();
-        } else {
-            this.createSession();
-        }
+        this.sMapResourceId = this.extension.MapFile ? this.extension.MapFile[0] : '';
+        this.mapMetadataKeys = this.extension.MapMetadata ? this.extension.MapMetadata[0] : null;
+        this.layerMetadataKeys = this.extension.LayerMetadata ? this.extension.LayerMetadata[0] : null;
+        
+        this.aVisibleLayers = this.extension.Showlayers || [];
+        this.aVisibleGroups = this.extension.Showgroups || [];
     },
 
-    createSession: function() {
-        if (!this.session[0]) {
-            this.session[0] = this;
-            var sl = Fusion.getScriptLanguage();
-            var scriptURL = this.arch + '/' + sl + '/CreateSession.' + sl;
-            var options = {onSuccess: OpenLayers.Function.bind(this.createSessionCB, this)};
-            Fusion.ajaxRequest(scriptURL,options);
-        }
-        if (this.session[0] instanceof Fusion.Maps.MapServer) {
-            this.session[0].registerForEvent(Fusion.Event.MAP_SESSION_CREATED, 
-                        OpenLayers.Function.bind(this.mapSessionCreated, this));
+    getMapParams: function() {
+        var params;
+        if (this.getMapName()) {
+            params = {
+                'mapname': this.getMapName(),
+                'session': this.getSessionID()
+            };
         } else {
-            this.mapSessionCreated();
-        }
-    },
-
-    createSessionCB : function(r) {
-        if (r.status == 200) {
-            var o;
-            eval('o='+r.responseText);
-            this.session[0] = o.sessionId;
-            this.triggerEvent(Fusion.Event.MAP_SESSION_CREATED);
-        }
-    },
-
-    mapSessionCreated: function() {
-        if (this.sMapFile != '') {
-            this.loadMap(this.sMapFile);
-        }
-        window.setInterval(OpenLayers.Function.bind(this.pingServer, this), 
-                                                this.keepAliveInterval * 1000);
-    },
-
-    sessionReady: function() {
-        return (typeof this.session[0] == 'string');
-    },
-
-    getSessionID: function() {
-        return this.session[0];
-    },
-
-    getMapName: function() {
-        return this._sMapname;
-    },
-
-    getMapTitle: function() {
-        return this._sMapTitle;
-    },
-
-    loadMap: function(mapfile, options) {
-        while (this.mapWidget.isBusy()) {
-	        this.mapWidget._removeWorker();
-		}
-        this.bMapLoaded = false;
-        //console.log('loadMap: ' + resourceId);
-        /* don't do anything if the map is already loaded? */
-        if (this._sMapFile == mapfile) {
-            return;
-        }
-
-        if (!this.sessionReady()) {
-            this.sMapFile = mapfile;
-            return;
-        }
-
-        if (this.bIsMapWidgetLayer) {
-            this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADING);
-        } else {
-            this.triggerEvent(Fusion.Event.MAP_LOADING);
-        }
-        this.mapWidget._addWorker();
-
-        this._fScale = -1;
-        this._nDpi = 72;
-
-        options = options || {};
-
-        this._oMaxExtent = null;
-        this.aVisibleLayers = options.showlayers || [];
-        this.aVisibleGroups = options.showgroups || [];
-        this.aLayers = [];
-
-        this.oSelection = null;
-        this.aSelectionCallbacks = [];
-        this._bSelectionIsLoading = false;
-
-        var sl = Fusion.getScriptLanguage();
-        var loadmapScript = this.arch + '/' + sl  + '/LoadMap.' + sl;
-        var params = {
-            'mapfile': mapfile,
-            'session': this.getSessionID()
-        };
-        if (this.mapMetadataKeys) {
-            params.map_metadata = this.mapMetadataKeys;
-        }
-        if (this.layerMetadataKeys) {
-            params.layer_metadata = this.layerMetadataKeys;
-        }
-        var options = {onSuccess:OpenLayers.Function.bind(this.mapLoaded, this), parameters: params};
-        Fusion.ajaxRequest(loadmapScript, options);
-    },
-
-    mapLoaded: function(r) {
-        if (r.status == 200)
-        {
-            var o;
-            eval('o='+r.responseText);
-            this._sMapFile = o.mapId;
-            this._sMapname = o.mapName;
-            this._sMapTitle = o.mapTitle;
-            this._fMetersperunit = o.metersPerUnit;
-            this.mapWidget._fMetersperunit = this._fMetersperunit;
-            this._sImageType = o.imagetype;
-            this.metadata = o.metadata;
-
-            this._oMaxExtent = OpenLayers.Bounds.fromArray(o.extent);
-
-            this.layerRoot.clear();
-            this.layerRoot.legendLabel = this._sMapTitle;
-
-            this.parseMapLayersAndGroups(o);
-
-            var minScale = 1.0e10;
-            var maxScale = 0;
-            for (var i=0; i<this.aLayers.length; i++) {
-              if (this.aLayers[i].visible) {
-                  this.aVisibleLayers.push(this.aLayers[i].layerName);
-              }
-      				minScale = Math.min(minScale, this.aLayers[i].minScale);
-      				maxScale = Math.max(maxScale, this.aLayers[i].maxScale);
-            }
-            //a scale value of 0 is undefined
-            if (minScale <= 0) {
-              minScale = 1.0;
-            }
-
-            if (o.dpi) {
-                OpenLayers.DOTS_PER_INCH = o.dpi;
-            }
-
-            var layerOptions = {
-      				singleTile: true,
-      				ratio: this.ratio,
-      				maxExtent : this._oMaxExtent,
-              maxResolution : 'auto',
-      				minScale : maxScale,	//OL interpretation of min/max scale is reversed from Fusion
-      				maxScale : minScale
-      			};
-
-            //set OpenLayer projection units and code if supplied (OL defaults units to degrees)
-            if (o.metersPerUnit == 0.0254)
-               layerOptions.units = 'inches';
-            else if (o.metersPerUnit == 0.3048)
-               layerOptions.units = 'ft';
-            else if (o.metersPerUnit == 1609.344)
-               layerOptions.units = 'mi';
-            else if (o.metersPerUnit == 1)
-               layerOptions.units = 'm';
-               //layerOptions.projection = 'EPSG:42304';  //TODO: not necessary, but can this be supplied by LoadMap?
-            else if (o.metersPerUnit == 1000)
-               layerOptions.units = 'km';
-            else if (o.metersPerUnit == 111118.7516)
-               layerOptions.units = 'dd';
-
-            //this.mapWidget.setMapOptions(oMapOptions);
-
-            //create the OL layer for this Map layer
-            var params = {
-              layers: this.aVisibleLayers.join(' '),
-              session : this.getSessionID(),
-              map : this._sMapFile,
-              map_imagetype : this._sImageType
+            params = {
+                'mapfile': this.sMapResourceId,
+                'session': this.getSessionID()
             };
-
-            //remove this layer if it was already loaded
-            if (this.oLayerOL) {
-                this.oLayerOL.events.unregister("loadstart", this, this.loadStart);
-                this.oLayerOL.events.unregister("loadend", this, this.loadEnd);
-                this.oLayerOL.events.unregister("loadcancel", this, this.loadEnd);
-                this.oLayerOL.destroy();
-            }
-
-            var url = Fusion.getConfigurationItem('mapserver', 'cgi');
-            this.oLayerOL = new OpenLayers.Layer.MapServer( o.mapName, url, params, layerOptions);
-            this.oLayerOL.events.register("loadstart", this, this.loadStart);
-            this.oLayerOL.events.register("loadend", this, this.loadEnd);
-            this.oLayerOL.events.register("loadcancel", this, this.loadEnd);
-
-            if (this.bIsMapWidgetLayer) {
-              this.mapWidget.addMap(this);
-              this.mapWidget.oMapOL.setBaseLayer(this.oLayerOL);
-              this.mapWidget._oInitialExtents = null;
-              this.mapWidget.fullExtents();
-              this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADED);
-            } else {
-              this.triggerEvent(Fusion.Event.MAP_LOADED);
-            }
-
-            this.bMapLoaded = true;
         }
-        else
-        {
-            Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL,
-					'Failed to load requested map:\n'+r.responseText));
-        }
-        this.mapWidget._removeWorker();
-    },
-
-    reloadMap: function() {
-        this.mapWidget._addWorker();
-        this.aShowLayers = [];
-        this.aHideLayers = [];
-        this.aShowGroups = [];
-        this.aHideGroups = [];
-        this.aRefreshLayers = [];
-        this.layerRoot.clear();
-        this.aLayers = [];
-
-        var sl = Fusion.getScriptLanguage();
-        var loadmapScript = this.arch + '/' + sl  + '/LoadMap.' + sl;
-
-        var params = {
-            'mapname': this._sMapname,
-            'session': this.getSessionID()
-        };
         if (this.mapMetadataKeys) {
             params.map_metadata = this.mapMetadataKeys;
         }
         if (this.layerMetadataKeys) {
             params.layer_metadata = this.layerMetadataKeys;
         }
-        var options = {onSuccess: OpenLayers.Function.bind(this.mapReloaded, this),
-                                     parameters: params};
-        Fusion.ajaxRequest(loadmapScript, options);
+        return params;
     },
 
-    mapReloaded: function(r) {  
-        if (r.status == 200) {
-            var o;
-            eval('o='+r.responseText);
-
-            //can metadata change?
-            //this.metadata = o.metadata;
-
-            this.parseMapLayersAndGroups(o);
-            this.aVisibleLayers = [];
-            for (var i=0; i<this.aLayers.length; i++) {
-                if (this.aLayers[i].visible) {
-                    this.aVisibleLayers.push(this.aLayers[i].layerName);
-                }
-            }
-            this.drawMap();
-            this.mapWidget.triggerEvent(Fusion.Event.MAP_RELOADED);
-        } else {
-            Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL,
-                OpenLayers.i18n('mapLoadError', {'error':r.responseText})));
+    /**
+     * Function: createOLLayer
+     * 
+     * Returns an OpenLayers MapGuide layer object
+     */
+    createOLLayer: function(layerName, layerOptions) {
+      for (var i=0; i<this.aLayers.length; i++) {
+        if (this.aLayers[i].visible) {
+            this.aVisibleLayers.push(this.aLayers[i].layerName);
         }
-        this.mapWidget._removeWorker();
+      }
+      
+      //create the OL layer for this Map layer
+      var params = {
+        layers: this.aVisibleLayers.join(' '),
+        session : this.getSessionID(),
+        map : this._sResourceId,
+        map_imagetype : this.sImageType
+      };
+      
+      var url = Fusion.getConfigurationItem('mapserver', 'cgi');
+      var oLayerOL = new OpenLayers.Layer.MapServer( layerName, url, params, layerOptions );
+      return oLayerOL;
     },
-
-    reorderLayers: function(aLayerIndex) {
-        var sl = Fusion.getScriptLanguage();
-        var loadmapScript = this.arch + '/' + sl  + '/SetLayers.' + sl;
-
-        var params = {
-            'mapname': this._sMapname,
-            'session': this.getSessionID(),
-            'layerindex': aLayerIndex.join()
-        };
-        var options = {onSuccess: OpenLayers.Function.bind(this.mapLayersReset, this, aLayerIndex),
-                                     parameters: params};
-        Fusion.ajaxRequest(loadmapScript, options);
-    },
-
-    mapLayersReset: function(aLayerIndex,r) {
+            
+    xxxmapLayersReset: function(aLayerIndex,r) {
       if (r.status == 200) {
         var o;
         eval('o='+r.responseText);
@@ -411,44 +121,6 @@
       }
     },
 
-    parseMapLayersAndGroups: function(o) {
-        for (var i=0; i<o.groups.length; i++) {
-            var group = new Fusion.Maps.MapServer.Group(o.groups[i], this);
-            var parent;
-            if (group.parentUniqueId != '') {
-                parent = this.layerRoot.findGroup(group.parentUniqueId);
-            } else {
-                parent = this.layerRoot;
-            }
-            parent.addGroup(group, this.bLayersReversed);
-        }
-
-        for (var i=0; i<o.layers.length; i++) {
-            var layer = new Fusion.Maps.MapServer.Layer(o.layers[i], this);
-            var parent;
-            if (layer.parentGroup != '') {
-                parent = this.layerRoot.findGroup(layer.parentGroup);
-            } else {
-                parent = this.layerRoot;
-            }
-            parent.addLayer(layer, this.bLayersReversed);
-            this.aLayers.push(layer);
-        }
-    },
-
-    /**
-     * Function: isMapLoaded
-     *
-     * Returns true if the Map has been laoded succesfully form the server
-     */
-    isMapLoaded: function() {
-        return this.bMapLoaded;
-    },
-
-    getScale : function() {
-        return this.mapWidget.getScale();
-    },
-
     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});
@@ -466,7 +138,7 @@
                 aLayers.push(l.layerName);
             }
         }
-        var params = { layers: /*this.aVisibleLayers */aLayers.join(' '), ts : (new Date()).getTime()};
+        var params = { layers: aLayers.join(' '), ts : (new Date()).getTime()};
         if (this.hasSelection()) {
             params['queryfile']=this._sQueryfile;
         } else {
@@ -475,487 +147,19 @@
         this.oLayerOL.mergeNewParams(params);
     },
 
-    showLayer: function( sLayer ) {
-        this.aVisibleLayers.push(sLayer);
-        this.drawMap();
-    },
-
-    hideLayer: function( sLayer ) {
-        for (var i=0; i<this.aLayers.length; i++) {
-            if (this.aVisibleLayers[i] == sLayer) {
-                this.aVisibleLayers.splice(i,1);
-                break;
-            }
-        }
-        this.drawMap();
-    },
-
-    showGroup: function( sGroup ) {
-      if (sGroup == 'layerRoot') {
-        this.oLayerOL.setVisibility(true);
-      } else {
-        this.aVisibleGroups.push(sGroup);
-        var group = this.layerRoot.findGroup(sGroup);
-        this.deferredDraw = true;
-        for (var i=0; i<group.layers.length; ++i) {
-          group.layers[i].show();
-        }
-        this.deferredDraw = false;
-        this.drawMap();
-      }
-    },
-
-    hideGroup: function( sGroup ) {
-      if (sGroup == 'layerRoot') {
-        this.oLayerOL.setVisibility(false);
-      } else {
-        for (var i=0; i<this.aVisibleGroups.length; i++) {
-            if (this.aVisibleGroups[i] == sGroup) {
-                this.aVisibleGroups.splice(i,1);
-                break;
-            }
-        }
-        var group = this.layerRoot.findGroup(sGroup);
-        this.deferredDraw = true;
-        for (var i=0; i<group.layers.length; ++i) {
-          group.layers[i].hide();
-        }
-        this.deferredDraw = false;
-        this.drawMap();
-      }
-    },
-
-    refreshLayer: function( sLayer ) {
-        this.drawMap();
-    },
-
-    hasSelection: function() { return this.bSelectionOn; },
-
-    getSelectionCB : function(userFunc, layers, startend, r) {
-      if (r.status == 200)
-      {
-          var o;
-          eval("o="+r.responseText);
-
-          var oSelection = new GxSelectionObject(o);
-          userFunc(oSelection);
-      }
-    },
-
-    /**
-     * advertise a new selection is available and redraw the map
-     */
-    newSelection: function() {
-
-        this.bSelectionOn = true;
-        this.drawMap();
-        this.triggerEvent(Fusion.Event.MAP_SELECTION_ON);
-    },
-
-    /**
-     * Returns the number of features selected for this map layer
-     */
-    getSelectedFeatureCount : function() {
-      var total = 0;
-      for (var j=0; j<this.aLayers.length; ++j) {
-        total += this.aLayers[j].selectedFeatureCount;
-      }
-      return total;
-    },
-
-    /**
-     * Returns the number of features selected for this map layer
-     */
-    getSelectedLayers : function() {
-      var layers = [];
-      for (var j=0; j<this.aLayers.length; ++j) {
-        if (this.aLayers[j].selectedFeatureCount>0) {
-          layers.push(this.aLayers[j]);
-        }
-      }
-      return layers;
-    },
-
-    /**
-     * Returns the number of features selected for this map layer
-     */
-    getSelectableLayers : function() {
-      var layers = [];
-      for (var j=0; j<this.aLayers.length; ++j) {
-        if (this.aLayers[j].selectable) {
-          layers.push(this.aLayers[j]);
-        }
-      }
-      return layers;
-    },
-
-    /**
-     * asynchronously load the current selection.  When the current
-     * selection changes, the selection is not loaded because it
-     * could be a lengthy process.  The user-supplied function will
-     * be called when the selection is available.
-     *
-     * @param userFunc {Function} a function to call when the
-     *        selection has loaded
-     * @param layers {string} Optional parameter.  A comma separated
-     *        list of layer names (Roads,Parcels). If it is not
-     *        given, all the layers that have a selection will be used
-     *
-     * @param startcount {string} Optional parameter.  A comma separated
-     *        list of a statinh index and the number of features to be retured for
-     *        each layer given in the layers parameter. Index starts at 0
-     *        (eg: 0:4,2:6 : return 4 elements for the first layers starting at index 0 and
-     *         six elements for layer 2 starting at index 6). If it is not
-     *        given, all the elemsnts will be returned.
-     */
-    getSelection : function(userFunc, layers, startcount) {
-
-        if (userFunc)
-        {
-            var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Selection." + Fusion.getScriptLanguage() ;
-            var params = {
-                'mapname': this._sMapname,
-                'session': this.getSessionID(),
-                'layers': layers,
-                'startcount': startcount,
-                'queryfile': this._sQueryfile
-            };
-            var options = {
-                parameters:params,
-                onSuccess: OpenLayers.Function.bind(this.getSelectionCB, this, userFunc, layers, startcount)
-            };
-            Fusion.ajaxRequest(s, options);
-        }
-
-    },
-
-    /**
-       Utility function to clear current selection
-    */
-    clearSelection : function() {
-      if (!this.aLayers) return;
-
-        //clear the selection count for the layers
-        for (var j=0; j<this.aLayers.length; ++j) {
-          this.aLayers[j].selectedFeatureCount = 0;
-        }
-
-        this.bSelectionOn = false;
-        this._sQueryfile = "";
-        this.triggerEvent(Fusion.Event.MAP_SELECTION_OFF);
-        this.drawMap();
-        this.oSelection = null;
-    },
-
-
-    /**
-       Call back function when slect functions are called (eg queryRect)
-    */
-    processQueryResults : function(zoomTo, r) {
-        this.mapWidget._removeWorker();
-        if (r.status == 200) {
-            var o;
-            eval("o="+r.responseText);
-            if (!o.hasSelection) {
-                //this.drawMap();
-                return;
-            } else {
-                this._sQueryfile = o.queryFile;
-                for (var i=0; i<o.layers.length; ++i) {
-                  var layerName = o.layers[i];
-                  for (var j=0; j<this.aLayers.length; ++j) {
-                    if (layerName == this.aLayers[j].layerName) {
-                      this.aLayers[j].selectedFeatureCount = o[layerName].featureCount;
-                    }
-                  }
-                }
-                this.newSelection();
-                if (zoomTo) {
-                var ext = oNode.extents
-                var extents = new OpenLayers.Bounds(ext.minx, ext.miny, ext.maxx, ext.maxy);
-                this.zoomToSelection(extents);
-              }
-            }
-        }
-    },
-    /**
-       Do a query on the map
-    */
-    query : function(options) {
-        this.mapWidget._addWorker();
-
-        //clear the selection count for the layers
-        for (var j=0; j<this.aLayers.length; ++j) {
-          this.aLayers[j].selectedFeatureCount = 0;
-        }
-
-        var bPersistant = options.persistent || true;
-        var layers = options.layers || '';
-        /* if no layes are given, query only visible layers. This is ususally the most common case*/
-        if (layers == '') {
-          layers = this.aVisibleLayers.join(',');
-        }
-        var zoomTo = options.zoomTo || false;
-        var sl = Fusion.getScriptLanguage();
-        var queryScript = this.arch + '/' + sl  + '/Query.' + sl;
-
-        var params = {
-            'mapname': this._sMapname,
-            'session': this.getSessionID(),
-            'spatialfilter': options.geometry || '',
-            'maxfeatures': options.maxFeatures || -1, //-1 means select all features
-            'layers': layers,
-            'variant': options.selectionType || this.selectionType
-        }
-        if (options.filter) {
-            params.filter = options.filter;
-        }
-        if (options.extendSelection) {
-            params.extendselection = true;
-        }
-        if (options.computedProperties) {
-            params.computed = true;
-        }
-        var ajaxOptions = {
-            onSuccess: OpenLayers.Function.bind(this.processQueryResults, this, zoomTo), 
-            parameters: params
-        };
-        Fusion.ajaxRequest(queryScript, ajaxOptions);
-    },
-
-    loadStart: function() {
-      this.mapWidget._addWorker();
-    },
-
-    loadEnd: function() {
-      this.mapWidget._removeWorker();
-    },
-
-    pingServer: function() {
-        var s = this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
-        var params = {};
-        params.parameters = {'session': this.getSessionID()};
-        Fusion.ajaxRequest(s, params);
-  },
-
-    getGroupInfoUrl: function(groupName) {
-      return null;
-   },
-
-    getLayerInfoUrl: function(layerName) {
-      return null;
-  },
-
   getMetadata: function(key) {
       if (typeof this.metadata[key] != 'undefined') {
           return this.metadata[key];
       } else {
           return '';
       }
+  },
+  
+  getLegendImageURL: function(fScale, layer, style) {
+      var sl = Fusion.getScriptLanguage();
+      var url = Fusion.getFusionURL() + '/layers/' + layer.oMap.arch + '/' + sl  + '/LegendIcon.' + sl;
+      var sessionid = this.getSessionID();
+      var params = 'mapname='+this._sMapname+"&session="+sessionid + '&layername='+layer.resourceId + '&classindex='+style.index;
+      return url + '?'+params;
   }
-
 });
-
-
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.Group
- *
- * Implements the map layer groups for MapServer CGI services
-*/
-
-Fusion.Maps.MapServer.Group = OpenLayers.Class(Fusion.Widget.Map.Group, {
-    oMap: null,
-    initialize: function(o, oMap) {
-        this.uniqueId = o.uniqueId;
-        Fusion.Widget.Map.Group.prototype.initialize.apply(this, [o.groupName]);
-        this.oMap = oMap;
-        this.groupName = o.groupName;
-        this.legendLabel = o.legendLabel;
-        this.parentUniqueId = o.parentUniqueId;
-        this.groupType = o.groupType;
-        this.displayInLegend = o.displayInLegend;
-        this.expandInLegend = o.expandInLegend;
-        this.visible = o.visible;
-        this.actuallyVisible = o.actuallyVisible;
-    },
-
-    clear: function() {
-        Fusion.Widget.Map.Group.prototype.clear.apply(this, []);
-        //this.oMap = null;
-    },
-
-    show: function() {
-        this.visible = true;
-        this.oMap.showGroup(this.groupName);
-    },
-
-    hide: function() {
-        this.visible = false;
-        this.oMap.hideGroup(this.groupName);
-    },
-
-    isVisible: function() {
-        var bParentVisible = (this.parentGroup && this.parentGroup.isVisible) ? this.parentGroup.isVisible() : true;
-        return this.visible && bParentVisible;
-    }
-
-});
-
-var MSLAYER_POINT_TYPE = 0;
-var MSLAYER_LINE_TYPE = 1;
-var MSLAYER_POLYGON_TYPE = 2;
-var MSLAYER_SOLID_TYPE = 3;
-var MSLAYER_RASTER_TYPE = 4;
-
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.Layer
- *
-* Implements individual map legend layers for MapServer services
-*/
-
-Fusion.Maps.MapServer.Layer = OpenLayers.Class(Fusion.Widget.Map.Group, {
-
-    scaleRanges: null,
-
-    oMap: null,
-
-    initialize: function(o, oMap) {
-        this.uniqueId = o.uniqueId;
-        Fusion.Widget.Map.Layer.prototype.initialize.apply(this, [this.uniqueId]);
-        this.oMap = oMap;
-        this.layerName = o.layerName;
-        this.uniqueId = o.uniqueId;
-        this.resourceId = o.resourceId;
-        this.legendLabel = o.legendLabel;
-        this.selectable = o.selectable;
-        this.selectedFeatureCount = 0;
-        this.layerTypes = [].concat(o.layerTypes);
-        this.displayInLegend = o.displayInLegend;
-        this.expandInLegend = o.expandInLegend;
-        this.visible = o.visible;
-        this.actuallyVisible = o.actuallyVisible;
-        this.editable = o.editable;
-        this.parentGroup = o.parentGroup;
-        this.metadata = o.metadata;
-        this.scaleRanges = [];
-    		this.minScale = 1.0e10;
-    		this.maxScale = 0;
-        for (var i=0; i<o.scaleRanges.length; i++) {
-            var scaleRange = new Fusion.Maps.MapServer.ScaleRange(o.scaleRanges[i], this.supportsType(4));
-            this.scaleRanges.push(scaleRange);
-      			this.minScale = Math.min(this.minScale, scaleRange.minScale);
-      			this.maxScale = Math.max(this.maxScale, scaleRange.maxScale);
-        }
-    },
-
-    clear: function() {
-        Fusion.Widget.Map.Layer.prototype.clear.apply(this, []);
-        this.oMap = null;
-        this.legend = null;
-    },
-
-    supportsType: function(type) {
-        for (var i=0; i<this.layerTypes.length; i++) {
-            if (this.layerTypes[i] == type) {
-                return true;
-            }
-        }
-        return false;
-    },
-
-    getScaleRange: function(fScale) {
-        for (var i=0; i<this.scaleRanges.length; i++) {
-            if (this.scaleRanges[i].contains(fScale)) {
-                return this.scaleRanges[i];
-            }
-        }
-        return null;
-    },
-
-    show: function() {
-        this.set('visible', true);
-        this.oMap.showLayer(this.layerName);
-    },
-
-    hide: function() {
-        this.set('visible',false);
-        this.oMap.hideLayer(this.layerName);
-    },
-
-    isVisible: function() {
-        var bParentVisible = this.parentGroup ? this.parentGroup.isVisible() : true;
-        return this.visible && bParentVisible;
-    },
-
-    getMetadata: function(key) {
-        if (typeof this.metadata[key] != 'undefined') {
-            return this.metadata[key];
-        } else {
-            return '';
-        }
-    }
-});
-
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.ScaleRange
- *
-* Implements a scale range object for MapServer services
-*/
-
-Fusion.Maps.MapServer.ScaleRange = OpenLayers.Class({
-    styles: null,
-    initialize: function(o, bRaster) {
-        this.minScale = o.minScale;
-        this.maxScale = o.maxScale;
-        this.styles = [];
-        if (!o.styles) {
-            return;
-        }
-
-        /*special case : if there are no classes and it is a raster layer
-          we set it to use the default static raster icon*/
-        if (o.styles.length == 0 && bRaster)
-        {
-          var tmpsyle = {};
-          tmpsyle.legendLabel = "raster";
-          tmpsyle.filter = "";
-          tmpsyle.index = 0;
-          tmpsyle.staticIcon = true;
-          var styleItem = new Fusion.Maps.MapServer.StyleItem(tmpsyle, tmpsyle.staticIcon);
-          this.styles.push(styleItem);
-        }
-        else
-        {
-          var staticIcon = o.styles.length>=1 ? false : bRaster;
-          for (var i=0; i<o.styles.length; i++) {
-            var styleItem = new Fusion.Maps.MapServer.StyleItem(o.styles[i], staticIcon);
-            this.styles.push(styleItem);
-          }
-        }
-    },
-    contains: function(fScale) {
-        return fScale >= this.minScale && fScale <= this.maxScale;
-    }
-});
-
-/******************************************************************************
- * Class: Fusion.Maps.MapServer.StyleItem
- *
-* Implements the legend style items to get a legend icon from the server
-*/
-
-Fusion.Maps.MapServer.StyleItem = OpenLayers.Class({
-    initialize: function(o, staticIcon) {
-        this.legendLabel = o.legendLabel;
-        this.filter = o.filter;
-        this.index = o.index;
-        this.staticIcon = staticIcon;
-    },
-    getLegendImageURL: function(fScale, layer) {
-        var sl = Fusion.getScriptLanguage();
-        var url = Fusion.getFusionURL() + '/' + layer.oMap.arch + '/' + sl  + '/LegendIcon.' + sl;
-        var sessionid = layer.oMap.getSessionID();
-        var params = 'mapname='+layer.oMap._sMapname+"&session="+sessionid + '&layername='+layer.resourceId + '&classindex='+this.index;
-        return url + '?'+params;
-    }
-});

Modified: sandbox/olcore/layers/MapServer/php/CreateSession.php
===================================================================
--- sandbox/olcore/MapServer/php/CreateSession.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapServer/php/CreateSession.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -30,7 +30,7 @@
  
  /* initialize a session and return the session id to the caller */
 include(dirname(__FILE__).'/Common.php');
-include('../../common/php/Utilities.php');
+include('../../../common/php/Utilities.php');
 
 initializeSession( "sid", "", "" );
 $sessionId = session_id();

Modified: sandbox/olcore/layers/MapServer/php/LoadMap.php
===================================================================
--- sandbox/olcore/MapServer/php/LoadMap.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapServer/php/LoadMap.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -30,7 +30,7 @@
  *****************************************************************************/
 
 /* Common starts the session */
-include(dirname(__FILE__).'/../../common/php/Utilities.php');
+include(dirname(__FILE__).'/../../../common/php/Utilities.php');
 include(dirname(__FILE__).'/Common.php');
 include(dirname(__FILE__).'/Utilities.php');
 

Modified: sandbox/olcore/layers/MapServer/php/Measure.php
===================================================================
--- sandbox/olcore/MapServer/php/Measure.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapServer/php/Measure.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -29,7 +29,7 @@
 /* set up the session */
 include ("Common.php");
 include ("Utilities.php");
-include('../../common/php/Utilities.php');
+include('../../../common/php/Utilities.php');
 
 try {
     if (!isset($_REQUEST['session']) || 

Modified: sandbox/olcore/layers/MapServer/php/Query.php
===================================================================
--- sandbox/olcore/MapServer/php/Query.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapServer/php/Query.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -32,7 +32,7 @@
 /* set up the session */
 include ("Common.php");
 include ("Utilities.php");
-include('../../common/php/Utilities.php');
+include('../../../common/php/Utilities.php');
 
 /* the name of the layer in the map to query */
 if ($_REQUEST['layers'] != '') {

Modified: sandbox/olcore/layers/MapServer/php/Selection.php
===================================================================
--- sandbox/olcore/MapServer/php/Selection.php	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/layers/MapServer/php/Selection.php	2008-04-18 14:33:05 UTC (rev 1380)
@@ -31,7 +31,7 @@
 
 /* set up the session */
 include ("Common.php");
-include('../../common/php/Utilities.php');
+include('../../../common/php/Utilities.php');
 include ("Utilities.php");
 
 



More information about the fusion-commits mailing list