Deep clone geometry coordinates
Our geometries are mutable, so they can be modified without creating garbage by changing coordinates in place and calling setGeometry afterwards. But this also means that we need to create a deep clone of the coordinates.
This commit is contained in:
1 parent
15053cbe56
commit
ed09173730
2 files changed
+17
-1
No files matched your search
@@ -4,6 +4,7 @@ goog.provide('ol.geom.GeometryType');
|
||||
|
||||
goog.require('goog.events.Event');
|
||||
goog.require('goog.events.EventTarget');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.TransformFunction');
|
||||
|
||||
@@ -25,7 +26,7 @@ goog.inherits(ol.geom.Geometry, goog.events.EventTarget);
|
||||
* @return {ol.geom.Geometry} The cloned geometry.
|
||||
*/
|
||||
ol.geom.Geometry.prototype.clone = function() {
|
||||
return new this.constructor(this.getCoordinates());
|
||||
return new this.constructor(goog.object.unsafeClone(this.getCoordinates()));
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user