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.
|
* Unsets a property.
|
||||||
* @param {string} key Key name.
|
* @param {string} key Key name.
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Circle extends SimpleGeometry {
|
|||||||
undefined,
|
undefined,
|
||||||
this.layout
|
this.layout
|
||||||
);
|
);
|
||||||
circle.importPropertiesFrom(this);
|
circle.applyProperties(this);
|
||||||
return circle;
|
return circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,17 +109,6 @@ class Geometry extends BaseObject {
|
|||||||
return abstract();
|
return abstract();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Import properties from another geometry.
|
|
||||||
* @param {Geometry} geometry Source geometry.
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
importPropertiesFrom(geometry) {
|
|
||||||
if (geometry.hasProperties()) {
|
|
||||||
this.setProperties(geometry.getProperties(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @param {number} x X.
|
* @param {number} x X.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class GeometryCollection extends Geometry {
|
|||||||
clone() {
|
clone() {
|
||||||
const geometryCollection = new GeometryCollection(null);
|
const geometryCollection = new GeometryCollection(null);
|
||||||
geometryCollection.setGeometries(this.geometries_);
|
geometryCollection.setGeometries(this.geometries_);
|
||||||
geometryCollection.importPropertiesFrom(this);
|
geometryCollection.applyProperties(this);
|
||||||
return geometryCollection;
|
return geometryCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class LineString extends SimpleGeometry {
|
|||||||
this.flatCoordinates.slice(),
|
this.flatCoordinates.slice(),
|
||||||
this.layout
|
this.layout
|
||||||
);
|
);
|
||||||
lineString.importPropertiesFrom(this);
|
lineString.applyProperties(this);
|
||||||
return lineString;
|
return lineString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class MultiLineString extends SimpleGeometry {
|
|||||||
this.layout,
|
this.layout,
|
||||||
this.ends_.slice()
|
this.ends_.slice()
|
||||||
);
|
);
|
||||||
multiLineString.importPropertiesFrom(this);
|
multiLineString.applyProperties(this);
|
||||||
return multiLineString;
|
return multiLineString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class MultiPoint extends SimpleGeometry {
|
|||||||
this.flatCoordinates.slice(),
|
this.flatCoordinates.slice(),
|
||||||
this.layout
|
this.layout
|
||||||
);
|
);
|
||||||
multiPoint.importPropertiesFrom(this);
|
multiPoint.applyProperties(this);
|
||||||
return multiPoint;
|
return multiPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class MultiPolygon extends SimpleGeometry {
|
|||||||
this.layout,
|
this.layout,
|
||||||
newEndss
|
newEndss
|
||||||
);
|
);
|
||||||
multiPolygon.importPropertiesFrom(this);
|
multiPolygon.applyProperties(this);
|
||||||
|
|
||||||
return multiPolygon;
|
return multiPolygon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Point extends SimpleGeometry {
|
|||||||
*/
|
*/
|
||||||
clone() {
|
clone() {
|
||||||
const point = new Point(this.flatCoordinates.slice(), this.layout);
|
const point = new Point(this.flatCoordinates.slice(), this.layout);
|
||||||
point.importPropertiesFrom(this);
|
point.applyProperties(this);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class Polygon extends SimpleGeometry {
|
|||||||
this.layout,
|
this.layout,
|
||||||
this.ends_.slice()
|
this.ends_.slice()
|
||||||
);
|
);
|
||||||
polygon.importPropertiesFrom(this);
|
polygon.applyProperties(this);
|
||||||
return polygon;
|
return polygon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user