Remove use of shared vertices in geom package
This commit is contained in:
+8
-35
@@ -4,42 +4,28 @@ goog.require('goog.asserts');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.geom.SharedVertices');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.geom.Geometry}
|
||||
* @param {ol.Coordinate} coordinates Coordinates array (e.g. [x, y]).
|
||||
* @param {ol.geom.SharedVertices=} opt_shared Shared vertices.
|
||||
* @param {ol.Coordinate} coordinates Coordinate values (e.g. [x, y]).
|
||||
*/
|
||||
ol.geom.Point = function(coordinates, opt_shared) {
|
||||
ol.geom.Point = function(coordinates) {
|
||||
goog.base(this);
|
||||
|
||||
var vertices = opt_shared,
|
||||
dimension;
|
||||
|
||||
if (!goog.isDef(vertices)) {
|
||||
dimension = coordinates.length;
|
||||
vertices = new ol.geom.SharedVertices({dimension: dimension});
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {ol.geom.SharedVertices}
|
||||
*/
|
||||
this.vertices = vertices;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* Point coordinate values.
|
||||
* @type {ol.Coordinate}
|
||||
* @private
|
||||
*/
|
||||
this.sharedId_ = vertices.add([coordinates]);
|
||||
this.coordinates_ = coordinates;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.dimension = vertices.getDimension();
|
||||
this.dimension = coordinates.length;
|
||||
goog.asserts.assert(this.dimension >= 2);
|
||||
|
||||
/**
|
||||
@@ -57,7 +43,7 @@ goog.inherits(ol.geom.Point, ol.geom.Geometry);
|
||||
* @return {number} The coordinate value.
|
||||
*/
|
||||
ol.geom.Point.prototype.get = function(dim) {
|
||||
return this.vertices.get(this.sharedId_, 0, dim);
|
||||
return this.getCoordinates()[dim];
|
||||
};
|
||||
|
||||
|
||||
@@ -79,11 +65,7 @@ ol.geom.Point.prototype.getBounds = function() {
|
||||
* @return {ol.Coordinate} Coordinates array.
|
||||
*/
|
||||
ol.geom.Point.prototype.getCoordinates = function() {
|
||||
var coordinates = new Array(this.dimension);
|
||||
for (var i = 0; i < this.dimension; ++i) {
|
||||
coordinates[i] = this.get(i);
|
||||
}
|
||||
return coordinates;
|
||||
return this.coordinates_;
|
||||
};
|
||||
|
||||
|
||||
@@ -93,12 +75,3 @@ ol.geom.Point.prototype.getCoordinates = function() {
|
||||
ol.geom.Point.prototype.getType = function() {
|
||||
return ol.geom.GeometryType.POINT;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the identifier used to mark this point in the shared vertices structure.
|
||||
* @return {number} The identifier.
|
||||
*/
|
||||
ol.geom.Point.prototype.getSharedId = function() {
|
||||
return this.sharedId_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user