Skip to content

Commit

Permalink
Merge pull request #4411 from camptocamp/rm_ol_obj_assign
Browse files Browse the repository at this point in the history
Stop using 'assign' function from ol
  • Loading branch information
fredj committed Nov 26, 2018
2 parents 87f68d7 + 2fea1d2 commit 76d61c1
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 75 deletions.
5 changes: 2 additions & 3 deletions contribs/gmf/src/contextualdata/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import googAsserts from 'goog/asserts.js';
import olOverlay from 'ol/Overlay.js';
import * as olProj from 'ol/proj.js';
import * as olEvents from 'ol/events.js';
import * as olObj from 'ol/obj.js';

/**
* @type {angular.IModule}
Expand Down Expand Up @@ -188,9 +187,9 @@ exports.Controller_.prototype.setContent_ = function(coordinate) {
});

const getRasterSuccess = function(resp) {
olObj.assign(scope, resp);
Object.assign(scope, resp);
if (this.callback) {
olObj.assign(scope, this.callback.call(this, coordinate, resp));
Object.assign(scope, this.callback.call(this, coordinate, resp));
}
}.bind(this);
const getRasterError = function(resp) {
Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/src/controllers/AbstractAPIController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ngeoQueryBboxQueryComponent from 'ngeo/query/bboxQueryComponent.js';
import ngeoMapResizemap from 'ngeo/map/resizemap.js';
import {inherits as olUtilInherits} from 'ol/util.js';
import * as olProj from 'ol/proj.js';
import * as olObj from 'ol/obj.js';
import olMap from 'ol/Map.js';
import olView from 'ol/View.js';
import olControlScaleLine from 'ol/control/ScaleLine.js';
Expand Down Expand Up @@ -34,7 +33,7 @@ const exports = function(config, $scope, $injector) {
const viewConfig = {
projection: olProj.get(`EPSG:${config.srid || 21781}`)
};
olObj.assign(viewConfig, config.mapViewConfig || {});
Object.assign(viewConfig, config.mapViewConfig || {});

const arrow = gmfControllersAbstractAppController.prototype.getLocationIcon();

Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/src/controllers/AbstractMobileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import gmfMobileNavigationModule from 'gmf/mobile/navigation/module.js';
import gmfQueryWindowComponent from 'gmf/query/windowComponent.js';
import ngeoGeolocationMobile from 'ngeo/geolocation/mobile.js';
import {inherits as olUtilInherits} from 'ol/util.js';
import * as olObj from 'ol/obj.js';
import * as olProj from 'ol/proj.js';
import olMap from 'ol/Map.js';
import olView from 'ol/View.js';
Expand Down Expand Up @@ -95,7 +94,7 @@ const exports = function(config, $scope, $injector) {
const viewConfig = {
projection: olProj.get(`EPSG:${config.srid || 21781}`)
};
olObj.assign(viewConfig, config.mapViewConfig || {});
Object.assign(viewConfig, config.mapViewConfig || {});

const arrow = gmfControllersAbstractAppController.prototype.getLocationIcon();

Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/src/datasource/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import gmfEditingEnumerateAttribute from 'gmf/editing/EnumerateAttribute.js';
import ngeoDatasourceHelper from 'ngeo/datasource/Helper.js';
import ngeoFormatAttributeType from 'ngeo/format/AttributeType.js';
import * as olArray from 'ol/array.js';

const exports = class {

Expand Down Expand Up @@ -104,7 +103,7 @@ const exports = class {
if (enumAttributes && enumAttributes.length) {
const promises = [];
for (const attribute of attributes) {
if (olArray.includes(enumAttributes, attribute.name) &&
if (enumAttributes.includes(attribute.name) &&
attribute.type !== ngeoFormatAttributeType.SELECT &&
(!attribute.choices || !attribute.choices.length)) {
promises.push(
Expand Down
5 changes: 2 additions & 3 deletions contribs/gmf/src/drawing/drawFeatureComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import ngeoMiscFeatureHelper from 'ngeo/misc/FeatureHelper.js';
import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate.js';
import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr.js';
import {getUid as olUtilGetUid} from 'ol/util.js';
import * as olArray from 'ol/array.js';
import * as olEvents from 'ol/events.js';
import olCollection from 'ol/Collection.js';
import olStyleFill from 'ol/style/Fill.js';
Expand Down Expand Up @@ -590,7 +589,7 @@ exports.Controller_.prototype.handleMapClick_ = function(evt) {
pixel,
(feature) => {
let ret = false;
if (olArray.includes(this.features.getArray(), feature)) {
if (this.features.getArray().includes(feature)) {
ret = feature;
}
return ret;
Expand Down Expand Up @@ -646,7 +645,7 @@ exports.Controller_.prototype.handleMapContextMenu_ = function(evt) {
pixel,
(feature) => {
let ret = false;
if (olArray.includes(this.features.getArray(), feature)) {
if (this.features.getArray().includes(feature)) {
ret = feature;
}
return ret;
Expand Down
5 changes: 2 additions & 3 deletions contribs/gmf/src/editing/editFeatureComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate.js';
import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr.js';

import {getUid as olUtilGetUid} from 'ol/util.js';
import * as olArray from 'ol/array.js';
import olCollection from 'ol/Collection.js';
import * as olEvents from 'ol/events.js';
import * as olExtent from 'ol/extent.js';
Expand Down Expand Up @@ -1006,7 +1005,7 @@ exports.Controller_.prototype.handleMapClick_ = function(evt) {
pixel,
(feature) => {
let ret = false;
if (olArray.includes(this.features.getArray(), feature)) {
if (this.features.getArray().includes(feature)) {
ret = feature;
}
return ret;
Expand Down Expand Up @@ -1060,7 +1059,7 @@ exports.Controller_.prototype.handleMapContextMenu_ = function(evt) {
pixel,
(feature) => {
let ret = false;
if (olArray.includes(this.features.getArray(), feature)) {
if (this.features.getArray().includes(feature)) {
ret = feature;
}
return ret;
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/filters/filterselectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ exports.Controller_ = class {
const msgs = [];

// (1) The name of the DS must be in list of filtrable layer node names
if (olArray.includes(names, dataSource.name)) {
if (names.includes(dataSource.name)) {

// (2) The DS must support WFS
if (!dataSource.supportsWFS) {
Expand Down Expand Up @@ -594,7 +594,7 @@ exports.Controller_ = class {
dataSource.gmfLayer.metadata.directedFilterAttributes;
const attributes = googAsserts.assert(dataSource.attributes);
for (const attribute of attributes) {
if (olArray.includes(directedAttributes, attribute.name)) {
if (directedAttributes.includes(attribute.name)) {
item.directedRules.push(
this.ngeoRuleHelper_.createRuleFromAttribute(attribute)
);
Expand Down
6 changes: 2 additions & 4 deletions contribs/gmf/src/layertree/TreeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import ngeoLayertreeController from 'ngeo/layertree/Controller.js';
import ngeoMessageMessage from 'ngeo/message/Message.js';
import ngeoMessageNotification from 'ngeo/message/Notification.js';
import ngeoStatemanagerService from 'ngeo/statemanager/Service.js';
import * as olArray from 'ol/array.js';
import * as olEvents from 'ol/events.js';
import * as olObj from 'ol/obj.js';

/**
* Manage a tree with children. This service can be used in mode 'flush'
Expand Down Expand Up @@ -404,7 +402,7 @@ exports.prototype.removeAll = function() {
* @private
*/
exports.prototype.cloneGroupNode_ = function(group, names) {
const clone = /** @type {gmfThemes.GmfGroup} */ (olObj.assign({}, group));
const clone = /** @type {gmfThemes.GmfGroup} */ (Object.assign({}, group));
this.toggleNodeCheck_(clone, names);
return clone;
};
Expand All @@ -426,7 +424,7 @@ exports.prototype.toggleNodeCheck_ = function(node, names) {
if (childNode.children) {
this.toggleNodeCheck_(childNode, names);
} else if (childNode.metadata) {
childNode.metadata.isChecked = olArray.includes(names, childNode.name);
childNode.metadata.isChecked = names.includes(childNode.name);
}
});
};
Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/src/permalink/Permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import ngeoStatemanagerService from 'ngeo/statemanager/Service.js';
import ngeoLayertreeController from 'ngeo/layertree/Controller.js';
import googAsserts from 'goog/asserts.js';
import {getUid as olUtilGetUid} from 'ol/util.js';
import * as olArray from 'ol/array.js';
import * as olEvents from 'ol/events.js';
import olFeature from 'ol/Feature.js';
import olGeomMultiPoint from 'ol/geom/MultiPoint.js';
Expand Down Expand Up @@ -1016,7 +1015,7 @@ exports.prototype.initLayers_ = function() {
const groupLayersArray = groupLayers == '' ? [] : groupLayers.split(',');
treeCtrl.traverseDepthFirst((treeCtrl) => {
if (treeCtrl.node.children === undefined) {
const enable = olArray.includes(groupLayersArray, treeCtrl.node.name);
const enable = groupLayersArray.includes(treeCtrl.node.name);
if (enable) {
groupLayersArray.splice(groupLayersArray.indexOf(treeCtrl.node.name), 1);
}
Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/src/print/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import ngeoMiscFeatureHelper from 'ngeo/misc/FeatureHelper.js';
import ngeoPrintService from 'ngeo/print/Service.js';
import ngeoPrintUtils from 'ngeo/print/Utils.js';
import ngeoQueryMapQuerent from 'ngeo/query/MapQuerent.js';
import * as olArray from 'ol/array.js';
import * as olEvents from 'ol/events.js';
import olLayerImage from 'ol/layer/Image.js';
import olLayerTile from 'ol/layer/Tile.js';
Expand Down Expand Up @@ -580,7 +579,7 @@ exports.Controller_ = class {
googAsserts.assert(this.layoutInfo.scales);
googAsserts.assert(this.layoutInfo.scale !== undefined);
if (!this.scaleManuallySelected_ &&
(this.layoutInfo.scale === -1 || olArray.includes(this.layoutInfo.scales, this.layoutInfo.scale))) {
(this.layoutInfo.scale === -1 || this.layoutInfo.scales.includes(this.layoutInfo.scale))) {
const mapSize = frameState.size;
const viewResolution = frameState.viewState.resolution;
this.layoutInfo.scale = this.getOptimalScale_(mapSize, viewResolution);
Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/src/profile/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import olFeature from 'ol/Feature.js';
import olOverlay from 'ol/Overlay.js';
import olGeomLineString from 'ol/geom/LineString.js';
import olGeomPoint from 'ol/geom/Point.js';
import * as olObj from 'ol/obj.js';
import olStyleCircle from 'ol/style/Circle.js';
import olStyleFill from 'ol/style/Fill.js';
import olStyleStyle from 'ol/style/Style.js';
Expand Down Expand Up @@ -367,7 +366,7 @@ exports.Controller_.prototype.$onInit = function() {
if (optionsFn) {
const options = optionsFn();
googAsserts.assertObject(options);
olObj.assign(this.profileOptions, options);
Object.assign(this.profileOptions, options);
}
};

Expand Down
7 changes: 3 additions & 4 deletions contribs/gmf/src/search/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import ngeoSearchModule from 'ngeo/search/module.js';
import olFeature from 'ol/Feature.js';
import * as olColor from 'ol/color.js';
import olGeomPoint from 'ol/geom/Point.js';
import * as olObj from 'ol/obj.js';
import olFormatGeoJSON from 'ol/format/GeoJSON.js';
import * as olProj from 'ol/proj.js';
import olStyleCircle from 'ol/style/Circle.js';
Expand Down Expand Up @@ -458,7 +457,7 @@ exports.SearchController_ = class {
this.featureOverlay_.setStyle(this.getSearchStyle_.bind(this));

if (this.typeaheadOptions) {
olObj.assign(this.options, this.typeaheadOptions);
Object.assign(this.options, this.typeaheadOptions);
}

this.initDatasets_();
Expand Down Expand Up @@ -643,7 +642,7 @@ exports.SearchController_ = class {
})
});
if (config.typeaheadDatasetOptions) {
olObj.assign(typeaheadDataset, config.typeaheadDatasetOptions);
Object.assign(typeaheadDataset, config.typeaheadDatasetOptions);
}
return typeaheadDataset;
}
Expand Down Expand Up @@ -808,7 +807,7 @@ exports.SearchController_ = class {
stroke: stroke
});
const customStyles = this.featuresStyles || {};
olObj.assign(this.styles_, customStyles);
Object.assign(this.styles_, customStyles);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/test/spec/services/permalinkservice.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import olMap from 'ol/Map.js';
import olView from 'ol/View.js';
import olCollection from 'ol/Collection.js';
import * as olProj from 'ol/proj.js';
import * as olObj from 'ol/obj.js';


describe('Permalink service', () => {
Expand All @@ -21,7 +20,7 @@ describe('Permalink service', () => {
PermalinkService.setMap(map);
// need to work on a clone of themes, because the permalink service
// seems to change the original object?!
const themesClone = olObj.assign({}, gmfTestDataThemes);
const themesClone = Object.assign({}, gmfTestDataThemes);
PermalinkService.themes_ = themesClone['themes'];


Expand Down
5 changes: 2 additions & 3 deletions src/filter/RuleHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import ngeoRuleSelect from 'ngeo/rule/Select.js';
import ngeoRuleText from 'ngeo/rule/Text.js';
import {writeFilter} from 'ol/format/WFS.js';
import * as olFormatFilter from 'ol/format/filter.js';
import * as olArray from 'ol/array.js';

import moment from 'moment';

Expand Down Expand Up @@ -581,7 +580,7 @@ const exports = class {
}
filter = olFormatFilter.or.apply(null, conditions);
}
} else if (olArray.includes(spatialTypes, operator)) {
} else if (spatialTypes.includes(operator)) {
const geometryName = dataSource.geometryName;
googAsserts.assertInstanceof(rule, ngeoRuleGeometry);
const geometry = googAsserts.assert(rule.geometry);
Expand All @@ -604,7 +603,7 @@ const exports = class {
opt_srsName
);
}
} else if (olArray.includes(numericTypes, operator)) {
} else if (numericTypes.includes(operator)) {
const numericExpression = googAsserts.assertNumber(expression);
if (operator === rot.GREATER_THAN) {
filter = olFormatFilter.greaterThan(
Expand Down
5 changes: 2 additions & 3 deletions src/filter/ruleComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {getUid as olUtilGetUid} from 'ol/util.js';
import olFeature from 'ol/Feature.js';
import olCollection from 'ol/Collection.js';
import * as olEvents from 'ol/events.js';
import * as olArray from 'ol/array.js';
import olStyleStyle from 'ol/style/Style.js';
import olStyleText from 'ol/style/Text.js';
import olStyleFill from 'ol/style/Fill.js';
Expand Down Expand Up @@ -462,7 +461,7 @@ exports.RuleController_ = class {
ngeoGeometryType.POLYGON,
ngeoGeometryType.RECTANGLE
];
if (!olArray.includes(supportedTypes, geomType)) {
if (!supportedTypes.includes(geomType)) {
this.clone.setExpression(null);
}
}
Expand Down Expand Up @@ -843,7 +842,7 @@ exports.RuleController_ = class {
pixel,
(feature) => {
let ret = false;
if (olArray.includes(this.selectedFeatures.getArray(), feature)) {
if (this.selectedFeatures.getArray().includes(feature)) {
ret = feature;
}
return ret;
Expand Down
5 changes: 2 additions & 3 deletions src/format/FeatureHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ngeoUtils from 'ngeo/utils.js';
import {inherits as olUtilInherits} from 'ol/util.js';
import olFeature from 'ol/Feature.js';
import * as olColor from 'ol/color.js';
import * as olArray from 'ol/array.js';
import * as olFormatFeature from 'ol/format/Feature.js';
import olFormatTextFeature from 'ol/format/TextFeature.js';
import olGeomGeometryLayout from 'ol/geom/GeometryLayout.js';
Expand Down Expand Up @@ -694,9 +693,9 @@ exports.castValue_ = function(key, value) {
'showLabel'
];

if (olArray.includes(numProperties, key)) {
if (numProperties.includes(key)) {
return +value;
} else if (olArray.includes(boolProperties, key)) {
} else if (boolProperties.includes(key)) {
return (value === 'true') ? true : false;
} else {
return value;
Expand Down
3 changes: 1 addition & 2 deletions src/interaction/MeasureLengthMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ngeoInteractionMeasureLength from 'ngeo/interaction/MeasureLength.js';
import ngeoInteractionMobileDraw from 'ngeo/interaction/MobileDraw.js';
import {inherits as olUtilInherits} from 'ol/util.js';
import * as olObj from 'ol/obj.js';

/**
* @classdesc
Expand All @@ -21,7 +20,7 @@ const exports = function(format, gettextCatalog, opt_options) {

const options = opt_options !== undefined ? opt_options : {};

olObj.assign(options, {displayHelpTooltip: false});
Object.assign(options, {displayHelpTooltip: false});

ngeoInteractionMeasureLength.call(this, format, gettextCatalog, options);

Expand Down
4 changes: 2 additions & 2 deletions src/interaction/MeasurePointMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import googAsserts from 'goog/asserts.js';
import ngeoInteractionMeasure from 'ngeo/interaction/Measure.js';
import ngeoInteractionMobileDraw from 'ngeo/interaction/MobileDraw.js';
import {inherits as olUtilInherits} from 'ol/util.js';
import * as olObj from 'ol/obj.js';

import olGeomPoint from 'ol/geom/Point.js';

/**
Expand All @@ -21,7 +21,7 @@ import olGeomPoint from 'ol/geom/Point.js';
*/
const exports = function(format, coordFormat, options = /** @type {ngeox.interaction.MeasureOptions} */ ({})) {

olObj.assign(options, {displayHelpTooltip: false});
Object.assign(options, {displayHelpTooltip: false});

ngeoInteractionMeasure.call(this, /** @type {ngeo.interaction.MeasureBaseOptions} */(options));

Expand Down
Loading

0 comments on commit 76d61c1

Please sign in to comment.