diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index 645cb13f7a3006be65b40e26c18c1b5757eb9142..9d55d00fe139b738143d44e2d285dce0ffa644cc 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -696,6 +696,25 @@ CustomMap.prototype.renderOverlayCollection = function (params) { return overlayCollection.getIdentifiedElements().then(function (identifiedElements) { elements = identifiedElements; + var elementsByModelId = []; + var modelId; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + modelId = element.getModelId(); + if (elementsByModelId[modelId] === undefined) { + elementsByModelId[modelId] = []; + } + elementsByModelId[modelId].push(element); + } + var promises = []; + for (modelId in elementsByModelId) { + if (elementsByModelId.hasOwnProperty(modelId)) { + promises.push(self.getModel().getSubmodelById(parseInt(modelId)).getByIdentifiedElements(elementsByModelId[modelId], false)); + } + } + return Promise.all(promises); + }).then(function () { return Promise.each(elements, function (element) { var icon = element.getIcon(); if (icon !== null && icon !== undefined) { diff --git a/frontend-js/src/main/js/map/data/IdentifiedElement.js b/frontend-js/src/main/js/map/data/IdentifiedElement.js index bf6d87ecfbd8e946ea531894ca2e31b2012cb7d8..727425d6611892b1f64a0fee59f72e9d816bb65a 100644 --- a/frontend-js/src/main/js/map/data/IdentifiedElement.js +++ b/frontend-js/src/main/js/map/data/IdentifiedElement.js @@ -82,11 +82,11 @@ function IdentifiedElement(javaObject) { /** * Returns point where it should be visualized when the type of object is * "POINT". - * + * * @returns {@linke google.maps.Point} where it should be visualized when the * type of object is "POINT". */ -IdentifiedElement.prototype.getPoint = function() { +IdentifiedElement.prototype.getPoint = function () { if (this._point === undefined || this._point === null) { logger.warn("No point associated with IdentifiedElement"); return null; @@ -97,15 +97,15 @@ IdentifiedElement.prototype.getPoint = function() { /** * Returns element identifier. - * + * * @returns element identifier */ -IdentifiedElement.prototype.getId = function() { +IdentifiedElement.prototype.getId = function () { return this.id; }; -IdentifiedElement.prototype.setId = function(id) { - // some elements are identfied by id that is not a number (like point on the +IdentifiedElement.prototype.setId = function (id) { + // some elements are identified by id that is not a number (like point on the // map) if (!isNaN(id)) { id = parseInt(id); @@ -113,7 +113,7 @@ IdentifiedElement.prototype.setId = function(id) { this.id = id; }; -IdentifiedElement.prototype.setModelId = function(modelId) { +IdentifiedElement.prototype.setModelId = function (modelId) { if (modelId === undefined || modelId === null) { throw new Error("ModelId is invalid"); } @@ -122,10 +122,10 @@ IdentifiedElement.prototype.setModelId = function(modelId) { /** * Returns model identifier where element is placed. - * + * * @returns model identifier */ -IdentifiedElement.prototype.getModelId = function() { +IdentifiedElement.prototype.getModelId = function () { return this.modelId; }; @@ -137,14 +137,14 @@ IdentifiedElement.prototype.getModelId = function() { * <li>"POINT" - for any point on the map, the data connected to this kind of * objects are stored in {@link PointData}</li> * </ul> - * + * * @returns type of the element */ -IdentifiedElement.prototype.getType = function() { +IdentifiedElement.prototype.getType = function () { return this.type; }; -IdentifiedElement.prototype.setType = function(type) { +IdentifiedElement.prototype.setType = function (type) { if (type === undefined || type === null) { throw new Error("Type not defined"); } @@ -154,77 +154,77 @@ IdentifiedElement.prototype.setType = function(type) { /** * Returns icon that should be used for visualization. - * + * * @returns icon that should be used for visualization */ -IdentifiedElement.prototype.getIcon = function() { +IdentifiedElement.prototype.getIcon = function () { return this._visualizationdata._icon; }; -IdentifiedElement.prototype.setIcon = function(icon) { +IdentifiedElement.prototype.setIcon = function (icon) { this._visualizationdata._icon = icon; }; -IdentifiedElement.prototype.getColor = function() { +IdentifiedElement.prototype.getColor = function () { return this._visualizationdata._color; }; -IdentifiedElement.prototype.setColor = function(color) { +IdentifiedElement.prototype.setColor = function (color) { this._visualizationdata._color = color; }; -IdentifiedElement.prototype.getOpacity = function() { +IdentifiedElement.prototype.getOpacity = function () { return this._visualizationdata._opacity; }; -IdentifiedElement.prototype.setOpacity = function(opacity) { +IdentifiedElement.prototype.setOpacity = function (opacity) { this._visualizationdata._opacity = opacity; }; -IdentifiedElement.prototype.getLineWeight = function() { +IdentifiedElement.prototype.getLineWeight = function () { return this._visualizationdata._lineWeight; }; -IdentifiedElement.prototype.setLineWeight = function(lineWeight) { +IdentifiedElement.prototype.setLineWeight = function (lineWeight) { this._visualizationdata._lineWeight = lineWeight; }; -IdentifiedElement.prototype.getLineOpacity = function() { +IdentifiedElement.prototype.getLineOpacity = function () { return this._visualizationdata._lineOpacity; }; -IdentifiedElement.prototype.setLineOpacity = function(lineOpacity) { +IdentifiedElement.prototype.setLineOpacity = function (lineOpacity) { this._visualizationdata._lineOpacity = lineOpacity; }; -IdentifiedElement.prototype.getLineColor = function() { +IdentifiedElement.prototype.getLineColor = function () { return this._visualizationdata._lineColor; }; -IdentifiedElement.prototype.setLineColor = function(lineColor) { +IdentifiedElement.prototype.setLineColor = function (lineColor) { this._visualizationdata._lineColor = lineColor; }; -IdentifiedElement.prototype.getOnClickHandler = function() { +IdentifiedElement.prototype.getOnClickHandler = function () { return this._visualizationdata._onClickHandler; }; -IdentifiedElement.prototype.setOnClickHandler = function(onClickHandler) { +IdentifiedElement.prototype.setOnClickHandler = function (onClickHandler) { this._visualizationdata._onClickHandler = onClickHandler; }; -IdentifiedElement.prototype.equals = function(argument) { +IdentifiedElement.prototype.equals = function (argument) { if (argument instanceof IdentifiedElement) { return (this.getType() === argument.getType() && // - this.getId() === argument.getId() && // - this.getModelId() === argument.getModelId()); + this.getId() === argument.getId() && // + this.getModelId() === argument.getModelId()); } else { return false; } }; -IdentifiedElement.prototype.toString = function() { +IdentifiedElement.prototype.toString = function () { var self = this; return "[" + IdentifiedElement.prototype.constructor.name + "] " + self.getType() + " " + self.getId() + " (model: " - + self.getModelId() + ")"; + + self.getModelId() + ")"; }; module.exports = IdentifiedElement; diff --git a/frontend-js/src/main/js/map/data/MapModel.js b/frontend-js/src/main/js/map/data/MapModel.js index da7ef90962065c696b5b547f610579736a1ff55c..fe059bcad1102b1473ec065ed0961fdd9d406226 100644 --- a/frontend-js/src/main/js/map/data/MapModel.js +++ b/frontend-js/src/main/js/map/data/MapModel.js @@ -687,6 +687,14 @@ MapModel.prototype.isAvailable = function(ie, complete) { element = this._aliases[ie.getId()]; } else if (ie.getType() === "REACTION") { element = this._reactions[ie.getId()]; + } else if (ie.getType() === "POINT") { + var id = this._pointToId(ie.getId()); + var result = this._pointsData[id]; + if (result === undefined) { + result = new PointData(ie); + this._pointsData[id] = result; + } + element = this._pointsData[id]; } else { throw new Error("Unknown type: " + ie.getType(), complete); } diff --git a/frontend-js/src/test/js/helper.js b/frontend-js/src/test/js/helper.js index 97165ac923f42ebeee442c566f97276c0cb7503f..947e0cd77818364a27696614efef19a550a9d28b 100644 --- a/frontend-js/src/test/js/helper.js +++ b/frontend-js/src/test/js/helper.js @@ -34,6 +34,7 @@ function Helper(configuration) { } this.setConfiguration(configuration); this.idCounter = 1000000; + this.EPSILON = Helper.EPSILON; } Helper.prototype.setConfiguration = function (configuration) { diff --git a/frontend-js/src/test/js/minerva-test.js b/frontend-js/src/test/js/minerva-test.js index 6d989ae49367d46f79e121cd6197df6d322d0d2f..b09a1fa0edf2cb3a669be8f3b45b95f2af6746be 100644 --- a/frontend-js/src/test/js/minerva-test.js +++ b/frontend-js/src/test/js/minerva-test.js @@ -1,7 +1,5 @@ "use strict"; -var Helper = require('./helper'); - require("./mocha-config.js"); var Alias = require('../../main/js/map/data/Alias'); @@ -417,8 +415,8 @@ describe('minerva global', function() { var sessionData = ServerConnectorMock.getSessionData(globalResult.getProject()); var center = sessionData.getCenter(globalResult.getProject().getModel()); assert.ok(center instanceof google.maps.Point); - assert.closeTo(parseFloat(center.x), 10, Helper.EPSILON); - assert.closeTo(parseFloat(center.y), 20, Helper.EPSILON); + assert.closeTo(parseFloat(center.x), 10, helper.EPSILON); + assert.closeTo(parseFloat(center.y), 20, helper.EPSILON); }).then(function() { globalResult.destroy(); });