Method that copies properties from another object moved to the BaseObject class. Not using getProperties() to avoid creating an intermediate object that is not used later
This commit is contained in:
@@ -188,6 +188,18 @@ class BaseObject extends Observable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply any properties from another object without triggering events.
|
||||
* @param {BaseObject} source The source object.
|
||||
* @protected
|
||||
*/
|
||||
applyProperties(source) {
|
||||
if (!source.values_) {
|
||||
return;
|
||||
}
|
||||
assign(this.values_ || (this.values_ = {}), source.values_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets a property.
|
||||
* @param {string} key Key name.
|
||||
|
||||
@@ -42,7 +42,7 @@ class Circle extends SimpleGeometry {
|
||||
undefined,
|
||||
this.layout
|
||||
);
|
||||
circle.importPropertiesFrom(this);
|
||||
circle.applyProperties(this);
|
||||
return circle;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,17 +109,6 @@ class Geometry extends BaseObject {
|
||||
return abstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* Import properties from another geometry.
|
||||
* @param {Geometry} geometry Source geometry.
|
||||
* @protected
|
||||
*/
|
||||
importPropertiesFrom(geometry) {
|
||||
if (geometry.hasProperties()) {
|
||||
this.setProperties(geometry.getProperties(), true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {number} x X.
|
||||
|
||||
@@ -69,7 +69,7 @@ class GeometryCollection extends Geometry {
|
||||
clone() {
|
||||
const geometryCollection = new GeometryCollection(null);
|
||||
geometryCollection.setGeometries(this.geometries_);
|
||||
geometryCollection.importPropertiesFrom(this);
|
||||
geometryCollection.applyProperties(this);
|
||||
return geometryCollection;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class LineString extends SimpleGeometry {
|
||||
this.flatCoordinates.slice(),
|
||||
this.layout
|
||||
);
|
||||
lineString.importPropertiesFrom(this);
|
||||
lineString.applyProperties(this);
|
||||
return lineString;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class MultiLineString extends SimpleGeometry {
|
||||
this.layout,
|
||||
this.ends_.slice()
|
||||
);
|
||||
multiLineString.importPropertiesFrom(this);
|
||||
multiLineString.applyProperties(this);
|
||||
return multiLineString;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class MultiPoint extends SimpleGeometry {
|
||||
this.flatCoordinates.slice(),
|
||||
this.layout
|
||||
);
|
||||
multiPoint.importPropertiesFrom(this);
|
||||
multiPoint.applyProperties(this);
|
||||
return multiPoint;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ class MultiPolygon extends SimpleGeometry {
|
||||
this.layout,
|
||||
newEndss
|
||||
);
|
||||
multiPolygon.importPropertiesFrom(this);
|
||||
multiPolygon.applyProperties(this);
|
||||
|
||||
return multiPolygon;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Point extends SimpleGeometry {
|
||||
*/
|
||||
clone() {
|
||||
const point = new Point(this.flatCoordinates.slice(), this.layout);
|
||||
point.importPropertiesFrom(this);
|
||||
point.applyProperties(this);
|
||||
return point;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class Polygon extends SimpleGeometry {
|
||||
this.layout,
|
||||
this.ends_.slice()
|
||||
);
|
||||
polygon.importPropertiesFrom(this);
|
||||
polygon.applyProperties(this);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user