Change the inhertance of MultiPoint/multipoint.
This commit is contained in:
@@ -2,13 +2,9 @@ goog.provide('ol.geom.multipoint');
|
||||
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.point');
|
||||
goog.require('ol.geom.collection');
|
||||
goog.require('ol.projection');
|
||||
|
||||
///**
|
||||
// * @typedef {ol.MultiPointLike|Array.<number>|Object} point Point.
|
||||
// */
|
||||
//ol.PointLike;
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @param {Array.<ol.PointLike>} opt_arg Point.
|
||||
@@ -45,7 +41,7 @@ ol.geom.multipoint = function(opt_arg){
|
||||
var mp = new ol.geom.MultiPoint(points);
|
||||
return mp;
|
||||
};
|
||||
goog.inherits(ol.geom.multipoint, ol.geom.geometry);
|
||||
goog.inherits(ol.geom.multipoint, ol.geom.collection);
|
||||
|
||||
/**
|
||||
* @export
|
||||
@@ -56,7 +52,7 @@ ol.geom.MultiPoint.prototype.points = function(opt_arg){
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
var points = [],
|
||||
allValid = false;
|
||||
goog.array.every(opt_arg, function(spec){
|
||||
allValid = goog.array.every(opt_arg, function(spec){
|
||||
var p = ol.geom.point(spec);
|
||||
if (p instanceof ol.geom.Point) {
|
||||
points.push(p);
|
||||
@@ -68,11 +64,11 @@ ol.geom.MultiPoint.prototype.points = function(opt_arg){
|
||||
if (!allValid) {
|
||||
points = [];
|
||||
}
|
||||
this.setPoints(points);
|
||||
this.setComponents(points);
|
||||
return this;
|
||||
}
|
||||
else {
|
||||
return this.getPoints();
|
||||
return this.getComponents();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,8 +80,7 @@ ol.geom.MultiPoint.prototype.points = function(opt_arg){
|
||||
* @return {ol.geom.MultiPoint} The MultiPoint instance.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.add = function(point, opt_index){
|
||||
var index = this.points_.length,
|
||||
allValid = false,
|
||||
var index = this.getPoints().length,
|
||||
p = ol.geom.point(point);
|
||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||
index = opt_index;
|
||||
@@ -102,7 +97,7 @@ ol.geom.MultiPoint.prototype.add = function(point, opt_index){
|
||||
* @return {ol.geom.MultiPoint} The MultiPoint instance.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.addAll = function(points, opt_index){
|
||||
var index = this.points_.length,
|
||||
var index = this.getPoints().length,
|
||||
p;
|
||||
|
||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||
@@ -126,8 +121,7 @@ ol.geom.MultiPoint.prototype.addAll = function(points, opt_index){
|
||||
* @return {ol.geom.MultiPoint} The MultiPoint instance.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.remove = function(points){
|
||||
var pointArr = [],
|
||||
allValid = false;
|
||||
var pointArr = [];
|
||||
if (!goog.isArray(points)) {
|
||||
pointArr.push(points);
|
||||
} else {
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
goog.provide('ol.geom.MultiPoint');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.geom.Collection');
|
||||
|
||||
/**
|
||||
* Creates ol.geom.MultiPoint objects.
|
||||
*
|
||||
* @extends {ol.geom.Geometry}
|
||||
* @extends {ol.geom.Collection}
|
||||
* @param {Array.<ol.geom.Point>} points An array of points.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.geom.MultiPoint = function(points) {
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.geom.Point>}
|
||||
*/
|
||||
this.points_ = points;
|
||||
|
||||
this.setComponents(points);
|
||||
};
|
||||
|
||||
goog.inherits(ol.geom.MultiPoint, ol.geom.Geometry);
|
||||
goog.inherits(ol.geom.MultiPoint, ol.geom.Collection);
|
||||
|
||||
/**
|
||||
* Sets the MultiPoint's points.
|
||||
@@ -29,7 +23,7 @@ goog.inherits(ol.geom.MultiPoint, ol.geom.Geometry);
|
||||
* @return {Array.<ol.geom.Point>} An array of points.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.getPoints = function() {
|
||||
return this.points_;
|
||||
return this.getComponents();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -38,7 +32,7 @@ ol.geom.MultiPoint.prototype.getPoints = function() {
|
||||
* @param {Array.<ol.geom.Point>} points An array of points.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.setPoints = function(points) {
|
||||
this.points_ = points;
|
||||
this.setComponents(points);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -48,7 +42,7 @@ ol.geom.MultiPoint.prototype.setPoints = function(points) {
|
||||
* @param {number} index The index where to add.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.addPoint = function(point, index) {
|
||||
goog.array.insertAt(this.points_,point,index);
|
||||
this.addComponent(point, index);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,5 +51,5 @@ ol.geom.MultiPoint.prototype.addPoint = function(point, index) {
|
||||
* @param {ol.geom.Point} point A point to be removed.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.removePoint = function(point) {
|
||||
goog.array.remove(this.points_, point);
|
||||
this.removeComponent(point);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user