The shared vertices structure now works with integer arrays only
Previously, a lookup object containing start indexes was also used. This allowed us to remove arrays of vertices and properly update the start indexes for remaining coordinate values. In order to provide callers with stable identifiers and to work with arrays of integers alone, we cannot support a remove method. I think this is worth revisiting. Even if the array length cannot be changed in WebGL, we don't need to also impose the restriction outside. Instead, the WebGL renderer could be notified when array sizes change and update itself accordingly. I think there is more value in providing geometries with stable identifiers. This common structure is used to store vertices for all geometry types. A slight optimization could be made by creating yet another structure to store point vertices - since these don't need to have a counts array (always 1). Creating a new structure would mean saving memory at the expense of more lib code to transport. The coordinate value lookups are not negatively impacted by using the same structure for points and higher order geometries. Since the first change above goes against my instincts, I'm not making this second change (to add another structure for shared point vertices).
This commit is contained in:
@@ -34,7 +34,7 @@ ol.geom.LineString = function(coordinates, opt_shared) {
|
||||
this.vertices = vertices;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.sharedId_ = vertices.add(coordinates);
|
||||
@@ -142,7 +142,7 @@ ol.geom.LineString.prototype.getType = function() {
|
||||
|
||||
/**
|
||||
* Get the identifier used to mark this line in the shared vertices structure.
|
||||
* @return {string} The identifier.
|
||||
* @return {number} The identifier.
|
||||
*/
|
||||
ol.geom.LineString.prototype.getSharedId = function() {
|
||||
return this.sharedId_;
|
||||
|
||||
Reference in New Issue
Block a user