Merge pull request #13888 from tschaub/object-assign

Use Object.assign
This commit is contained in:
Tim Schaub
2022-07-28 13:29:12 -06:00
committed by GitHub
46 changed files with 108 additions and 212 deletions

14
package-lock.json generated
View File

@@ -11,7 +11,7 @@
"dependencies": { "dependencies": {
"earcut": "^2.2.3", "earcut": "^2.2.3",
"geotiff": "2.0.4", "geotiff": "2.0.4",
"ol-mapbox-style": "8.2.0", "ol-mapbox-style": "8.2.1",
"pbf": "3.2.1", "pbf": "3.2.1",
"rbush": "^3.0.1" "rbush": "^3.0.1"
}, },
@@ -7353,9 +7353,9 @@
"dev": true "dev": true
}, },
"node_modules/ol-mapbox-style": { "node_modules/ol-mapbox-style": {
"version": "8.2.0", "version": "8.2.1",
"resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.0.tgz", "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.1.tgz",
"integrity": "sha512-WyCiNUj5DiD3+MvgqXvxSf0mDUvagtlq9JQ97mHwDD1FliHt5G1333Lvqskg8psBfxijHSEWNHwqzBGnEUo1bw==", "integrity": "sha512-3kBBuZC627vDL8vnUdfVbCbfkhkcZj2kXPHQcuLhC4JJEA+XkEVEtEde8x8+AZctRbHwBkSiubTPaRukgLxIRw==",
"dependencies": { "dependencies": {
"@mapbox/mapbox-gl-style-spec": "^13.23.1", "@mapbox/mapbox-gl-style-spec": "^13.23.1",
"mapbox-to-css-font": "^2.4.1" "mapbox-to-css-font": "^2.4.1"
@@ -15844,9 +15844,9 @@
"dev": true "dev": true
}, },
"ol-mapbox-style": { "ol-mapbox-style": {
"version": "8.2.0", "version": "8.2.1",
"resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.0.tgz", "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.1.tgz",
"integrity": "sha512-WyCiNUj5DiD3+MvgqXvxSf0mDUvagtlq9JQ97mHwDD1FliHt5G1333Lvqskg8psBfxijHSEWNHwqzBGnEUo1bw==", "integrity": "sha512-3kBBuZC627vDL8vnUdfVbCbfkhkcZj2kXPHQcuLhC4JJEA+XkEVEtEde8x8+AZctRbHwBkSiubTPaRukgLxIRw==",
"requires": { "requires": {
"@mapbox/mapbox-gl-style-spec": "^13.23.1", "@mapbox/mapbox-gl-style-spec": "^13.23.1",
"mapbox-to-css-font": "^2.4.1" "mapbox-to-css-font": "^2.4.1"

View File

@@ -47,7 +47,7 @@
"dependencies": { "dependencies": {
"earcut": "^2.2.3", "earcut": "^2.2.3",
"geotiff": "2.0.4", "geotiff": "2.0.4",
"ol-mapbox-style": "8.2.0", "ol-mapbox-style": "8.2.1",
"pbf": "3.2.1", "pbf": "3.2.1",
"rbush": "^3.0.1" "rbush": "^3.0.1"
}, },

View File

@@ -3,7 +3,6 @@
*/ */
import CompositeMapRenderer from './renderer/Composite.js'; import CompositeMapRenderer from './renderer/Composite.js';
import PluggableMap from './PluggableMap.js'; import PluggableMap from './PluggableMap.js';
import {assign} from './obj.js';
import {defaults as defaultControls} from './control.js'; import {defaults as defaultControls} from './control.js';
import {defaults as defaultInteractions} from './interaction.js'; import {defaults as defaultInteractions} from './interaction.js';
@@ -59,7 +58,7 @@ class Map extends PluggableMap {
* @param {import("./PluggableMap.js").MapOptions} options Map options. * @param {import("./PluggableMap.js").MapOptions} options Map options.
*/ */
constructor(options) { constructor(options) {
options = assign({}, options); options = Object.assign({}, options);
if (!options.controls) { if (!options.controls) {
options.controls = defaultControls(); options.controls = defaultControls();
} }

View File

@@ -4,8 +4,8 @@
import Event from './events/Event.js'; import Event from './events/Event.js';
import ObjectEventType from './ObjectEventType.js'; import ObjectEventType from './ObjectEventType.js';
import Observable from './Observable.js'; import Observable from './Observable.js';
import {assign, isEmpty} from './obj.js';
import {getUid} from './util.js'; import {getUid} from './util.js';
import {isEmpty} from './obj.js';
/** /**
* @classdesc * @classdesc
@@ -155,7 +155,7 @@ class BaseObject extends Observable {
* @api * @api
*/ */
getProperties() { getProperties() {
return (this.values_ && assign({}, this.values_)) || {}; return (this.values_ && Object.assign({}, this.values_)) || {};
} }
/** /**
@@ -239,7 +239,7 @@ class BaseObject extends Observable {
if (!source.values_) { if (!source.values_) {
return; return;
} }
assign(this.values_ || (this.values_ = {}), source.values_); Object.assign(this.values_ || (this.values_ = {}), source.values_);
} }
/** /**

View File

@@ -24,7 +24,6 @@ import {
rotate as rotateCoordinate, rotate as rotateCoordinate,
} from './coordinate.js'; } from './coordinate.js';
import {assert} from './asserts.js'; import {assert} from './asserts.js';
import {assign} from './obj.js';
import {none as centerNone, createExtent} from './centerconstraint.js'; import {none as centerNone, createExtent} from './centerconstraint.js';
import {clamp, modulo} from './math.js'; import {clamp, modulo} from './math.js';
import { import {
@@ -325,7 +324,7 @@ class View extends BaseObject {
*/ */
this.un; this.un;
const options = assign({}, opt_options); const options = Object.assign({}, opt_options);
/** /**
* @private * @private
@@ -418,7 +417,7 @@ class View extends BaseObject {
* @param {ViewOptions} options View options. * @param {ViewOptions} options View options.
*/ */
applyOptions_(options) { applyOptions_(options) {
const properties = assign({}, options); const properties = Object.assign({}, options);
for (const key in ViewProperty) { for (const key in ViewProperty) {
delete properties[key]; delete properties[key];
} }
@@ -541,7 +540,7 @@ class View extends BaseObject {
// preserve rotation // preserve rotation
options.rotation = this.getRotation(); options.rotation = this.getRotation();
return assign({}, options, newOptions); return Object.assign({}, options, newOptions);
} }
/** /**
@@ -585,14 +584,14 @@ class View extends BaseObject {
for (let i = 0; i < args.length; ++i) { for (let i = 0; i < args.length; ++i) {
let options = arguments[i]; let options = arguments[i];
if (options.center) { if (options.center) {
options = assign({}, options); options = Object.assign({}, options);
options.center = fromUserCoordinate( options.center = fromUserCoordinate(
options.center, options.center,
this.getProjection() this.getProjection()
); );
} }
if (options.anchor) { if (options.anchor) {
options = assign({}, options); options = Object.assign({}, options);
options.anchor = fromUserCoordinate( options.anchor = fromUserCoordinate(
options.anchor, options.anchor,
this.getProjection() this.getProjection()

View File

@@ -11,10 +11,10 @@ import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js'; import Polygon from '../geom/Polygon.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign, isEmpty} from '../obj.js';
import {containsExtent} from '../extent.js'; import {containsExtent} from '../extent.js';
import {deflateCoordinates} from '../geom/flat/deflate.js'; import {deflateCoordinates} from '../geom/flat/deflate.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import {isEmpty} from '../obj.js';
import {linearRingIsClockwise} from '../geom/flat/orient.js'; import {linearRingIsClockwise} from '../geom/flat/orient.js';
import {transformGeometryWithOptions} from './Feature.js'; import {transformGeometryWithOptions} from './Feature.js';
@@ -274,10 +274,10 @@ function readGeometry(object, opt_options) {
const rings = convertRings(esriJSONPolygon.rings, layout); const rings = convertRings(esriJSONPolygon.rings, layout);
if (rings.length === 1) { if (rings.length === 1) {
type = 'Polygon'; type = 'Polygon';
object = assign({}, object, {['rings']: rings[0]}); object = Object.assign({}, object, {['rings']: rings[0]});
} else { } else {
type = 'MultiPolygon'; type = 'MultiPolygon';
object = assign({}, object, {['rings']: rings}); object = Object.assign({}, object, {['rings']: rings});
} }
} }
const geometryReader = GEOMETRY_READERS[type]; const geometryReader = GEOMETRY_READERS[type];

View File

@@ -3,7 +3,6 @@
*/ */
import Units from '../proj/Units.js'; import Units from '../proj/Units.js';
import {abstract} from '../util.js'; import {abstract} from '../util.js';
import {assign} from '../obj.js';
import { import {
equivalent as equivalentProjection, equivalent as equivalentProjection,
get as getProjection, get as getProjection,
@@ -127,7 +126,7 @@ class FeatureFormat {
* Updated options. * Updated options.
*/ */
adaptOptions(options) { adaptOptions(options) {
return assign( return Object.assign(
{ {
dataProjection: this.dataProjection, dataProjection: this.dataProjection,
featureProjection: this.defaultFeatureProjection, featureProjection: this.defaultFeatureProjection,

View File

@@ -13,7 +13,6 @@ import {
pushParseAndPop, pushParseAndPop,
pushSerializeAndPop, pushSerializeAndPop,
} from '../xml.js'; } from '../xml.js';
import {assign} from '../obj.js';
import {createOrUpdate} from '../extent.js'; import {createOrUpdate} from '../extent.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import { import {
@@ -245,7 +244,7 @@ class GML2 extends GMLBase {
} }
} }
} }
const item = assign({}, context); const item = Object.assign({}, context);
item.node = node; item.node = node;
pushSerializeAndPop( pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */ /** @type {import("../xml.js").NodeStackItem} */
@@ -330,7 +329,7 @@ class GML2 extends GMLBase {
const context = /** @type {import("./Feature.js").WriteOptions} */ ( const context = /** @type {import("./Feature.js").WriteOptions} */ (
objectStack[objectStack.length - 1] objectStack[objectStack.length - 1]
); );
const item = assign({}, context); const item = Object.assign({}, context);
item['node'] = node; item['node'] = node;
let value; let value;
if (Array.isArray(geometry)) { if (Array.isArray(geometry)) {

View File

@@ -21,7 +21,6 @@ import {
pushParseAndPop, pushParseAndPop,
pushSerializeAndPop, pushSerializeAndPop,
} from '../xml.js'; } from '../xml.js';
import {assign} from '../obj.js';
import {createOrUpdate} from '../extent.js'; import {createOrUpdate} from '../extent.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
@@ -815,7 +814,7 @@ class GML3 extends GMLBase {
const context = /** @type {import("./Feature.js").WriteOptions} */ ( const context = /** @type {import("./Feature.js").WriteOptions} */ (
objectStack[objectStack.length - 1] objectStack[objectStack.length - 1]
); );
const item = assign({}, context); const item = Object.assign({}, context);
item['node'] = node; item['node'] = node;
let value; let value;
if (Array.isArray(geometry)) { if (Array.isArray(geometry)) {
@@ -888,7 +887,7 @@ class GML3 extends GMLBase {
} }
} }
} }
const item = assign({}, context); const item = Object.assign({}, context);
item.node = node; item.node = node;
pushSerializeAndPop( pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */ /** @type {import("../xml.js").NodeStackItem} */
@@ -918,7 +917,7 @@ class GML3 extends GMLBase {
this.writeFeatureElement, this.writeFeatureElement,
this this
); );
const item = assign({}, context); const item = Object.assign({}, context);
item.node = node; item.node = node;
pushSerializeAndPop( pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */ /** @type {import("../xml.js").NodeStackItem} */
@@ -1001,7 +1000,7 @@ class GML3 extends GMLBase {
multiCurve: this.multiCurve_, multiCurve: this.multiCurve_,
}; };
if (opt_options) { if (opt_options) {
assign(context, opt_options); Object.assign(context, opt_options);
} }
this.writeGeometryElement(geom, geometry, [context]); this.writeGeometryElement(geom, geometry, [context]);
return geom; return geom;
@@ -1034,7 +1033,7 @@ class GML3 extends GMLBase {
featureType: this.featureType, featureType: this.featureType,
}; };
if (opt_options) { if (opt_options) {
assign(context, opt_options); Object.assign(context, opt_options);
} }
this.writeFeatureMembers_(node, features, [context]); this.writeFeatureMembers_(node, features, [context]);
return node; return node;

View File

@@ -13,7 +13,6 @@ import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js'; import Polygon from '../geom/Polygon.js';
import XMLFeature from './XMLFeature.js'; import XMLFeature from './XMLFeature.js';
import {assign} from '../obj.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import { import {
getAllTextContent, getAllTextContent,
@@ -570,7 +569,7 @@ class GMLBase extends XMLFeature {
featureNS: this.featureNS, featureNS: this.featureNS,
}; };
if (opt_options) { if (opt_options) {
assign(options, this.getReadOptions(node, opt_options)); Object.assign(options, this.getReadOptions(node, opt_options));
} }
const features = this.readFeaturesInternal(node, [options]); const features = this.readFeaturesInternal(node, [options]);
return features || []; return features || [];

View File

@@ -12,8 +12,8 @@ import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js'; import Polygon from '../geom/Polygon.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign, isEmpty} from '../obj.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import {isEmpty} from '../obj.js';
import {transformGeometryWithOptions} from './Feature.js'; import {transformGeometryWithOptions} from './Feature.js';
/** /**
@@ -476,7 +476,7 @@ function writeGeometry(geometry, opt_options) {
*/ */
function writeGeometryCollectionGeometry(geometry, opt_options) { function writeGeometryCollectionGeometry(geometry, opt_options) {
const geometries = geometry.getGeometriesArray().map(function (geometry) { const geometries = geometry.getGeometriesArray().map(function (geometry) {
const options = assign({}, opt_options); const options = Object.assign({}, opt_options);
delete options.featureProjection; delete options.featureProjection;
return writeGeometry(geometry, options); return writeGeometry(geometry, options);
}); });

View File

@@ -21,7 +21,6 @@ import {
} from '../xml.js'; } from '../xml.js';
import {and as andFilterFn, bbox as bboxFilterFn} from './filter.js'; import {and as andFilterFn, bbox as bboxFilterFn} from './filter.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import { import {
readNonNegativeIntegerString, readNonNegativeIntegerString,
@@ -333,12 +332,15 @@ class WFS extends XMLFeature {
const context = { const context = {
node, node,
}; };
assign(context, { Object.assign(context, {
'featureType': this.featureType_, 'featureType': this.featureType_,
'featureNS': this.featureNS_, 'featureNS': this.featureNS_,
}); });
assign(context, this.getReadOptions(node, opt_options ? opt_options : {})); Object.assign(
context,
this.getReadOptions(node, opt_options ? opt_options : {})
);
const objectStack = [context]; const objectStack = [context];
let featuresNS; let featuresNS;
if (this.version_ === '2.0.0') { if (this.version_ === '2.0.0') {
@@ -511,7 +513,7 @@ class WFS extends XMLFeature {
const context = { const context = {
node, node,
}; };
assign(context, { Object.assign(context, {
'version': this.version_, 'version': this.version_,
'srsName': options.srsName, 'srsName': options.srsName,
'featureNS': options.featureNS ? options.featureNS : this.featureNS_, 'featureNS': options.featureNS ? options.featureNS : this.featureNS_,
@@ -530,7 +532,7 @@ class WFS extends XMLFeature {
filter filter
); );
} }
assign(context, { Object.assign(context, {
'geometryName': options.geometryName, 'geometryName': options.geometryName,
'filter': filter, 'filter': filter,
}); });
@@ -548,7 +550,7 @@ class WFS extends XMLFeature {
options.srsName, options.srsName,
options.filter options.filter
); );
assign(context, { Object.assign(context, {
'geometryName': featureType.geometryName, 'geometryName': featureType.geometryName,
'filter': completeFilter, 'filter': completeFilter,
}); });
@@ -686,7 +688,7 @@ function createTransactionRequest(node, baseObj, version, options) {
} else if (version === '2.0.0') { } else if (version === '2.0.0') {
gmlVersion = 3.2; gmlVersion = 3.2;
} }
const obj = assign( const obj = Object.assign(
{node}, {node},
{ {
version, version,
@@ -1035,7 +1037,7 @@ function writeQuery(node, featureType, objectStack) {
node.setAttributeNS(XMLNS, 'xmlns:' + featurePrefix, featureNS); node.setAttributeNS(XMLNS, 'xmlns:' + featurePrefix, featureNS);
} }
const item = /** @type {import("../xml.js").NodeStackItem} */ ( const item = /** @type {import("../xml.js").NodeStackItem} */ (
assign({}, context) Object.assign({}, context)
); );
item.node = node; item.node = node;
pushSerializeAndPop( pushSerializeAndPop(
@@ -1062,7 +1064,7 @@ function writeFilterCondition(node, filter, objectStack) {
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]); const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
/** @type {import("../xml.js").NodeStackItem} */ /** @type {import("../xml.js").NodeStackItem} */
const item = {node}; const item = {node};
assign(item, {context}); Object.assign(item, {context});
pushSerializeAndPop( pushSerializeAndPop(
item, item,
GETFEATURE_SERIALIZERS, GETFEATURE_SERIALIZERS,
@@ -1167,7 +1169,7 @@ function writeLogicalFilter(node, filter, objectStack) {
const context = parent['context']; const context = parent['context'];
/** @type {import("../xml.js").NodeStackItem} */ /** @type {import("../xml.js").NodeStackItem} */
const item = {node}; const item = {node};
assign(item, {context}); Object.assign(item, {context});
const conditions = filter.conditions; const conditions = filter.conditions;
for (let i = 0, ii = conditions.length; i < ii; ++i) { for (let i = 0, ii = conditions.length; i < ii; ++i) {
const condition = conditions[i]; const condition = conditions[i];
@@ -1191,7 +1193,7 @@ function writeNotFilter(node, filter, objectStack) {
const context = parent['context']; const context = parent['context'];
/** @type {import("../xml.js").NodeStackItem} */ /** @type {import("../xml.js").NodeStackItem} */
const item = {node}; const item = {node};
assign(item, {context}); Object.assign(item, {context});
const condition = filter.condition; const condition = filter.condition;
pushSerializeAndPop( pushSerializeAndPop(
item, item,
@@ -1332,7 +1334,7 @@ export function writeFilter(filter, opt_version) {
const context = { const context = {
node: child, node: child,
}; };
assign(context, { Object.assign(context, {
'version': version, 'version': version,
'filter': filter, 'filter': filter,
}); });
@@ -1348,7 +1350,7 @@ export function writeFilter(filter, opt_version) {
function writeGetFeature(node, featureTypes, objectStack) { function writeGetFeature(node, featureTypes, objectStack) {
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]); const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const item = /** @type {import("../xml.js").NodeStackItem} */ ( const item = /** @type {import("../xml.js").NodeStackItem} */ (
assign({}, context) Object.assign({}, context)
); );
item.node = node; item.node = node;
pushSerializeAndPop( pushSerializeAndPop(

View File

@@ -13,7 +13,6 @@ import Polygon from '../geom/Polygon.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import SimpleGeometry from '../geom/SimpleGeometry.js'; import SimpleGeometry from '../geom/SimpleGeometry.js';
import {assign} from '../obj.js';
// WKB spec: https://www.ogc.org/standards/sfa // WKB spec: https://www.ogc.org/standards/sfa
// EWKB spec: https://raw.githubusercontent.com/postgis/postgis/2.1.0/doc/ZMSgeoms.txt // EWKB spec: https://raw.githubusercontent.com/postgis/postgis/2.1.0/doc/ZMSgeoms.txt
@@ -423,7 +422,7 @@ class WkbWriter {
* @property {number} Z NoData value for Z * @property {number} Z NoData value for Z
* @property {number} M NoData value for M * @property {number} M NoData value for M
*/ */
this.nodata_ = assign({X: 0, Y: 0, Z: 0, M: 0}, opts.nodata); this.nodata_ = Object.assign({X: 0, Y: 0, Z: 0, M: 0}, opts.nodata);
} }
/** /**
@@ -459,7 +458,7 @@ class WkbWriter {
* @property {number} [Z] NoData value for Z * @property {number} [Z] NoData value for Z
* @property {number} [M] NoData value for M * @property {number} [M] NoData value for M
*/ */
const coordsObj = assign.apply( const coordsObj = Object.assign.apply(
null, null,
layout.split('').map((axis, idx) => ({[axis]: coords[idx]})) layout.split('').map((axis, idx) => ({[axis]: coords[idx]}))
); );

View File

@@ -3,7 +3,6 @@
*/ */
import GML2 from './GML2.js'; import GML2 from './GML2.js';
import XMLFeature from './XMLFeature.js'; import XMLFeature from './XMLFeature.js';
import {assign} from '../obj.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js'; import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js';
@@ -157,7 +156,7 @@ class WMSGetFeatureInfo extends XMLFeature {
readFeaturesFromNode(node, opt_options) { readFeaturesFromNode(node, opt_options) {
const options = {}; const options = {};
if (opt_options) { if (opt_options) {
assign(options, this.getReadOptions(node, opt_options)); Object.assign(options, this.getReadOptions(node, opt_options));
} }
return this.readFeatures_(node, [options]); return this.readFeatures_(node, [options]);
} }

View File

@@ -4,7 +4,6 @@
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import Interaction from './Interaction.js'; import Interaction from './Interaction.js';
import MapEventType from '../MapEventType.js'; import MapEventType from '../MapEventType.js';
import {assign} from '../obj.js';
import {listen, unlistenByKey} from '../events.js'; import {listen, unlistenByKey} from '../events.js';
import {toFixed} from '../math.js'; import {toFixed} from '../math.js';
@@ -76,7 +75,7 @@ class Link extends Interaction {
constructor(opt_options) { constructor(opt_options) {
super(); super();
const options = assign( const options = Object.assign(
{animate: true, replace: false, prefix: ''}, {animate: true, replace: false, prefix: ''},
opt_options || {} opt_options || {}
); );
@@ -282,7 +281,7 @@ class Link extends Interaction {
if (updateView) { if (updateView) {
if (!this.initial_ && this.animationOptions_) { if (!this.initial_ && this.animationOptions_) {
view.animate(assign(viewProperties, this.animationOptions_)); view.animate(Object.assign(viewProperties, this.animationOptions_));
} else { } else {
if (viewProperties.center) { if (viewProperties.center) {
view.setCenter(viewProperties.center); view.setCenter(viewProperties.center);

View File

@@ -5,7 +5,6 @@ import BaseObject from '../Object.js';
import LayerProperty from './Property.js'; import LayerProperty from './Property.js';
import {abstract} from '../util.js'; import {abstract} from '../util.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {clamp} from '../math.js'; import {clamp} from '../math.js';
/** /**
@@ -92,10 +91,10 @@ class BaseLayer extends BaseObject {
/** /**
* @type {Object<string, *>} * @type {Object<string, *>}
*/ */
const properties = assign({}, options); const properties = Object.assign({}, options);
if (typeof options.properties === 'object') { if (typeof options.properties === 'object') {
delete properties.properties; delete properties.properties;
assign(properties, options.properties); Object.assign(properties, options.properties);
} }
properties[LayerProperty.OPACITY] = properties[LayerProperty.OPACITY] =

View File

@@ -3,7 +3,6 @@
*/ */
import Layer from './Layer.js'; import Layer from './Layer.js';
import TileProperty from './TileProperty.js'; import TileProperty from './TileProperty.js';
import {assign} from '../obj.js';
/*** /***
* @template Return * @template Return
@@ -66,7 +65,7 @@ class BaseTileLayer extends Layer {
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const baseOptions = assign({}, options); const baseOptions = Object.assign({}, options);
delete baseOptions.preload; delete baseOptions.preload;
delete baseOptions.useInterimTilesOnError; delete baseOptions.useInterimTilesOnError;

View File

@@ -3,7 +3,6 @@
*/ */
import Layer from './Layer.js'; import Layer from './Layer.js';
import RBush from 'rbush'; import RBush from 'rbush';
import {assign} from '../obj.js';
import { import {
createDefaultStyle, createDefaultStyle,
toFunction as toStyleFunction, toFunction as toStyleFunction,
@@ -91,7 +90,7 @@ class BaseVectorLayer extends Layer {
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const baseOptions = assign({}, options); const baseOptions = Object.assign({}, options);
delete baseOptions.style; delete baseOptions.style;
delete baseOptions.renderBuffer; delete baseOptions.renderBuffer;

View File

@@ -25,7 +25,6 @@ import {
isEmpty, isEmpty,
wrapX as wrapExtentX, wrapX as wrapExtentX,
} from '../extent.js'; } from '../extent.js';
import {assign} from '../obj.js';
import {clamp} from '../math.js'; import {clamp} from '../math.js';
import {degreesToStringHDMS} from '../coordinate.js'; import {degreesToStringHDMS} from '../coordinate.js';
import { import {
@@ -170,7 +169,7 @@ class Graticule extends VectorLayer {
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const baseOptions = assign( const baseOptions = Object.assign(
{ {
updateWhileAnimating: true, updateWhileAnimating: true,
updateWhileInteracting: true, updateWhileInteracting: true,

View File

@@ -8,7 +8,7 @@ import Event from '../events/Event.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import ObjectEventType from '../ObjectEventType.js'; import ObjectEventType from '../ObjectEventType.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign, clear} from '../obj.js'; import {clear} from '../obj.js';
import {getIntersection} from '../extent.js'; import {getIntersection} from '../extent.js';
import {getUid} from '../util.js'; import {getUid} from '../util.js';
import {listen, unlistenByKey} from '../events.js'; import {listen, unlistenByKey} from '../events.js';
@@ -92,7 +92,7 @@ class LayerGroup extends BaseLayer {
*/ */
constructor(opt_options) { constructor(opt_options) {
const options = opt_options || {}; const options = opt_options || {};
const baseOptions = /** @type {Options} */ (assign({}, options)); const baseOptions = /** @type {Options} */ (Object.assign({}, options));
delete baseOptions.layers; delete baseOptions.layers;
let layers = options.layers; let layers = options.layers;

View File

@@ -3,7 +3,6 @@
*/ */
import BaseVector from './BaseVector.js'; import BaseVector from './BaseVector.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js'; import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
import {assign} from '../obj.js';
import {clamp} from '../math.js'; import {clamp} from '../math.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
@@ -71,7 +70,7 @@ class Heatmap extends BaseVector {
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const baseOptions = assign({}, options); const baseOptions = Object.assign({}, options);
delete baseOptions.gradient; delete baseOptions.gradient;
delete baseOptions.radius; delete baseOptions.radius;

View File

@@ -6,7 +6,6 @@ import EventType from '../events/EventType.js';
import LayerProperty from './Property.js'; import LayerProperty from './Property.js';
import RenderEventType from '../render/EventType.js'; import RenderEventType from '../render/EventType.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {listen, unlistenByKey} from '../events.js'; import {listen, unlistenByKey} from '../events.js';
/** /**
@@ -95,7 +94,7 @@ class Layer extends BaseLayer {
* @param {Options<SourceType>} options Layer options. * @param {Options<SourceType>} options Layer options.
*/ */
constructor(options) { constructor(options) {
const baseOptions = assign({}, options); const baseOptions = Object.assign({}, options);
delete baseOptions.source; delete baseOptions.source;
super(baseOptions); super(baseOptions);

View File

@@ -3,7 +3,6 @@
*/ */
import BaseVectorLayer from './BaseVector.js'; import BaseVectorLayer from './BaseVector.js';
import CanvasVectorImageLayerRenderer from '../renderer/canvas/VectorImageLayer.js'; import CanvasVectorImageLayerRenderer from '../renderer/canvas/VectorImageLayer.js';
import {assign} from '../obj.js';
/** /**
* @template {import("../source/Vector.js").default} VectorSourceType * @template {import("../source/Vector.js").default} VectorSourceType
@@ -69,7 +68,7 @@ class VectorImageLayer extends BaseVectorLayer {
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const baseOptions = assign({}, options); const baseOptions = Object.assign({}, options);
delete baseOptions.imageRatio; delete baseOptions.imageRatio;
super(baseOptions); super(baseOptions);

View File

@@ -6,7 +6,6 @@ import CanvasVectorTileLayerRenderer from '../renderer/canvas/VectorTileLayer.js
import TileProperty from './TileProperty.js'; import TileProperty from './TileProperty.js';
import VectorTileRenderType from './VectorTileRenderType.js'; import VectorTileRenderType from './VectorTileRenderType.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign} from '../obj.js';
/*** /***
* @template Return * @template Return
@@ -102,7 +101,7 @@ class VectorTileLayer extends BaseVectorLayer {
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const baseOptions = /** @type {Object} */ (assign({}, options)); const baseOptions = /** @type {Object} */ (Object.assign({}, options));
delete baseOptions.preload; delete baseOptions.preload;
delete baseOptions.useInterimTilesOnError; delete baseOptions.useInterimTilesOnError;

View File

@@ -3,7 +3,6 @@
*/ */
import Layer from './Layer.js'; import Layer from './Layer.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js'; import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
import {assign} from '../obj.js';
import {parseLiteralStyle} from '../webgl/ShaderBuilder.js'; import {parseLiteralStyle} from '../webgl/ShaderBuilder.js';
/** /**
@@ -77,7 +76,7 @@ class WebGLPointsLayer extends Layer {
* @param {Options<VectorSourceType>} options Options. * @param {Options<VectorSourceType>} options Options.
*/ */
constructor(options) { constructor(options) {
const baseOptions = assign({}, options); const baseOptions = Object.assign({}, options);
super(baseOptions); super(baseOptions);
@@ -120,7 +119,7 @@ class WebGLPointsLayer extends Layer {
* @param {Object<string, number>} variables Variables to update. * @param {Object<string, number>} variables Variables to update.
*/ */
updateStyleVariables(variables) { updateStyleVariables(variables) {
assign(this.styleVariables_, variables); Object.assign(this.styleVariables_, variables);
this.changed(); this.changed();
} }
} }

View File

@@ -14,7 +14,6 @@ import {
getStringNumberEquivalent, getStringNumberEquivalent,
uniformNameForVariable, uniformNameForVariable,
} from '../style/expressions.js'; } from '../style/expressions.js';
import {assign} from '../obj.js';
/** /**
* @typedef {import("../source/DataTile.js").default|import("../source/TileImage.js").default} SourceType * @typedef {import("../source/DataTile.js").default|import("../source/TileImage.js").default} SourceType
@@ -308,7 +307,7 @@ class WebGLTileLayer extends BaseTileLayer {
* @param {Options} opt_options Tile layer options. * @param {Options} opt_options Tile layer options.
*/ */
constructor(opt_options) { constructor(opt_options) {
const options = opt_options ? assign({}, opt_options) : {}; const options = opt_options ? Object.assign({}, opt_options) : {};
const style = options.style || {}; const style = options.style || {};
delete options.style; delete options.style;
@@ -511,7 +510,7 @@ class WebGLTileLayer extends BaseTileLayer {
* @api * @api
*/ */
updateStyleVariables(variables) { updateStyleVariables(variables) {
assign(this.styleVariables_, variables); Object.assign(this.styleVariables_, variables);
this.changed(); this.changed();
} }
} }

View File

@@ -2,37 +2,6 @@
* @module ol/obj * @module ol/obj
*/ */
/**
* Polyfill for Object.assign(). Assigns enumerable and own properties from
* one or more source objects to a target object.
* See https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign.
*
* @param {!Object} target The target object.
* @param {...Object} var_sources The source object(s).
* @return {!Object} The modified target object.
*/
export const assign =
typeof Object.assign === 'function'
? Object.assign
: function (target, var_sources) {
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}
const output = Object(target);
for (let i = 1, ii = arguments.length; i < ii; ++i) {
const source = arguments[i];
if (source !== undefined && source !== null) {
for (const key in source) {
if (source.hasOwnProperty(key)) {
output[key] = source[key];
}
}
}
}
return output;
};
/** /**
* Removes all properties from an object. * Removes all properties from an object.
* @param {Object} object The object to clear. * @param {Object} object The object to clear.

View File

@@ -12,7 +12,6 @@ import {
makeInverse, makeInverse,
toString as toTransformString, toString as toTransformString,
} from '../../transform.js'; } from '../../transform.js';
import {assign} from '../../obj.js';
import { import {
containsCoordinate, containsCoordinate,
containsExtent, containsExtent,
@@ -239,7 +238,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
const dh = img.height * transform[3]; const dh = img.height * transform[3];
if (!this.getLayer().getSource().getInterpolate()) { if (!this.getLayer().getSource().getInterpolate()) {
assign(context, IMAGE_SMOOTHING_DISABLED); Object.assign(context, IMAGE_SMOOTHING_DISABLED);
} }
this.preRender(context, frameState); this.preRender(context, frameState);
@@ -262,7 +261,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
if (clipped) { if (clipped) {
context.restore(); context.restore();
} }
assign(context, IMAGE_SMOOTHING_ENABLED); Object.assign(context, IMAGE_SMOOTHING_ENABLED);
if (canvasTransform !== canvas.style.transform) { if (canvasTransform !== canvas.style.transform) {
canvas.style.transform = canvasTransform; canvas.style.transform = canvasTransform;

View File

@@ -13,7 +13,6 @@ import {
makeInverse, makeInverse,
toString as toTransformString, toString as toTransformString,
} from '../../transform.js'; } from '../../transform.js';
import {assign} from '../../obj.js';
import { import {
containsCoordinate, containsCoordinate,
createEmpty, createEmpty,
@@ -411,7 +410,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
} }
if (!tileSource.getInterpolate()) { if (!tileSource.getInterpolate()) {
assign(context, IMAGE_SMOOTHING_DISABLED); Object.assign(context, IMAGE_SMOOTHING_DISABLED);
} }
this.preRender(context, frameState); this.preRender(context, frameState);
@@ -562,7 +561,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
if (layerState.extent) { if (layerState.extent) {
context.restore(); context.restore();
} }
assign(context, IMAGE_SMOOTHING_ENABLED); Object.assign(context, IMAGE_SMOOTHING_ENABLED);
if (canvasTransform !== canvas.style.transform) { if (canvasTransform !== canvas.style.transform) {
canvas.style.transform = canvasTransform; canvas.style.transform = canvasTransform;

View File

@@ -9,7 +9,6 @@ import ImageState from '../../ImageState.js';
import RBush from 'rbush'; import RBush from 'rbush';
import ViewHint from '../../ViewHint.js'; import ViewHint from '../../ViewHint.js';
import {apply, compose, create} from '../../transform.js'; import {apply, compose, create} from '../../transform.js';
import {assign} from '../../obj.js';
import {getHeight, getWidth, isEmpty, scaleFromCenter} from '../../extent.js'; import {getHeight, getWidth, isEmpty, scaleFromCenter} from '../../extent.js';
/** /**
@@ -109,15 +108,15 @@ class CanvasVectorImageLayerRenderer extends CanvasImageLayerRenderer {
const context = vectorRenderer.context; const context = vectorRenderer.context;
const layerState = frameState.layerStatesArray[frameState.layerIndex]; const layerState = frameState.layerStatesArray[frameState.layerIndex];
context.globalAlpha = layerState.opacity; context.globalAlpha = layerState.opacity;
const imageLayerState = assign({}, layerState, {opacity: 1}); const imageLayerState = Object.assign({}, layerState, {opacity: 1});
const imageFrameState = const imageFrameState =
/** @type {import("../../PluggableMap.js").FrameState} */ ( /** @type {import("../../PluggableMap.js").FrameState} */ (
assign({}, frameState, { Object.assign({}, frameState, {
declutterTree: new RBush(9), declutterTree: new RBush(9),
extent: renderedExtent, extent: renderedExtent,
size: [width, height], size: [width, height],
viewState: /** @type {import("../../View.js").State} */ ( viewState: /** @type {import("../../View.js").State} */ (
assign({}, frameState.viewState, { Object.assign({}, frameState.viewState, {
rotation: 0, rotation: 0,
}) })
), ),

View File

@@ -2,7 +2,6 @@
* @module ol/reproj * @module ol/reproj
*/ */
import {IMAGE_SMOOTHING_DISABLED} from './renderer/canvas/common.js'; import {IMAGE_SMOOTHING_DISABLED} from './renderer/canvas/common.js';
import {assign} from './obj.js';
import { import {
containsCoordinate, containsCoordinate,
createEmpty, createEmpty,
@@ -227,7 +226,7 @@ export function render(
); );
if (!opt_interpolate) { if (!opt_interpolate) {
assign(context, IMAGE_SMOOTHING_DISABLED); Object.assign(context, IMAGE_SMOOTHING_DISABLED);
} }
if (sources.length === 0) { if (sources.length === 0) {
@@ -255,7 +254,7 @@ export function render(
); );
if (!opt_interpolate) { if (!opt_interpolate) {
assign(stitchContext, IMAGE_SMOOTHING_DISABLED); Object.assign(stitchContext, IMAGE_SMOOTHING_DISABLED);
} }
const stitchScale = pixelRatio / sourceResolution; const stitchScale = pixelRatio / sourceResolution;

View File

@@ -3,7 +3,6 @@
*/ */
import XYZ from './XYZ.js'; import XYZ from './XYZ.js';
import {assign} from '../obj.js';
/** /**
* @typedef {Object} Options * @typedef {Object} Options
@@ -104,7 +103,7 @@ class CartoDB extends XYZ {
* @api * @api
*/ */
updateConfig(config) { updateConfig(config) {
assign(this.config_, config); Object.assign(this.config_, config);
this.initializeMap_(); this.initializeMap_();
} }

View File

@@ -6,7 +6,6 @@ import EventType from '../events/EventType.js';
import TileEventType from './TileEventType.js'; import TileEventType from './TileEventType.js';
import TileSource, {TileSourceEvent} from './Tile.js'; import TileSource, {TileSourceEvent} from './Tile.js';
import TileState from '../TileState.js'; import TileState from '../TileState.js';
import {assign} from '../obj.js';
import {createXYZ, extentFromProjection} from '../tilegrid.js'; import {createXYZ, extentFromProjection} from '../tilegrid.js';
import {getKeyZXY} from '../tilecoord.js'; import {getKeyZXY} from '../tilecoord.js';
import {getUid} from '../util.js'; import {getUid} from '../util.js';
@@ -197,7 +196,7 @@ class DataTileSource extends TileSource {
}); });
} }
const options = assign( const options = Object.assign(
{ {
tileCoord: [z, x, y], tileCoord: [z, x, y],
loader: loader, loader: loader,

View File

@@ -7,7 +7,6 @@ import ImageSource, {defaultImageLoadFunction} from './Image.js';
import ImageWrapper from '../Image.js'; import ImageWrapper from '../Image.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {containsExtent, getHeight, getWidth} from '../extent.js'; import {containsExtent, getHeight, getWidth} from '../extent.js';
/** /**
@@ -172,7 +171,7 @@ class ImageArcGISRest extends ImageSource {
'FORMAT': 'PNG32', 'FORMAT': 'PNG32',
'TRANSPARENT': true, 'TRANSPARENT': true,
}; };
assign(params, this.params_); Object.assign(params, this.params_);
extent = extent.slice(); extent = extent.slice();
const centerX = (extent[0] + extent[2]) / 2; const centerX = (extent[0] + extent[2]) / 2;
@@ -311,7 +310,7 @@ class ImageArcGISRest extends ImageSource {
* @api * @api
*/ */
updateParams(params) { updateParams(params) {
assign(this.params_, params); Object.assign(this.params_, params);
this.image_ = null; this.image_ = null;
this.changed(); this.changed();
} }

View File

@@ -6,7 +6,6 @@ import EventType from '../events/EventType.js';
import ImageSource, {defaultImageLoadFunction} from './Image.js'; import ImageSource, {defaultImageLoadFunction} from './Image.js';
import ImageWrapper from '../Image.js'; import ImageWrapper from '../Image.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
import {assign} from '../obj.js';
import { import {
containsExtent, containsExtent,
getCenter, getCenter,
@@ -220,7 +219,7 @@ class ImageMapGuide extends ImageSource {
* @api * @api
*/ */
updateParams(params) { updateParams(params) {
assign(this.params_, params); Object.assign(this.params_, params);
this.changed(); this.changed();
} }
@@ -250,7 +249,7 @@ class ImageMapGuide extends ImageSource {
'SETVIEWCENTERX': center[0], 'SETVIEWCENTERX': center[0],
'SETVIEWCENTERY': center[1], 'SETVIEWCENTERY': center[1],
}; };
assign(baseParams, params); Object.assign(baseParams, params);
return appendParams(baseUrl, baseParams); return appendParams(baseUrl, baseParams);
} }

View File

@@ -7,7 +7,6 @@ import ImageSource, {defaultImageLoadFunction} from './Image.js';
import ImageState from '../ImageState.js'; import ImageState from '../ImageState.js';
import ImageWrapper from '../Image.js'; import ImageWrapper from '../Image.js';
import {IMAGE_SMOOTHING_DISABLED} from '../renderer/canvas/common.js'; import {IMAGE_SMOOTHING_DISABLED} from '../renderer/canvas/common.js';
import {assign} from '../obj.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import {getHeight, getWidth, intersects} from '../extent.js'; import {getHeight, getWidth, intersects} from '../extent.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
@@ -158,7 +157,7 @@ class Static extends ImageSource {
if (targetWidth !== imageWidth || targetHeight !== imageHeight) { if (targetWidth !== imageWidth || targetHeight !== imageHeight) {
const context = createCanvasContext2D(targetWidth, targetHeight); const context = createCanvasContext2D(targetWidth, targetHeight);
if (!this.getInterpolate()) { if (!this.getInterpolate()) {
assign(context, IMAGE_SMOOTHING_DISABLED); Object.assign(context, IMAGE_SMOOTHING_DISABLED);
} }
const canvas = context.canvas; const canvas = context.canvas;
context.drawImage( context.drawImage(

View File

@@ -8,7 +8,6 @@ import ImageWrapper from '../Image.js';
import {DEFAULT_VERSION} from './wms.js'; import {DEFAULT_VERSION} from './wms.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {calculateSourceResolution} from '../reproj.js'; import {calculateSourceResolution} from '../reproj.js';
import {ceil, floor, round} from '../math.js'; import {ceil, floor, round} from '../math.js';
import {compareVersions} from '../string.js'; import {compareVersions} from '../string.js';
@@ -206,7 +205,7 @@ class ImageWMS extends ImageSource {
'TRANSPARENT': true, 'TRANSPARENT': true,
'QUERY_LAYERS': this.params_['LAYERS'], 'QUERY_LAYERS': this.params_['LAYERS'],
}; };
assign(baseParams, this.params_, params); Object.assign(baseParams, this.params_, params);
const x = floor((coordinate[0] - extent[0]) / resolution, DECIMALS); const x = floor((coordinate[0] - extent[0]) / resolution, DECIMALS);
const y = floor((extent[3] - coordinate[1]) / resolution, DECIMALS); const y = floor((extent[3] - coordinate[1]) / resolution, DECIMALS);
@@ -265,7 +264,7 @@ class ImageWMS extends ImageSource {
baseParams['SCALE'] = (resolution * mpu) / pixelSize; baseParams['SCALE'] = (resolution * mpu) / pixelSize;
} }
assign(baseParams, params); Object.assign(baseParams, params);
return appendParams(/** @type {string} */ (this.url_), baseParams); return appendParams(/** @type {string} */ (this.url_), baseParams);
} }
@@ -338,7 +337,7 @@ class ImageWMS extends ImageSource {
'FORMAT': 'image/png', 'FORMAT': 'image/png',
'TRANSPARENT': true, 'TRANSPARENT': true,
}; };
assign(params, this.params_); Object.assign(params, this.params_);
this.imageSize_[0] = round( this.imageSize_[0] = round(
getWidth(requestExtent) / imageResolution, getWidth(requestExtent) / imageResolution,
@@ -480,7 +479,7 @@ class ImageWMS extends ImageSource {
* @api * @api
*/ */
updateParams(params) { updateParams(params) {
assign(this.params_, params); Object.assign(this.params_, params);
this.updateV13_(); this.updateV13_();
this.image_ = null; this.image_ = null;
this.changed(); this.changed();

View File

@@ -11,7 +11,6 @@ import Source from './Source.js';
import TileLayer from '../layer/Tile.js'; import TileLayer from '../layer/Tile.js';
import TileQueue from '../TileQueue.js'; import TileQueue from '../TileQueue.js';
import TileSource from './Tile.js'; import TileSource from './Tile.js';
import {assign} from '../obj.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import {create as createTransform} from '../transform.js'; import {create as createTransform} from '../transform.js';
import {equals, getCenter, getHeight, getWidth} from '../extent.js'; import {equals, getCenter, getHeight, getWidth} from '../extent.js';
@@ -711,11 +710,11 @@ class RasterSource extends ImageSource {
*/ */
updateFrameState_(extent, resolution, projection) { updateFrameState_(extent, resolution, projection) {
const frameState = /** @type {import("../PluggableMap.js").FrameState} */ ( const frameState = /** @type {import("../PluggableMap.js").FrameState} */ (
assign({}, this.frameState_) Object.assign({}, this.frameState_)
); );
frameState.viewState = /** @type {import("../View.js").State} */ ( frameState.viewState = /** @type {import("../View.js").State} */ (
assign({}, frameState.viewState) Object.assign({}, frameState.viewState)
); );
const center = getCenter(extent); const center = getCenter(extent);

View File

@@ -4,7 +4,6 @@
import TileImage from './TileImage.js'; import TileImage from './TileImage.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
import {assign} from '../obj.js';
import {createEmpty} from '../extent.js'; import {createEmpty} from '../extent.js';
import {modulo} from '../math.js'; import {modulo} from '../math.js';
import {scale as scaleSize, toSize} from '../size.js'; import {scale as scaleSize, toSize} from '../size.js';
@@ -208,7 +207,7 @@ class TileArcGISRest extends TileImage {
* @api * @api
*/ */
updateParams(params) { updateParams(params) {
assign(this.params_, params); Object.assign(this.params_, params);
this.setKey(this.getKeyForParams_()); this.setKey(this.getKeyForParams_());
} }
@@ -246,7 +245,7 @@ class TileArcGISRest extends TileImage {
'FORMAT': 'PNG32', 'FORMAT': 'PNG32',
'TRANSPARENT': true, 'TRANSPARENT': true,
}; };
assign(baseParams, this.params_); Object.assign(baseParams, this.params_);
return this.getRequestUrl_( return this.getRequestUrl_(
tileCoord, tileCoord,

View File

@@ -6,7 +6,6 @@ import TileImage from './TileImage.js';
import {DEFAULT_VERSION} from './wms.js'; import {DEFAULT_VERSION} from './wms.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {assign} from '../obj.js';
import {buffer, createEmpty} from '../extent.js'; import {buffer, createEmpty} from '../extent.js';
import {buffer as bufferSize, scale as scaleSize, toSize} from '../size.js'; import {buffer as bufferSize, scale as scaleSize, toSize} from '../size.js';
import {calculateSourceResolution} from '../reproj.js'; import {calculateSourceResolution} from '../reproj.js';
@@ -218,7 +217,7 @@ class TileWMS extends TileImage {
'TRANSPARENT': true, 'TRANSPARENT': true,
'QUERY_LAYERS': this.params_['LAYERS'], 'QUERY_LAYERS': this.params_['LAYERS'],
}; };
assign(baseParams, this.params_, params); Object.assign(baseParams, this.params_, params);
const x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution); const x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution);
const y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution); const y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution);
@@ -279,7 +278,7 @@ class TileWMS extends TileImage {
baseParams['SCALE'] = (resolution * mpu) / pixelSize; baseParams['SCALE'] = (resolution * mpu) / pixelSize;
} }
assign(baseParams, params); Object.assign(baseParams, params);
return appendParams(/** @type {string} */ (this.urls[0]), baseParams); return appendParams(/** @type {string} */ (this.urls[0]), baseParams);
} }
@@ -407,7 +406,7 @@ class TileWMS extends TileImage {
* @api * @api
*/ */
updateParams(params) { updateParams(params) {
assign(this.params_, params); Object.assign(this.params_, params);
this.updateV13_(); this.updateV13_();
this.setKey(this.getKeyForParams_()); this.setKey(this.getKeyForParams_());
} }
@@ -462,7 +461,7 @@ class TileWMS extends TileImage {
'FORMAT': 'image/png', 'FORMAT': 'image/png',
'TRANSPARENT': true, 'TRANSPARENT': true,
}; };
assign(baseParams, this.params_); Object.assign(baseParams, this.params_);
return this.getRequestUrl_( return this.getRequestUrl_(
tileCoord, tileCoord,

View File

@@ -4,7 +4,6 @@
import TileImage from './TileImage.js'; import TileImage from './TileImage.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
import {assign} from '../obj.js';
import {containsExtent} from '../extent.js'; import {containsExtent} from '../extent.js';
import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js'; import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js';
import {createFromTileUrlFunctions, expandUrl} from '../tileurlfunction.js'; import {createFromTileUrlFunctions, expandUrl} from '../tileurlfunction.js';
@@ -267,7 +266,7 @@ class WMTS extends TileImage {
* @api * @api
*/ */
updateDimensions(dimensions) { updateDimensions(dimensions) {
assign(this.dimensions_, dimensions); Object.assign(this.dimensions_, dimensions);
this.setKey(this.getKeyForDimensions_()); this.setKey(this.getKeyForDimensions_());
} }
@@ -287,7 +286,7 @@ class WMTS extends TileImage {
}; };
if (requestEncoding == 'KVP') { if (requestEncoding == 'KVP') {
assign(context, { Object.assign(context, {
'Service': 'WMTS', 'Service': 'WMTS',
'Request': 'GetTile', 'Request': 'GetTile',
'Version': this.version_, 'Version': this.version_,
@@ -327,7 +326,7 @@ class WMTS extends TileImage {
'TileCol': tileCoord[1], 'TileCol': tileCoord[1],
'TileRow': tileCoord[2], 'TileRow': tileCoord[2],
}; };
assign(localContext, dimensions); Object.assign(localContext, dimensions);
let url = template; let url = template;
if (requestEncoding == 'KVP') { if (requestEncoding == 'KVP') {
url = appendParams(url, localContext); url = appendParams(url, localContext);

View File

@@ -3,7 +3,6 @@
*/ */
import TileGrid from '../tilegrid/TileGrid.js'; import TileGrid from '../tilegrid/TileGrid.js';
import {assign} from '../obj.js';
import {getJSON, resolveUrl} from '../net.js'; import {getJSON, resolveUrl} from '../net.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import {getIntersection as intersectExtents} from '../extent.js'; import {getIntersection as intersectExtents} from '../extent.js';
@@ -324,7 +323,7 @@ function parseTileMatrixSet(
} }
} }
assign(localContext, context); Object.assign(localContext, context);
const url = tileUrlTemplate.replace(/\{(\w+?)\}/g, function (m, p) { const url = tileUrlTemplate.replace(/\{(\w+?)\}/g, function (m, p) {
return localContext[p]; return localContext[p];

View File

@@ -3,7 +3,6 @@
*/ */
import {SAFARI_BUG_237906} from './has.js'; import {SAFARI_BUG_237906} from './has.js';
import {assign} from './obj.js';
/** /**
* Constants taken from goog.webgl * Constants taken from goog.webgl
@@ -92,7 +91,7 @@ const CONTEXT_IDS = ['experimental-webgl', 'webgl', 'webkit-3d', 'moz-webgl'];
* @return {WebGLRenderingContext} WebGL rendering context. * @return {WebGLRenderingContext} WebGL rendering context.
*/ */
export function getContext(canvas, opt_attributes) { export function getContext(canvas, opt_attributes) {
const attributes = assign( const attributes = Object.assign(
{ {
preserveDrawingBuffer: true, preserveDrawingBuffer: true,
antialias: SAFARI_BUG_237906 ? false : true, // https://bugs.webkit.org/show_bug.cgi?id=237906 antialias: SAFARI_BUG_237906 ? false : true, // https://bugs.webkit.org/show_bug.cgi?id=237906

View File

@@ -3,7 +3,6 @@
* @module ol/worker/webgl * @module ol/worker/webgl
*/ */
import {WebGLWorkerMessageType} from '../render/webgl/constants.js'; import {WebGLWorkerMessageType} from '../render/webgl/constants.js';
import {assign} from '../obj.js';
import { import {
create as createTransform, create as createTransform,
makeInverse as makeInverseTransform, makeInverse as makeInverseTransform,
@@ -49,7 +48,7 @@ worker.onmessage = (event) => {
} }
/** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */ /** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */
const message = assign( const message = Object.assign(
{ {
vertexBuffer: vertexBuffer.buffer, vertexBuffer: vertexBuffer.buffer,
indexBuffer: indexBuffer.buffer, indexBuffer: indexBuffer.buffer,
@@ -116,7 +115,7 @@ worker.onmessage = (event) => {
const vertexBuffer = Float32Array.from(vertices); const vertexBuffer = Float32Array.from(vertices);
/** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */ /** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */
const message = assign( const message = Object.assign(
{ {
vertexBuffer: vertexBuffer.buffer, vertexBuffer: vertexBuffer.buffer,
indexBuffer: indexBuffer.buffer, indexBuffer: indexBuffer.buffer,
@@ -154,7 +153,7 @@ worker.onmessage = (event) => {
const vertexBuffer = Float32Array.from(vertices); const vertexBuffer = Float32Array.from(vertices);
/** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */ /** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */
const message = assign( const message = Object.assign(
{ {
vertexBuffer: vertexBuffer.buffer, vertexBuffer: vertexBuffer.buffer,
indexBuffer: indexBuffer.buffer, indexBuffer: indexBuffer.buffer,

View File

@@ -2,7 +2,6 @@ import Collection from '../../../../../src/ol/Collection.js';
import Layer from '../../../../../src/ol/layer/Layer.js'; import Layer from '../../../../../src/ol/layer/Layer.js';
import LayerGroup from '../../../../../src/ol/layer/Group.js'; import LayerGroup from '../../../../../src/ol/layer/Group.js';
import Source from '../../../../../src/ol/source/Source.js'; import Source from '../../../../../src/ol/source/Source.js';
import {assign} from '../../../../../src/ol/obj.js';
import {getIntersection} from '../../../../../src/ol/extent.js'; import {getIntersection} from '../../../../../src/ol/extent.js';
import {getUid} from '../../../../../src/ol/util.js'; import {getUid} from '../../../../../src/ol/util.js';
@@ -531,9 +530,9 @@ describe('ol/layer/Group', function () {
expect(layerStatesArray[0]).to.eql(layer1.getLayerState()); expect(layerStatesArray[0]).to.eql(layer1.getLayerState());
// layer state should match except for layer reference // layer state should match except for layer reference
const layerState = assign({}, layerStatesArray[0]); const layerState = Object.assign({}, layerStatesArray[0]);
delete layerState.layer; delete layerState.layer;
const groupState = assign({}, group.getLayerState()); const groupState = Object.assign({}, group.getLayerState());
delete groupState.layer; delete groupState.layer;
expect(layerState).to.eql(groupState); expect(layerState).to.eql(groupState);
@@ -580,14 +579,14 @@ describe('ol/layer/Group', function () {
// compare layer state to group state // compare layer state to group state
// layer state should match except for layer reference // layer state should match except for layer reference
let layerState = assign({}, layerStatesArray[0]); let layerState = Object.assign({}, layerStatesArray[0]);
delete layerState.layer; delete layerState.layer;
const groupState = assign({}, group.getLayerState()); const groupState = Object.assign({}, group.getLayerState());
delete groupState.layer; delete groupState.layer;
expect(layerState).to.eql(groupState); expect(layerState).to.eql(groupState);
// layer state should be transformed (and we ignore layer reference) // layer state should be transformed (and we ignore layer reference)
layerState = assign({}, layerStatesArray[1]); layerState = Object.assign({}, layerStatesArray[1]);
delete layerState.layer; delete layerState.layer;
expect(layerState).to.eql({ expect(layerState).to.eql({
opacity: 0.25, opacity: 0.25,

View File

@@ -1,45 +1,7 @@
import expect from '../expect.js'; import expect from '../expect.js';
import {assign, clear, isEmpty} from '../../../src/ol/obj.js'; import {clear, isEmpty} from '../../../src/ol/obj.js';
describe('ol/obj.js', () => { describe('ol/obj.js', () => {
describe('assign()', function () {
it('is an alias for Object.assign() where available', function () {
if (typeof Object.assign === 'function') {
expect(assign).to.be(Object.assign);
}
});
it('assigns properties from a source object to a target object', function () {
const source = {
sourceProp1: 'sourceValue1',
sourceProp2: 'sourceValue2',
};
const target = {
sourceProp1: 'overridden',
targetProp1: 'targetValue1',
};
const assigned = assign(target, source);
expect(assigned).to.be(target);
expect(assigned.sourceProp1).to.be('sourceValue1');
expect(assigned.sourceProp2).to.be('sourceValue2');
expect(assigned.targetProp1).to.be('targetValue1');
});
it('throws a TypeError with `undefined` as target', function () {
expect(() => assign()).to.throwException(
/Cannot convert undefined or null to object/
);
});
it('throws a TypeError with `null` as target', function () {
expect(() => assign(null)).to.throwException(
/Cannot convert undefined or null to object/
);
});
});
describe('clear()', function () { describe('clear()', function () {
it('removes all properties from an object', function () { it('removes all properties from an object', function () {
expect(isEmpty(clear({foo: 'bar'}))).to.be(true); expect(isEmpty(clear({foo: 'bar'}))).to.be(true);