diff --git a/src/Common/Controls/DrawingDOM.js b/src/Common/Controls/DrawingDOM.js index 4c9d4d5af..9b508ae5b 100644 --- a/src/Common/Controls/DrawingDOM.js +++ b/src/Common/Controls/DrawingDOM.js @@ -1,3 +1,7 @@ +import Logger from "../../Common/Utils/LoggerByDefault"; + +var logger = Logger.getLogger("DrawingDOM"); + var DrawingDOM = { /** @@ -255,7 +259,7 @@ var DrawingDOM = { var ul = document.createElement("ul"); ul.className = "drawing-tools-flex-display"; var context = this; - /** li click handler function */ + // li click handler function function liClickHandler (e) { /* jshint validthis: true */ // this == elem clicked @@ -318,10 +322,10 @@ var DrawingDOM = { * @returns {Object} hex and opacity formated values */ rgbaToHex : function (rgba) { - /** number to hex conversion */ + // number to hex conversion function hex (number) { if (number > 255) { - throw "'" + number + "'' is greater than 255(0xff);"; + throw new Error("'" + number + "'' is greater than 255(0xff);"); } var str = Number(number).toString(16); return ("0" + str).slice(-2); @@ -329,7 +333,7 @@ var DrawingDOM = { var regex = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(0?.?\d+)\s*)?\)/; var parsed = regex.exec(rgba); if (!parsed) { - throw "Invalid format: " + rgba; + throw new Error("Invalid format: " + rgba); } var red = parsed[1]; var green = parsed[2]; @@ -356,7 +360,7 @@ var DrawingDOM = { // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; if (!hex) { - throw "Invalid format"; + throw new Error("Invalid format"); } hex = hex.replace(shorthandRegex, function (m, r, g, b) { return r + r + g + g + b + b; @@ -560,7 +564,7 @@ var DrawingDOM = { ul.appendChild(li); break; default: - console.log("Unhandled geometry type for styling."); + logger.log("Unhandled geometry type for styling."); } div.appendChild(ul); // apply button @@ -632,11 +636,11 @@ var DrawingDOM = { inputLabel.placeholder = options.placeholder; inputLabel.id = options.inputId; popup.appendChild(inputLabel); - /** blur */ + // blur inputLabel.onblur = function () { options.applyFunc.call(this, inputLabel.value, true); }; - /** keyup */ + // keyup inputLabel.onkeyup = function (evtk) { if (options.geomType === "Text" && evtk.keyCode === 13) { options.applyFunc.call(this, inputLabel.value, true); diff --git a/src/Common/Controls/LocationSelectorDOM.js b/src/Common/Controls/LocationSelectorDOM.js index 4a47f7169..ea03d8edb 100644 --- a/src/Common/Controls/LocationSelectorDOM.js +++ b/src/Common/Controls/LocationSelectorDOM.js @@ -1,4 +1,7 @@ import ID from "../Utils/SelectorID"; +import Logger from "../../Common/Utils/LoggerByDefault"; + +var logger = Logger.getLogger("LocationSelectorDOM"); var LocationSelectorDOM = { @@ -163,21 +166,21 @@ var LocationSelectorDOM = { switch (charCode) { case 38: // arrow up - console.log("arrow up"); + logger.log("arrow up"); current.className = "GPautoCompleteProposal"; prev.className = "GPautoCompleteProposal current"; prev.style.color = "#000000"; prev.style["background-color"] = "#CEDBEF"; break; case 40: // arrow down - console.log("arrow down"); + logger.log("arrow down"); current.className = "GPautoCompleteProposal"; next.className = "GPautoCompleteProposal current"; next.style.color = "#000000"; next.style["background-color"] = "#CEDBEF"; break; case 13: // enter - console.log("enter"); + logger.log("enter"); current.click(e); break; } diff --git a/src/Common/Controls/RouteDOM.js b/src/Common/Controls/RouteDOM.js index 9a7cb0053..f5c704d12 100644 --- a/src/Common/Controls/RouteDOM.js +++ b/src/Common/Controls/RouteDOM.js @@ -1,4 +1,7 @@ import ID from "../Utils/SelectorID"; +import Logger from "../../Common/Utils/LoggerByDefault"; + +var logger = Logger.getLogger("RouteDOM"); var RouteDOM = { @@ -156,7 +159,7 @@ var RouteDOM = { form.setAttribute("onkeypress", "return event.keyCode != 13;"); // FIXME hack pour desactiver l'execution via 'enter' au clavier ! form.addEventListener("submit", function (e) { - console.log(e); + logger.log(e); e.preventDefault(); // points @@ -168,10 +171,10 @@ var RouteDOM = { var startID = ID.index(start); var endID = ID.index(end); - if ((document.getElementById(self._addUID("GPlocationOrigin_" + startID)).value == "" && - document.getElementById(self._addUID("GPlocationOriginCoords_" + startID)).value == "") || - (document.getElementById(self._addUID("GPlocationOrigin_" + endID)).value == "" && - document.getElementById(self._addUID("GPlocationOriginCoords_" + endID)).value == "")) { + if ((document.getElementById(self._addUID("GPlocationOrigin_" + startID)).value === "" && + document.getElementById(self._addUID("GPlocationOriginCoords_" + startID)).value === "") || + (document.getElementById(self._addUID("GPlocationOrigin_" + endID)).value === "" && + document.getElementById(self._addUID("GPlocationOriginCoords_" + endID)).value === "")) { return false; } @@ -181,7 +184,7 @@ var RouteDOM = { for (var i = 0; i < points.length; i++) { var tag = points[i].childNodes[0].id; id = ID.index(tag); - if (document.getElementById(self._addUID("GPlocationPoint_" + id)).className == "GPflexInput GPlocationStageFlexInput") { + if (document.getElementById(self._addUID("GPlocationPoint_" + id)).className === "GPflexInput GPlocationStageFlexInput") { var resultStage = document.createElement("div"); resultStage.className = "GProuteResultsStages"; var resultStageLabel = document.createElement("div"); @@ -193,13 +196,13 @@ var RouteDOM = { var elementCoords = document.getElementById(self._addUID("GPlocationOriginCoords_" + id)); var stageCoords = elementCoords.value; var visible = (elementCoords.className === "GPlocationOriginVisible"); - if (stageCoords != null && stageCoords != "" && visible) { + if (stageCoords !== null && stageCoords !== "" && visible) { resultStageValue.innerHTML = stageCoords; } else { resultStageValue.innerHTML = document.getElementById(self._addUID("GPlocationOrigin_" + id)).value; } resultStage.appendChild(resultStageValue); - if (resultStageValue.innerHTML != "") { + if (resultStageValue.innerHTML !== "") { document.getElementById(self._addUID("GProuteResultsStages")).appendChild(resultStage); } } @@ -397,6 +400,9 @@ var RouteDOM = { * Add Results Duration and Distance * (results dynamically generate !) * see event! + * @param {Number} distance - distance + * @param {Number} duration - duration + * @param {Function} fconvert - fconvert * * @returns {DOMElement} DOM element */ @@ -481,6 +487,8 @@ var RouteDOM = { /** * Add Results Details * (results dynamically generate !) + * @param {Object[]} instructions - instructions + * @param {Function} fconvert - fconvert * * @returns {DOMElement} DOM element */ @@ -558,6 +566,9 @@ var RouteDOM = { * see event ! * OVERWRITTEN BY LOCATIONSELECTOR ! * (version initial without LOCATIONSELECTOR PLUGIN) + * @param {Integer} n - n + * @param {String} text - text + * @param {Boolean} visibility - visibility * * @returns {DOMElement} DOM element */ @@ -636,9 +647,9 @@ var RouteDOM = { var i = this.id.charAt(this.id.length - 1); var j; for (j = 1; j < 8; j++) { - if (i != j) { + if (i !== j) { document.getElementById("GProuteOriginPointer" + j).checked = false; - if (document.getElementById("GProuteOriginCoords" + j).value == "Pointer un lieu sur la carte") { + if (document.getElementById("GProuteOriginCoords" + j).value === "Pointer un lieu sur la carte") { document.getElementById("GProuteOriginCoords" + j).value = ""; document.getElementById("GProuteOrigin" + j).className = "GProuteOriginVisible"; document.getElementById("GProuteOriginCoords" + j).className = "GProuteOriginHidden"; @@ -657,7 +668,7 @@ var RouteDOM = { } else { document.getElementById("GProuteOriginCoords" + i).value = "Pointer un lieu sur la carte"; for (j = 1; j < 8; j++) { - if (i == j) { + if (i === j) { document.getElementById("GProutePoint" + j).style.display = "flex"; } else { document.getElementById("GProutePoint" + j).style.display = "none"; @@ -682,6 +693,7 @@ var RouteDOM = { * see event ! * OVERWRITTEN BY LOCATIONSELECTOR ! * (version initial without LOCATIONSELECTOR PLUGIN) + * @param {Integer} n - n * * @returns {DOMElement} DOM element */ @@ -693,7 +705,7 @@ var RouteDOM = { divRm.id = "GProuteStageRemove" + n; divRm.className = "GProuteStageRemove"; divRm.title = "Supprimer l'étape"; - if (n != 1 && n != 7) { + if (n !== 1 && n !== 7) { divRm.addEventListener("click", function (e) { var i = this.id.charAt(this.id.length - 1); document.getElementById("GProutePoint" + i).className = "GPflexInput GProuteStageFlexInputHidden"; @@ -732,8 +744,8 @@ var RouteDOM = { var lastStage = 1; var nbStages = 0; for (var i = 2; i < 7; i++) { - if (document.getElementById("GProutePoint" + i).className == "GPflexInput GProuteStageFlexInputHidden") { - if (lastStage == 1) { + if (document.getElementById("GProutePoint" + i).className === "GPflexInput GProuteStageFlexInputHidden") { + if (lastStage === 1) { lastStage = i; } } else { @@ -746,7 +758,7 @@ var RouteDOM = { var exclusionsPictoTop = document.getElementById("GPshowRouteExclusionsPicto").style.top; document.getElementById("GPshowRouteExclusionsPicto").style.top = (parseInt(exclusionsPictoTop, 10) + 33).toString() + "px"; } - if (nbStages == 4) { + if (nbStages === 4) { document.getElementById("GProuteStageAdd").style.display = "none"; } // gestionnaire d'evenement : @@ -762,6 +774,7 @@ var RouteDOM = { * see event! * OVERWRITTEN BY LOCATIONSELECTOR ! * (version initial without LOCATIONSELECTOR PLUGIN) + * @param {Integer} n - n * * @returns {DOMElement} DOM element */ @@ -836,6 +849,7 @@ var RouteDOM = { * Create Mode choice transport * see event ! * FIXME event not useful + * @param {String[]} transports - transports * * @returns {DOMElement} DOM element */ @@ -1038,6 +1052,7 @@ var RouteDOM = { * Create Exclusions Options * see event ! * FIXME event not useful + * @param {Object[]} exclusions - exclusions * * @returns {DOMElement} DOM element */ diff --git a/src/Common/Controls/SearchEngineDOM.js b/src/Common/Controls/SearchEngineDOM.js index bc626dabf..c9dfbb5b7 100644 --- a/src/Common/Controls/SearchEngineDOM.js +++ b/src/Common/Controls/SearchEngineDOM.js @@ -79,6 +79,7 @@ var SearchEngineDOM = { /** * Simple search input + * @param {String} placeholder - placeholder * * @returns {DOMElement} DOM element */ @@ -383,7 +384,9 @@ var SearchEngineDOM = { // ############### Geocoding with advanced container ################# // // ################################################################### // - /** ... */ + /** + * @returns {DOMElement} DOM element + */ _createAdvancedSearchPanelHeaderElement : function () { // contexte d'execution var self = this; @@ -424,7 +427,11 @@ var SearchEngineDOM = { return container; }, - /** ... */ + /** + * @param {Object[]} advancedSearchCodes - codes + * + * @returns {DOMElement} DOM element + */ _createAdvancedSearchPanelFormElement : function (advancedSearchCodes) { // contexte d'execution var self = this; @@ -479,7 +486,10 @@ var SearchEngineDOM = { return form; }, - /** ... */ + /** + * @param {Object[]} codes - codes + * @returns {DOMElement} DOM element + */ _createAdvancedSearchFormCodeElement : function (codes) { // contexte d'execution var self = this; @@ -522,7 +532,9 @@ var SearchEngineDOM = { return select; }, - /** ... */ + /** + * @returns {DOMElement} DOM element + */ _createAdvancedSearchFormInputElement : function () { var input = document.createElement("input"); input.type = "submit"; @@ -549,6 +561,9 @@ var SearchEngineDOM = { * "PositionOfInterest", "StreetAddress", ... * * @param {String} code - code of geocoding resource + * @param {Boolean} display - display + * + * @returns {DOMElement} DOM element */ _createAdvancedSearchFiltersTableElement : function (code, display) { var container = document.createElement("div"); @@ -571,6 +586,8 @@ var SearchEngineDOM = { * @param {String} filterAttributes.title - label * @param {String} filterAttributes.description - description * @param {String} filterAttributes.value - value + * + * @returns {DOMElement} DOM element */ _createAdvancedSearchFiltersAttributElement : function (filterAttributes) { // INFORMATION @@ -620,7 +637,9 @@ var SearchEngineDOM = { // ################## Geocoding results container #################### // // ################################################################### // - /** ... */ + /** + * @returns {DOMElement} DOM element + */ _createGeocodeResultsHeaderElement : function () { var self = this; diff --git a/src/Common/Utils/MathUtils.js b/src/Common/Utils/MathUtils.js index 199471d11..de92949ee 100644 --- a/src/Common/Utils/MathUtils.js +++ b/src/Common/Utils/MathUtils.js @@ -3,7 +3,7 @@ var MathUtils = { * Reste de la division euclidienne * @param {Number} a - divisor * @param {Number} b - quotient - * @returns {Number} + * @returns {Number} Modulo */ modulo : function (a, b) { var r = a % b; @@ -17,7 +17,7 @@ var MathUtils = { * @param {Number} degrees - decimal degrees * @param {Array} hemispheres - "NS" ou "EO" * @param {Number} numDigits - number of digits for seconds - * @returns {Object} + * @returns {Object} DMS coordinate */ decimalToDMS : function (degrees, hemispheres, numDigits) { var normalizedDegrees = this.modulo(degrees + 180, 360) - 180; @@ -54,7 +54,7 @@ var MathUtils = { * * @param {String} s - string number * @param {Numeric} base - between 2 and 36 - * @returns {null|Numeric} + * @returns {null|Numeric} result */ toInteger : function (s, base) { var _base = base || 10; @@ -69,7 +69,7 @@ var MathUtils = { * check if s represents an integer * * @param {String} s - string number - * @returns {Boolean} + * @returns {Boolean} is integer */ isInteger : function (s) { if (isNaN(s)) { @@ -84,7 +84,7 @@ var MathUtils = { * Converts s to float * * @param {String} s - string number - * @returns {null|Numeric} + * @returns {null|Numeric} result */ toFloat : function (s) { var n = parseFloat(s); diff --git a/src/Common/Utils/ProxyUtils.js b/src/Common/Utils/ProxyUtils.js index a4024110b..acf440a4e 100644 --- a/src/Common/Utils/ProxyUtils.js +++ b/src/Common/Utils/ProxyUtils.js @@ -8,6 +8,8 @@ var ProxyUtils = { * @param {Object} [proxyOptions] - Object defining proxy options. * @param {String} proxyOptions.proxyUrl - Proxy URL. * @param {Array.} [proxyOptions.noProxyDomains] - Proxy will not be used for this list of domain names. + * + * @returns {String} proxy url */ proxifyUrl : function (url, proxyOptions) { // logger @@ -17,7 +19,7 @@ var ProxyUtils = { if (!proxyOptions || !proxyOptions.hasOwnProperty("proxyUrl") || proxyOptions.proxyUrl === null || - proxyOptions.proxyUrl.trim().length == 0) { + proxyOptions.proxyUrl.trim().length === 0) { return url; } // on regarde si l'url nest pas dans les domaines sans proxy diff --git a/src/Common/Utils/Register.js b/src/Common/Utils/Register.js index ff9975f5a..26f122e3c 100644 --- a/src/Common/Utils/Register.js +++ b/src/Common/Utils/Register.js @@ -21,7 +21,7 @@ var Register = { * get the definition for a code * * @param {String} name - ie. EPSG:2154 (Lambert) - * @returns {Object} + * @returns {Object} definition */ get : function (name) { if (name === "" || name === null || typeof name === "undefined") { diff --git a/src/Common/Utils/SearchEngineUtils.js b/src/Common/Utils/SearchEngineUtils.js index 1dd11a23d..86402a719 100644 --- a/src/Common/Utils/SearchEngineUtils.js +++ b/src/Common/Utils/SearchEngineUtils.js @@ -89,7 +89,7 @@ var SearchEngineUtils = { * Provides default zoom based on results. * * @param {Object} info - location information - * @returns zoom level + * @returns {Integer} zoom level */ zoomToResultsByDefault : function (info) { // FIXME diff --git a/src/Leaflet/CRS/CRS.js b/src/Leaflet/CRS/CRS.js index e1455fa86..445398c5b 100644 --- a/src/Leaflet/CRS/CRS.js +++ b/src/Leaflet/CRS/CRS.js @@ -1,6 +1,3 @@ -import L from "leaflet"; -import proj4 from "proj4"; -import Proj4Leaflet from "proj4leaflet"; import Register from "../../Common/Utils/Register"; import Epsg2154 from "./EPSG2154"; import Epsg27572 from "./EPSG27572"; @@ -45,7 +42,7 @@ var CRS = { * @method EPSG2154 * @static * @alias L.geoportalCRS.EPSG2154 - * @returns {EPSG2154} + * @returns {EPSG2154} epsg code */ EPSG2154 : function () { return Epsg2154.build(); @@ -57,7 +54,7 @@ var CRS = { * @ignore * @method EPSG27572 * @alias L.geoportalCRS.EPSG27572 - * @returns {EPSG27572} + * @returns {EPSG27572} epsg code */ EPSG27572 : function () { return Epsg27572.build(); @@ -69,7 +66,7 @@ var CRS = { * @ignore * @method EPSG4326 * @alias L.geoportalCRS.EPSG4326 - * @returns {EPSG4326} + * @returns {EPSG4326} epsg code */ EPSG4326 : function () { return Epsg4326.build(); diff --git a/src/Leaflet/CRS/EPSG2154.js b/src/Leaflet/CRS/EPSG2154.js index 48e749080..412b45038 100644 --- a/src/Leaflet/CRS/EPSG2154.js +++ b/src/Leaflet/CRS/EPSG2154.js @@ -32,6 +32,7 @@ var EPSG2154 = { /** * execution * + * @returns {Object} instance * @private */ build : function () { @@ -52,6 +53,7 @@ var EPSG2154 = { /** * resolutions * + * @returns {Number[]} resolutions * @private */ _getResolutions : function () { @@ -96,6 +98,7 @@ var EPSG2154 = { /** * origine * + * @returns {Number[]} origin * @private */ _getOrigin : function () { diff --git a/src/Leaflet/CRS/EPSG27572.js b/src/Leaflet/CRS/EPSG27572.js index 95a7e7353..89c757b11 100644 --- a/src/Leaflet/CRS/EPSG27572.js +++ b/src/Leaflet/CRS/EPSG27572.js @@ -42,6 +42,7 @@ var EPSG27572 = { /** * execution * + * @returns {Object} instance * @private */ build : function () { @@ -62,6 +63,7 @@ var EPSG27572 = { /** * resolutions * + * @returns {Number[]} resolutions * @private */ _getResolutions : function () { @@ -108,6 +110,7 @@ var EPSG27572 = { /** * origine * + * @returns {Number[]} origin * @private */ _getOrigin : function () { diff --git a/src/Leaflet/CRS/EPSG4326.js b/src/Leaflet/CRS/EPSG4326.js index aefca8e21..8b740471b 100644 --- a/src/Leaflet/CRS/EPSG4326.js +++ b/src/Leaflet/CRS/EPSG4326.js @@ -50,6 +50,7 @@ var EPSG4326 = { /** * execution * + * @returns {Object} instance * @private */ build : function () { @@ -70,6 +71,7 @@ var EPSG4326 = { /** * resolutions * + * @returns {Number[]} resolutions * @private */ _getResolutions : function () { diff --git a/src/Leaflet/Controls/ElevationPath.js b/src/Leaflet/Controls/ElevationPath.js index 258e1275c..26be08a2b 100644 --- a/src/Leaflet/Controls/ElevationPath.js +++ b/src/Leaflet/Controls/ElevationPath.js @@ -1,11 +1,9 @@ /* globals AmCharts, d3 */ import Gp from "gp"; import L from "leaflet"; -import Draw from "leaflet-draw"; import Logger from "../../Common/Utils/LoggerByDefault"; import RightManagement from "../../Common/Utils/CheckRightManagement"; import ID from "../../Common/Utils/SelectorID"; -import LocationSelector from "./LocationSelector"; import PositionFormater from "./Utils/PositionFormater"; import IconDefault from "./Utils/IconDefault"; import ElevationPathDOM from "../../Common/Controls/ElevationPathDOM"; @@ -138,6 +136,9 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath * and fills variable 'this._container = this.onAdd(map)', * and create or disable events on map. * + * @param {Object} map - the map + * + * @returns {DOMElement} DOM element * @private */ onAdd : function (map) { @@ -252,6 +253,7 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath * this method is called by this.onAdd(map) * and initialize the container HTMLElement * + * @returns {DOMElement} DOM element * @private */ _initLayout : function () { @@ -548,6 +550,7 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath /** * set current position of feature * + * @param {Object} layer - layer * @private */ _getFeatureGeometry : function (layer) { @@ -583,6 +586,7 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath /** * set current layer of feature * + * @param {Object} layer - layer * @private */ _addFeatureLayer : function (layer) { @@ -595,6 +599,7 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath /** * remove layer feature from group * + * @param {Integer} id - id * @private */ _removeFeatureLayer : function (id) { @@ -673,7 +678,7 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath /** sampling à 200 (iso portail) */ sampling : _sampling, - /** callback onSuccess */ + // callback onSuccess onSuccess : this.options.elevationPathOptions.onSuccess || function (result) { logger.log(result); if (result) { @@ -687,7 +692,7 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath } }, - /** callback onFailure */ + // callback onFailure onFailure : this.options.elevationPathOptions.onFailure || function (error) { logger.log(error.message); self._pictoContainer.style.display = "block"; @@ -725,7 +730,7 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath * @private */ _computeElevationMeasure : function (elevations) { - /** Returns the distance from c1 to c2 using the haversine formula */ + // Returns the distance from c1 to c2 using the haversine formula var _haversineDistance = function (c1, c2) { var lat1 = PositionFormater.decimalToRadian(c1[1]); var lat2 = PositionFormater.decimalToRadian(c2[1]); @@ -943,6 +948,9 @@ var ElevationPath = L.Control.extend(/** @lends L.geoportalControl.ElevationPath /** * create Profile Marker + * + * @param {Object} context - context + * @param {Object} data - data */ ElevationPath.__createProfileMarker = function (context, data) { logger.log("__createProfileMarker"); @@ -968,6 +976,9 @@ ElevationPath.__createProfileMarker = function (context, data) { /** * update Profile Marker + * + * @param {Object} context - context + * @param {Object} data - data */ ElevationPath.__updateProfileMarker = function (context, data) { logger.log("__updateProfileMarker"); @@ -998,6 +1009,8 @@ ElevationPath.__updateProfileMarker = function (context, data) { /** * remove Profile Marker + * + * @param {Object} context - context */ ElevationPath.__removeProfileMarker = function (context) { logger.log("__removeProfileMarker"); @@ -1022,6 +1035,9 @@ ElevationPath.__customRawProfileOperation = function () { /** * custom operation into raw profil... * TODO + * + * @param {Object} context - context + * @param {Object} e - event */ ElevationPath.__customRawProfileMouseOverEvent = function (context, e) { logger.log("__customRawProfileMouseOverEvent", context, e); @@ -1075,7 +1091,7 @@ ElevationPath.DISPLAY_PROFILE_LIB_D3 = function (data, container, context) { logger.trace("ElevationPath.DISPLAY_PROFILE_LIB_D3"); if (typeof d3 === "undefined") { - console.log("Lib. D3 is not loaded !"); + logger.log("Lib. D3 is not loaded !"); return; } @@ -1099,7 +1115,7 @@ ElevationPath.DISPLAY_PROFILE_LIB_AMCHARTS = function (data, container, context) // Calcul du profile if (typeof AmCharts === "undefined") { - console.log("Lib. AmCharts is not loaded !"); + logger.log("Lib. AmCharts is not loaded !"); return; } diff --git a/src/Leaflet/Controls/Isocurve.js b/src/Leaflet/Controls/Isocurve.js index d953369dd..e31a27c8e 100644 --- a/src/Leaflet/Controls/Isocurve.js +++ b/src/Leaflet/Controls/Isocurve.js @@ -820,7 +820,7 @@ var Isocurve = L.Control.extend(/** @lends L.geoportalControl.Isocurve.prototype timeout : 7000, protocol : "XHR", - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { @@ -828,7 +828,7 @@ var Isocurve = L.Control.extend(/** @lends L.geoportalControl.Isocurve.prototype } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME mise à jour du controle mais le service ne repond pas en 200 !? self._hideWaitingContainer(); @@ -894,7 +894,7 @@ var Isocurve = L.Control.extend(/** @lends L.geoportalControl.Isocurve.prototype } // on fait quoi ? if (!bFound) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } diff --git a/src/Leaflet/Controls/LayerSwitcher.js b/src/Leaflet/Controls/LayerSwitcher.js index 01dcfb67a..38401171c 100644 --- a/src/Leaflet/Controls/LayerSwitcher.js +++ b/src/Leaflet/Controls/LayerSwitcher.js @@ -321,6 +321,10 @@ var LayerSwitcher = L.Control.Layers.extend(/** @lends L.geoportalControl.LayerS /** * Method 'addTo' * (overwritten : L.Control.Layers because of exception with _expandIfNotCollapsed()) + * + * @param {Object} map - the map + * + * @returns {Object} this */ addTo : function (map) { L.Control.prototype.addTo.call(this, map); @@ -779,12 +783,12 @@ var LayerSwitcher = L.Control.Layers.extend(/** @lends L.geoportalControl.LayerS var cfg = this._layersConfig; if (!layer) { - console.log("[ERROR] LayerSwitcher:addLayer - missing layer parameter !"); + logger.log("[ERROR] LayerSwitcher:addLayer - missing layer parameter !"); return; } if (!map.hasLayer(layer)) { - console.log("[WARN] LayerSwitcher:addLayer - layer has not been added on map !"); + logger.log("[WARN] LayerSwitcher:addLayer - layer has not been added on map !"); map.addLayer(layer); } diff --git a/src/Leaflet/Controls/LocationSelector.js b/src/Leaflet/Controls/LocationSelector.js index 9f89cbb50..3d13b386a 100644 --- a/src/Leaflet/Controls/LocationSelector.js +++ b/src/Leaflet/Controls/LocationSelector.js @@ -146,6 +146,7 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ * this method is called by this.addTo(map) * and fills variable : this._container = this.onAdd(map) * + * @returns {DOMElement} DOM element * @private */ onAdd : function (/* map */) { @@ -176,22 +177,15 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ // ########################## publics methods ######################## // // ################################################################### // - /** - * get coordinate - */ + // get coordinate getCoordinate : function () { return this._coordinate; }, - - /** - * set coordinate : {lon,lat || x,y || N,E} - */ + // set coordinate : {lon,lat || x,y || N,E} setCoordinate : function (coordinate) { this._displayResultOfCoordinate(coordinate); }, - /** - * get coordinate inverse (EPSG:4326) - */ + // get coordinate inverse (EPSG:4326) getCoordinateInverse : function () { if (!this._coordinate) { return; @@ -207,6 +201,8 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ /** * set map + * + * @param {Object} map - the map */ setMap : function (map) { if (!this._map) { @@ -247,6 +243,8 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ * this method is called by this.onAdd(map) * and initialize the container HTMLElement * + * @returns {DOMElement} DOM element + * * @private */ _initLayout : function () { @@ -389,13 +387,8 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ var lng = null; // decimal by default ! - if (false) { - lat = PositionFormater.decimalLatToDMS(oLatLng.lat); - lng = PositionFormater.decimalLongToDMS(oLatLng.lng); - } else { - lat = PositionFormater.roundToDecimal(oLatLng.lat, 4); - lng = PositionFormater.roundToDecimal(oLatLng.lng, 4); - } + lat = PositionFormater.roundToDecimal(oLatLng.lat, 4); + lng = PositionFormater.roundToDecimal(oLatLng.lng, 4); // on envoie du lon/lat à l'affichage var value = lng + " , " + lat; @@ -586,13 +579,13 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ // on ne fait pas de requête si aucun droit ! if (this._noRightManagement) { - console.log("no rights for all service !?"); + logger.log("no rights for all service !?"); return; } // gestion des droits ! if (!this._resources["AutoCompletion"]) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -627,6 +620,8 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ * it creates a HTML Element per location * (cf. this. ...) * + * @param {Object[]} locations - locations + * * @private */ _fillAutoCompletedLocationListContainer : function (locations) { @@ -683,13 +678,13 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ // on ne fait pas de requête si aucun droit ! if (this._noRightManagement) { - console.log("no rights for all service !?"); + logger.log("no rights for all service !?"); return; } // gestion des droits ! if (!this._resources["ReverseGeocode"]) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -821,7 +816,7 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ // aucun droits ! // on evite une requête... if (this._noRightManagement) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -838,12 +833,11 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ // on met en place des callbacks afin de recuperer les resultats ou // les messages d'erreurs du service. // les resultats sont affichés dans une liste deroulante. - // les messages d'erreurs sont affichés sur la console (?) var context = this; this._requestAutoComplete({ text : value, maximumResponses : 5, // FIXME je limite le nombre de reponse car le container DOM est limité dans l'affichage !!! - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { @@ -851,7 +845,7 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ context._fillAutoCompletedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME // où affiche t on les messages : ex. 'No suggestion matching the search' ? @@ -1018,7 +1012,7 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ y : oLatLng.lng // on envoie Y->LON à l'API service IGN car on spécifie EPSG:4326 }, srs : "EPSG:4326", - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results.locations.length !== 0) { @@ -1028,7 +1022,7 @@ var LocationSelector = L.Control.extend(/** @lends LocationSelector.prototype */ self._displayResultOfCoordinate(oLatLng); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { logger.log(error.message); self._displayResultOfCoordinate(oLatLng); diff --git a/src/Leaflet/Controls/Logo.js b/src/Leaflet/Controls/Logo.js index bd9f15371..2f8c80e28 100644 --- a/src/Leaflet/Controls/Logo.js +++ b/src/Leaflet/Controls/Logo.js @@ -43,6 +43,7 @@ var Logo = L.Control.extend(/** @lends Logo.prototype */ { /** * constructor * + * @param {Object} options - options * @private */ initialize : function (options) { @@ -52,10 +53,12 @@ var Logo = L.Control.extend(/** @lends Logo.prototype */ { /** * event * + * @returns {DOMElement} DOM element * @private */ onAdd : function (/* map */) { - var container = L.DomUtil.create("div", "gp-control-logo", container); + var container = null; + container = L.DomUtil.create("div", "gp-control-logo", container); var bLink = !!((this.options.url || this.options.text)); var link = null; @@ -65,7 +68,7 @@ var Logo = L.Control.extend(/** @lends Logo.prototype */ { link.target = "_blank"; if (this.options.url) { link.href = this.options.url; - (this.options.text) ? link.title = this.options.text : null; + if (this.options.text) link.title = this.options.text; } } diff --git a/src/Leaflet/Controls/MousePosition.js b/src/Leaflet/Controls/MousePosition.js index bda30bda9..1347504de 100644 --- a/src/Leaflet/Controls/MousePosition.js +++ b/src/Leaflet/Controls/MousePosition.js @@ -192,7 +192,9 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition * this method is called by this.addTo(map) when the control is added on the map * and fills variable 'this._container = this.onAdd(map)', * and create events on map. + * @param {Object} map - the map * + * @returns {DOMElement} DOM element * @private */ onAdd : function (map) { @@ -227,6 +229,7 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition /** * this method is called when the control is removed from the map * and removes events on map. + * @param {Object} map - the map * * @private */ @@ -427,6 +430,7 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition * this information is useful to switch to touch mode. * Detection : test for desktop or tactile * + * @returns {Boolean} is desktop * @private */ _detectSupport : function () { @@ -466,6 +470,7 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition * this method is called by this.onAdd(map) * and initialize the container HTMLElement * + * @returns {DOMElement} DOM element * @private */ _initLayout : function () { @@ -613,7 +618,9 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition /** * degreedecimal + * @param {Object} oLatLng - coordinates * + * @returns {Object} coordinates in decimal * @private */ _displayDEC : function (oLatLng) { @@ -626,7 +633,9 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition /** * degreedecimal2sexagecimal + * @param {Object} oLatLng - coordinates * + * @returns {Object} coordinates in DMS * @private */ _displayDMS : function (oLatLng) { @@ -638,7 +647,9 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition /** * degreedecimal2radian + * @param {Object} oLatLng - coordinates * + * @returns {Object} coordinates in radian * @private */ _displayRAD : function (oLatLng) { @@ -651,7 +662,9 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition /** * degreedecimal2grade + * @param {Object} oLatLng - coordinates * + * @returns {Object} coordinates in gon * @private */ _displayGON : function (oLatLng) { @@ -664,7 +677,9 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition /** * meter + * @param {Object} oXY - coordinates * + * @returns {Object} coordinates in meters * @private */ _displayMeter : function (oXY) { @@ -678,7 +693,9 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition /** * kilometer + * @param {Object} oXY - coordinates * + * @returns {Object} coordinates in km * @private */ _displayKMeter : function (oXY) { @@ -944,6 +961,7 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition * it executes a request to the elevation service. * * @param {Object} coordinate - {lat:..., lng:...} + * @param {Function} callback - callback * * @private */ @@ -990,7 +1008,7 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition // et les callbacks L.Util.extend(options, { scope : this, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results && Object.keys(results)) { @@ -999,7 +1017,7 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition callback.call(this, results.elevations[0].z); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { logger.error(error.message); } @@ -1091,7 +1109,8 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition * Convert Coordinate value : km to meters, radians, grades to decimal degrees * @param {Number} value - value to convert * @param {String} unit - unit - * @returns {Number} + * + * @returns {Number} converted value * @private */ _convertCoordinate : function (value, unit) { @@ -1119,7 +1138,7 @@ var MousePosition = L.Control.extend(/** @lends L.geoportalControl.MousePosition * @param {String} coordType - Lat or Lon * @param {String} value - coordinate * @param {Event} e - event - * @returns {Boolean} + * @returns {Boolean} value is within extent */ validateExtentCoordinate : function (coordType, value, e) { // FIXME pas de validation... diff --git a/src/Leaflet/Controls/ReverseGeocoding.js b/src/Leaflet/Controls/ReverseGeocoding.js index 1e53e14ad..e827da8a6 100644 --- a/src/Leaflet/Controls/ReverseGeocoding.js +++ b/src/Leaflet/Controls/ReverseGeocoding.js @@ -1,6 +1,5 @@ import Gp from "gp"; import L from "leaflet"; -import Draw from "leaflet-draw"; import Logger from "../../Common/Utils/LoggerByDefault"; import RightManagement from "../../Common/Utils/CheckRightManagement"; import ID from "../../Common/Utils/SelectorID"; @@ -141,6 +140,10 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo * and fills variable 'this._container = this.onAdd(map)', * and create events on map. * + * @param {Object} map - the map + * + * @returns {DOMElement} DOM element + * * @private */ onAdd : function (map) { @@ -167,6 +170,8 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo * this method is called when the control is removed from the map * and removes events on map. * + * @param {Object} map - the map + * * @private */ onRemove : function (map) { @@ -247,7 +252,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo var resources = this.options.resources; // on vérifie que la liste des ressources de geocodage est bien un tableau if (!Array.isArray(resources)) { - console.log("[ReverseGeocoding] 'options.resources' parameter should be an array"); + logger.log("[ReverseGeocoding] 'options.resources' parameter should be an array"); resources = null; } var resourcesList = ["StreetAddress", "PositionOfInterest", "CadastralParcel", "Administratif"]; @@ -255,7 +260,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo if (resourcesList.indexOf(resources[i]) === -1) { // si la resource n'est pas référencée, on l'enlève // resources.splice(i, 1); - console.log("[ReverseGeocoding] options.resources : " + resources[i] + " is not a resource for reverse geocode"); + logger.log("[ReverseGeocoding] options.resources : " + resources[i] + " is not a resource for reverse geocode"); } } } @@ -264,7 +269,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo var delimitations = this.options.delimitations; // on vérifie que la liste des delimitations est bien un tableau if (!Array.isArray(delimitations)) { - console.log("[ReverseGeocoding] 'options.delimitations' parameter should be an array"); + logger.log("[ReverseGeocoding] 'options.delimitations' parameter should be an array"); delimitations = null; } var delimitationsList = ["Circle", "Point", "Extent"]; @@ -272,7 +277,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo if (delimitationsList.indexOf(delimitations[i]) === -1) { // si la delimitations n'est pas référencée, on l'enlève // resources.splice(i, 1); - console.log("[ReverseGeocoding] options.delimitations : " + delimitations[i] + " is not a delimitation for reverse geocode"); + logger.log("[ReverseGeocoding] options.delimitations : " + delimitations[i] + " is not a delimitation for reverse geocode"); } } } @@ -302,7 +307,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo if (this._servicesRightManagement["Geocode"].indexOf(resources[i]) < 0) { // si on n'a pas les droits sur la ressource, on va la supprimer : on stocke son index noRightsIndexes.push(i); - console.log("[ReverseGeocode] no rights for options.resources : " + resources[i]); + logger.log("[ReverseGeocode] no rights for options.resources : " + resources[i]); } } // on retire les ressoures non autorisées qu'on a pu rencontrer @@ -358,6 +363,8 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo * this method is called by this.onAdd(map) * and initialize the container HTMLElement * + * @returns {DOMElement} DOM element + * * @private */ _initLayout : function () { @@ -593,6 +600,9 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo /** * set current position of feature * + * @param {Object} layer - layer + * @param {String} type - type + * * @private */ _setFeaturePosition : function (layer, type) { @@ -643,6 +653,8 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo /** * set current layer of feature * + * @param {Object} layer - layer + * * @private */ _setFeatureLayer : function (layer) { @@ -654,6 +666,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo /** * remove layer feature from group + * @param {Integer} id - id * * @private */ @@ -680,6 +693,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo /** * this methode is called by this.onReverseGeocodingSubmit method, * it generates and sends reverse geocode request, then displays results + * @param {Object} settings - settings * * @private */ @@ -886,7 +900,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo var map = this._map; var self = this; - /** function set style Highlight for results */ + // function set style Highlight for results function _setHighLight (e) { var layer = e.target; @@ -897,7 +911,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo div.scrollIntoView(false); } - /** function reset style Highlight for results */ + // function reset style Highlight for results function _resetHighLight (e) { var layer = e.target; @@ -1080,7 +1094,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo filterOptions : { type : [self._currentGeocodingType] }, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { @@ -1089,7 +1103,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo self._hideWaitingContainer(); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { self._hideWaitingContainer(); @@ -1195,6 +1209,7 @@ var ReverseGeocoding = L.Control.extend(/** @lends L.geoportalControl.ReverseGeo /** * TODO this method clears previous location results marker + * @param {Object} map - the map * * @private */ diff --git a/src/Leaflet/Controls/Route.js b/src/Leaflet/Controls/Route.js index c118b0a37..0a2f2564a 100644 --- a/src/Leaflet/Controls/Route.js +++ b/src/Leaflet/Controls/Route.js @@ -146,6 +146,10 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * and fills variable 'this._container = this.onAdd(map)', * and create or disable events on map. * + * @param {Object} map - the map + * + * @returns {DOMElement} DOM element + * * @private */ onAdd : function (map) { @@ -329,6 +333,8 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * this information is useful to switch to touch mode. * Detection : test for desktop or tactile * + * @returns {Boolean} is desktop + * * @private */ _detectSupport : function () { @@ -368,6 +374,10 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * this method is called by this.onAdd(map) * and initialize the container HTMLElement * + * @param {Object} map - the map + * + * @returns {DOMElement} DOM element + * * @private */ _initLayout : function (map) { @@ -440,6 +450,8 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * Create List Points * FIXME OVERWRITTEN RouteDOM._createRoutePanelFormPointsElement() ! * + * @param {Object} map - the map + * * @returns {Array} List DOM element * * @private @@ -734,14 +746,14 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { exclusions : this._currentExclusions, geometryInInstructions : true, // surcharge obligatoire ! distanceUnit : "m", // surcharge obligatoire ! - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { context._fillRouteResultsDetails(results); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME mise à jour du controle mais le service ne repond pas en 200 !? context._hideWaitingContainer(); @@ -934,13 +946,13 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { // on ne fait pas de requête si aucun droit ! if (this._noRightManagement) { - console.log("no rights for all service !?"); + logger.log("no rights for all service !?"); return; } // gestion des droits ! if (!this._resources["Itineraire"]) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -968,7 +980,7 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { // on fait quoi ? if (!bFound) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -988,6 +1000,8 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * and fills the container of the route instructions list, distance and time * information, aslo, constructs the geometry route. * + * @param {Object} results - results of the route calculation + * * @private */ _fillRouteResultsDetails : function (results) { @@ -1043,6 +1057,10 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * and fills the container of the route instructions list, distance and time * information. * + * @param {Number} distance - distance + * @param {Number} duration - duration + * @param {Object[]} instructions - list of instructions + * * @private */ _fillRouteResultsDetailsContainer : function (distance, duration, instructions) { @@ -1059,6 +1077,8 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * this method is called by this._fillRouteResultsDetails() * and constructs the simplified geometry route. * + * @param {Object} geometry - geometry + * * @private */ _fillRouteResultsDetailsGeometry : function (geometry) { @@ -1083,6 +1103,8 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { * this method is called by this._fillRouteResultsDetails() * and constructs the geometries street with informations. * + * @param {Object[]} instructions - instructions + * * @private */ _fillRouteResultsDetailsFeatureGeometry : function (instructions) { @@ -1119,7 +1141,7 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { } var self = this; - /** ... */ + function resetHighlight (e) { var layer = e.target; self._geojsonSections.resetStyle(layer); @@ -1127,7 +1149,6 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { L.DomUtil.removeClass(div, "GProuteResultsDetailsHighlight"); } - /** ... */ function highlightFeature (e) { var layer = e.target; logger.log(layer); @@ -1142,7 +1163,7 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { this._geojsonSections = L.geoJson(_geometry, { style : _style, - /** Function that will be called on each created feature layer. */ + // Function that will be called on each created feature layer. onEachFeature : function (feature, layer) { layer.on({ mouseover : highlightFeature, @@ -1290,7 +1311,11 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { // ################################################################### // /** - * simplified instructions + * simplifies instructions + * + * @param {Object[]} instructions - instructions + * + * @returns {Object[]} simplified instructions * * @private */ @@ -1337,6 +1362,10 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { /** * convert seconds to time : HH:MM:SS * + * @param {Number} duration - duration in seconds + * + * @returns {String} duration in HH:MM:SS + * * @private */ _convertSecondsToTime : function (duration) { @@ -1367,6 +1396,10 @@ var Route = L.Control.extend(/** @lends L.geoportalControl.Route.prototype */ { /** * convert distance in meters or kilometers * + * @param {Number} distance - distance in meters + * + * @returns {String} distance in km + * * @private */ _convertDistance : function (distance) { diff --git a/src/Leaflet/Controls/SearchEngine.js b/src/Leaflet/Controls/SearchEngine.js index 71ef5e016..17cadaa44 100644 --- a/src/Leaflet/Controls/SearchEngine.js +++ b/src/Leaflet/Controls/SearchEngine.js @@ -171,6 +171,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p * this method is called by this.addTo(map) * and fills variable : this._container = this.onAdd(map) * + * @returns {DOMElement} DOM element * @private */ onAdd : function (/* map */) { @@ -195,6 +196,8 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p * this method is called when the control is removed from the map * and removes events on map. * + * @param {Object} map - the map + * * @private */ onRemove : function (map) { @@ -333,6 +336,8 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p * this method is called by this.onAdd(map) * and initialize the container HTMLElement * + * @returns {DOMElement} DOM element + * * @private */ _initLayout : function () { @@ -650,6 +655,8 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p * * @param {String} code - resource geocoding name * + * @returns {DOMElement} DOM element + * * @private */ _setFilter : function (code) { @@ -739,13 +746,13 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p // on ne fait pas de requête si aucun droit ! if (this._noRightManagement) { - console.log("no rights for all service !?"); + logger.log("no rights for all service !?"); return; } // gestion des droits ! if (!this._servicesRightManagement["AutoCompletion"]) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -837,13 +844,13 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p // on ne fait pas de requête si aucun droit ! if (this._noRightManagement) { - console.log("no rights for all service !?"); + logger.log("no rights for all service !?"); return; } // gestion des droits ! if (!this._servicesRightManagement["Geocode"]) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -892,6 +899,8 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p * it creates a HTML Element per location * (cf. this. ...) * + * @param {Object[]} locations - locations + * * @private */ _fillGeocodedLocationListContainer : function (locations) { @@ -934,7 +943,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p var context = this; this._requestGeocoding({ location : _location, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (response) { logger.log("request from Geocoding (coordinates null)", response); if (response.locations && response.locations.length !== 0 && response.locations[0].position) { @@ -998,7 +1007,9 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p * this method is called by this.on*ResultsItemClick() * and get zoom. * - * @param {Object} info - {} + * @param {Object} info - info + * + * @returns {Integer} zoom level * * @private */ @@ -1099,7 +1110,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p _icon = marker; } else { _icon = new IconDefault("blue"); - console.log("Utilisation du marker par défaut !"); + logger.log("Utilisation du marker par défaut !"); } // cf. http://leafletjs.com/reference.html#marker-options @@ -1285,7 +1296,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p var context = this; this._requestAutoComplete({ text : value, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log("request from AutoComplete", results); if (results) { @@ -1319,7 +1330,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p } } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME // où affiche t on les messages : ex. 'No suggestion matching the search' ? @@ -1338,7 +1349,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p context._requestGeocoding({ location : value, returnFreeForm : true, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log("request from Geocoding", results); if (results) { @@ -1358,7 +1369,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p context._fillAutoCompletedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { logger.log(error.message); } @@ -1447,7 +1458,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p var context = this; this._requestGeocoding({ location : value, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log("request from Geocoding", results); if (results) { @@ -1455,7 +1466,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p context._fillGeocodedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME cf. this.onAutoCompleteSearch() context._clearGeocodedLocation(); @@ -1614,7 +1625,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p this._requestGeocoding({ location : _location, filterOptions : _filterOptions, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { @@ -1622,7 +1633,7 @@ var SearchEngine = L.Control.extend(/** @lends L.geoportalControl.SearchEngine.p context._fillGeocodedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME cf. this.onAutoCompleteSearch() context._clearGeocodedLocation(); diff --git a/src/Leaflet/Controls/Utils/IconDefault.js b/src/Leaflet/Controls/Utils/IconDefault.js index bf3ae49d7..c74d9a602 100644 --- a/src/Leaflet/Controls/Utils/IconDefault.js +++ b/src/Leaflet/Controls/Utils/IconDefault.js @@ -51,6 +51,10 @@ var IconDefault = L.Icon.Default.extend(/** @lends IconDefault.prototype */ { * Overload function to ensure compatibility between versions 0.7.X and 1.0.X * (extend to L.Icon._getIconUrl) * + * @param {String} name - name + * + * @returns {String} url + * */ _getIconUrl : function (name) { logger.trace("OVERWRITTEN L.Icon.Default._getIconUrl(" + name + ")"); diff --git a/src/Leaflet/Controls/Utils/PositionFormater.js b/src/Leaflet/Controls/Utils/PositionFormater.js index 4c193c655..c6c002269 100644 --- a/src/Leaflet/Controls/Utils/PositionFormater.js +++ b/src/Leaflet/Controls/Utils/PositionFormater.js @@ -31,25 +31,44 @@ var PositionFormater = { /** ... */ digitRadian : 8, - /** ... */ + /** + * @param {Number} inputNum -inputNum + * @param {Integer} numPoints - numPoints + * + * @returns {Number} rounded result + */ roundToDecimal : function (inputNum, numPoints) { var multiplier = Math.pow(10, numPoints); return Math.round(inputNum * multiplier) / multiplier; }, - /** ... */ + /** + * @param {Number} location -location + * + * @returns {Number} location in radian + */ decimalToRadian : function (location) { var d = 0.01745329251994329577; return this.roundToDecimal(location * d, this.digitRadian); }, - /** ... */ + /** + * @param {Number} location -location + * + * @returns {Number} location in grade + */ decimalToGrade : function (location) { var d = 1.11111111111111111111; return this.roundToDecimal(location * d, this.digitRadian); }, - /** ... */ + /** + * @param {Number} location -location + * @param {String} hemisphere -hemisphere + * @param {Boolean} obj -specifies if an object must be returned + * + * @returns {String|Object} DMS (String or Object depending on obj parameter value) + */ decimalToDMS : function (location, hemisphere, obj) { if (location < 0) { location *= -1; // strip dash '-' @@ -78,19 +97,36 @@ var PositionFormater = { return dms; }, - /** ... */ + /** + * @param {Number} location -location + * @param {Boolean} obj -specifies if an object must be returned + * + * @returns {String|Object} DMS (String or Object depending on obj parameter value) + */ decimalLatToDMS : function (location, obj) { var hemisphere = (location < 0) ? this.SOUTH : this.NORTH; // south if negative return this.decimalToDMS(location, hemisphere, obj); }, - /** ... */ + /** + * @param {Number} location -location + * @param {Boolean} obj -specifies if an object must be returned + * + * @returns {String|Object} DMS (String or Object depending on obj parameter value) + */ decimalLonToDMS : function (location, obj) { var hemisphere = (location < 0) ? this.WEST : this.EAST; // west if negative return this.decimalToDMS(location, hemisphere, obj); }, - /** ... */ + /** + * @param {Number} degrees -degrees + * @param {Number} minutes -minutes + * @param {Number} seconds -seconds + * @param {String} hemisphere -hemisphere + * + * @returns {Number} decimal + */ DMSToDecimal : function (degrees, minutes, seconds, hemisphere) { var ddVal = degrees + minutes / 60 + seconds / 3600; ddVal = (hemisphere === this.SOUTH || hemisphere === this.WEST) ? ddVal * -1 : ddVal; diff --git a/src/Leaflet/Layers/LayerConfig.js b/src/Leaflet/Layers/LayerConfig.js index 2afdf4556..956ea836f 100644 --- a/src/Leaflet/Layers/LayerConfig.js +++ b/src/Leaflet/Layers/LayerConfig.js @@ -13,6 +13,10 @@ var logger = Logger.getLogger("layer-config"); var LayerConfig = { /** * options : key, layer, service + * + * @param {Object} options - options + * + * @returns {Object} layer parameters */ get : function (options) { var params = {}; diff --git a/src/Leaflet/Layers/LayerEvent.js b/src/Leaflet/Layers/LayerEvent.js index c72589539..421a83e59 100644 --- a/src/Leaflet/Layers/LayerEvent.js +++ b/src/Leaflet/Layers/LayerEvent.js @@ -19,6 +19,10 @@ var LayerEvent = { /** * activation du controle attribution + * + * @param {Object} map - the map + * + * @return {Boolean} attribution controle is enable */ isEnable : function (map) { if (!map.attributionControl) { @@ -49,10 +53,12 @@ var LayerEvent = { /** * fonction de suppresion d'un layer du controle des layers + * + * @param {Object} e - event */ _onRemoveLayer : function (e) { logger.trace("onRemove event", e); - if (e.layer._geoportal_id != this._geoportal_id) { + if (e.layer._geoportal_id !== this._geoportal_id) { return; } // attributions non visibles @@ -61,10 +67,12 @@ var LayerEvent = { /** * fonction d'ajout d'un layer du controle des layers + * + * @param {Object} e - event */ _onAddLayer : function (e) { logger.trace("onAdd event", e); - if (e.layer._geoportal_id != this._geoportal_id) { + if (e.layer._geoportal_id !== this._geoportal_id) { return; } // attributions visibles @@ -73,6 +81,8 @@ var LayerEvent = { /** * fonction de deplacement d'un layer + * + * @param {Object} e - event */ _onMoveEndLayer : function (e) { logger.trace("moveend event", e); @@ -80,7 +90,11 @@ var LayerEvent = { this.updateAttributions(this._map, this); }, - /** updateAttributions */ + /** + * updateAttributions + * + * @param {Object} map - the map + */ updateAttributions : function (map) { // FIXME on peut realiser une mise à jour plus intelligente que cette manière brutale... // Ex. mise en place de la notion 'hidden' de l'originators à desactiver @@ -95,7 +109,11 @@ var LayerEvent = { this.fire("attributionchange"); }, - /** removeAttributions */ + /** + * removeAttributions + * + * @param {Object} map - the map + */ removeAttributions : function (map) { logger.trace("removeAttributions...", this._geoportal_id); // suppression des attributions @@ -117,7 +135,11 @@ var LayerEvent = { } }, - /** addAttributions */ + /** + * addAttributions + * + * @param {Object} map - the map + */ addAttributions : function (map) { logger.trace("addAttributions...", this._geoportal_id); // on interroge les originators en options pour obtenir les infos diff --git a/src/Leaflet/Layers/Layers.js b/src/Leaflet/Layers/Layers.js index b800f8b98..84213a119 100644 --- a/src/Leaflet/Layers/Layers.js +++ b/src/Leaflet/Layers/Layers.js @@ -5,6 +5,8 @@ import LayerConfig from "./LayerConfig"; import WMS from "./WMS"; import WMTS from "./WMTS"; +var logger = Logger.getLogger("layers"); + /** * Geoportal Layers Factory to be used together with Leaflet Maps. * @@ -38,7 +40,7 @@ var Layers = { // FIXME est ce utile de le preciser ? if (!this.options.apiKey) { - console.log("PARAM_MISSING : apiKey !"); + logger.log("PARAM_MISSING : apiKey !"); } // par defaut @@ -80,7 +82,7 @@ var Layers = { this.params = {}; if (!this.options.apiKey) { // FIXME on retire l'exception... - console.log("WARNING PARAM_MISSING : parameter 'apiKey' is mandatory if the contract key configuration has not been loaded !"); + logger.log("WARNING PARAM_MISSING : parameter 'apiKey' is mandatory if the contract key configuration has not been loaded !"); } } }, @@ -92,12 +94,15 @@ var Layers = { * @static * @alias L.geoportalLayer.WMS * @extends {L.TileLayer.WMS} + * * @param {Object} options - options for function call. * @param {String} options.layer - layer name (e.g. "ORTHOIMAGERY.ORTHOPHOTOS") * @param {Boolean} [options.ssl] - if set true, enforce protocol https (only for nodejs) * @param {String} [options.apiKey] - access key to Geoportal platform, obtained [here]{@link http://professionnels.ign.fr/ign/contrats}. * @param {Object} [settings] - other options for L.TileLayer.WMS function (see {@link http://leafletjs.com/reference.html#tilelayer-wms-options}) - * @returns {L.geoportalLayer.WMS} + * + * @returns {L.geoportalLayer.WMS} WMS layer + * * @example * var map = L.Map('divmap').setView(); * var lyr = L.geoportalLayer.WMS( @@ -188,12 +193,15 @@ var Layers = { * @static * @alias L.geoportalLayer.WMTS * @extends {L.TileLayer} + * * @param {Object} options - options for function call. * @param {String} options.layer - layer name (e.g. "ORTHOIMAGERY.ORTHOPHOTOS") * @param {Boolean} [options.ssl] - if set true, enforce protocol https (only for nodejs) * @param {String} [options.apiKey] - access key to Geoportal platform, obtained [here]{@link http://professionnels.ign.fr/ign/contrats}. * @param {Object} [settings] - other options for L.TileLayer function (see {@link http://leafletjs.com/reference.html#tilelayer-options}) - * @returns {L.geoportalLayer.WMTS} + * + * @returns {L.geoportalLayer.WMTS} WMTS layer + * * @example * var map = L.Map('divmap').setView(); * var lyr = L.geoportalLayer.WMTS( diff --git a/src/Leaflet/Layers/WMS.js b/src/Leaflet/Layers/WMS.js index 99840e7b4..943923e9c 100644 --- a/src/Leaflet/Layers/WMS.js +++ b/src/Leaflet/Layers/WMS.js @@ -211,6 +211,8 @@ var WMS = L.TileLayer.WMS.extend(/** @lends WMS.prototype */ { * (overwritten) * * @param {Object} tilePoint - Point object + * + * @returns {String} url * @private */ getTileUrl : function (tilePoint) { diff --git a/src/Leaflet/Layers/WMTS.js b/src/Leaflet/Layers/WMTS.js index 8551cd625..25f4527b0 100644 --- a/src/Leaflet/Layers/WMTS.js +++ b/src/Leaflet/Layers/WMTS.js @@ -226,6 +226,8 @@ var WMTS = L.TileLayer.extend(/** @lends WMTS.prototype */ { * (overwritten) * * @param {Object} tilePoint - Point leaflet object + * + * @returns {String} url * @private */ getTileUrl : function (tilePoint) { @@ -257,6 +259,10 @@ var WMTS = L.TileLayer.extend(/** @lends WMTS.prototype */ { * event 'setParams' * (overwritten) * + * @param {Object} params - parameters + * @param {Object} noRedraw - no redraw + * + * @returns {Object} this * @private */ setParams : function (params, noRedraw) { diff --git a/src/OpenLayers/CRS/CRS.js b/src/OpenLayers/CRS/CRS.js index 6e4126853..7e148d50c 100644 --- a/src/OpenLayers/CRS/CRS.js +++ b/src/OpenLayers/CRS/CRS.js @@ -1,6 +1,9 @@ import ol from "ol"; import Proj4 from "proj4"; import Register from "../../Common/Utils/Register"; +import Logger from "../../Common/Utils/LoggerByDefault"; + +var logger = Logger.getLogger("CRS"); /** * Autoload function that loads all defs into proj4 @@ -13,7 +16,7 @@ import Register from "../../Common/Utils/Register"; if (!ol.proj.proj4_ && ol.proj.setProj4) { ol.proj.setProj4(Proj4); } else { - console.log("WARNING : OpenLayers library should manage proj4 dependency in order to add custom projections (Lambert 93 for instance)"); + logger.log("WARNING : OpenLayers library should manage proj4 dependency in order to add custom projections (Lambert 93 for instance)"); } })(); diff --git a/src/OpenLayers/Controls/Drawing.js b/src/OpenLayers/Controls/Drawing.js index 1c39f5bab..c4639c27f 100644 --- a/src/OpenLayers/Controls/Drawing.js +++ b/src/OpenLayers/Controls/Drawing.js @@ -1,10 +1,8 @@ import ol from "ol"; -import Gp from "gp"; import Logger from "../../Common/Utils/LoggerByDefault"; import SelectorID from "../../Common/Utils/SelectorID"; import Interactions from "./Utils/Interactions"; import DrawingDOM from "../../Common/Controls/DrawingDOM"; -import Utils from "../../Common/Utils"; import KMLExtended from "../Formats/KML"; var logger = Logger.getLogger("Drawing"); @@ -227,7 +225,7 @@ Drawing.prototype.setMap = function (map) { // gestion des suppressions "externes" de la couche de dessin. this.eventKey = this.getMap().getLayers().on("remove", function (evtRm) { - if (evtRm.element == this.layer) { + if (evtRm.element == this.layer) { // FIXME object comparison // found layer removed. this.layer = null; // on supprime l'interaction en cours si besoin @@ -242,22 +240,22 @@ Drawing.prototype.setMap = function (map) { /** * Export features of current drawing layer in KML. * - * @returns {String} - a KML representation of drawn features or null if not possible. + * @returns {String} a KML representation of drawn features or null if not possible. */ Drawing.prototype.exportFeatures = function () { var result = null; if (ol.control.Control.prototype.getMap.call(this) == null) { - console.log("Impossible to export : control isn't attached to any map."); + logger.log("Impossible to export : control isn't attached to any map."); return result; } if (!this.layer) { - console.log("Impossible to export : no layer is hosting features."); + logger.log("Impossible to export : no layer is hosting features."); return result; } if (!this.layer.getSource() || !this.layer.getSource().getFeatures() || !this.layer.getSource().getFeatures().length) { - console.log("Impossible to export : no features found."); + logger.log("Impossible to export : no features found."); return result; } var featProj = this.layer.getSource().getProjection(); @@ -286,7 +284,7 @@ Drawing.prototype.exportFeatures = function () { */ Drawing.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] Drawing:setCollapsed - missing collapsed parameter"); + logger.error("[ERROR] Drawing:setCollapsed - missing collapsed parameter"); return; } if ((collapsed && this.collapsed) || (!collapsed && !this.collapsed)) { @@ -309,7 +307,7 @@ Drawing.prototype.setExportName = function (name) { /** * getter for Export Name. * - * @returns {String} - export name + * @returns {String} export name */ Drawing.prototype.getExportName = function () { return this._exportName; @@ -323,13 +321,13 @@ Drawing.prototype.getExportName = function () { * Gets marker options in options.markersList given its src. * * @param {String} src - marker image URI, - * @returns {Object} - markers options + * @returns {Object} markers options * @private */ Drawing.prototype._getsMarkersOptionsFromSrc = function (src) { var markerOptions = null; for (var i = 0; i < this.options.markersList.length; i++) { - if (this.options.markersList[i].src == src) { + if (this.options.markersList[i].src === src) { markerOptions = this.options.markersList[i]; return markerOptions; } @@ -341,7 +339,7 @@ Drawing.prototype._getsMarkersOptionsFromSrc = function (src) { * Converts markerElement options into Openlayers IconStyles options. * * @param {Object} markerElement - marker element - * @returns {Object} - ol.Style.Icon constructor options. + * @returns {Object} ol.Style.Icon constructor options. * @private */ Drawing.prototype._getIconStyleOptions = function (markerElement) { @@ -501,17 +499,17 @@ Drawing.prototype._initialize = function (options) { this.options.defaultStyles[key] = Drawing.DefaultStyles[key]; return; } - if (key == "polyFillOpacity" && + if (key === "polyFillOpacity" && (options.defaultStyles[key] < 0 || options.defaultStyles[key] > 1)) { - console.log("Wrong value (" + options.defaultStyles[key] + ") for defaultStyles.polyFillOpactity. Must be between 0 and 1"); + logger.log("Wrong value (" + options.defaultStyles[key] + ") for defaultStyles.polyFillOpactity. Must be between 0 and 1"); this.options.defaultStyles[key] = Drawing.DefaultStyles[key]; return; } - if (key == "strokeWidth" || key == "polyStrokeWidth") { + if (key === "strokeWidth" || key === "polyStrokeWidth") { var intValue = parseInt(options.defaultStyles[key], 10); if (isNaN(intValue) || intValue < 0) { - console.log("Wrong value (" + options.defaultStyles[key] + ") for defaultStyles.strokeWidth. Must be a positive interger value."); + logger.log("Wrong value (" + options.defaultStyles[key] + ") for defaultStyles.strokeWidth. Must be a positive interger value."); this.options.defaultStyles[key] = Drawing.DefaultStyles[key]; return; } @@ -564,7 +562,7 @@ Drawing.prototype.setLayer = function (vlayer) { } if (!(vlayer instanceof ol.layer.Vector)) { - console.log("no valid layer given for hosting drawn features."); + logger.log("no valid layer given for hosting drawn features."); return; } @@ -573,7 +571,7 @@ Drawing.prototype.setLayer = function (vlayer) { if (layers) { var found = false; layers.forEach(function (mapLayer) { - if (mapLayer == vlayer) { + if (mapLayer == vlayer) { // FIXME object comparison logger.trace("layer already in map. Not adding."); found = true; } @@ -604,6 +602,8 @@ Drawing.prototype.setLayer = function (vlayer) { * Detection : test for desktop or tactile * * @method _detectSupport + * + * @returns {Boolean} is desktop * @private */ Drawing.prototype._detectSupport = function () { @@ -643,6 +643,8 @@ Drawing.prototype._detectSupport = function () { * Create control main container (called by Drawing constructor) * * @method _initContainer + * + * @returns {DOMElement} DOM element * @private */ Drawing.prototype._initContainer = function () { @@ -668,6 +670,8 @@ Drawing.prototype._initContainer = function () { /** * Callback de fin de dessin de geometrie + * @param {Object} feature - ol feature + * @param {String} geomType - geometry type * * @private */ @@ -762,7 +766,7 @@ Drawing.prototype._createRemoveInteraction = function () { layers : [this.layer] }); interaction.on("select", function (seEv) { - if (!seEv || !seEv.selected || seEv.selected.length == 0) { + if (!seEv || !seEv.selected || seEv.selected.length === 0) { return; } this.layer.getSource().removeFeature(seEv.selected[0]); @@ -790,7 +794,7 @@ Drawing.prototype._createStylingInteraction = function () { if (this.stylingOvl) { this.getMap().removeOverlay(this.stylingOvl); } - if (!seEv || !seEv.selected || seEv.selected.length == 0) { + if (!seEv || !seEv.selected || seEv.selected.length === 0) { return; } @@ -897,7 +901,7 @@ Drawing.prototype._createStylingInteraction = function () { initValues.fillOpacity = initValues.hasOwnProperty("fillOpacity") ? initValues.fillOpacity : this.options.defaultStyles.polyFillOpacity; } if (!geomType) { - console.log("Unhandled geometry type for styling."); + logger.log("Unhandled geometry type for styling."); return; } var dtObj = this; @@ -907,11 +911,11 @@ Drawing.prototype._createStylingInteraction = function () { * @param {String} action - "apply" (to selected object), "default" (set as default), "cancel" (do nothing). */ var applyStyle = function (action) { - if (action == "cancel") { + if (action === "cancel") { dtObj.getMap().removeOverlay(popupOvl); return; } - var setDefault = action != "apply"; + var setDefault = action !== "apply"; var fillColorElem = document.getElementById(dtObj._addUID("fillColor")); var fillOpacityElem = document.getElementById(dtObj._addUID("fillOpacity")); @@ -945,7 +949,7 @@ Drawing.prototype._createStylingInteraction = function () { if (dtObj.options.markersList.length > 1) { // index du marker dans la liste des markers var idxMarker = dtObj.options.markersList.findIndex(function (mrk) { - if (mrk == markerSelected) { + if (mrk == markerSelected) { // FIXME object comparison return true; } return false; @@ -1042,7 +1046,7 @@ Drawing.prototype._createLabelInteraction = function () { if (this.labelOvl) { this.getMap().removeOverlay(this.labelOvl); } - if (!seEv || !seEv.selected || seEv.selected.length == 0) { + if (!seEv || !seEv.selected || seEv.selected.length === 0) { return; } var popupOvl = null; @@ -1065,10 +1069,10 @@ Drawing.prototype._createLabelInteraction = function () { geomType = "Polygon"; } if (!geomType) { - console.log("Unhandled geometry type for styling."); + logger.log("Unhandled geometry type for styling."); return; } - if (geomType == "Text") { + if (geomType === "Text") { // pour les labels on récupère la valeur dans le style _textValue = seEv.selected[0].getStyle().getText().getText(); } else { @@ -1094,7 +1098,7 @@ Drawing.prototype._createLabelInteraction = function () { return; } var feature = seEv.selected[0]; - if (geomType == "Text") { + if (geomType === "Text") { var style = feature.getStyle(); style.getText().setText(value); feature.setProperties({ @@ -1111,7 +1115,7 @@ Drawing.prototype._createLabelInteraction = function () { var popupDiv = this._createLabelDiv({ applyFunc : setTextValue, inputId : this._addUID("label-input"), - placeholder : (geomType == "Text" ? "Saisir un label..." : "Saisir une description..."), + placeholder : (geomType === "Text" ? "Saisir un label..." : "Saisir une description..."), text : _textValue, measure : (this.options.tools.measure) ? _measure : null, geomType : geomType @@ -1138,6 +1142,8 @@ Drawing.prototype._createLabelInteraction = function () { /** * Callback de fin de modification du dessin afin de mettre à jour la mesure * TODO + * @param {Object} feature - ol feature + * @param {String} geomType - geometry type * * @private */ @@ -1149,7 +1155,7 @@ Drawing.prototype._updateMeasure = function (feature, geomType) { var wgs84Sphere = new ol.Sphere(6378137); var projection = this.getMap().getView().getProjection(); - /** arrondi */ + // arrondi function __roundDecimal (nombre, precision) { precision = precision || 2; var factor = Math.pow(10, precision); @@ -1419,7 +1425,7 @@ Drawing.prototype._handleToolClick = function (clickEvent, toolId, context) { }) }) }), - /** deleteCondition : aucune en mode "edition" */ + // deleteCondition : aucune en mode "edition" deleteCondition : function (/* event */) { return false; } diff --git a/src/OpenLayers/Controls/ElevationPath.js b/src/OpenLayers/Controls/ElevationPath.js index 451475867..d3ba0355c 100644 --- a/src/OpenLayers/Controls/ElevationPath.js +++ b/src/OpenLayers/Controls/ElevationPath.js @@ -154,6 +154,8 @@ Utils.assign(ElevationPath.prototype, ElevationPathDOM); /** * suppression du marker * + * @param {Object} context - context + * * @private */ ElevationPath.__removeProfileMarker = function (context) { @@ -168,6 +170,9 @@ ElevationPath.__removeProfileMarker = function (context) { /** * suppression du marker * + * @param {Object} context - context + * @param {Object} d - d + * * @private */ ElevationPath.__createProfileMarker = function (context, d) { @@ -198,6 +203,9 @@ ElevationPath.__createProfileMarker = function (context, d) { /** * mise à jour du marker * + * @param {Object} context - context + * @param {Object} d - data + * * @private */ ElevationPath.__updateProfileMarker = function (context, d) { @@ -208,6 +216,10 @@ ElevationPath.__updateProfileMarker = function (context, d) { /** * TODO : customisation possible d'une opération sur le profil + * + * @param {Object} context - context + * @param {Object} d - data + * * @private */ ElevationPath.__customRawProfileOperation = function (context, d) { @@ -251,6 +263,9 @@ ElevationPath.__customRawProfileOperation = function (context, d) { /** * TODO : customisation possible d'une opération sur le profil * Ex. Methode appélée dans le DOM : ProfileElevationPathDOM + * + * @param {Object} context - context + * @param {Object} e - event * @private */ ElevationPath.__customRawProfileMouseOverEvent = function (context, e) { @@ -269,7 +284,7 @@ ElevationPath.DISPLAY_PROFILE_LIB_AMCHARTS = function (data, container, context) // Calcul du profile if (typeof AmCharts === "undefined") { - console.log("Lib. AmCharts is not loaded !"); + logger.log("Lib. AmCharts is not loaded !"); return; } @@ -292,7 +307,7 @@ ElevationPath.DISPLAY_PROFILE_LIB_D3 = function (data, container, context) { // Calcul du profile if (typeof d3 === "undefined") { - console.log("Lib. D3 is not loaded !"); + logger.log("Lib. D3 is not loaded !"); return; } @@ -559,6 +574,8 @@ ElevationPath.prototype._removeProfile = function () { /** * Initialize control (called by constructor) * + * @param {Object} options - options + * * @private */ ElevationPath.prototype._initialize = function (options) { @@ -628,6 +645,8 @@ ElevationPath.prototype._initialize = function (options) { /** * initialize component container (DOM) * + * @returns {DOMElement} DOM element + * * @private */ ElevationPath.prototype._initializeContainer = function () { @@ -937,6 +956,8 @@ ElevationPath.prototype._removeMeasureInteraction = function (map) { /** * transforme geometry feature to position coordinate (service) * + * @returns {Object[]} geometry + * * @private */ ElevationPath.prototype._getGeometry = function () { @@ -973,6 +994,8 @@ ElevationPath.prototype._getGeometry = function () { /** * get geometry feature length * + * @returns {Integer} length + * * @private */ ElevationPath.prototype._getLength = function () { @@ -1036,7 +1059,7 @@ ElevationPath.prototype._requestService = function () { // les callbacks var self = this; - /** callback _requestServiceOnSuccess */ + // callback _requestServiceOnSuccess var _requestServiceOnSuccess = function (result) { logger.trace(result); if (result) { @@ -1048,7 +1071,7 @@ ElevationPath.prototype._requestService = function () { } }; - /** callback _requestServiceOnFailure */ + // callback _requestServiceOnFailure var _requestServiceOnFailure = function (error) { // on ferme le panneau en cas d'erreur ! self._panelContainer.style.display = "none"; diff --git a/src/OpenLayers/Controls/GeoportalAttribution.js b/src/OpenLayers/Controls/GeoportalAttribution.js index 51ea22632..35fb12ec0 100644 --- a/src/OpenLayers/Controls/GeoportalAttribution.js +++ b/src/OpenLayers/Controls/GeoportalAttribution.js @@ -1,6 +1,9 @@ import ol from "ol"; import LayerUtils from "../../Common/Utils/LayerUtils"; +import Logger from "../../Common/Utils/LoggerByDefault"; + +var logger = Logger.getLogger("geoportalattribution"); /** * @classdesc @@ -131,7 +134,7 @@ GeoportalAttribution.prototype._updateAttributions = function (map) { if (lyr.getSource) { context._updateLayerAttributions(lyr, mapAttributions, standardExtent, mapProjection, zoom); } else { - console.log("cannot find layer source in layergroup ", layers[i]); + logger.log("cannot find layer source in layergroup ", layers[i]); } } ); diff --git a/src/OpenLayers/Controls/GetFeatureInfo.js b/src/OpenLayers/Controls/GetFeatureInfo.js index 23008e091..7a86e447b 100644 --- a/src/OpenLayers/Controls/GetFeatureInfo.js +++ b/src/OpenLayers/Controls/GetFeatureInfo.js @@ -1,10 +1,11 @@ import ol from "ol"; -import Gp from "gp"; -import Proj4 from "proj4"; import Utils from "../../Common/Utils"; import GfiUtils from "../GfiUtils"; import SelectorID from "../../Common/Utils/SelectorID"; import GetFeatureInfoDOM from "../../Common/Controls/GetFeatureInfoDOM"; +import Logger from "../../Common/Utils/LoggerByDefault"; + +var logger = Logger.getLogger("getfeatureinfo"); /** * @classdesc @@ -109,42 +110,42 @@ GetFeatureInfo.prototype._initialize = function (options, layers) { this._eventsHandler = {}; if (typeof options.auto !== "undefined" && typeof options.auto !== "boolean") { - console.log("[ERROR] GetFeatureInfo:_initialize - auto parameter should be a boolean"); + logger.log("[ERROR] GetFeatureInfo:_initialize - auto parameter should be a boolean"); return; } this._auto = options.auto || false; if (typeof options.active !== "undefined" && typeof options.active !== "boolean") { - console.log("[ERROR] GetFeatureInfo:_initialize - active parameter should be a boolean"); + logger.log("[ERROR] GetFeatureInfo:_initialize - active parameter should be a boolean"); return; } this._active = (typeof options.active === "undefined") ? true : options.active; if (options.defaultEvent && typeof options.defaultEvent !== "string") { - console.log("[ERROR] GetFeatureInfo:_initialize - defaultEvent parameter should be a string"); + logger.log("[ERROR] GetFeatureInfo:_initialize - defaultEvent parameter should be a string"); return; } this._defaultEvent = options.defaultEvent || "singleclick"; if (!this._isValidEvent(this._defaultEvent)) { - console.log("[ERROR] GetFeatureInfo:_initialize - _defaultEvent '" + this._defaultEvent + "' is not a valid event"); + logger.log("[ERROR] GetFeatureInfo:_initialize - _defaultEvent '" + this._defaultEvent + "' is not a valid event"); return; } if (options.defaultInfoFormat && typeof options.defaultInfoFormat !== "string") { - console.log("[ERROR] GetFeatureInfo:_initialize - defaultInfoFormat parameter should be a string"); + logger.log("[ERROR] GetFeatureInfo:_initialize - defaultInfoFormat parameter should be a string"); return; } this._defaultInfoFormat = options.defaultInfoFormat || "text/html"; if (options.cursorStyle && typeof options.cursorStyle !== "string") { - console.log("[ERROR] GetFeatureInfo:_initialize - cursorStyle parameter should be a string"); + logger.log("[ERROR] GetFeatureInfo:_initialize - cursorStyle parameter should be a string"); return; } this._cursorStyle = options.cursorStyle || "pointer"; if (options.proxyUrl) { if (typeof options.proxyUrl !== "string") { - console.log("[ERROR] GetFeatureInfo:_initialize - proxyUrl parameter should be a string"); + logger.log("[ERROR] GetFeatureInfo:_initialize - proxyUrl parameter should be a string"); return; } this._proxyUrl = options.proxyUrl; @@ -152,14 +153,14 @@ GetFeatureInfo.prototype._initialize = function (options, layers) { if (options.noProxyDomains) { if (!Array.isArray(options.noProxyDomains)) { - console.log("[ERROR] GetFeatureInfo:_initialize - noProxyDomains parameter should be a array"); + logger.log("[ERROR] GetFeatureInfo:_initialize - noProxyDomains parameter should be a array"); return; } this._noProxyDomains = options.noProxyDomains; } if (typeof options.autoPan !== "undefined" && typeof options.autoPan !== "boolean") { - console.log("[ERROR] GetFeatureInfo:_initialize - autoPan parameter should be a boolean"); + logger.log("[ERROR] GetFeatureInfo:_initialize - autoPan parameter should be a boolean"); return; } this._autoPan = (typeof options.autoPan === "undefined") ? true : options.autoPan; @@ -167,14 +168,14 @@ GetFeatureInfo.prototype._initialize = function (options, layers) { if (options.autoPanAnimation) { if (options.autoPanAnimation.duration) { if (typeof options.autoPanAnimation.duration !== "number") { - console.log("[ERROR] GetFeatureInfo:_initialize - autoPanAnimation parameter is invalid : duration should be a number."); + logger.log("[ERROR] GetFeatureInfo:_initialize - autoPanAnimation parameter is invalid : duration should be a number."); return; } } if (options.autoPanAnimation.easing) { if (typeof options.autoPanAnimation.easing !== "function") { - console.log("[ERROR] GetFeatureInfo:_initialize - autoPanAnimation parameter is invalid : easing should be a ol.easing function or a custom function."); + logger.log("[ERROR] GetFeatureInfo:_initialize - autoPanAnimation parameter is invalid : easing should be a ol.easing function or a custom function."); return; } } @@ -183,7 +184,7 @@ GetFeatureInfo.prototype._initialize = function (options, layers) { if (options.autoPanMargin) { if (typeof options.autoPanMargin !== "number") { - console.log("[ERROR] GetFeatureInfo:_initialize - autoPanMargin parameter should be a number"); + logger.log("[ERROR] GetFeatureInfo:_initialize - autoPanMargin parameter should be a number"); return; } this._autoPanMargin = options.autoPanMargin; @@ -191,7 +192,7 @@ GetFeatureInfo.prototype._initialize = function (options, layers) { // {Object} control layers list. if (!Array.isArray(layers)) { - console.log("[ERROR] GetFeatureInfo:_initialize - layers parameter should be an array"); + logger.log("[ERROR] GetFeatureInfo:_initialize - layers parameter should be an array"); return; } this._setLayers(layers); @@ -233,7 +234,7 @@ GetFeatureInfo.prototype.setMap = function (map) { var updated = false; map.getLayers().forEach(function (olLayer) { var layerFormat = GfiUtils.getLayerFormat(olLayer); - if (!this._hasLayer(olLayer) && layerFormat == "vector") { + if (!this._hasLayer(olLayer) && layerFormat === "vector") { this._layers.push({ obj : olLayer }); @@ -251,7 +252,7 @@ GetFeatureInfo.prototype.setMap = function (map) { "add", function (evt) { var layerFormat = GfiUtils.getLayerFormat(evt.element); - if (layerFormat == "vector") { + if (layerFormat === "vector") { this._layers.push({ obj : evt.element }); @@ -294,11 +295,11 @@ GetFeatureInfo.prototype.getLayers = function () { */ GetFeatureInfo.prototype.setDefaultEvent = function (eventName) { if (typeof eventName !== "string") { - console.log("[ERROR] GetFeatureInfo:setDefaultEvent - eventName parameter should be a string"); + logger.log("[ERROR] GetFeatureInfo:setDefaultEvent - eventName parameter should be a string"); return; } if (!eventName || !this._isValidEvent(eventName)) { - console.log("[ERROR] GetFeatureInfo:setDefaultEvent - event '" + eventName + "' is not allowed."); + logger.log("[ERROR] GetFeatureInfo:setDefaultEvent - event '" + eventName + "' is not allowed."); return; } @@ -313,7 +314,7 @@ GetFeatureInfo.prototype.setDefaultEvent = function (eventName) { */ GetFeatureInfo.prototype.setCursorStyle = function (cursorStyle) { if (typeof cursorStyle !== "string") { - console.log("[ERROR] GetFeatureInfo:setCursorStyle - cursorStyle parameter should be a string"); + logger.log("[ERROR] GetFeatureInfo:setCursorStyle - cursorStyle parameter should be a string"); return; } if (this._active) { @@ -348,7 +349,7 @@ GetFeatureInfo.prototype.setActive = function (active) { */ GetFeatureInfo.prototype._setActive = function (active) { if (typeof active !== "boolean") { - console.log("[ERROR] GetFeatureInfo:_setActive - active parameter should be a boolean"); + logger.log("[ERROR] GetFeatureInfo:_setActive - active parameter should be a boolean"); return; } if (this._active === active) { @@ -381,10 +382,10 @@ GetFeatureInfo.prototype.setHidden = function (hidden) { /** * Indicates if the widget is hidden * - * @return {Boolean} hidden + * @return {Boolean} is hidden */ GetFeatureInfo.prototype.isHidden = function () { - return this.element.style.visibility == "hidden"; + return this.element.style.visibility === "hidden"; }; /** @@ -402,8 +403,10 @@ GetFeatureInfo.prototype.setLayers = function (gfiLayers) { /** * Indicates if an event is allowed + * * @param {String} eventName - name of the mouse event chosen in the list : 'singleclick', 'dblclick', 'contextmenu'. - * @returns {Boolean} + * + * @returns {Boolean} is valid event * * @private */ @@ -422,14 +425,11 @@ GetFeatureInfo.prototype._isValidEvent = function (eventName) { GetFeatureInfo.prototype._activateEvent = function (eventName, map) { var gfiObj = this; - /** - * getFeatureInfoHandler - */ var getFeatureInfoHandler = function (e) { GfiUtils.onDisplayFeatureInfo(e, gfiObj); }; - if (eventName == "contextmenu") { + if (eventName === "contextmenu") { map.getViewport().addEventListener( eventName, getFeatureInfoHandler @@ -454,7 +454,7 @@ GetFeatureInfo.prototype._activateEvent = function (eventName, map) { * @private */ GetFeatureInfo.prototype._deactivateEvent = function (eventName, map) { - if (eventName == "contextmenu") { + if (eventName === "contextmenu") { map.getViewport().removeEventListener( eventName, this._eventsHandler[eventName] @@ -515,8 +515,10 @@ GetFeatureInfo.prototype._clearEvents = function () { /** * Indicates if the control has the specified layer attached + * * @param {ol.layer.Layer} olLayer - layer openlayers - * @returns {Boolean} + * + * @returns {Boolean} has layer * * @private */ @@ -544,14 +546,11 @@ GetFeatureInfo.prototype._activateCursor = function (activate, map) { if (activate) { if (this._eventsHandler.hasOwnProperty("pointermove")) { - console.log("[ERROR] _activateCursor - inconsistent state: pointermove event handler already registered"); + logger.log("[ERROR] _activateCursor - inconsistent state: pointermove event handler already registered"); return; } var gfiObj = this; - /** - * displayCursor - */ var displayCursor = function (evt) { var hit = map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) { // on ne prend en compte que les couches vecteurs connues du controle @@ -586,7 +585,7 @@ GetFeatureInfo.prototype._activateCursor = function (activate, map) { */ GetFeatureInfo.prototype._setLayers = function (gfiLayers) { if (!gfiLayers || !Array.isArray(gfiLayers)) { - console.log("[ERROR] GetFeatureInfo:setLayers - gfiLayers parameter should be a array"); + logger.log("[ERROR] GetFeatureInfo:setLayers - gfiLayers parameter should be a array"); return; } this._layers = []; @@ -596,7 +595,7 @@ GetFeatureInfo.prototype._setLayers = function (gfiLayers) { if (gfiLayers[i].event) { if (!this._isValidEvent(gfiLayers[i].event)) { - console.log("[ERROR] GetFeatureInfo:setLayers - layer event '" + this._layers[i].event + "' is not allowed."); + logger.log("[ERROR] GetFeatureInfo:setLayers - layer event '" + this._layers[i].event + "' is not allowed."); } else { this._layers[ind].event = gfiLayers[i].event; } @@ -632,6 +631,8 @@ GetFeatureInfo.prototype.onActivateGetFeatureInfoElementChange = function (e) { * @param {Object} [options] - options object to configure the widget : * @param {Boolean} [options.hidden] - specifies if the widget should be hidden. * + * @return {DOMElement} DOM element + * * @method _initContainer * * @private @@ -649,7 +650,7 @@ GetFeatureInfo.prototype._initContainer = function (options) { if (typeof options.hidden !== "undefined") { if (typeof options.hidden !== "boolean") { - console.log("[ERROR] GetFeatureInfo:_initContainer - hidden parameter should be a boolean"); + logger.log("[ERROR] GetFeatureInfo:_initContainer - hidden parameter should be a boolean"); return; } if (options.hidden) { diff --git a/src/OpenLayers/Controls/Isocurve.js b/src/OpenLayers/Controls/Isocurve.js index 667d00c7c..ac7ee0218 100644 --- a/src/OpenLayers/Controls/Isocurve.js +++ b/src/OpenLayers/Controls/Isocurve.js @@ -118,7 +118,7 @@ Isocurve.prototype.getCollapsed = function () { */ Isocurve.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] Isocurve:setCollapsed - missing collapsed parameter"); + logger.log("[ERROR] Isocurve:setCollapsed - missing collapsed parameter"); return; } if ((collapsed && this.collapsed) || (!collapsed && !this.collapsed)) { @@ -256,6 +256,8 @@ Isocurve.prototype.initialize = function (options) { /** * this method is called by this.initialize() * + * @param {Object} options - options + * * @private */ Isocurve.prototype._checkInputOptions = function (options) { @@ -272,7 +274,7 @@ Isocurve.prototype._checkInputOptions = function (options) { } else { for (i = 0; i < options.methods.length; i++) { if (typeof options.methods[i] !== "string") { - console.log("[ol.control.Isocurve] ERROR : parameter 'methods' elements should be of type 'string'"); + logger.log("[ol.control.Isocurve] ERROR : parameter 'methods' elements should be of type 'string'"); } } } @@ -291,7 +293,7 @@ Isocurve.prototype._checkInputOptions = function (options) { } else { for (i = 0; i < options.graphs.length; i++) { if (typeof options.graphs[i] !== "string") { - console.log("[ol.control.Isocurve] ERROR : parameter 'graphs' elements should be of type 'string'"); + logger.log("[ol.control.Isocurve] ERROR : parameter 'graphs' elements should be of type 'string'"); } else { if (options.graphs[i].toLowerCase() === "pieton") { options.graphs[i] = "Pieton"; @@ -317,7 +319,7 @@ Isocurve.prototype._checkInputOptions = function (options) { } else { for (i = 0; i < options.directions.length; i++) { if (typeof options.directions[i] !== "string") { - console.log("[ol.control.Isocurve] ERROR : parameter 'directions' elements should be of type 'string'"); + logger.log("[ol.control.Isocurve] ERROR : parameter 'directions' elements should be of type 'string'"); } } } @@ -546,6 +548,10 @@ Isocurve.prototype._checkRightsManagement = function () { /** * initialize component container (DOM) * + * @param {Object} map - the map + * + * @returns {DOMElement} DOM element + * * @private */ Isocurve.prototype._initContainer = function (map) { @@ -630,7 +636,7 @@ Isocurve.prototype._initContainer = function (map) { // hide autocomplete suggested locations on container click if (container.addEventListener) { container.addEventListener("click", function (e) { - context._hideIsoSuggestedLocations.call(context, e); + context._hideIsoSuggestedLocations(e); }); } @@ -640,6 +646,8 @@ Isocurve.prototype._initContainer = function (map) { /** * Create start point * + * @param {Object} map - the map + * * @returns {Object} DOM element * @private */ @@ -717,7 +725,7 @@ Isocurve.prototype._createIsoPanelFormPointElement = function (map) { Isocurve.prototype.onIsoComputationSubmit = function () { // si on n'a pas de valeur récupérée pour notre point origine, on ne fait rien if (!this._originPoint || !this._originPoint.getCoordinate || !this._originPoint.getCoordinate()) { - console.log("[Isocurve] Missing position parameter to submit isocurve request"); + logger.log("[Isocurve] Missing position parameter to submit isocurve request"); return; } @@ -756,14 +764,14 @@ Isocurve.prototype.onIsoComputationSubmit = function () { // si on n'a pas de valeur de calcul renseignée, on ne lance pas la requête. if (!time && !distance) { - console.log("[Isocurve] Missing time or distance parameter to submit isocurve request"); + logger.log("[Isocurve] Missing time or distance parameter to submit isocurve request"); return; } // oups, aucun droits ! // on evite donc une requête inutile ... if (this._noRightManagement) { - console.log("[Isocurve] no rights for this service"); + logger.log("[Isocurve] no rights for this service"); return; } @@ -789,14 +797,14 @@ Isocurve.prototype.onIsoComputationSubmit = function () { smoothing : options.smoothing || true, timeOut : _timeout, protocol : _protocol, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { context._drawIsoResults(results); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME mise à jour du controle mais le service ne repond pas en 200 !? context._hideWaitingContainer(); @@ -957,14 +965,14 @@ Isocurve.prototype._requestIsoCurve = function (options) { } // ni si on n'a aucun droit if (this._noRightManagement || !this._resources["Isocurve"]) { - console.log("no rights for this service"); + logger.log("no rights for this service"); return; } // gestion des droits ! var resources = this._resources["Isocurve"].resources; if (!resources || (typeof resources === "object" && Object.keys(resources).length === 0)) { - console.log("no rights for this service"); + logger.log("no rights for this service"); return; } @@ -977,7 +985,7 @@ Isocurve.prototype._requestIsoCurve = function (options) { } // on fait quoi ? if (!bFound) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -1239,6 +1247,8 @@ Isocurve.prototype._clearGeojsonLayer = function () { * this method is called by event 'click' on control main container * and hide suggested Locations (unless target is an autocomplete input) * + * @param {Object} e - event + * * @private */ Isocurve.prototype._hideIsoSuggestedLocations = function (e) { diff --git a/src/OpenLayers/Controls/LayerImport.js b/src/OpenLayers/Controls/LayerImport.js index 8d3fed20d..d39a824d5 100644 --- a/src/OpenLayers/Controls/LayerImport.js +++ b/src/OpenLayers/Controls/LayerImport.js @@ -175,7 +175,7 @@ LayerImport.prototype.getCollapsed = function () { */ LayerImport.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] LayerImport:setCollapsed - missing collapsed parameter"); + logger.log("[ERROR] LayerImport:setCollapsed - missing collapsed parameter"); return; } if ((collapsed && this.collapsed) || (!collapsed && !this.collapsed)) { @@ -354,7 +354,7 @@ LayerImport.prototype._checkInputOptions = function (options) { var layerTypes = options.layerTypes; // on vérifie que la liste des types est bien un tableau if (!Array.isArray(layerTypes)) { - console.log("[ol.control.LayerImport] 'options.layerTypes' parameter should be an array. Set default values [\"KML\", \"GPX\", \"GeoJSON\", \"WMS\", \"WMTS\"]"); + logger.log("[ol.control.LayerImport] 'options.layerTypes' parameter should be an array. Set default values [\"KML\", \"GPX\", \"GeoJSON\", \"WMS\", \"WMTS\"]"); options.layerTypes = [ "KML", "GPX", @@ -376,14 +376,14 @@ LayerImport.prototype._checkInputOptions = function (options) { if (typeof layerTypes[i] !== "string") { // si l'élément du tableau n'est pas une chaine de caractères, on stocke l'index pour le retirer du tableau wrongTypesIndexes.push(i); - console.log("[ol.control.LayerImport] 'options.layerTypes' elements should be of type string (" + layerTypes[i] + ")"); + logger.log("[ol.control.LayerImport] 'options.layerTypes' elements should be of type string (" + layerTypes[i] + ")"); } else { // on passe en majuscules pour comparer layerTypes[i] = layerTypes[i].toUpperCase(); if (typesList.indexOf(layerTypes[i]) === -1) { // si le type n'est pas référencé, on stocke son index pour le retirer du tableau (après avoir terminé de parcourir le tableau) wrongTypesIndexes.push(i); - console.log("[ol.control.LayerImport] options.layerTypes : " + layerTypes[i] + " is not a supported type"); + logger.log("[ol.control.LayerImport] options.layerTypes : " + layerTypes[i] + " is not a supported type"); } // cas spécial du GeoJSON qu'on ne laisse pas en majuscules if (layerTypes[i] === "GEOJSON") { @@ -697,7 +697,7 @@ LayerImport.prototype._importStaticLayerFromUrl = function (layerName) { var url = this._staticUrlImportInput.value; logger.log("url : ", url); if (url.length === 0) { - console.log("[ol.control.LayerImport] url parameter is mandatory"); + logger.log("[ol.control.LayerImport] url parameter is mandatory"); return; } // on supprime les éventuels espaces avant ou après @@ -707,7 +707,7 @@ LayerImport.prototype._importStaticLayerFromUrl = function (layerName) { // 2. récupération proxy if (!this.options.webServicesOptions || (!this.options.webServicesOptions.proxyUrl && !this.options.webServicesOptions.noProxyDomains)) { - console.log("[ol.control.LayerImport] options.webServicesOptions.proxyUrl parameter is mandatory to request resources on another domain (cross-domain)"); + logger.log("[ol.control.LayerImport] options.webServicesOptions.proxyUrl parameter is mandatory to request resources on another domain (cross-domain)"); return; }; url = ProxyUtils.proxifyUrl(url, this.options.webServicesOptions); @@ -721,16 +721,16 @@ LayerImport.prototype._importStaticLayerFromUrl = function (layerName) { url : url, method : "GET", timeOut : 15000, - /** on success callback : display results in container */ + // on success callback : display results in container onResponse : function (response) { context._hideWaitingContainer(); context._addFeaturesFromImportStaticLayer(response, layerName); }, - /** on error callback : log error */ + // on error callback : log error onFailure : function (error) { // en cas d'erreur, on revient au panel initial et on cache la patience context._hideWaitingContainer(); - console.log("[ol.control.LayerImport] KML/GPX/GeoJSON request failed : ", error); + logger.log("[ol.control.LayerImport] KML/GPX/GeoJSON request failed : ", error); } }); }; @@ -745,7 +745,7 @@ LayerImport.prototype._importStaticLayerFromUrl = function (layerName) { LayerImport.prototype._importStaticLayerFromLocalFile = function (layerName) { var file = this._staticLocalImportInput.files[0]; if (!file) { - console.log("[ol.control.LayerImport] missing file"); + logger.log("[ol.control.LayerImport] missing file"); return; } @@ -755,7 +755,7 @@ LayerImport.prototype._importStaticLayerFromLocalFile = function (layerName) { // Définition des fonctions de callbacks associées au reader, // notamment la fonction onload qui affichera les entités chargées à la carte var context = this; - /** on readAsText error */ + // on readAsText error fReader.onerror = function (e) { // en cas d'erreur, on revient au panel initial et on cache la patience context._hideWaitingContainer(); @@ -777,7 +777,7 @@ LayerImport.prototype._importStaticLayerFromLocalFile = function (layerName) { context._hideWaitingContainer(); logger.log("onabort"); }; - /** on readAsText loadend */ + // on readAsText loadend fReader.onloadend = function (e) { // fReader = null ? // en cas d'erreur, on revient au panel initial et on cache la patience @@ -785,7 +785,7 @@ LayerImport.prototype._importStaticLayerFromLocalFile = function (layerName) { // TODO : replier le formulaire ? logger.log("onloadend : ", e); }; - /** on readAsText load */ + // on readAsText load fReader.onload = function (e) { logger.log("fileReader onload - file content : ", e.target.result); @@ -996,7 +996,7 @@ LayerImport.prototype._addFeaturesFromImportStaticLayerUrl = function (url, laye */ LayerImport.prototype._importServiceLayers = function () { if (this._currentImportType === "WFS") { - console.log("[ol.control.LayerImport] WFS layer import is not implemented yet"); + logger.log("[ol.control.LayerImport] WFS layer import is not implemented yet"); return; } @@ -1006,7 +1006,7 @@ LayerImport.prototype._importServiceLayers = function () { // 1. récupération de l'url renseignée var url = this._getCapRequestUrl = this._serviceUrlImportInput.value; if (!url) { - console.log("[ol.control.LayerImport] url parameter is mandatory"); + logger.log("[ol.control.LayerImport] url parameter is mandatory"); return; } logger.log("url : ", url); @@ -1028,7 +1028,7 @@ LayerImport.prototype._importServiceLayers = function () { // 2. récupération proxy if (!this.options.webServicesOptions || (!this.options.webServicesOptions.proxyUrl && !this.options.webServicesOptions.noProxyDomains)) { - console.log("[ol.control.LayerImport] options.webServicesOptions.proxyUrl parameter is mandatory to request web service layers (getcapabilities request)"); + logger.log("[ol.control.LayerImport] options.webServicesOptions.proxyUrl parameter is mandatory to request web service layers (getcapabilities request)"); return; }; var proxyUrl = this.options.webServicesOptions.proxyUrl; @@ -1058,16 +1058,16 @@ LayerImport.prototype._importServiceLayers = function () { url : url, method : "GET", timeOut : 15000, - /** on success callback : display results in container */ + // on success callback : display results in container onResponse : function (response) { context._hideWaitingContainer(); - context._displayGetCapResponseLayers.call(context, response); + context._displayGetCapResponseLayers(response); }, - /** on error callback : log error */ + // on error callback : log error onFailure : function (error) { // en cas d'erreur, on revient au panel initial et on cache la patience context._hideWaitingContainer(); - console.log("[ol.control.LayerImport] getCapabilities request failed : ", error); + logger.log("[ol.control.LayerImport] getCapabilities request failed : ", error); } }); }; @@ -1148,7 +1148,7 @@ LayerImport.prototype._displayGetCapResponseLayers = function (xmlResponse) { } else { // si la projection de la couche n'est pas connue par ol.proj, // on n'affiche pas la couche dans le panel des résultats - console.log("[ol.control.LayerImport] wmts layer cannot be added to map : unknown projection", layers[j]); + logger.log("[ol.control.LayerImport] wmts layer cannot be added to map : unknown projection", layers[j]); continue; } } @@ -1168,7 +1168,7 @@ LayerImport.prototype._displayGetCapResponseLayers = function (xmlResponse) { */ LayerImport.prototype._displayGetCapResponseWMSLayer = function (layerObj, parentLayersInfos) { if (!layerObj) { - console.log("[ol.control.LayerImport] _displayGetCapResponseWMSLayer : getCapabilities layer object not found"); + logger.log("[ol.control.LayerImport] _displayGetCapResponseWMSLayer : getCapabilities layer object not found"); } else { logger.log("[ol.control.LayerImport] _displayGetCapResponseWMSLayer - layerObj : ", layerObj); } @@ -1257,7 +1257,7 @@ LayerImport.prototype._displayGetCapResponseWMSLayer = function (layerObj, paren if (!projection) { // si aucune projection n'est compatible avec celle de la carte ou connue par ol.proj, // on n'affiche pas la couche dans le panel des résultats - console.log("[ol.control.LayerImport] wms layer cannot be added to map : unknown projection", layerObj); + logger.log("[ol.control.LayerImport] wms layer cannot be added to map : unknown projection", layerObj); } else { // si on a une projection compatible : on la stocke et la couche sera éventuellement reprojetée à l'ajout layerObj._projection = projection; @@ -1317,11 +1317,11 @@ LayerImport.prototype._onGetCapResponseLayerClick = function (e) { LayerImport.prototype._addGetCapWMSLayer = function (layerInfo) { var map = this.getMap(); if (!map) { - console.log("[ol.control.LayerImport] _addGetCapWMSLayer error : map is not defined"); + logger.log("[ol.control.LayerImport] _addGetCapWMSLayer error : map is not defined"); return; } if (!layerInfo) { - console.log("[ol.control.LayerImport] _addGetCapWMSLayer error : layerInfo is not defined"); + logger.log("[ol.control.LayerImport] _addGetCapWMSLayer error : layerInfo is not defined"); return; } @@ -1349,7 +1349,7 @@ LayerImport.prototype._addGetCapWMSLayer = function (layerInfo) { if (layerInfo.Name) { wmsSourceOptions.params["LAYERS"] = layerInfo.Name; } else { - console.log("[ol.control.LayerImport] unable to add wms layer : mandatory layer 'name' parameter cannot be found", layerInfo); + logger.log("[ol.control.LayerImport] unable to add wms layer : mandatory layer 'name' parameter cannot be found", layerInfo); return; } wmsSourceOptions.params["SERVICE"] = "WMS"; @@ -1362,7 +1362,7 @@ LayerImport.prototype._addGetCapWMSLayer = function (layerInfo) { // ou soit connue par proj4js var projection = layerInfo._projection; if (!projection) { - console.log("[ol.control.LayerImport] wms layer cannot be added to map : unknown projection"); + logger.log("[ol.control.LayerImport] wms layer cannot be added to map : unknown projection"); return; } else if (projection !== mapProjCode) { // si la projection de la carte n'est pas disponible pour cette couche, @@ -1515,7 +1515,7 @@ LayerImport.prototype._getWMSLayerMinMaxResolution = function (layerInfo, mapPro */ LayerImport.prototype._getWMSLayerExtent = function (layerInfo, mapProjCode, layerTileOptions) { if (!layerInfo) { - console.log("[ol.control.LayerImport] _getWMSLayerExtent error : layerInfo is not defined"); + logger.log("[ol.control.LayerImport] _getWMSLayerExtent error : layerInfo is not defined"); return; } @@ -1635,7 +1635,7 @@ LayerImport.prototype._getWMSLayerInfoForLayerSwitcher = function (layerInfo, le */ LayerImport.prototype._addGetCapWMTSLayer = function (layerInfo) { if (!layerInfo || !layerInfo.Identifier) { - console.log("[ol.control.LayerImport] layer information not found in getCapabilities response for layer "); + logger.log("[ol.control.LayerImport] layer information not found in getCapabilities response for layer "); return; } @@ -1695,7 +1695,7 @@ LayerImport.prototype._addGetCapWMTSLayer = function (layerInfo) { } } if (defaultStyle == null) { - console.log("[ol.control.LayerImport] style information not found in getCapabilities response for layer " + layerInfo.Identifier); + logger.log("[ol.control.LayerImport] style information not found in getCapabilities response for layer " + layerInfo.Identifier); } wmtsSourceOptions.style = defaultStyle; @@ -1705,7 +1705,7 @@ LayerImport.prototype._addGetCapWMTSLayer = function (layerInfo) { format = layerInfo.Format[0]; } if (format == null) { - console.log("[ol.control.LayerImport] format information not found in getCapabilities response for layer " + layerInfo.Identifier); + logger.log("[ol.control.LayerImport] format information not found in getCapabilities response for layer " + layerInfo.Identifier); } wmtsSourceOptions.format = format; @@ -1735,7 +1735,7 @@ LayerImport.prototype._addGetCapWMTSLayer = function (layerInfo) { try { wmtsLayer = new ol.layer.Tile(layerTileOptions); } catch (e) { - console.log("[ol.control.LayerImport] an error occured while trying to create ol.layer.Tile from getCapabilities information. error : ", e); + logger.log("[ol.control.LayerImport] an error occured while trying to create ol.layer.Tile from getCapabilities information. error : ", e); return; } // on rajoute le champ gpResultLayerId permettant d'identifier une couche crée par le composant. (pour layerSwitcher par ex) @@ -1902,7 +1902,7 @@ LayerImport.prototype._getTMSParams = function (layerInfo) { } } } else { - console.log("[ol.control.LayerImport] TileMatrixSet data not found in getCapabilities response for layer " + layerInfo.Identifier); + logger.log("[ol.control.LayerImport] TileMatrixSet data not found in getCapabilities response for layer " + layerInfo.Identifier); } } else { return; diff --git a/src/OpenLayers/Controls/LayerSwitcher.js b/src/OpenLayers/Controls/LayerSwitcher.js index 1bbd18fbb..01a7d91be 100644 --- a/src/OpenLayers/Controls/LayerSwitcher.js +++ b/src/OpenLayers/Controls/LayerSwitcher.js @@ -2,6 +2,9 @@ import ol from "ol"; import Utils from "../../Common/Utils"; import SelectorID from "../../Common/Utils/SelectorID"; import LayerSwitcherDOM from "../../Common/Controls/LayerSwitcherDOM"; +import Logger from "../../Common/Utils/LoggerByDefault"; + +var logger = Logger.getLogger("layerswitcher"); /** * @classdesc @@ -107,7 +110,7 @@ LayerSwitcher.prototype.setMap = function (map) { this._listeners.onMoveListener = map.on( "moveend", function () { - this._onMapMoveEnd.call(this, map); + this._onMapMoveEnd(map); }, this ); @@ -189,13 +192,13 @@ LayerSwitcher.prototype.addLayer = function (layer, config) { config = config || {}; if (!layer) { - console.log("[ERROR] LayerSwitcher:addLayer - missing layer parameter"); + logger.log("[ERROR] LayerSwitcher:addLayer - missing layer parameter"); return; } var id = layer.gpLayerId; if (id === "undefined") { - console.log("[ERROR] LayerSwitcher:addLayer - configuration cannot be set for " + layer + " layer (layer id not found)"); + logger.log("[ERROR] LayerSwitcher:addLayer - configuration cannot be set for " + layer + " layer (layer id not found)"); return; } @@ -210,7 +213,7 @@ LayerSwitcher.prototype.addLayer = function (layer, config) { this ); if (!isLayerInMap) { - console.log("[ERROR] LayerSwitcher:addLayer - configuration cannot be set for ", layer, " layer (layer is not in map.getLayers() )"); + logger.log("[ERROR] LayerSwitcher:addLayer - configuration cannot be set for ", layer, " layer (layer is not in map.getLayers() )"); return; } @@ -266,9 +269,9 @@ LayerSwitcher.prototype.addLayer = function (layer, config) { ); // listener for zIndex change var context = this; - /** fonction de callback appelée au changement de zindex d'une couche */ + // fonction de callback appelée au changement de zindex d'une couche var updateLayersOrder = function (e) { - context._updateLayersOrder.call(context, e); + context._updateLayersOrder(e); }; if (this._layers[id].onZIndexChangeEvent == null) { this._layers[id].onZIndexChangeEvent = layer.on( @@ -351,7 +354,7 @@ LayerSwitcher.prototype.removeLayer = function (layer) { */ LayerSwitcher.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] LayerSwitcher:setCollapsed - missing collapsed parameter"); + logger.log("[ERROR] LayerSwitcher:setCollapsed - missing collapsed parameter"); return; } var isCollapsed = !document.getElementById(this._addUID("GPshowLayersList")).checked; @@ -371,6 +374,7 @@ LayerSwitcher.prototype.setCollapsed = function (collapsed) { /** * Returns true if widget is collapsed (minimize), false otherwise + * @returns {Boolean} is collapsed */ LayerSwitcher.prototype.getCollapsed = function () { return this.collapsed; @@ -388,11 +392,11 @@ LayerSwitcher.prototype.setRemovable = function (layer, removable) { } var layerID = layer.gpLayerId; if (layerID == null) { // on teste si layerID est null ou undefined - console.log("[LayerSwitcher:setRemovable] layer should be added to map before calling setRemovable method"); + logger.log("[LayerSwitcher:setRemovable] layer should be added to map before calling setRemovable method"); return; } var removalDiv = document.getElementById(this._addUID("GPremove_ID_" + layerID)); - console.log(removalDiv.style.display); + logger.log(removalDiv.style.display); if (removalDiv) { if (removable === false) { removalDiv.style.display = "none"; @@ -498,7 +502,7 @@ LayerSwitcher.prototype._initContainer = function () { // on ajoute un écouteur d'évènement sur le bouton (checkbox) de dépliement/repliement des couches, // pour modifier la propriété this.collapsed quand on clique dessus var context = this; - /** event listener */ + // event listener var changeCollapsed = function (e) { this.collapsed = !e.target.checked; // on génère nous même l'evenement OpenLayers de changement de pté @@ -607,9 +611,9 @@ LayerSwitcher.prototype._addMapLayers = function (map) { ); // on récupère l'ordre d'affichage des couches entre elles dans la carte, à partir de zindex. - /** fonction de callback appelée au changement de zindex d'une couche */ + // fonction de callback appelée au changement de zindex d'une couche var updateLayersOrder = function (e) { - context._updateLayersOrder.call(context, e); + context._updateLayersOrder(e); }; for (var zindex in this._layersIndex) { if (this._layersIndex.hasOwnProperty(zindex)) { @@ -644,6 +648,9 @@ LayerSwitcher.prototype._addMapLayers = function (map) { * create layer div (to append to control DOM element). * * @param {Object} layerOptions - layer options (id, title, description, legends, metadata, quicklookUrl ...) + * + * @returns {DOMElement} DOM element + * * @private */ LayerSwitcher.prototype._createLayerDiv = function (layerOptions) { @@ -779,9 +786,9 @@ LayerSwitcher.prototype._updateLayersOrder = function () { // on réordonne les couches entre elles dans la carte, à partir des zindex stockés ci-dessus. this._lastZIndex = 0; var context = this; - /** fonction de callback appelée au changement de zindex d'une couche */ + // fonction de callback appelée au changement de zindex d'une couche var updateLayersOrder = function (e) { - context._updateLayersOrder.call(context, e); + context._updateLayersOrder(e); }; this._layersOrder = []; for (var zindex in this._layersIndex) { @@ -815,7 +822,7 @@ LayerSwitcher.prototype._updateLayersOrder = function () { this._layerListContainer.appendChild(layerOptions.div); } } else { - console.log("[ol.control.LayerSwitcher] _updateLayersOrder : layer list container not found to update layers order ?!"); + logger.log("[ol.control.LayerSwitcher] _updateLayersOrder : layer list container not found to update layers order ?!"); } }; @@ -920,9 +927,9 @@ LayerSwitcher.prototype._onDragAndDropLayerClick = function () { // INFO : e.oldIndex et e.newIndex marchent en mode AMD mais pas Bundle. var map = this.getMap(); var context = this; - /** fonction de callback appelée au changement de zindex d'une couche */ + // fonction de callback appelée au changement de zindex d'une couche var updateLayersOrder = function (e) { - context._updateLayersOrder.call(context, e); + context._updateLayersOrder(e); }; // on récupère l'ordre des div dans le contrôle pour réordonner les couches (avec zindex) @@ -1004,7 +1011,7 @@ LayerSwitcher.prototype.getLayerDOMId = function (olLayer) { var foundId = null; this.getMap().getLayers().forEach(function (layer) { - if (layer == olLayer) { + if (layer == olLayer) { // FIXME object comparison foundId = layer.hasOwnProperty("gpLayerId") ? layer.gpLayerId : null; } }, diff --git a/src/OpenLayers/Controls/LocationSelector.js b/src/OpenLayers/Controls/LocationSelector.js index e1d8d5f9c..d37384721 100644 --- a/src/OpenLayers/Controls/LocationSelector.js +++ b/src/OpenLayers/Controls/LocationSelector.js @@ -87,6 +87,8 @@ LocationSelector.prototype.constructor = LocationSelector; /** * initialize component + * + * @param {Object} options - options */ LocationSelector.prototype.initialize = function (options) { // set default options @@ -183,7 +185,7 @@ LocationSelector.prototype._initMarker = function () { if (Array.isArray(offset) && offset.length === 2) { this._markerOffset = offset; } else { - console.log("markerOpts.offset should be an array. e.g. : [0,0]"); + logger.log("markerOpts.offset should be an array. e.g. : [0,0]"); } } } else { @@ -255,6 +257,8 @@ LocationSelector.prototype._checkRightsManagement = function () { /** * initialize component container + * + * @returns {DOMElement} DOM element */ LocationSelector.prototype._initContainer = function () { var id = this.options.tag.id; @@ -336,7 +340,7 @@ LocationSelector.prototype.onAutoCompleteSearchText = function (e) { // aucun droits ! // on evite une requête... if (this._noRightManagement) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -359,14 +363,14 @@ LocationSelector.prototype.onAutoCompleteSearchText = function (e) { this._requestAutoComplete({ text : value, maximumResponses : 5, // FIXME je limite le nombre de reponse car le container DOM est limité dans l'affichage !!! - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { if (results) { var locations = results.suggestedLocations; context._fillAutoCompletedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME // où affiche t on les messages : ex. 'No suggestion matching the search' ? @@ -780,6 +784,8 @@ LocationSelector.prototype._requestAutoComplete = function (settings) { * it creates a HTML Element per location * (cf. this. ...) * + * @param {Object[]} locations - locations + * * @private */ LocationSelector.prototype._fillAutoCompletedLocationListContainer = function (locations) { diff --git a/src/OpenLayers/Controls/MeasureToolBox.js b/src/OpenLayers/Controls/MeasureToolBox.js index 768cf195e..b6a11f567 100644 --- a/src/OpenLayers/Controls/MeasureToolBox.js +++ b/src/OpenLayers/Controls/MeasureToolBox.js @@ -1,4 +1,3 @@ -import ol from "ol"; import Logger from "../../Common/Utils/LoggerByDefault"; import Utils from "../../Common/Utils"; import ID from "../../Common/Utils/SelectorID"; diff --git a/src/OpenLayers/Controls/Measures/MeasureArea.js b/src/OpenLayers/Controls/Measures/MeasureArea.js index 84b7d3722..8b1502383 100644 --- a/src/OpenLayers/Controls/Measures/MeasureArea.js +++ b/src/OpenLayers/Controls/Measures/MeasureArea.js @@ -142,6 +142,8 @@ MeasureArea.prototype.setMap = function (map) { /** * Initialize measure control (called by constructor) * + * @param {Object} options - options + * * @private */ MeasureArea.prototype._initialize = function (options) { @@ -160,6 +162,8 @@ MeasureArea.prototype._initialize = function (options) { /** * initialize component container (DOM) * + * @returns {DOMElement} DOM element + * * @private */ MeasureArea.prototype._initializeContainer = function () { diff --git a/src/OpenLayers/Controls/Measures/MeasureAzimuth.js b/src/OpenLayers/Controls/Measures/MeasureAzimuth.js index 16983bb27..7ff71e360 100644 --- a/src/OpenLayers/Controls/Measures/MeasureAzimuth.js +++ b/src/OpenLayers/Controls/Measures/MeasureAzimuth.js @@ -160,6 +160,8 @@ MeasureAzimuth.prototype.isGeodesic = function () { /** * Initialize measure control (called by constructor) * + * @param {Object} options - options + * * @private */ MeasureAzimuth.prototype._initialize = function (options) { @@ -178,6 +180,8 @@ MeasureAzimuth.prototype._initialize = function (options) { /** * initialize component container (DOM) * + * @returns {DOMElement} DOM element + * * @private */ MeasureAzimuth.prototype._initializeContainer = function () { diff --git a/src/OpenLayers/Controls/Measures/MeasureLength.js b/src/OpenLayers/Controls/Measures/MeasureLength.js index 689ce5268..dfcddc979 100644 --- a/src/OpenLayers/Controls/Measures/MeasureLength.js +++ b/src/OpenLayers/Controls/Measures/MeasureLength.js @@ -136,6 +136,8 @@ MeasureLength.prototype.setMap = function (map) { /** * Initialize measure control (called by constructor) * + * @param {Object} options - options + * * @private */ MeasureLength.prototype._initialize = function (options) { @@ -154,6 +156,8 @@ MeasureLength.prototype._initialize = function (options) { /** * initialize component container (DOM) * + * @returns {DOMElement} DOM element + * * @private */ MeasureLength.prototype._initializeContainer = function () { diff --git a/src/OpenLayers/Controls/Measures/Measures.js b/src/OpenLayers/Controls/Measures/Measures.js index 01ac8e26d..9a1606acd 100644 --- a/src/OpenLayers/Controls/Measures/Measures.js +++ b/src/OpenLayers/Controls/Measures/Measures.js @@ -393,7 +393,7 @@ var Measures = { var self = this; this.measureDraw = new ol.interaction.Draw({ source : this.measureSource, - /** condition : permet de gerer la suppression des derniers points saisis */ + // condition : permet de gerer la suppression des derniers points saisis condition : function (event) { if (event.originalEvent.ctrlKey) { if (self.sketch) { diff --git a/src/OpenLayers/Controls/MousePosition.js b/src/OpenLayers/Controls/MousePosition.js index 4ef3da9c4..eaf4a88b3 100644 --- a/src/OpenLayers/Controls/MousePosition.js +++ b/src/OpenLayers/Controls/MousePosition.js @@ -1,6 +1,5 @@ import ol from "ol"; import Gp from "gp"; -import Proj4 from "proj4"; import Logger from "../../Common/Utils/LoggerByDefault"; import Utils from "../../Common/Utils"; import Markers from "./Utils/Markers"; @@ -120,6 +119,9 @@ MousePosition.prototype.constructor = MousePosition; /** * Overload ol.control.Control setMap method, called when + * + * @param {Object} map - the map + * */ MousePosition.prototype.setMap = function (map) { var context = this; @@ -205,7 +207,7 @@ MousePosition.prototype.setMap = function (map) { */ MousePosition.prototype.addSystem = function (system) { if (typeof system !== "object") { - console.log("[ERROR] MousePosition:addSystem - system parameter should be an object"); + logger.log("[ERROR] MousePosition:addSystem - system parameter should be an object"); return; } if (!system.crs) { @@ -222,11 +224,9 @@ MousePosition.prototype.addSystem = function (system) { } // 1. add system to control systems - var found = false; for (var j = 0; j < this._projectionSystems.length; j++) { var obj = this._projectionSystems[j]; if (system.crs === obj.crs) { - found = true; // warn user logger.info("crs '{}' already configured", obj.crs); } @@ -257,7 +257,7 @@ MousePosition.prototype.addSystems = function (systems) { return; } if (!Array.isArray(systems)) { - console.log("[ERROR] MousePosition:addSystems - systems parameter should be an array"); + logger.log("[ERROR] MousePosition:addSystems - systems parameter should be an array"); return; } for (var i = 0; i < systems.length; i++) { @@ -272,7 +272,7 @@ MousePosition.prototype.addSystems = function (systems) { */ MousePosition.prototype.removeSystem = function (systemCrs) { if (!systemCrs || typeof systemCrs !== "string") { - console.log("[ERROR] MousePosition:removeSystem - systemCode parameter should be a string"); + logger.log("[ERROR] MousePosition:removeSystem - systemCode parameter should be a string"); return; } @@ -291,7 +291,7 @@ MousePosition.prototype.removeSystem = function (systemCrs) { } if (systemCode == null) { - console.log("[WARN] MousePosition:removeSystem - system not found"); + logger.log("[WARN] MousePosition:removeSystem - system not found"); return; } @@ -307,7 +307,7 @@ MousePosition.prototype.removeSystem = function (systemCrs) { var indexChildToRemove = null; for (var k = 0; k < systemList.childNodes.length; k++) { - if (systemCode == systemList.childNodes[j].value) { + if (systemCode === systemList.childNodes[j].value) { indexChildToRemove = k; continue; } @@ -318,8 +318,8 @@ MousePosition.prototype.removeSystem = function (systemCrs) { systemList.removeChild(systemList.childNodes[indexChildToRemove]); } - /* choose arbitrarily a new current system if needed */ - if (this._currentProjectionSystems.code == systemCode) { + // choose arbitrarily a new current system if needed + if (this._currentProjectionSystems.code === systemCode) { systemList.childNodes[0].setAttribute("selected", "selected"); this._setCurrentSystem(systemList.childNodes[0].value); } @@ -404,7 +404,7 @@ MousePosition.prototype.displayCoordinates = function (displayCoordinates) { */ MousePosition.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] MousePosition:setCollapsed - missing collapsed parameter"); + logger.log("[ERROR] MousePosition:setCollapsed - missing collapsed parameter"); return; } if ((collapsed && this.collapsed) || (!collapsed && !this.collapsed)) { @@ -547,7 +547,7 @@ MousePosition.prototype._initMarker = function (option) { if (Array.isArray(option.offset) && option.offset.length === 2) { this._markerOffset = option.offset; } else { - console.log("positionMarker.offset should be an array. e.g. : [0,0]"); + logger.log("positionMarker.offset should be an array. e.g. : [0,0]"); this._markerOffset = Markers.defaultOffset; } } else { @@ -702,6 +702,9 @@ MousePosition.prototype._initProjectionUnits = function () { * this method get label from the current projection units * * @method _getCurrentProjectionInformation + * + * @returns {String} projection information + * * @private */ MousePosition.prototype._getCurrentProjectionInformation = function () { @@ -753,6 +756,9 @@ MousePosition.prototype._checkRightsManagement = function () { * Create control main container (called by MousePosition constructor) * * @method _initContainer + * + * @returns {DOMElement} DOM element + * * @private */ MousePosition.prototype._initContainer = function () { @@ -1024,7 +1030,7 @@ MousePosition.prototype._setCoordinate = function (olCoordinate, crs) { // on projete le point dans le systeme demandé var oSrs = this._currentProjectionSystems.crs; if (!oSrs) { - console.log("ERROR : system crs not found"); + logger.log("ERROR : system crs not found"); return; } // on reprojette les coordonnées depuis leur CRS d'origine (CRS) vers le CRS demandé (oSrs) @@ -1043,7 +1049,7 @@ MousePosition.prototype._setCoordinate = function (olCoordinate, crs) { } } if (!format || typeof format !== "function") { - console.log("WARNING : coordinates format function not found"); + logger.log("WARNING : coordinates format function not found"); return; } else { coordinate = format(olCoordinate); @@ -1153,6 +1159,7 @@ MousePosition.prototype.onMapMove = function () { * * @method onRequestAltitude * @param {Object} coordinate - {lat:..., lng:...} + * @param {Function} callback - callback * @private */ MousePosition.prototype.onRequestAltitude = function (coordinate, callback) { @@ -1161,7 +1168,6 @@ MousePosition.prototype.onRequestAltitude = function (coordinate, callback) { // on met en place des callbacks afin de recuperer les resultats ou // les messages d'erreurs du service. // le resultat est affiché dans une balise du dom. - // les messages d'erreurs sont affichés sur la console (?) if (!coordinate || Object.keys(coordinate).length === 0) { return; @@ -1175,7 +1181,7 @@ MousePosition.prototype.onRequestAltitude = function (coordinate, callback) { // si on n'a pas les droits sur la ressource, pas la peine de // continuer ! if (this._noRightManagement) { - console.log("[WARNING] contract key configuration has no rights to load geoportal elevation "); + logger.log("[WARNING] contract key configuration has no rights to load geoportal elevation "); document.getElementById("GPmousePositionAlt-" + this._uid).innerHTML = "No rights!"; return; } @@ -1206,22 +1212,22 @@ MousePosition.prototype.onRequestAltitude = function (coordinate, callback) { if (!_rawResponse) { // dans le cas général - /** callback onSuccess */ + // callback onSuccess _onSuccess = function (results) { if (results && Object.keys(results)) { callback.call(this, results.elevations[0].z); } }; } else { - /** callback onSuccess */ + // callback onSuccess _onSuccess = function (results) { - console.log("alti service raw response : ", results); + logger.log("alti service raw response : ", results); }; } - /** callback onFailure */ + // callback onFailure _onFailure = function (error) { - console.log("[getAltitude] ERROR : " + error.message); + logger.log("[getAltitude] ERROR : " + error.message); }; // cas où la clef API n'est pas renseignée dans les options du service, @@ -1404,7 +1410,7 @@ MousePosition.prototype.locateDMSCoordinates = function () { var oSrs = this._currentProjectionSystems.crs; if (!oSrs) { - console.log("ERROR : system crs not found"); + logger.log("ERROR : system crs not found"); return; } @@ -1442,7 +1448,7 @@ MousePosition.prototype.locateCoordinates = function () { var oSrs = this._currentProjectionSystems.crs; if (!oSrs) { - console.log("ERROR : system crs not found"); + logger.log("ERROR : system crs not found"); return; } @@ -1517,14 +1523,14 @@ MousePosition.prototype.onMousePositionProjectionSystemChange = function (e) { * this method selects the current system projection. * * @method _setCurrentSystem - * @param {Object} systemCode - inner code (rank in array _projectionSystems) + * @param {String} systemCode - inner code (rank in array _projectionSystems) * @private */ MousePosition.prototype._setCurrentSystem = function (systemCode) { // si on change de type de systeme, on doit aussi changer le type d'unités ! var type = null; for (var i = 0; i < this._projectionSystems.length; ++i) { - if (this._projectionSystems[i].code == systemCode) { + if (this._projectionSystems[i].code === systemCode) { type = this._projectionSystems[i].type; break; } @@ -1672,7 +1678,9 @@ MousePosition.prototype.convert = function (value) { /** * @param {String} coordType - "Lon" or "Lat" * @param {String} value - input value - * @returns {Boolean} + * + * @returns {Boolean} value is within extent + * * @private */ MousePosition.prototype.validateExtentCoordinate = function (coordType, value) { diff --git a/src/OpenLayers/Controls/ReverseGeocode.js b/src/OpenLayers/Controls/ReverseGeocode.js index cc01bb970..17fe1c5be 100644 --- a/src/OpenLayers/Controls/ReverseGeocode.js +++ b/src/OpenLayers/Controls/ReverseGeocode.js @@ -99,7 +99,7 @@ ReverseGeocode.prototype.getCollapsed = function () { */ ReverseGeocode.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] ReverseGeocode:setCollapsed - missing collapsed parameter"); + logger.log("[ERROR] ReverseGeocode:setCollapsed - missing collapsed parameter"); return; } if ((collapsed && this.collapsed) || (!collapsed && !this.collapsed)) { @@ -275,6 +275,8 @@ ReverseGeocode.prototype.initialize = function (options) { * this method is called by this.initialize() * and makes sure input options are correctly formated * + * @param {Object} options - options + * * @private */ ReverseGeocode.prototype._checkInputOptions = function (options) { @@ -286,7 +288,7 @@ ReverseGeocode.prototype._checkInputOptions = function (options) { var resources = options.resources; // on vérifie que la liste des ressources de geocodage est bien un tableau if (!Array.isArray(resources)) { - console.log("[ReverseGeocode] 'options.resources' parameter should be an array"); + logger.log("[ReverseGeocode] 'options.resources' parameter should be an array"); resources = null; } var resourcesList = ["StreetAddress", "PositionOfInterest", "CadastralParcel", "Administratif"]; @@ -295,7 +297,7 @@ ReverseGeocode.prototype._checkInputOptions = function (options) { if (resourcesList.indexOf(resources[i]) === -1) { // si la resource n'est pas référencée, on stocke son index pour la retirer du tableau (après avoir terminé de parcourir le tableau) wrongResourcesIndexes.push(i); - console.log("[ReverseGeocode] options.resources : " + resources[i] + " is not a resource for reverse geocode"); + logger.log("[ReverseGeocode] options.resources : " + resources[i] + " is not a resource for reverse geocode"); } } // on retire les ressoures non référencées qu'on a pu rencontrer @@ -311,7 +313,7 @@ ReverseGeocode.prototype._checkInputOptions = function (options) { var delimitations = options.delimitations; // on vérifie que la liste des delimitations est bien un tableau if (!Array.isArray(delimitations)) { - console.log("[ReverseGeocode] 'options.delimitations' parameter should be an array"); + logger.log("[ReverseGeocode] 'options.delimitations' parameter should be an array"); delimitations = null; } var delimitationsList = ["Circle", "Point", "Extent"]; @@ -320,7 +322,7 @@ ReverseGeocode.prototype._checkInputOptions = function (options) { if (delimitationsList.indexOf(delimitations[i]) === -1) { // si la delimitations n'est pas référencée, on stocke son index pour la retirer du tableau (après avoir terminé de parcourir le tableau) wrongDelimitationsIndexes.push(i); - console.log("[ReverseGeocode] options.delimitations : " + delimitations[i] + " is not a delimitation for reverse geocode"); + logger.log("[ReverseGeocode] options.delimitations : " + delimitations[i] + " is not a delimitation for reverse geocode"); } } // on retire les ressoures non référencées qu'on a pu rencontrer @@ -356,7 +358,7 @@ ReverseGeocode.prototype._initGeocodingType = function () { if (this._servicesRightManagement["Geocode"].indexOf(resources[i]) < 0) { // si on n'a pas les droits sur la ressource, on va la supprimer : on stocke son index noRightsIndexes.push(i); - console.log("[ReverseGeocode] no rights for options.resources : " + resources[i]); + logger.log("[ReverseGeocode] no rights for options.resources : " + resources[i]); } } // on retire les ressoures non autorisées qu'on a pu rencontrer @@ -418,7 +420,7 @@ ReverseGeocode.prototype._initPopupDiv = function () { var closer = document.createElement("input"); closer.type = "button"; closer.className = "gp-styling-button closer"; - /** on closer click : remove popup */ + // on closer click : remove popup closer.onclick = function () { if (context._popupOverlay != null) { context._popupOverlay.setPosition(undefined); @@ -487,6 +489,8 @@ ReverseGeocode.prototype._checkRightsManagement = function () { /** * Create control main container (DOM initialize) * + * @returns {DOMElement} DOM element + * * @private */ ReverseGeocode.prototype._initContainer = function () { @@ -755,7 +759,7 @@ ReverseGeocode.prototype._activateBoxInteraction = function (map) { // on aura donc une géométrie LineString avec 5 coordonnées : start, point2, end, point4, start, // où les coordonnées de point2 et point4 sont calculées à partir de start et end, et start est répété à la fin pour fermer la géométrie. - /** function to draw rectangle with only 2 points */ + // function to draw rectangle with only 2 points var geometryFunction = function (coordinates, geometry) { if (!geometry) { geometry = new ol.geom.Polygon(null); @@ -1003,14 +1007,14 @@ ReverseGeocode.prototype._getReverseGeocodingRequestOptions = function () { maximumResponses : reverseGeocodeOptions.maximumResponses || 25, timeOut : reverseGeocodeOptions.timeOut || 30000, protocol : reverseGeocodeOptions.protocol || "XHR", - /** callback onSuccess */ + // callback onSuccess onSuccess : function (response) { if (response.locations) { logger.log("reverseGeocode results : ", response.locations); context._displayGeocodedLocations(response.locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME mise à jour du controle mais le service ne repond pas en 200 !? @@ -1032,7 +1036,7 @@ ReverseGeocode.prototype._getReverseGeocodingRequestOptions = function () { if (this._currentGeocodingDelimitation.toLowerCase() === "circle" && this._requestCircleFilter) { // FIXME : a confirmer ! if (this._requestCircleFilter.radius > 1000) { - console.log("INFO : initial circle radius (" + this._requestCircleFilter.radius + ") limited to 1000m."); + logger.log("INFO : initial circle radius (" + this._requestCircleFilter.radius + ") limited to 1000m."); this._requestCircleFilter.radius = 1000; } requestOptions.filterOptions.circle = this._requestCircleFilter; diff --git a/src/OpenLayers/Controls/Route.js b/src/OpenLayers/Controls/Route.js index 378104781..1057dc228 100644 --- a/src/OpenLayers/Controls/Route.js +++ b/src/OpenLayers/Controls/Route.js @@ -122,7 +122,7 @@ Route.prototype.getCollapsed = function () { */ Route.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] Route:setCollapsed - missing collapsed parameter"); + logger.log("[ERROR] Route:setCollapsed - missing collapsed parameter"); return; } if ((collapsed && this.collapsed) || (!collapsed && !this.collapsed)) { @@ -294,6 +294,8 @@ Route.prototype.initialize = function (options) { /** * this method is called by this.initialize() * + * @param {Object} options - options + * * @private */ Route.prototype._checkInputOptions = function (options) { @@ -307,7 +309,7 @@ Route.prototype._checkInputOptions = function (options) { } else { for (var i = 0; i < options.graphs.length; i++) { if (typeof options.graphs[i] !== "string") { - console.log("[ol.control.Route] ERROR : parameter 'graphs' elements should be of type 'string'"); + logger.log("[ol.control.Route] ERROR : parameter 'graphs' elements should be of type 'string'"); options.graphs = null; } else { if (options.graphs[i].toLowerCase() === "pieton") { @@ -400,6 +402,10 @@ Route.prototype._checkRightsManagement = function () { /** * initialize component container (DOM) * + * @param {Object} map - the map + * + * @returns {DOMElement} DOM element + * * @private */ Route.prototype._initContainer = function (map) { @@ -468,7 +474,7 @@ Route.prototype._initContainer = function (map) { // hide autocomplete suggested locations on container click if (container.addEventListener) { container.addEventListener("click", function (e) { - context._hideRouteSuggestedLocations.call(context, e); + context._hideRouteSuggestedLocations(e); }); } @@ -578,7 +584,7 @@ Route.prototype._initPopupDiv = function () { var closer = document.createElement("input"); closer.type = "button"; closer.className = "gp-styling-button closer"; - /** on closer click : remove popup */ + // on closer click : remove popup closer.onclick = function () { if (context._popupOverlay != null) { context._popupOverlay.setPosition(undefined); @@ -601,6 +607,8 @@ Route.prototype._initPopupDiv = function () { * Create List Points * Overwrite RouteDOM method ! * + * @param {Object} map - the map + * * @returns {Array} List DOM element * @private */ @@ -849,14 +857,14 @@ Route.prototype.onRouteComputationSubmit = function (options) { distanceUnit : "m", timeOut : _timeout, protocol : _protocol, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { context._fillRouteResultsDetails(results); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { context._hideWaitingContainer(); context._clearRouteResultsDetails(); @@ -1197,7 +1205,7 @@ Route.prototype._requestRouting = function (options) { // on fait quoi ? if (!bFound) { - console.log("no rights for this service !?"); + logger.log("no rights for this service !?"); return; } @@ -1219,6 +1227,8 @@ Route.prototype._requestRouting = function (options) { * and fills the container of the route instructions list, distance and time * information, also, constructs the geometry route. * + * @param {Object} results - results of the route calculation + * * @private */ Route.prototype._fillRouteResultsDetails = function (results) { @@ -1272,6 +1282,10 @@ Route.prototype._fillRouteResultsDetails = function (results) { * and fills the container of the route instructions list, distance and time * information. * + * @param {Number} distance - distance + * @param {Number} duration - duration + * @param {Object[]} instructions - list of instructions + * * @private */ Route.prototype._fillRouteResultsDetailsContainer = function (distance, duration, instructions) { @@ -1465,6 +1479,8 @@ Route.prototype._fillRouteResultsDetailsFeatureGeometry = function (instructions * this method is called on route features hover * and highlight instruction label * + * @param {Object} e - event + * * @private */ Route.prototype._onResultsFeatureMouseOver = function (e) { @@ -1620,7 +1636,6 @@ Route.prototype._clearRouteInputOptions = function () { */ Route.prototype._removeRouteStepLocations = function () { var points = document.querySelectorAll("div[id^=\"GPlocationPoint\"]"); - var stepPoints = 0; if (points.length !== 0) { // on boucle sur les points intermédiaires for (var i = 1; i < (points.length - 1); i++) { @@ -1631,7 +1646,6 @@ Route.prototype._removeRouteStepLocations = function () { if (classList[j] === "GPlocationStageFlexInput") { // si l'élément est visible, on le supprime en simulant un clic sur la croix (x) document.getElementById(this._addUID("GPlocationStageRemove_" + (i + 1))).click(); - stepPoints += 1; } } } @@ -1718,6 +1732,8 @@ Route.prototype._clearRouteResultsFeatureGeometry = function () { * this method is called by event 'click' on control main container * and hide suggested Locations (unless target is an autocomplete input) * + * @param {Object} e - event + * * @private */ Route.prototype._hideRouteSuggestedLocations = function (e) { @@ -1794,6 +1810,10 @@ Route.prototype._hideWaitingContainer = function () { /** * simplified instructions * + * @param {Object[]} instructions - list of instructions + * + * @returns {Object[]} simplified instructions + * * @private */ Route.prototype._simplifiedInstructions = function (instructions) { @@ -1834,6 +1854,10 @@ Route.prototype._simplifiedInstructions = function (instructions) { /** * convert seconds to time : HH:MM:SS * + * @param {Number} duration - duration in seconds + * + * @returns {String} time in hours/minutes/seconds + * * @private */ Route.prototype._convertSecondsToTime = function (duration) { @@ -1864,6 +1888,10 @@ Route.prototype._convertSecondsToTime = function (duration) { /** * convert distance in meters or kilometers * + * @param {Number} distance - distance in meters + * + * @returns {String} distance in km + * * @private */ Route.prototype._convertDistance = function (distance) { diff --git a/src/OpenLayers/Controls/SearchEngine.js b/src/OpenLayers/Controls/SearchEngine.js index bcc8ab2ea..1b98104a4 100644 --- a/src/OpenLayers/Controls/SearchEngine.js +++ b/src/OpenLayers/Controls/SearchEngine.js @@ -138,7 +138,7 @@ SearchEngine.prototype.getCollapsed = function () { */ SearchEngine.prototype.setCollapsed = function (collapsed) { if (collapsed === undefined) { - console.log("[ERROR] SearchEngine:setCollapsed - missing collapsed parameter"); + logger.log("[ERROR] SearchEngine:setCollapsed - missing collapsed parameter"); return; } if ((collapsed && this.collapsed) || (!collapsed && !this.collapsed)) { @@ -272,6 +272,8 @@ SearchEngine.prototype.initialize = function (options) { * this method is called by this.initialize() * and makes sure input options are correctly formated * + * @param {Object} options - options + * * @private */ SearchEngine.prototype._checkInputOptions = function (options) { @@ -285,7 +287,7 @@ SearchEngine.prototype._checkInputOptions = function (options) { if (geocodeResources) { // on vérifie que la liste des ressources de geocodage est bien un tableau if (!Array.isArray(geocodeResources)) { - console.log("[SearchEngine] 'options.resources.geocode' parameter should be an array"); + logger.log("[SearchEngine] 'options.resources.geocode' parameter should be an array"); geocodeResources = null; } var geocodeResourcesList = ["StreetAddress", "PositionOfInterest", "CadastralParcel", "Administratif"]; @@ -293,7 +295,7 @@ SearchEngine.prototype._checkInputOptions = function (options) { if (geocodeResourcesList.indexOf(geocodeResources[i]) === -1) { // si la resource n'est pas référencée, on l'enlève // geocodeResources.splice(i, 1); - console.log("[SearchEngine] options.resources.geocode : " + geocodeResources[i] + " is not a resource for geocode"); + logger.log("[SearchEngine] options.resources.geocode : " + geocodeResources[i] + " is not a resource for geocode"); } } } @@ -303,7 +305,7 @@ SearchEngine.prototype._checkInputOptions = function (options) { if (autocompleteResources) { // on vérifie que la liste des ressources d'autocompletion est bien un tableau if (!Array.isArray(autocompleteResources)) { - console.log("[SearchEngine] 'options.resources.autocomplete' parameter should be an array"); + logger.log("[SearchEngine] 'options.resources.autocomplete' parameter should be an array"); autocompleteResources = null; } var autocompleteResourcesList = ["StreetAddress", "PositionOfInterest"]; @@ -311,12 +313,12 @@ SearchEngine.prototype._checkInputOptions = function (options) { if (autocompleteResourcesList.indexOf(autocompleteResources[i]) === -1) { // si la resource n'est pas référencée, on l'enlève // autocompleteResources.splice(i, 1); - console.log("[SearchEngine] options.resources.autocomplete : " + autocompleteResources[i] + " is not a resource for autocomplete"); + logger.log("[SearchEngine] options.resources.autocomplete : " + autocompleteResources[i] + " is not a resource for autocomplete"); } } } } else { - console.log("[SearchEngine] 'resources' parameter should be an object"); + logger.log("[SearchEngine] 'resources' parameter should be an object"); options.resources = null; } } @@ -412,7 +414,7 @@ SearchEngine.prototype._initPopupDiv = function () { var closer = document.createElement("input"); closer.type = "button"; closer.className = "gp-styling-button closer"; - /** on closer click : remove popup */ + // on closer click : remove popup closer.onclick = function () { if (context._popupOverlay != null) { context._popupOverlay.setPosition(undefined); @@ -435,6 +437,8 @@ SearchEngine.prototype._initPopupDiv = function () { /** * Create control main container * + * @returns {DOMElement} DOM element + * * @private */ SearchEngine.prototype._initContainer = function () { @@ -511,6 +515,8 @@ SearchEngine.prototype._initContainer = function () { * to the geocoding advanced menu. * * @param {String} code - resource geocoding name + * + * @returns {DOMElement} DOM element * @private */ SearchEngine.prototype._setFilter = function (code) { @@ -820,6 +826,8 @@ SearchEngine.prototype._requestGeocoding = function (settings) { * it creates a HTML Element per location * (cf. this. ...) * + * @param {Object[]} locations - locations + * * @private */ SearchEngine.prototype._fillGeocodedLocationListContainer = function (locations) { @@ -880,6 +888,7 @@ SearchEngine.prototype._setPosition = function (position, zoom) { * FIXME * * @param {Array} position - ol.Coordinate object [lon, lat] ou [x, y] + * @param {Object} info - location information * @private */ SearchEngine.prototype._setMarker = function (position, info) { @@ -930,7 +939,9 @@ SearchEngine.prototype._setMarker = function (position, info) { * this method is called by this.on*ResultsItemClick() * and get zoom to results. * - * @param {Object} info - {} + * @param {Object} info - info + * + * @returns {Integer} zoom * @private */ SearchEngine.prototype._getZoom = function (info) { @@ -1113,7 +1124,7 @@ SearchEngine.prototype.onAutoCompleteSearchText = function (e) { // aucun droits ! // on evite une requête... if (this._noRightManagement) { - console.log("no rights for this service !"); + logger.log("no rights for this service !"); return; } @@ -1134,11 +1145,10 @@ SearchEngine.prototype.onAutoCompleteSearchText = function (e) { // on met en place des callbacks afin de recuperer les resultats ou // les messages d'erreurs du service. // les resultats sont affichés dans une liste deroulante. - // les messages d'erreurs sont affichés sur la console (?) var context = this; this._requestAutoComplete({ text : value, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log("request from AutoComplete", results); if (results) { @@ -1167,7 +1177,7 @@ SearchEngine.prototype.onAutoCompleteSearchText = function (e) { } } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME // où affiche t on les messages : ex. 'No suggestion matching the search' ? @@ -1186,7 +1196,7 @@ SearchEngine.prototype.onAutoCompleteSearchText = function (e) { context._requestGeocoding({ location : value, returnFreeForm : true, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log("request from Geocoding", results); if (results) { @@ -1206,7 +1216,7 @@ SearchEngine.prototype.onAutoCompleteSearchText = function (e) { context._fillAutoCompletedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { logger.log(error.message); } @@ -1248,7 +1258,7 @@ SearchEngine.prototype._getGeocodeCoordinatesFromFullText = function (suggestedL filterOptions : { type : suggestedLocation.type }, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (response) { logger.log("request from Geocoding (coordinates null)", response); if (response.locations && response.locations.length !== 0 && response.locations[0].position) { @@ -1352,7 +1362,7 @@ SearchEngine.prototype.onGeocodingSearchSubmit = function (e) { // aucun droits ! // on evite une requête... if (this._noRightManagement) { - console.log("no rights for this service !"); + logger.log("no rights for this service !"); return; } @@ -1363,7 +1373,7 @@ SearchEngine.prototype.onGeocodingSearchSubmit = function (e) { var context = this; this._requestGeocoding({ location : value, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log("request from Geocoding", results); if (results) { @@ -1371,7 +1381,7 @@ SearchEngine.prototype.onGeocodingSearchSubmit = function (e) { context._fillGeocodedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME cf. this.onAutoCompleteSearch() context._clearGeocodedLocation(); @@ -1520,7 +1530,7 @@ SearchEngine.prototype.onGeocodingAdvancedSearchSubmit = function (e, data) { this._requestGeocoding({ location : _location, filterOptions : _filterOptions, - /** callback onSuccess */ + // callback onSuccess onSuccess : function (results) { logger.log(results); if (results) { @@ -1528,7 +1538,7 @@ SearchEngine.prototype.onGeocodingAdvancedSearchSubmit = function (e, data) { context._fillGeocodedLocationListContainer(locations); } }, - /** callback onFailure */ + // callback onFailure onFailure : function (error) { // FIXME cf. this.onAutoCompleteSearch() context._clearGeocodedLocation(); @@ -1583,9 +1593,9 @@ SearchEngine.prototype._getCadastralParcelRequestParams = function (filterOption l = commune.length; if (l === 3) { _location += commune; - } else if (l == 2) { + } else if (l === 2) { _location += "_" + commune; - } else if (l == 1) { + } else if (l === 1) { _location += "__" + commune; } else { // l > 3 _location += commune.substring(0, 3); diff --git a/src/OpenLayers/Controls/Utils/Interactions.js b/src/OpenLayers/Controls/Utils/Interactions.js index c18b443f0..6e9f80920 100644 --- a/src/OpenLayers/Controls/Utils/Interactions.js +++ b/src/OpenLayers/Controls/Utils/Interactions.js @@ -63,6 +63,9 @@ var Interactions = { * sauf l'interaction courrante (si elle est renseignée avec l'option 'current'). * Il est possible d'ajouter des fonctionnalités via les options. * Par defaut, l'option 'clean' est renseignée... + * + * @param {Object} map - the map + * @param {Object} options - options */ unset : function (map, options) { logger.trace("unset()"); diff --git a/src/OpenLayers/Formats/KML.js b/src/OpenLayers/Formats/KML.js index 39becc013..815c730b1 100644 --- a/src/OpenLayers/Formats/KML.js +++ b/src/OpenLayers/Formats/KML.js @@ -83,6 +83,10 @@ KML.prototype.constructor = KML; /** * Fonction d'indentation d'une chaine de caractères KML ou XML * cf. https://stackoverflow.com/questions/376373/pretty-printing-xml-with-javascript/ + * + * @param {String} xml - xml + * + * @returns {String} kml string */ function _kmlFormattedToString (xml) { var reg = /(>)\s*(<)(\/*)/g; // updated Mar 30, 2015 @@ -127,7 +131,7 @@ function _kmlFormattedToString (xml) { for (var j = 0; j < indent; j++) { padding += "\t"; } - if (fromTo == "opening->closing") { + if (fromTo === "opening->closing") { formatted = formatted.substr(0, formatted.length - 1) + ln + "\n"; // substr removes line break (\n) from prev loop } else { formatted += padding + ln + "\n"; @@ -140,6 +144,10 @@ function _kmlFormattedToString (xml) { /** * Fonction de parsing d'une chaine de caractères KML + * + * @param {String} kmlString - kml string + * + * @returns {DOMElement} kml document */ function _kmlParse (kmlString) { var kmlDoc = null; @@ -161,7 +169,7 @@ function _kmlParse (kmlString) { kmlDoc.async = false; kmlDoc.loadXML(kmlString); } else { - console.log("Incompatible environment for DOM Parser !"); + logger.log("Incompatible environment for DOM Parser !"); } logger.trace(kmlDoc); @@ -170,6 +178,10 @@ function _kmlParse (kmlString) { /** * Fonction de convertion en chaine de caractères. + * + * @param {DOMElement} kmlDoc - kml document + * + * @returns {String} kml string */ function _kmlToString (kmlDoc) { var oSerializer = new XMLSerializer(); @@ -186,6 +198,10 @@ function _kmlToString (kmlDoc) { * - creation de styles étendus ou correctifs sur le KML * - ajout de styles étendus sur les features * + * @param {DOMElement} kmlDoc - kml document + * @param {Object[]} features - features + * @param {Object} process - process + * * @example * // ajoute des fonctionnalités dans le KML * _kmlRead(kmlDoc, { @@ -320,18 +336,14 @@ function _kmlRead (kmlDoc, features, process) { if (fctLabel && typeof fctLabel === "function") { fctLabel(features[index], labelStyle); } - } - // C'est uniquement un marker ! - else if (iconStyle && !labelStyle) { + } else if (iconStyle && !labelStyle) { var fctIcon = process.iconStyle; if (fctIcon && typeof fctIcon === "function") { fctIcon(features[index], iconStyle); } - } - // C'est un marker avec un label ! - else if (iconStyle && labelStyle) { + } else if (iconStyle && labelStyle) { var fctIconLabel = process.iconLabelStyle; if (fctIconLabel && typeof fctIconLabel === "function") { fctIconLabel(features[index], iconStyle, labelStyle); @@ -352,8 +364,9 @@ function _kmlRead (kmlDoc, features, process) { * This function overloads ol.format.KML.writeFeatures ... * * @see ol.format.KML.prototype.writeFeatures - * @param {Array.} features - Features. + * @param {Object[]} features - Features. * @param {Object} options - Options. + * * @return {String} Result. */ KML.prototype.writeFeatures = function (features, options) { @@ -366,6 +379,11 @@ KML.prototype.writeFeatures = function (features, options) { /** * _writeExtendStylesFeatures * + * @param {Object[]} features - features + * @param {Object} options - options + * + * @returns {String} kml string formatted + * * @private */ KML.prototype._writeExtendStylesFeatures = function (features, options) { @@ -385,6 +403,9 @@ KML.prototype._writeExtendStylesFeatures = function (features, options) { * On va donc y ajouter qq styles sur le Label (police, halo, ...) : * Insertion : PlaceMark>Style>LabelStyle * + * @param {Object} feature - feature + * @param {DOMElement} style - style + * * @example * */ @@ -400,7 +421,7 @@ KML.prototype._writeExtendStylesFeatures = function (features, options) { return; } - /** RGB Colors (RRGGBB) To KML Colors (AABBGGRR) */ + // RGB Colors (RRGGBB) To KML Colors (AABBGGRR) function __convertRGBColorsToKML (data) { var strColor = data.toString(16); @@ -450,6 +471,9 @@ KML.prototype._writeExtendStylesFeatures = function (features, options) { * - PIXELS * Insertion du correctif dans le noeud :