Commit f82fd5ef authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Optimiza y corrige carga de estaciones en mapa

Desde el visor de series temporales, había varios problemas al consumir
datos de series temporales para representarlos en gráficas. Por un lado,
siempre se traían todos los campos de resultado, y por el otro eso era
necesario para crear las estructuras.
Ahora sólo se pide la geometría, y en caso de que se necesite pedir
datos (por ejemplo, si recargamos con selección previa), se piden con
los campos de respuesta que usa el listado, suficientes para generar las
estructuras de representación en gráficas.
A cambio, al pulsar una estación en el mapa, es necesario pedir los
datos completos correspondientes a ella, pero es más eficiente en
general.
parent d2710de3
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -540,17 +540,12 @@ define([], function() {
		],
		taxonsTree: ['scientificName', 'rank', 'path', 'leaves'],
		timeSeriesStationsList: [
			'uuid', 'properties.activityId', 'properties.site.path', 'properties.site.name', 'properties.site.code',
			'properties.activityId', 'properties.site.path', 'properties.site.name', 'properties.site.code',
			'properties.site.id', 'properties.measurements.parameter.id', 'properties.measurements.parameter.name',
			'properties.measurements.unit.id', 'properties.measurements.unit.name',
			'properties.measurements.dataDefinition.id', 'properties.measurements.dataDefinition.z'
		],
		timeSeriesStationsMap: [
			'uuid', 'geometry', 'properties.activityId', 'properties.site.path', 'properties.site.name',
			'properties.site.code', 'properties.measurements.parameter.id', 'properties.measurements.parameter.name',
			'properties.measurements.unit.id', 'properties.measurements.unit.name',
			'properties.measurements.dataDefinition.id'
		]
		timeSeriesStationsMap: ['geometry']
	};

	retObj.outerPaths = [
+13 −16
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ define([
			});

			this._showMap("showMap");
			this._getMapData();

			this._showGuideMessagesHandler = setTimeout(lang.hitch(this, this._showGuideMessagesAtStartup),
				this._guideMessagesStartupTimeout);
@@ -452,27 +453,23 @@ define([

		_clickInMarker: function(obj) {

			var _activeBrowserPopupCopy = this._activeBrowserPopup;
			var currClickedStationId = obj.data[this.idProperty];

			if (this._activeBrowserPopup) {
				if (this._activeBrowserPopup === obj.data[this.idProperty]) {
					this._activeBrowserPopup = false;
			if (this._lastClickedStationId) {
				if (currClickedStationId === this._lastClickedStationId) {
					this._lastClickedStationId = null;
				}

				this._publish(this.browserPopup.getChannel("HIDE"));
				this._publish(this.browserPopup.getChannel('HIDE'));
			}

			if (_activeBrowserPopupCopy !== obj.data[this.idProperty]) {
				this._itemAvailable(obj); // TODO refactorizar en _TimeSeriesDataManagement

				// TODO no hace falta pedir mientras la petición inicial siga trayendo todos los datos
				/*this._activeBrowserPopup = obj.data[this.idProperty];
			if (currClickedStationId !== this._lastClickedStationId) {
				this._lastClickedStationId = currClickedStationId;

				this._emitEvt('GET', {
					target: this.target,
					requesterId: this.getOwnChannel(),
					id: obj.data[this.idProperty]
				});*/
					id: currClickedStationId
				});
			}
		},

@@ -483,13 +480,13 @@ define([

		_resetMarkerActive: function() {

			if (this._activeBrowserPopup) {
			if (this._lastClickedStationId) {
				this._publish(this.mapLayerImpl.getChannel("DELETE_HIGHLIGHT_MARKER"), {
					id: this._activeBrowserPopup
					id: this._lastClickedStationId
				});
			}

			this._activeBrowserPopup = false;
			this._lastClickedStationId = false;
		},

		_onViewHidden: function() {
+17 −25
Original line number Diff line number Diff line
@@ -75,47 +75,39 @@ define([
				return;
			}

			if (this._getListDataDfd && !this._getListDataDfd.isFulfilled()) {
				this._prepareDataToInject(data.features);
				this._generateTimeSeriesDataFromSelectedData();

				this._getListDataDfd.resolve();
				this._getListDataDfd = null;

				return;
			}

			var embeddedButtonKeys = Object.keys(this.embeddedButtons),
				embeddedListKey = embeddedButtonKeys[1],
				currentEmbeddedContentKey = this._getCurrentContentKey();
				currentKey = this._getCurrentContentKey();

			if (currentKey === embeddedListKey) {
				this._prepareDataToInject(data.features);

			if (currentEmbeddedContentKey === embeddedListKey) {
				this._injectDataToList();
			} else {
				this._injectDataToMap(data);
			}

			if (this._getListDataDfd && !this._getListDataDfd.isFulfilled()) {
				this._generateTimeSeriesDataFromSelectedData();
				this._getListDataDfd.resolve();
				this._getListDataDfd = null;
			}
		},

		_itemAvailable: function(response) {

			this._publish(this.browserPopup.getChannel('SHOW'));

			var browserPopupData = [],
				itemProps = response.data.properties;

			var stationPath = itemProps.site.path,
				stationParsedData = this._getParsedStation(stationPath);
			var itemProps = response.data.properties;

			browserPopupData.push(stationParsedData);

			for (var i = 0; i < itemProps.measurements.length; i++) {
				var measurement = itemProps.measurements[i],
					parameterPath = measurement.parameter.path,
					dataDefinitionParsedData = this._getParsedDataDefinition(parameterPath);

				browserPopupData.push(dataDefinitionParsedData);
			}
			this._clearTimeseriesInternalStructures();
			this._parseData(itemProps);

			this._emitEvt('INJECT_DATA', {
				data: browserPopupData,
				data: this._getTimeseriesHierarchicalList(),
				target: this.browserPopupTarget
			});
		},