Automated class transform

npx lebab --replace src --transform class
This commit is contained in:
Tim Schaub
2018-07-16 16:18:16 -06:00
parent 60e85e7d89
commit 7b4a73f3b9
145 changed files with 32887 additions and 33714 deletions

View File

@@ -23,157 +23,152 @@ import {squaredDistance as squaredDx} from '../math.js';
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @api
*/
const MultiPoint = function(coordinates, opt_layout) {
SimpleGeometry.call(this);
if (opt_layout && !Array.isArray(coordinates[0])) {
this.setFlatCoordinates(opt_layout, coordinates);
} else {
this.setCoordinates(coordinates, opt_layout);
class MultiPoint {
constructor(coordinates, opt_layout) {
SimpleGeometry.call(this);
if (opt_layout && !Array.isArray(coordinates[0])) {
this.setFlatCoordinates(opt_layout, coordinates);
} else {
this.setCoordinates(coordinates, opt_layout);
}
}
};
/**
* Append the passed point to this multipoint.
* @param {module:ol/geom/Point} point Point.
* @api
*/
appendPoint(point) {
if (!this.flatCoordinates) {
this.flatCoordinates = point.getFlatCoordinates().slice();
} else {
extend(this.flatCoordinates, point.getFlatCoordinates());
}
this.changed();
}
/**
* Make a complete copy of the geometry.
* @return {!module:ol/geom/MultiPoint} Clone.
* @override
* @api
*/
clone() {
const multiPoint = new MultiPoint(this.flatCoordinates.slice(), this.layout);
return multiPoint;
}
/**
* @inheritDoc
*/
closestPointXY(x, y, closestPoint, minSquaredDistance) {
if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
return minSquaredDistance;
}
const flatCoordinates = this.flatCoordinates;
const stride = this.stride;
for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
const squaredDistance = squaredDx(
x, y, flatCoordinates[i], flatCoordinates[i + 1]);
if (squaredDistance < minSquaredDistance) {
minSquaredDistance = squaredDistance;
for (let j = 0; j < stride; ++j) {
closestPoint[j] = flatCoordinates[i + j];
}
closestPoint.length = stride;
}
}
return minSquaredDistance;
}
/**
* Return the coordinates of the multipoint.
* @return {Array.<module:ol/coordinate~Coordinate>} Coordinates.
* @override
* @api
*/
getCoordinates() {
return inflateCoordinates(
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
}
/**
* Return the point at the specified index.
* @param {number} index Index.
* @return {module:ol/geom/Point} Point.
* @api
*/
getPoint(index) {
const n = !this.flatCoordinates ? 0 : this.flatCoordinates.length / this.stride;
if (index < 0 || n <= index) {
return null;
}
return new Point(this.flatCoordinates.slice(
index * this.stride, (index + 1) * this.stride), this.layout);
}
/**
* Return the points of this multipoint.
* @return {Array.<module:ol/geom/Point>} Points.
* @api
*/
getPoints() {
const flatCoordinates = this.flatCoordinates;
const layout = this.layout;
const stride = this.stride;
/** @type {Array.<module:ol/geom/Point>} */
const points = [];
for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
const point = new Point(flatCoordinates.slice(i, i + stride), layout);
points.push(point);
}
return points;
}
/**
* @inheritDoc
* @api
*/
getType() {
return GeometryType.MULTI_POINT;
}
/**
* @inheritDoc
* @api
*/
intersectsExtent(extent) {
const flatCoordinates = this.flatCoordinates;
const stride = this.stride;
for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
const x = flatCoordinates[i];
const y = flatCoordinates[i + 1];
if (containsXY(extent, x, y)) {
return true;
}
}
return false;
}
/**
* Set the coordinates of the multipoint.
* @param {!Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
setCoordinates(coordinates, opt_layout) {
this.setLayout(opt_layout, coordinates, 1);
if (!this.flatCoordinates) {
this.flatCoordinates = [];
}
this.flatCoordinates.length = deflateCoordinates(
this.flatCoordinates, 0, coordinates, this.stride);
this.changed();
}
}
inherits(MultiPoint, SimpleGeometry);
/**
* Append the passed point to this multipoint.
* @param {module:ol/geom/Point} point Point.
* @api
*/
MultiPoint.prototype.appendPoint = function(point) {
if (!this.flatCoordinates) {
this.flatCoordinates = point.getFlatCoordinates().slice();
} else {
extend(this.flatCoordinates, point.getFlatCoordinates());
}
this.changed();
};
/**
* Make a complete copy of the geometry.
* @return {!module:ol/geom/MultiPoint} Clone.
* @override
* @api
*/
MultiPoint.prototype.clone = function() {
const multiPoint = new MultiPoint(this.flatCoordinates.slice(), this.layout);
return multiPoint;
};
/**
* @inheritDoc
*/
MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {
if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
return minSquaredDistance;
}
const flatCoordinates = this.flatCoordinates;
const stride = this.stride;
for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
const squaredDistance = squaredDx(
x, y, flatCoordinates[i], flatCoordinates[i + 1]);
if (squaredDistance < minSquaredDistance) {
minSquaredDistance = squaredDistance;
for (let j = 0; j < stride; ++j) {
closestPoint[j] = flatCoordinates[i + j];
}
closestPoint.length = stride;
}
}
return minSquaredDistance;
};
/**
* Return the coordinates of the multipoint.
* @return {Array.<module:ol/coordinate~Coordinate>} Coordinates.
* @override
* @api
*/
MultiPoint.prototype.getCoordinates = function() {
return inflateCoordinates(
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
};
/**
* Return the point at the specified index.
* @param {number} index Index.
* @return {module:ol/geom/Point} Point.
* @api
*/
MultiPoint.prototype.getPoint = function(index) {
const n = !this.flatCoordinates ? 0 : this.flatCoordinates.length / this.stride;
if (index < 0 || n <= index) {
return null;
}
return new Point(this.flatCoordinates.slice(
index * this.stride, (index + 1) * this.stride), this.layout);
};
/**
* Return the points of this multipoint.
* @return {Array.<module:ol/geom/Point>} Points.
* @api
*/
MultiPoint.prototype.getPoints = function() {
const flatCoordinates = this.flatCoordinates;
const layout = this.layout;
const stride = this.stride;
/** @type {Array.<module:ol/geom/Point>} */
const points = [];
for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
const point = new Point(flatCoordinates.slice(i, i + stride), layout);
points.push(point);
}
return points;
};
/**
* @inheritDoc
* @api
*/
MultiPoint.prototype.getType = function() {
return GeometryType.MULTI_POINT;
};
/**
* @inheritDoc
* @api
*/
MultiPoint.prototype.intersectsExtent = function(extent) {
const flatCoordinates = this.flatCoordinates;
const stride = this.stride;
for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
const x = flatCoordinates[i];
const y = flatCoordinates[i + 1];
if (containsXY(extent, x, y)) {
return true;
}
}
return false;
};
/**
* Set the coordinates of the multipoint.
* @param {!Array.<module:ol/coordinate~Coordinate>} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @override
* @api
*/
MultiPoint.prototype.setCoordinates = function(coordinates, opt_layout) {
this.setLayout(opt_layout, coordinates, 1);
if (!this.flatCoordinates) {
this.flatCoordinates = [];
}
this.flatCoordinates.length = deflateCoordinates(
this.flatCoordinates, 0, coordinates, this.stride);
this.changed();
};
export default MultiPoint;