[fusion-commits] r1661 - in trunk: . layers layers/Generic
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Nov 12 15:49:30 EST 2008
Author: madair
Date: 2008-11-12 15:49:29 -0500 (Wed, 12 Nov 2008)
New Revision: 1661
Added:
trunk/layers/
trunk/layers/Generic/
trunk/layers/Generic/Generic.js
trunk/layers/Generic/php/
trunk/layers/Layers.js
Log:
re #140: add Layers base class for various layer types
Added: trunk/layers/Generic/Generic.js
===================================================================
--- trunk/layers/Generic/Generic.js (rev 0)
+++ trunk/layers/Generic/Generic.js 2008-11-12 20:49:29 UTC (rev 1661)
@@ -0,0 +1,184 @@
+/**
+ * Fusion.Maps.Generic
+ *
+ * $Id: Generic.js 1590 2008-10-10 14:01:27Z madair $
+ *
+ * Copyright (c) 2007, DM Solutions Group Inc.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/***************************************************************************
+* Class: Fusion.Maps.Generic
+*
+* Implements the map widget for Generic mapping services.
+*/
+
+Fusion.Layers.Generic = OpenLayers.Class(Fusion.Layers, {
+ arch: 'Generic',
+ sActiveLayer: null,
+ selectionType: 'INTERSECTS',
+ bSelectionOn: false,
+ oSelection: null,
+
+ initialize: function(map, mapTag, isMapWidgetLayer) {
+ // console.log('Generic.initialize');
+ Fusion.Layers.prototype.initialize.apply(this, arguments);
+
+ this._sMapname = mapTag.layerOptions['name'] ? mapTag.layerOptions['name'] : 'generic layer';
+
+ this.minScale = mapTag.layerOptions.minScale ? mapTag.layerOptions.minScale : 1;
+ this.maxScale = mapTag.layerOptions.maxScale ? mapTag.layerOptions.maxScale : 'auto';
+ var scaleRange = new Fusion.Layers.ScaleRange({
+ minScale: this.minScale,
+ maxScale: this.maxScale},
+ Fusion.Constant.LAYER_RASTER_TYPE);
+
+ rootOpts = {
+ layerName: this._sMapname,
+ resourceId: this.sMapResourceId,
+ selectable: false,
+ editable: false,
+ layerTypes: [Fusion.Constant.LAYER_RASTER_TYPE],
+ minScale: this.minScale,
+ maxScale: this.maxScale,
+ scaleRanges: [scaleRange],
+ parentGroup: map.layerRoot,
+ displayInLegend: this.bDisplayInLegend,
+ expandInLegend: this.bExpandInLegend,
+ legendLabel: this._sMapname,
+ uniqueId: 'layerRoot',
+ visible: true,
+ actuallyVisible: true
+ //TODO: set other opts for group initialization as required
+ };
+ this.layerRoot = new Fusion.Layers.Layer(rootOpts,this);
+ //this.layerRoot = new Fusion.Layers.Group(rootOpts,this);
+ this.loadMap(this.sMapResourceId);
+ },
+
+ loadMap: function(resourceId) {
+ this.bMapLoaded = false;
+
+ this.triggerEvent(Fusion.Event.LAYER_LOADING);
+ if (this.bIsMapWidgetLayer) {
+ this.mapWidget._addWorker();
+ }
+
+ //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();
+ }
+
+ switch (this.layerType) {
+ case 'Google':
+ switch (this.mapTag.layerOptions.type) { //Google layer types are actual objects
+ case 'G_PHYSICAL_MAP': //defined by gmap, not a string
+ this.mapTag.layerOptions.type = G_PHYSICAL_MAP;
+ break;
+ case 'G_HYBRID_MAP':
+ this.mapTag.layerOptions.type = G_HYBRID_MAP;
+ break;
+ case 'G_SATELLITE_MAP':
+ this.mapTag.layerOptions.type = G_SATELLITE_MAP;
+ break;
+ case 'G_NORMAL_MAP':
+ default:
+ this.mapTag.layerOptions.type = G_NORMAL_MAP;
+ break;
+ }
+ this.oLayerOL = new OpenLayers.Layer.Google(this.getMapName(), this.mapTag.layerOptions );
+ break;
+ default:
+ this.oLayerOL = new OpenLayers.Layer[this.layerType](
+ this.getMapName(),
+ this.sMapResourceId,
+ this.mapTag.layerParams,
+ this.mapTag.layerOptions );
+ break;
+ }
+ 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._removeWorker();
+ }
+
+ //this.triggerEvent(Fusion.Event.LAYER_LOADED);
+ window.setTimeout(OpenLayers.Function.bind(this.asyncTrigger, this),1000);
+ },
+
+ asyncTrigger: function() {
+ this.bMapLoaded = true;
+ this.triggerEvent(Fusion.Event.LAYER_LOADED);
+ },
+
+//TBD: this function not yet converted for OL
+ reloadMap: function() {
+
+ this.loadMap(this.sResourceId);
+ this.mapWidget.triggerEvent(Fusion.Event.MAP_RELOADED);
+ this.drawMap();
+ },
+
+ drawMap: function() {
+ if (!this.bMapLoaded) {
+ return;
+ }
+ this.oLayerOL.mergeNewParams(params);
+ },
+
+ showLayer: function( layer, noDraw ) {
+ this.processLayerEvents(layer, true);
+ if (!noDraw) {
+ this.oLayerOL.setVisibility(true);
+ }
+ },
+
+ hideLayer: function( layer, noDraw ) {
+ this.processLayerEvents(layer, false);
+ if (!noDraw) {
+ this.oLayerOL.setVisibility(false);
+ }
+ },
+
+ showGroup: function( group, noDraw ) {
+ this.processGroupEvents(group, true);
+ },
+
+ hideGroup: function( group, noDraw ) {
+ this.processGroupEvents(group, false);
+ },
+
+ refreshLayer: function( layer ) {
+ this.drawMap();
+ },
+
+ getLegendImageURL: function(fScale, layer, style) {
+ var url = null; //TODO: provide a generic icon url
+ return url;
+ }
+
+});
+
Added: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js (rev 0)
+++ trunk/layers/Layers.js 2008-11-12 20:49:29 UTC (rev 1661)
@@ -0,0 +1,576 @@
+/**
+ * Fusion.Layers
+ *
+ * $Id: MapGuide.js 1590 2008-10-10 14:01:27Z madair $
+ *
+ * Copyright (c) 2007, DM Solutions Group Inc.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/***************************************************************************
+* Class: Fusion.Layers
+*
+* Implements Layers for Fusion.
+*/
+
+Fusion.Event.MAP_LAYER_TOGGLED = Fusion.Event.lastEventId++;
+Fusion.Event.MAP_LAYER_ORDER_CHANGED = Fusion.Event.lastEventId++;
+Fusion.Event.LAYER_LOADED = Fusion.Event.lastEventId++;
+Fusion.Event.LAYER_LOADING = Fusion.Event.lastEventId++;
+
+Fusion.Layers = OpenLayers.Class(Fusion.Lib.EventMgr, {
+ bSingleTile: null,
+ bIsBaseLayer: false, //TODO: set this in AppDef?
+ bDisplayInLegend: true, //TODO: set this in AppDef?
+ bExpandInLegend: true, //TODO: set this in AppDef?
+ bMapLoaded: false,
+ bIsMapWidgetLayer: true, //Set this to false for overview map layers
+ bLayersReversed: false, //MGOS returns layers top-most layer first
+ sMapResourceId: null, //pointer to the resource that defines the map (URL, MapFile, MGOS, etc)
+ sImageType: 'png', //TODO: set this in AppDef?
+ clientAgent: 'Fusion Viewer',
+ _sMapTitle: null,
+ _sMapname: null,
+
+ initialize: function(map, mapTag, isMapWidgetLayer) {
+ // console.log('Fusion.Layers.initialize');
+
+ this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
+ this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
+ this.registerEventID(Fusion.Event.MAP_LOADED);
+ this.registerEventID(Fusion.Event.LAYER_LOADED);
+ this.registerEventID(Fusion.Event.LAYER_LOADING);
+ this.registerEventID(Fusion.Event.MAP_LAYER_ORDER_CHANGED);
+
+ this.mapWidget = map;
+ this.oSelection = null;
+ if (isMapWidgetLayer != null) {
+ this.bIsMapWidgetLayer = isMapWidgetLayer;
+ }
+
+ this.mapTag = mapTag;
+ this.ratio = this.mapTag.layerOptions.MapRatio ? this.extension.MapRatio[0] : 1.0;
+ this.bSingleTile = mapTag.singleTile; //this is set in thhe AppDef.Map class
+ this.bIsBaseLayer = mapTag.isBaseLayer;
+ this.sMapResourceId = mapTag.resourceId ? mapTag.resourceId : '';
+ this.mapInfo = mapTag.mapInfo;
+ this.layerType = mapTag.type;
+
+ },
+
+ /**
+ * Function: loadScaleRanges
+ *
+ * This function should be called after the map has loaded. It
+ * loads the scsle ranges for each layer. I tis for now only
+ * used by the legend widget.
+ */
+
+ loadScaleRanges: function(userFunc) {
+ userFunc();
+ },
+
+
+ getMapName: function() {
+ return this._sMapname;
+ },
+
+ getMapTitle: function() {
+ return this._sMapTitle;
+ },
+
+ /**
+ * Function: isMapLoaded
+ *
+ * Returns true if the Map has been laoded succesfully form the server
+ */
+ isMapLoaded: function() {
+ return this.bMapLoaded;
+ },
+
+ getMaxExtent: function() {
+ var maxExtent = null;
+ if (this.oLayerOL) {
+ maxExtent = this.oLayerOL.maxExtent;
+ }
+ return maxExtent;
+ },
+
+ hasSelection: function() { return this.bSelectionOn; },
+
+ /**
+ * Returns the number of features selected for this map layer
+ */
+ getSelectedFeatureCount: function() {
+ var total = 0;
+ return total;
+ },
+
+ /**
+ * Returns the number of features selected for this map layer
+ */
+ getSelectedLayers: function() {
+ var layers = [];
+ return layers;
+ },
+
+ /**
+ * Returns the number of features selected for this map layer
+ */
+ getSelectableLayers: function() {
+ var layers = [];
+ return layers;
+ },
+
+ setSelection: function (selText, zoomTo) {
+ },
+
+
+ /**
+ * 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) {
+ },
+
+ /**
+ Utility function to clear current selection
+ */
+ clearSelection: function() {
+ },
+
+ /**
+ Do a query on the map
+ */
+ query: function(options) {
+ },
+
+ processLayerEvents: function(layer, isEnabling) {
+ if (this.mapInfo && this.mapInfo.mapEvents.layerEvents[layer.layerName]) {
+ var layerEvent = this.mapInfo.mapEvents.layerEvents[layer.layerName];
+ var events = isEnabling ? layerEvent.onEnable : layerEvent.onDisable;
+ for (var i=0; i<events.length; i++) {
+ var o = events[i];
+ if (o.type == 'layer') {
+ var l = this.layerRoot.findLayer(o.name);
+ if (l) {
+ if (o.enable) {
+ l.show(true);
+ } else {
+ l.hide(true);
+ }
+ }
+
+ } else if (o.type == 'group') {
+ var g = this.layerRoot.findGroupByAttribute('groupName', o.name);
+ if (g) {
+ if (o.enable) {
+ g.show(true);
+ } else {
+ g.hide(true);
+ }
+ }
+ }
+ }
+ }
+ },
+
+ processGroupEvents: function(group, isEnabling) {
+ if (this.mapInfo && this.mapInfo.mapEvents.groupEvents[group.groupName]) {
+ var groupEvent = this.mapInfo.mapEvents.groupEvents[group.groupName];
+ var events = isEnabling ? groupEvent.onEnable : groupEvent.onDisable;
+ for (var i=0; i<events.length; i++) {
+ var o = events[i];
+ if (o.type == 'layer') {
+ var l = this.layerRoot.findLayer(o.name);
+ if (l) {
+ if (o.enable) {
+ l.show(true);
+ } else {
+ l.hide(true);
+ }
+ }
+
+ } else if (o.type == 'group') {
+ var g = this.layerRoot.findGroupByAttribute('groupName', o.name);
+ if (g) {
+ if (o.enable) {
+ g.show(true);
+ } else {
+ g.hide(true);
+ }
+ }
+ }
+ }
+ }
+ },
+
+ refreshLayer: function( layer ) {
+ this.drawMap();
+ },
+
+ setParameter: function(param, value) {
+ if (param == 'SelectionType') {
+ this.selectionType = value;
+ }
+ },
+
+ loadStart: function() {
+ if (this.bIsMapWidgetLayer) {
+ this.mapWidget._addWorker();
+ }
+ },
+
+ loadEnd: function() {
+ if (this.bIsMapWidgetLayer) {
+ this.mapWidget._removeWorker();
+ }
+ },
+
+ getGroupInfoUrl: function(groupName) {
+ if (this.mapInfo) {
+ var groups = this.mapInfo.links.groups;
+ for (var i=0; i<groups.length; i++) {
+ if (groups[i].name == groupName) {
+ return groups[i].url;
+ }
+ }
+ }
+ return null;
+ },
+ getLayerInfoUrl: function(layerName) {
+ if (this.mapInfo) {
+ var layers = this.mapInfo.links.layers;
+ for (var i=0; i<layers.length; i++) {
+ if (layers[i].name == layerName) {
+ return layers[i].url;
+ }
+ }
+ }
+ return null;
+ }
+});
+
+/***************************************************************************
+* Class: Fusion.Layers.Group
+*
+* Implements the map layer groups
+ * **********************************************************************/
+Fusion.Event.GROUP_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
+
+Fusion.Layers.Group = OpenLayers.Class(Fusion.Lib.EventMgr, {
+ name: null,
+ groups: null,
+ layers: null,
+ oMap: null,
+ initialize: function(o, oMap) {
+ this.uniqueId = o.uniqueId;
+ this.name = o.groupName;
+ this.groups = [];
+ this.layers = [];
+ 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;
+ this.registerEventID(Fusion.Event.GROUP_PROPERTY_CHANGED);
+ },
+
+ show: function(noDraw) {
+ if (this.visible) {
+ return;
+ }
+ this.oMap.showGroup(this, noDraw ? true : false);
+ this.visible = true;
+ if (this.legend && this.legend.checkBox) {
+ this.legend.checkBox.checked = true;
+ }
+ },
+
+ hide: function(noDraw) {
+ if (!this.visible) {
+ return;
+ }
+ this.oMap.hideGroup(this, noDraw ? true : false);
+ this.visible = false;
+ if (this.legend && this.legend.checkBox) {
+ this.legend.checkBox.checked = false;
+ }
+ },
+
+ isVisible: function() {
+ return this.visible;
+ },
+
+ clear: function() {
+ for (var i=0; i<this.groups.length; i++) {
+ this.groups[i].clear();
+ }
+ for (var i=0; i<this.layers.length; i++) {
+ this.layers[i].clear();
+ }
+ this.groups = [];
+ this.layers = [];
+ },
+
+ set: function(property, value) {
+ this[property] = value;
+ this.triggerEvent(Fusion.Event.GROUP_PROPERTY_CHANGED, this);
+ },
+
+ addGroup: function(group,reverse) {
+ group.parentGroup = this;
+ if (reverse) {
+ this.groups.unshift(group);
+ } else {
+ this.groups.push(group);
+ }
+ },
+
+ addLayer: function(layer,reverse) {
+ layer.parentGroup = this;
+ if (reverse) {
+ this.layers.unshift(layer);
+ } else {
+ this.layers.push(layer);
+ }
+ },
+
+ findGroup: function(name) {
+ return this.findGroupByAttribute('name', name);
+ },
+
+ findGroupByAttribute: function(attribute, value) {
+ if (this[attribute] == value) {
+ return this;
+ }
+ for (var i=0; i<this.groups.length; i++) {
+ var group = this.groups[i].findGroupByAttribute(attribute, value);
+ if (group) {
+ return group;
+ }
+ }
+ return null;
+ },
+
+ findLayer: function(name) {
+ return this.findLayerByAttribute('name', name);
+ },
+
+ findLayerByAttribute: function(attribute, value) {
+ for (var i=0; i<this.layers.length; i++) {
+ if (this.layers[i][attribute] == value) {
+ return this.layers[i];
+ }
+ }
+ for (var i=0; i<this.groups.length; i++) {
+ var layer = this.groups[i].findLayerByAttribute(attribute,value);
+ if (layer) {
+ return layer;
+ }
+ }
+ return null;
+ }
+
+});
+
+/***************************************************************************
+* Class: Fusion.Layers.Layer
+*
+* Implements individual map legend layers
+ * **********************************************************************/
+Fusion.Event.LAYER_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
+
+Fusion.Layers.Layer = OpenLayers.Class(Fusion.Lib.EventMgr, {
+
+ name: null,
+ scaleRanges: null,
+ oMap: null,
+
+ initialize: function(o, oMap) {
+ this.oMap = oMap;
+ this.layerName = o.layerName;
+ this.uniqueId = o.uniqueId;
+ this.resourceId = o.resourceId;
+ this.selectable = o.selectable;
+ this.selectedFeatureCount = 0;
+ this.layerTypes = [].concat(o.layerTypes);
+ this.visible = o.visible;
+ this.actuallyVisible = o.actuallyVisible;
+ this.editable = o.editable;
+
+ this.legendLabel = o.legendLabel;
+ this.displayInLegend = o.displayInLegend;
+ this.expandInLegend = o.expandInLegend;
+
+ //determine the layer type so that the correct icon can be displayed in the legend
+ this.layerType = null;
+ if (this.supportsType(Fusion.Constant.LAYER_RASTER_TYPE)) { //raster layers
+ this.layerType = Fusion.Constant.LAYER_RASTER_TYPE;
+ } else if (this.supportsType(Fusion.Constant.LAYER_DWF_TYPE)) { //DWF layers
+ this.layerType = Fusion.Constant.LAYER_DWF_TYPE;
+ }
+
+ this.parentGroup = o.parentGroup;
+ this.minScale = o.minScale;
+ this.maxScale = o.maxScale;
+ if (this.maxScale == 'infinity') {
+ this.maxScale = 100000000;
+ }
+ this.scaleRanges = [];
+
+ if (o.scaleRanges)
+ {
+ for (var i=0; i<o.scaleRanges.length; i++) {
+ var scaleRange = new Fusion.Layers.ScaleRange(o.scaleRanges[i],
+ this.layerType);
+ this.scaleRanges.push(scaleRange);
+ }
+ }
+ this.registerEventID(Fusion.Event.LAYER_PROPERTY_CHANGED);
+ },
+
+ 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(noDraw) {
+ if (this.visible) {
+ return;
+ }
+ this.set('visible', true);
+ this.oMap.showLayer(this, noDraw ? true : false);
+ if (this.legend && this.legend.checkBox) {
+ this.legend.checkBox.checked = true;
+ }
+ },
+
+ hide: function(noDraw) {
+ if (!this.visible) {
+ return;
+ }
+ this.set('visible',false);
+ this.oMap.hideLayer(this, noDraw ? true : false);
+ if (this.legend && this.legend.checkBox) {
+ this.legend.checkBox.checked = false;
+ }
+ },
+
+ isVisible: function() {
+ return this.visible;
+ },
+
+ clear: function() {},
+
+ set: function(property, value) {
+ this[property] = value;
+ this.triggerEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, this);
+ }
+
+});
+
+/***************************************************************************
+* Class: Fusion.Layers.ScaleRange
+*
+* Implements a scale range object
+*/
+
+Fusion.Layers.ScaleRange = OpenLayers.Class({
+ styles: null,
+ initialize: function(o, layerType) {
+ this.minScale = o.minScale;
+ this.maxScale = o.maxScale;
+ if (this.maxScale == 'infinity' || this.maxScale == 'auto') {
+ this.maxScale = Infinity;
+ }
+ this.styles = [];
+ if (!o.styles) {
+ var styleItem = new Fusion.Layers.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.Layers.StyleItem(o.styles[i], staticIcon);
+ this.styles.push(styleItem);
+ }
+ },
+ contains: function(fScale) {
+ var testScale = Math.round(fScale);
+ return testScale >= this.minScale && testScale <= this.maxScale;
+ }
+});
+
+/***************************************************************************
+* Class: Fusion.Layers.StyleItem
+*
+* Implements the legend style items to get a legend icon from the server
+*/
+
+Fusion.Layers.StyleItem = OpenLayers.Class({
+ clientAgent: 'Fusion Viewer',
+ initialize: function(o, staticIcon) {
+ this.legendLabel = o.legendLabel;
+ this.filter = o.filter;
+ this.geometryType = o.geometryType;
+ if (this.geometryType == '') {
+ this.geometryType = -1;
+ }
+ this.categoryIndex = o.categoryIndex;
+ if (this.categoryindex == '') {
+ this.categoryindex = -1;
+ }
+ this.index = o.index; //TODO: merge this with categoryIndex?
+ this.staticIcon = staticIcon;
+ }
+});
More information about the fusion-commits
mailing list