[fusion-commits] r2067 - in sandbox/adsk/2.2gp: layers layers/MapGuide lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Feb 10 16:12:28 EST 2010


Author: madair
Date: 2010-02-10 16:12:27 -0500 (Wed, 10 Feb 2010)
New Revision: 2067

Modified:
   sandbox/adsk/2.2gp/layers/Layers.js
   sandbox/adsk/2.2gp/layers/MapGuide/MapGuide.js
   sandbox/adsk/2.2gp/lib/ApplicationDefinition.js
   sandbox/adsk/2.2gp/lib/Map.js
Log:
re #310: carry through projection code and definitions to the map and layer objects, patch applied to adsk branch

Modified: sandbox/adsk/2.2gp/layers/Layers.js
===================================================================
--- sandbox/adsk/2.2gp/layers/Layers.js	2010-02-10 21:11:53 UTC (rev 2066)
+++ sandbox/adsk/2.2gp/layers/Layers.js	2010-02-10 21:12:27 UTC (rev 2067)
@@ -48,6 +48,7 @@
     noCache: false,
     _sMapTitle: null,
     _sMapname: null,
+    projCode: null,
 
     initialize: function(map, mapTag, isMapWidgetLayer) {
         // console.log('Fusion.Layers.initialize');
@@ -76,17 +77,6 @@
         this.sMapResourceId = mapTag.resourceId ? mapTag.resourceId : '';
         this.mapInfo = mapTag.mapInfo;
         this.layerType = mapTag.type;
-
-        //projection info from the extension
-        if (mapTag.extension.ProjectionCode) {
-          this.projCode = mapTag.extension.ProjectionCode[0];
-        }
-        if (mapTag.extension.ProjectionDef) {
-          var projDef = mapTag.extension.ProjectionDef[0];
-          this.projCode = "APP-DEF-PROJ";
-          Proj4js.defs[this.projCode] = projDef;
-        }
-        
     },
 
     /**

Modified: sandbox/adsk/2.2gp/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/adsk/2.2gp/layers/MapGuide/MapGuide.js	2010-02-10 21:11:53 UTC (rev 2066)
+++ sandbox/adsk/2.2gp/layers/MapGuide/MapGuide.js	2010-02-10 21:12:27 UTC (rev 2067)
@@ -85,6 +85,9 @@
             this.nTolerance = 2; //pixels, default pixel tolernace for a point click; TBD make this configurable
           }
         }
+        
+        //copy over projection info from maptag
+        this.projCode = mapTag.projCode;
 
         rootOpts = {
           displayInLegend: this.bDisplayInLegend,
@@ -304,7 +307,7 @@
             //to allow for scaling that doesn't match any of the pre-canned units
             this.units = Fusion.getClosestUnits(o.metersPerUnit);
             if (this.projCode) {
-              this.mapWidget.setProjection(this.projCode);
+              this.mapWidget.setProjection(this.projCode, this.units);
             }
 
             //add in scales array if supplied
@@ -574,6 +577,7 @@
       
       var layerOptions = {
         units: this.units,
+        projection: this.projCode,
         maxResolution: 'auto',
         useOverlay: this.selectionAsOverlay,
         useAsyncOverlay: this.useAsyncOverlay,

Modified: sandbox/adsk/2.2gp/lib/ApplicationDefinition.js
===================================================================
--- sandbox/adsk/2.2gp/lib/ApplicationDefinition.js	2010-02-10 21:11:53 UTC (rev 2066)
+++ sandbox/adsk/2.2gp/lib/ApplicationDefinition.js	2010-02-10 21:12:27 UTC (rev 2067)
@@ -486,6 +486,8 @@
     type: null,
     singleTile: false,
     extension: null,
+    projCode: null,
+    
     initialize: function(jsonNode) {
         /* TODO: type can be any supported OpenLayers type */
         this.type = jsonNode.Type[0];
@@ -522,6 +524,18 @@
             this.layerParams[key] = tagParams[0][key][0];
           }
         }
+        
+        //projection info from the extension
+        if (this.extension.ProjectionCode) {
+          this.projCode = this.extension.ProjectionCode[0];
+        }
+        if (this.extension.ProjectionDef) {
+          var projDef = this.extension.ProjectionDef[0];
+          if (!this.projCode) {
+            this.projCode = "APP-DEF-PROJ";
+          }
+          Proj4js.defs[this.projCode] = projDef;
+        }
 
         switch (this.type) {
           case 'MapGuide':
@@ -531,6 +545,11 @@
             }
             break;
           default:
+            if (this.layerOptions.sphericalMercator) {
+              this.projCode = "EPSG:3785";  //commercial map layer projection spherical mercator
+            } else {
+              this.projCode = "EPSG:4326";  //WGS84 lat long
+            }
             if ( !Fusion.Layers.Generic ) {
               Fusion.require('layers/Generic/Generic.js');
             }

Modified: sandbox/adsk/2.2gp/lib/Map.js
===================================================================
--- sandbox/adsk/2.2gp/lib/Map.js	2010-02-10 21:11:53 UTC (rev 2066)
+++ sandbox/adsk/2.2gp/lib/Map.js	2010-02-10 21:12:27 UTC (rev 2067)
@@ -169,7 +169,7 @@
         this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
         this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
         this.registerEventID(Fusion.Event.MAP_MAPTIP_REQ_FINISHED);
-		this.registerEventID(Fusion.Event.MAP_MAP_GROUP_LOADED);
+        this.registerEventID(Fusion.Event.MAP_MAP_GROUP_LOADED);
 
         this.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapLoaded,this));
 
@@ -215,7 +215,10 @@
             this.aMaps[i].oLayerOL.destroy();
           }
         }
-
+ 
+        this._fMetersperunit = -1;
+        this.oMapOL.center = null;
+        this.maxExtent = new OpenLayers.Bounds();
         this.aMaps = [];
         this.layerRoot.clear();
 
@@ -232,7 +235,7 @@
           }
           this.aMaps[i].registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.layerLoaded,this));
         }
-		this.triggerEvent(Fusion.Event.MAP_MAP_GROUP_LOADED);
+        this.triggerEvent(Fusion.Event.MAP_MAP_GROUP_LOADED);
     },
 
     layerLoaded: function() {
@@ -807,12 +810,14 @@
      *
      * @param projCode projection code
      */
-    setProjection: function(projCode) {
+    setProjection: function(projCode, units) {
         if (!Proj4js.defs[projCode]) {
           Fusion.reportError( new Fusion.Error(Fusion.Error.WARNING,
             'Projection definition not found for:'+projCode));
         }
+        this.projection = projCode;
         this.oMapOL.projection = projCode;
+        this.oMapOL.units = units;
     },
 
   /**



More information about the fusion-commits mailing list