Commit 28229ae3 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Simplifica y aclara estructuras de datos de atlas

Unifica objetos, renombra elementos y simplifica gestión de datos
procedentes del servicio atlas, para aclarar mejor su uso y facilitar su
mantenimiento.

Actualiza submódulo.
parent d3041b13
Loading
Loading
Loading
Loading
Compare 109631c9 to 0e3e2c58
Original line number Diff line number Diff line
Subproject commit 109631c9d8c34402aa57953f433640177cf3027a
Subproject commit 0e3e2c58d3f3c231bdd276181cd5a576e6471398
+17 −10
Original line number Diff line number Diff line
@@ -75,7 +75,8 @@ define([

			lang.mixin(this, this.config, args);

			aspect.before(this, '_createLayerInstance', lang.hitch(this, this._atlasBeforeCreateLayerInstance));
			aspect.before(this, '_createAtlasMapLayerInstance',
				lang.hitch(this, this._beforeCreateAtlasMapLayerInstance));
		},

		_setConfigurations: function() {
@@ -90,7 +91,10 @@ define([
								icon: 'fa-trash-o',
								btnId: 'remove',
								title: 'remove',
								condition: function(item) { return !!item.originalItem.atlas; },
								condition: function(atlasLayerItem) {

									return !!atlasLayerItem.atlasItem.atlas;
								},
								returnItem: true
							}]
						}
@@ -236,7 +240,10 @@ define([
			}
		},

		_atlasBeforeCreateLayerInstance: function(id, layerId) {
		_beforeCreateAtlasMapLayerInstance: function(atlasLayerItem) {

			var id = atlasLayerItem.id,
				layerId = atlasLayerItem.mapLayerId;

			this._layerIdsById[id] = layerId;
		},
@@ -335,13 +342,13 @@ define([

		_itemAvailable: function(response) {

			var item = response.data;
			var atlasItem = response.data;

			if (item.leaves) {
			if (atlasItem.leaves) {
				return;
			}

			var itemId = this._getAtlasLayerId(item);
			var itemId = this._getAtlasItemId(atlasItem);

			if (this._layerIdsById[itemId]) {
				return;
@@ -352,19 +359,19 @@ define([
				info: {
					category: TRACK.category.layer,
					action: TRACK.action.click,
					label: 'Layer loaded: ' + item.name
					label: 'Layer loaded: ' + atlasItem.name
				}
			});

			var layerItem = this._getLayerItemToInject(item);
			var atlasLayerItem = this._getAtlasLayerItemToInject(atlasItem);

			this._emitEvt('INJECT_ITEM', {
				data: layerItem,
				data: atlasLayerItem,
				target: this.localTarget
			});

			this._lastOrder++;
			this._activateLayer(layerItem, this._lastOrder);
			this._activateLayer(atlasLayerItem, this._lastOrder);
		},

		_subLayerRemoved: function(res) {
+3 −2
Original line number Diff line number Diff line
@@ -34,8 +34,9 @@ define([

			var container = browserButtonObj.node,
				elevationContainer = container.children[1],
				item = browserButtonObj.item.originalItem,
				layerId = this._createLayerId(item),
				atlasLayerItem = browserButtonObj.item,
				item = atlasLayerItem.atlasItem,
				layerId = atlasLayerItem.mapLayerId,
				elevationTagListInstance = this._getLayerElevationTagList(layerId, item),
				elevationShown = this._elevationShownByLayerId[layerId] || false;

+44 −45
Original line number Diff line number Diff line
@@ -253,51 +253,48 @@ define([
			}
		},

		_getAtlasLayerDefinition: function() {
		_getMapLayerComponentDefinition: function() {

			return declare([WmsLayerImpl, _PublishInfo]);
		},

		_getAtlasLayerConfiguration: function(layerItem) {
		_getMapLayerComponentConfiguration: function(atlasItem) {

			var layerId = this._createLayerId(layerItem),
				layerLabel = this._createLayerLabel(layerItem),
				layerDefinition = this._getLayerDefinitionByProtocol(layerItem);
			var layerId = this._createLayerId(atlasItem),
				layerLabel = this._createLayerLabel(atlasItem),
				innerLayerDefinition = this._getLayerDefinitionByProtocol(atlasItem);

			return {
				parentChannel: this.getChannel(),
				layerDefinition: layerDefinition,
				mapChannel: this.getMapChannel ? this.getMapChannel() : null,
				innerLayerDefinition: innerLayerDefinition,
				layerId: layerId,
				layerLabel: layerLabel,
				queryable: layerItem.queryable,
				refresh: layerItem.refresh
				queryable: atlasItem.queryable,
				refresh: atlasItem.refresh
			};
		},

		_getLayerItemToInject: function(item) {
		_getAtlasLayerItemToInject: function(atlasItem) {

			var itemId = this._getAtlasLayerId(item),
				layerDefinition = this._getAtlasLayerDefinition(),
				layerConfiguration = this._getAtlasLayerConfiguration(item),
				layerLabel = layerConfiguration.layerLabel;

			layerConfiguration.mapChannel = this.getMapChannel();
			var itemId = this._getAtlasItemId(atlasItem),
				mapLayerDefinition = this._getMapLayerComponentDefinition(),
				mapLayerConfig = this._getMapLayerComponentConfiguration(atlasItem);

			return {
				id: itemId,
				label: layerLabel,
				label: mapLayerConfig.layerLabel,
				state: this.defaultLayerItemState,
				originalItem: item,
				layer: {
					definition: layerDefinition,
					props: layerConfiguration
				}
				mapLayerId: mapLayerConfig.layerId,
				mapLayerDefinition: mapLayerDefinition,
				mapLayerConfig: mapLayerConfig,
				atlasItem: atlasItem
			};
		},

		_getAtlasLayerId: function(layerItem) {
		_getAtlasItemId: function(atlasItem) {

			return layerItem && layerItem.id;
			return atlasItem && atlasItem.id;
		},

		_createLayerId: function(layerItem) {
@@ -335,57 +332,59 @@ define([
			this._publish(layerInstance.getChannel('DISCONNECT'));
		},

		_getLayerInstance: function(id, layerId, Definition, props) {
		_getAtlasMapLayerInstance: function(atlasLayerItem) {

			var layerInstance = this._layerInstances[layerId];
			var mapLayerId = atlasLayerItem.mapLayerId,
				layerInstance = this._layerInstances[mapLayerId];

			if (layerInstance) {
				return layerInstance;
			}

			return this._createLayerInstance(id, layerId, Definition, props);
			return this._createAtlasMapLayerInstance(atlasLayerItem);
		},

		_createLayerInstance: function(_id, layerId, Definition, props) {
		_createAtlasMapLayerInstance: function(atlasLayerItem) {

			var layerInstance = new Definition(props);
			var MapLayerDefinition = atlasLayerItem.mapLayerDefinition,
				mapLayerConfig = atlasLayerItem.mapLayerConfig,
				mapLayerId = atlasLayerItem.mapLayerId;

			this._layerInstances[layerId] = layerInstance;
			var mapLayerInstance = new MapLayerDefinition(mapLayerConfig);

			this._createSubsAndPubsForLayer(layerInstance);
			this._layerInstances[mapLayerId] = mapLayerInstance;

			return layerInstance;
			this._createSubsAndPubsForLayer(mapLayerInstance);

			return mapLayerInstance;
		},

		_activateLayer: function(/*Object*/ item, order) {
		_activateLayer: function(/*Object*/ atlasLayerItem, order) {

			if (!item || !item.layer) {
			if (!atlasLayerItem) {
				return;
			}

			var definition = item.layer.definition,
				props = item.layer.props,
				id = item.id,
				layerId = this._createLayerId(item.originalItem),
				layer = this._getLayerInstance(id, layerId, definition, props);
			var mapLayerId = atlasLayerItem.mapLayerId,
				layer = this._getAtlasMapLayerInstance(atlasLayerItem);

			this._emitEvt('ADD_LAYER', {
				layer: layer,
				layerId: layerId,
				layerLabel: item.label,
				atlasItem: item.originalItem,
				layerId: mapLayerId,
				layerLabel: atlasLayerItem.label,
				atlasItem: atlasLayerItem.atlasItem,
				order: order
			});
		},

		_deactivateLayer: function(/*Object*/ item, order) {
		_deactivateLayer: function(/*Object*/ atlasLayerItem, order) {

			if (!item.layer) {
			if (!atlasLayerItem) {
				return;
			}

			var layerId = this._createLayerId(item.originalItem),
				layer = this._layerInstances[layerId];
			var mapLayerId = atlasLayerItem.mapLayerId,
				layer = this._layerInstances[mapLayerId];

			if (layer) {
				this._emitEvt('REMOVE_LAYER', {
+2 −2
Original line number Diff line number Diff line
@@ -63,8 +63,8 @@ define([

			var container = browserButtonObj.node,
				legendContainer = container.children[1],
				item = browserButtonObj.item.originalItem,
				layerId = this._createLayerId(item),
				atlasLayerItem = browserButtonObj.item,
				layerId = atlasLayerItem.mapLayerId,
				legend = this._legendByLayerId[layerId],
				legendShown = this._legendShownByLayerId[layerId];

Loading