[fusion-commits] r2982 - sandbox/mgrfc158/layers/MapGuide

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Apr 19 11:37:39 PDT 2017


Author: jng
Date: 2017-04-19 11:37:39 -0700 (Wed, 19 Apr 2017)
New Revision: 2982

Modified:
   sandbox/mgrfc158/layers/MapGuide/MapGuide.js
Log:
Use "clean" QUERYMAPFEATURES if supported when doing a selection

Modified: sandbox/mgrfc158/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/mgrfc158/layers/MapGuide/MapGuide.js	2017-04-19 18:27:06 UTC (rev 2981)
+++ sandbox/mgrfc158/layers/MapGuide/MapGuide.js	2017-04-19 18:37:39 UTC (rev 2982)
@@ -1598,7 +1598,7 @@
         //Set up the expected response text for renderSelection()
         if (returnAttributes) { //This update requires a client-side update of selection and attribute info
             var o = Fusion.parseJSON(r.responseText);
-            var sel = new Fusion.SimpleSelectionObject(o);
+            var sel = new Fusion.SimpleSelectionObject(o, this.bHasCleanJsonSupport);
             var attributes = this.convertExtendedFeatureInfo(o);
             this.previousSelection = sel;
             this.previousAttributes = attributes;
@@ -1723,6 +1723,9 @@
                                                                 reqData,
                                                                 this.selectionColor,
                                                                 this.selectionImageFormat);
+            if (this.bHasCleanJsonSupport) { //Clean json means no de-arrayification of responses required
+                r.setParams({ version: "3.3.0", clean: 1 });
+            }
             var callback = (options.extendSelection == true) ? OpenLayers.Function.bind(this.processAndMergeExtendedFeatureInfo, this) : OpenLayers.Function.bind(this.processExtendedFeatureInfo, this);
             Fusion.oBroker.dispatchRequest(r, callback);
         } else {
@@ -1978,6 +1981,9 @@
                                             reqData,
                                             this.selectionColor,
                                             this.selectionImageFormat);
+            if (this.bHasCleanJsonSupport) { //Clean json means no de-arrayification of responses required
+                r.setParams({ version: "3.3.0", clean: 1 });
+            }
             oBroker.dispatchRequest(r, OpenLayers.Function.bind(this.parseMapTip, this));
         } else {
             var r = new Fusion.Lib.MGRequest.MGQueryMapFeatures(this.getSessionID(),
@@ -2076,74 +2082,144 @@
         var layerNames = [];
         var featuresByLayer = {};
         if (efi.FeatureInformation.SelectedFeatures) {
-            var selLayers = efi.FeatureInformation.SelectedFeatures[0].SelectedLayer;
-            bHasSelection = (selLayers.length > 0);
             var box = new OpenLayers.Bounds();
+            if (this.bHasCleanJsonSupport) {
+                var selLayers = efi.FeatureInformation.SelectedFeatures.SelectedLayer;
+                bHasSelection = (selLayers.length > 0);
+                for (var i = 0; i < selLayers.length; i++) {
+                    var selLayer = selLayers[i];
+                    var selFeatures = selLayer.Feature || [];
+                    var layerName = selLayer["@name"];
+                    if (!result[layerName]) {
+                        if (selLayer.LayerMetadata) {
+                            var layerMeta = selLayer.LayerMetadata;
+                            var pnames = [];
+                            var ptypes = [];
+                            var pvals = [];
+                            for (var j = 0; j < layerMeta.Property.length; j++) {
+                                var metaProp = layerMeta.Property[j];
+                                pnames.push(metaProp.Name);
+                                ptypes.push(metaProp.Type);
+                                pvals.push(metaProp.DisplayName);
+                            }
+                        }
+                        result[layerName] = {
+                            metadata: [],  //NOTE: Probably a defect, but regular code path is putting blank string arrays here too
+                            metadatanames: ["dimension", "bbox", "center", "area", "length"],
+                            numelements: selFeatures.length,
+                            propertynames: pnames,
+                            propertytypes: ptypes,
+                            propertyvalues: pvals,
+                            values: []
+                        };
+                        layerNames.push(layerName);
+                    }
 
-            for (var i = 0; i < selLayers.length; i++) {
-                var selLayer = selLayers[i];
-                var selFeatures = selLayer.Feature || [];
-                var layerName = selLayer["@name"];
-                if (!result[layerName]) {
-                    if (selLayer.LayerMetadata) {
-                        var layerMeta = selLayer.LayerMetadata[0];
-                        var pnames = [];
-                        var ptypes = [];
-                        var pvals = [];
-                        for (var j = 0; j < layerMeta.Property.length; j++) {
-                            var metaProp = layerMeta.Property[j];
-                            pnames.push(metaProp.Name[0]);
-                            ptypes.push(metaProp.Type[0]);
-                            pvals.push(metaProp.DisplayName[0]);
+                    for (var j = 0; j < selFeatures.length; j++) {
+                        var feat = selFeatures[j];
+                        var featVals = [];
+                        if (feat.Property) {
+                            //If we have layer metadata, its order of properties we must follow
+                            if (selLayer.LayerMetadata) {
+                                for (var p = 0; p < selLayer.LayerMetadata.Property.length; p++) {
+                                    var name = selLayer.LayerMetadata.Property[p].DisplayName;
+                                    //Find matching property value
+                                    for (var fp = 0; fp < feat.Property.length; fp++) {
+                                        var featProp = feat.Property[fp];
+                                        if (featProp.Name == name) {
+                                            //Fusion represents null as empty string. Don't think that's right but we'll run with whatever
+                                            //the old code path produces
+                                            featVals.push(featProp.Value == null ? "" : featProp.Value);
+                                            break;
+                                        }
+                                    }
+                                }
+                            } else {
+                                for (var k = 0; k < feat.Property.length; k++) {
+                                    //Fusion represents null as empty string. Don't think that's right but we'll run with whatever
+                                    //the old code path produces
+                                    featVals.push(feat.Property[k].Value == null ? "" : feat.Property[k].Value);
+                                }
+                            }
                         }
+                        result[layerName].values.push(featVals);
+                        //NOTE: Probably a defect, but regular code path is putting blank string arrays here too, so let's do the same
+                        result[layerName].metadata.push(["","","","",""]);
+                        if (feat.Bounds) {
+                            var bounds = feat.Bounds.split(" "); //minx miny maxx maxy
+                            box.extend(new OpenLayers.LonLat(parseFloat(bounds), parseFloat(bounds[1])));
+                            box.extend(new OpenLayers.LonLat(parseFloat(bounds[2]), parseFloat(bounds[3])));
+                        }
                     }
-                    result[layerName] = {
-                        metadata: [],  //NOTE: Probably a defect, but regular code path is putting blank string arrays here too
-                        metadatanames: ["dimension", "bbox", "center", "area", "length"],
-                        numelements: selFeatures.length,
-                        propertynames: pnames,
-                        propertytypes: ptypes,
-                        propertyvalues: pvals,
-                        values: []
-                    };
-                    layerNames.push(layerName);
                 }
+            } else {
+                var selLayers = efi.FeatureInformation.SelectedFeatures[0].SelectedLayer;
+                bHasSelection = (selLayers.length > 0);
+                for (var i = 0; i < selLayers.length; i++) {
+                    var selLayer = selLayers[i];
+                    var selFeatures = selLayer.Feature || [];
+                    var layerName = selLayer["@name"];
+                    if (!result[layerName]) {
+                        if (selLayer.LayerMetadata) {
+                            var layerMeta = selLayer.LayerMetadata[0];
+                            var pnames = [];
+                            var ptypes = [];
+                            var pvals = [];
+                            for (var j = 0; j < layerMeta.Property.length; j++) {
+                                var metaProp = layerMeta.Property[j];
+                                pnames.push(metaProp.Name[0]);
+                                ptypes.push(metaProp.Type[0]);
+                                pvals.push(metaProp.DisplayName[0]);
+                            }
+                        }
+                        result[layerName] = {
+                            metadata: [],  //NOTE: Probably a defect, but regular code path is putting blank string arrays here too
+                            metadatanames: ["dimension", "bbox", "center", "area", "length"],
+                            numelements: selFeatures.length,
+                            propertynames: pnames,
+                            propertytypes: ptypes,
+                            propertyvalues: pvals,
+                            values: []
+                        };
+                        layerNames.push(layerName);
+                    }
 
-                for (var j = 0; j < selFeatures.length; j++) {
-                    var feat = selFeatures[j];
-                    var featVals = [];
-                    if (feat.Property) {
-                        //If we have layer metadata, its order of properties we must follow
-                        if (selLayer.LayerMetadata) {
-                            for (var p = 0; p < selLayer.LayerMetadata[0].Property.length; p++) {
-                                var name = selLayer.LayerMetadata[0].Property[p].DisplayName[0];
-                                //Find matching property value
-                                for (var fp = 0; fp < feat.Property.length; fp++) {
-                                    var featProp = feat.Property[fp];
-                                    if (featProp.Name[0] == name) {
-                                        //Fusion represents null as empty string. Don't think that's right but we'll run with whatever
-                                        //the old code path produces
-                                        featVals.push(featProp.Value == null ? "" : featProp.Value[0]);
-                                        break;
+                    for (var j = 0; j < selFeatures.length; j++) {
+                        var feat = selFeatures[j];
+                        var featVals = [];
+                        if (feat.Property) {
+                            //If we have layer metadata, its order of properties we must follow
+                            if (selLayer.LayerMetadata) {
+                                for (var p = 0; p < selLayer.LayerMetadata[0].Property.length; p++) {
+                                    var name = selLayer.LayerMetadata[0].Property[p].DisplayName[0];
+                                    //Find matching property value
+                                    for (var fp = 0; fp < feat.Property.length; fp++) {
+                                        var featProp = feat.Property[fp];
+                                        if (featProp.Name[0] == name) {
+                                            //Fusion represents null as empty string. Don't think that's right but we'll run with whatever
+                                            //the old code path produces
+                                            featVals.push(featProp.Value == null ? "" : featProp.Value[0]);
+                                            break;
+                                        }
                                     }
                                 }
+                            } else {
+                                for (var k = 0; k < feat.Property.length; k++) {
+                                    //Fusion represents null as empty string. Don't think that's right but we'll run with whatever
+                                    //the old code path produces
+                                    featVals.push(feat.Property[k].Value == null ? "" : feat.Property[k].Value[0]);
+                                }
                             }
-                        } else {
-                            for (var k = 0; k < feat.Property.length; k++) {
-                                //Fusion represents null as empty string. Don't think that's right but we'll run with whatever
-                                //the old code path produces
-                                featVals.push(feat.Property[k].Value == null ? "" : feat.Property[k].Value[0]);
-                            }
                         }
+                        result[layerName].values.push(featVals);
+                        //NOTE: Probably a defect, but regular code path is putting blank string arrays here too, so let's do the same
+                        result[layerName].metadata.push(["","","","",""]);
+                        if (feat.Bounds) {
+                            var bounds = feat.Bounds[0].split(" "); //minx miny maxx maxy
+                            box.extend(new OpenLayers.LonLat(parseFloat(bounds[0]), parseFloat(bounds[1])));
+                            box.extend(new OpenLayers.LonLat(parseFloat(bounds[2]), parseFloat(bounds[3])));
+                        }
                     }
-                    result[layerName].values.push(featVals);
-                    //NOTE: Probably a defect, but regular code path is putting blank string arrays here too, so let's do the same
-                    result[layerName].metadata.push(["","","","",""]);
-                    if (feat.Bounds) {
-                        var bounds = feat.Bounds[0].split(" "); //minx miny maxx maxy
-                        box.extend(new OpenLayers.LonLat(parseFloat(bounds[0]), parseFloat(bounds[1])));
-                        box.extend(new OpenLayers.LonLat(parseFloat(bounds[2]), parseFloat(bounds[3])));
-                    }
                 }
             }
             return OpenLayers.Util.extend(result, {
@@ -2219,7 +2295,7 @@
 
     processSelectedExtendedFeatureInfo: function(r, mergeSelection) {
         var o = Fusion.parseJSON(r.responseText);
-        var sel = new Fusion.SimpleSelectionObject(o);
+        var sel = new Fusion.SimpleSelectionObject(o, this.bHasCleanJsonSupport);
         var attributes = this.convertExtendedFeatureInfo(o);
         if (mergeSelection == true)
         {
@@ -2255,7 +2331,7 @@
     processSelectedFeatureInfo: function (r, mergeSelection) {
         var o = Fusion.parseJSON(r.responseText);
 
-        var newSelection = new Fusion.SimpleSelectionObject(o);
+        var newSelection = new Fusion.SimpleSelectionObject(o, this.bHasCleanJsonSupport);
         if(mergeSelection == true)
         {
             newSelection.merge(this.previousSelection);
@@ -2273,30 +2349,54 @@
     aLayers : null,
     nLayers : 0,
 
-    initialize: function(featureInfoResponse)
+    initialize: function(featureInfoResponse, bClean)
     {
         this.aLayers = [];
         this.nLayers = 0;
         try
         {
-            var layers = featureInfoResponse.FeatureInformation.FeatureSet[0].Layer;
-            if (layers != null)
-            {
-                for(var i = 0; i < layers.length; i++)
+            if (!!!bClean) {
+                var layers = featureInfoResponse.FeatureInformation.FeatureSet[0].Layer;
+                if (layers != null)
                 {
-                    var layerId = layers[i]['@id'][0];
+                    for(var i = 0; i < layers.length; i++)
+                    {
+                        var layerId = layers[i]['@id'][0];
 
-                    var classElt = layers[i]['Class'][0];
-                    var className = layers[i]['Class'][0]['@id'][0];
+                        var classElt = layers[i]['Class'][0];
+                        var className = layers[i]['Class'][0]['@id'][0];
 
-                    var layer = new Fusion.SimpleSelectionObject.Layer(layerId, className);
+                        var layer = new Fusion.SimpleSelectionObject.Layer(layerId, className);
 
-                    this.addLayer(layer);
+                        this.addLayer(layer);
 
-                    var features = classElt.ID;
-                    for(var j=0; j < features.length; j++)
+                        var features = classElt.ID;
+                        for(var j=0; j < features.length; j++)
+                        {
+                            layer.addFeature(features[j]);
+                        }
+                    }
+                }
+            } else {
+                var layers = featureInfoResponse.FeatureInformation.FeatureSet.Layer;
+                if (layers != null)
+                {
+                    for(var i = 0; i < layers.length; i++)
                     {
-                        layer.addFeature(features[j]);
+                        var layerId = layers[i]['@id'];
+
+                        var classElt = layers[i]['Class'];
+                        var className = layers[i]['Class']['@id'];
+
+                        var layer = new Fusion.SimpleSelectionObject.Layer(layerId, className);
+
+                        this.addLayer(layer);
+
+                        var features = classElt.ID;
+                        for(var j=0; j < features.length; j++)
+                        {
+                            layer.addFeature(features[j]);
+                        }
                     }
                 }
             }



More information about the fusion-commits mailing list