Sha256: 5c2f8d8312d08373aa29bcd9379460b8596293027668b36af51278c4d997f04d

Contents?: true

Size: 1.98 KB

Versions: 28

Compression:

Stored size: 1.98 KB

Contents

/**
 * FeatureInfo
 *
 * parse WMS GetFeatureInfo results
 * Implementation for QGIS Server XML query results
 */

var FeatureInfo = {};

// callback with GetFeatureInfo result features
FeatureInfo.callback = null;

FeatureInfo.setCallback = function(callback) {
  FeatureInfo.callback = callback;
}

/**
 * parse contents of GetFeatureInfo results and invoke the callback
 *
 * [
 *   {
 *     layer: <layername>,
 *     features: [
 *       {
 *         id: <feature id or null for rasters>,
 *         attributes: [
 *           name: <name>,
 *           value: <value>
 *         ]
 *       }
 *     ]
 *   }
 * ]
 */
FeatureInfo.parseResults = function(featureInfos) {
  var results = [];
  for (var i=0; i<featureInfos.length; i++) {
    var xml = $.parseXML(featureInfos[i]);
    $(xml).find('Layer').each(function() {
      var features = [];
      if ($(this).find('Feature').length > 0) {
        // vector features
        $(this).find('Feature').each(function() {
          var attributes = [];
          $(this).find('Attribute').each(function() {
            // filter geometry
            if ($(this).attr('name') != 'geometry') {
              attributes.push({
                name: $(this).attr('name'),
                value: $(this).attr('value')
              });
            }
          });
          features.push({
            id: $(this).attr('id'),
            attributes: attributes
          });
        });
      }
      else if ($(this).find('Attribute').length > 0) {
        // raster layer
        var attributes = [];
        $(this).find('Attribute').each(function() {
          attributes.push({
            name: $(this).attr('name'),
            value: $(this).attr('value')
          });
        });
        features.push({
          id: null,
          attributes: attributes
        });
      }

      if (features.length > 0) {
        results.push({
          layer: $(this).attr('name'),
          features: features
        });
      }
    });
  }

  FeatureInfo.callback(results);
}

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
gb_mapfish_appserver-2.0.0 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.1.1 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.1.0 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.0.6 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.0.5 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.0.4 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.0.3 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.0.2 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.0.1 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-1.0.0 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.7 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.6 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.5 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.4 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.3 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.2 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.1 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.9.0 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.8.7 test/dummy/public/apps/myviewer/src/feature_info.js
gb_mapfish_appserver-0.8.6 test/dummy/public/apps/myviewer/src/feature_info.js