Do not accept null coordinates in Point constructor
This commit is contained in:
@@ -105,10 +105,8 @@ MultiPoint.prototype.getPoint = function(index) {
|
||||
if (index < 0 || n <= index) {
|
||||
return null;
|
||||
}
|
||||
const point = new Point(null);
|
||||
point.setFlatCoordinates(this.layout, this.flatCoordinates.slice(
|
||||
index * this.stride, (index + 1) * this.stride));
|
||||
return point;
|
||||
return new Point(this.flatCoordinates.slice(
|
||||
index * this.stride, (index + 1) * this.stride), this.layout);
|
||||
};
|
||||
|
||||
|
||||
@@ -124,8 +122,7 @@ MultiPoint.prototype.getPoints = function() {
|
||||
/** @type {Array.<module:ol/geom/Point>} */
|
||||
const points = [];
|
||||
for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
|
||||
const point = new Point(null);
|
||||
point.setFlatCoordinates(layout, flatCoordinates.slice(i, i + stride));
|
||||
const point = new Point(flatCoordinates.slice(i, i + stride), layout);
|
||||
points.push(point);
|
||||
}
|
||||
return points;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {createOrUpdateFromCoordinate, containsXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import {deflateCoordinate} from '../geom/flat/deflate.js';
|
||||
@@ -34,8 +33,7 @@ inherits(Point, SimpleGeometry);
|
||||
* @api
|
||||
*/
|
||||
Point.prototype.clone = function() {
|
||||
const point = new Point(null);
|
||||
point.setFlatCoordinates(this.layout, this.flatCoordinates.slice());
|
||||
const point = new Point(this.flatCoordinates.slice(), this.layout);
|
||||
return point;
|
||||
};
|
||||
|
||||
@@ -101,26 +99,13 @@ Point.prototype.intersectsExtent = function(extent) {
|
||||
* @api
|
||||
*/
|
||||
Point.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
if (!coordinates) {
|
||||
this.setFlatCoordinates(GeometryLayout.XY, null);
|
||||
} else {
|
||||
this.setLayout(opt_layout, coordinates, 0);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
this.flatCoordinates.length = deflateCoordinate(
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.changed();
|
||||
this.setLayout(opt_layout, coordinates, 0);
|
||||
if (!this.flatCoordinates) {
|
||||
this.flatCoordinates = [];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/geom/GeometryLayout} layout Layout.
|
||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||
*/
|
||||
Point.prototype.setFlatCoordinates = function(layout, flatCoordinates) {
|
||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||
this.flatCoordinates.length = deflateCoordinate(
|
||||
this.flatCoordinates, 0, coordinates, this.stride);
|
||||
this.changed();
|
||||
};
|
||||
|
||||
export default Point;
|
||||
|
||||
@@ -214,7 +214,7 @@ SimpleGeometry.prototype.setFlatCoordinatesInternal = function(layout, flatCoord
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Array} coordinates Coordinates.
|
||||
* @param {!Array} coordinates Coordinates.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
*/
|
||||
SimpleGeometry.prototype.setCoordinates = function(coordinates, opt_layout) {};
|
||||
|
||||
Reference in New Issue
Block a user