Use extends and super for geom
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/Circle
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {createOrUpdate, forEachCorner, intersects} from '../extent.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
@@ -11,18 +10,19 @@ import {deflateCoordinate} from '../geom/flat/deflate.js';
|
||||
* @classdesc
|
||||
* Circle geometry.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {!module:ol/geom/SimpleGeometry}
|
||||
* @param {!module:ol/coordinate~Coordinate} center Center. (For internal use,
|
||||
* flat coordinates in combination with `opt_layout` and no `opt_radius` are
|
||||
* also accepted.)
|
||||
* @param {number=} opt_radius Radius.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
class Circle {
|
||||
class Circle extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {!module:ol/coordinate~Coordinate} center Center.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` and no
|
||||
* `opt_radius` are also accepted.
|
||||
* @param {number=} opt_radius Radius.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
*/
|
||||
constructor(center, opt_radius, opt_layout) {
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
if (opt_layout !== undefined && opt_radius === undefined) {
|
||||
this.setFlatCoordinates(opt_layout, center);
|
||||
} else {
|
||||
@@ -212,8 +212,6 @@ class Circle {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(Circle, SimpleGeometry);
|
||||
|
||||
|
||||
/**
|
||||
* Transform each coordinate of the circle from one coordinate reference system
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/Geometry
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import BaseObject from '../Object.js';
|
||||
import {createEmpty, getHeight, returnOrUpdate} from '../extent.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
@@ -26,15 +25,13 @@ const tmpTransform = createTransform();
|
||||
* To get notified of changes to the geometry, register a listener for the
|
||||
* generic `change` event on your geometry instance.
|
||||
*
|
||||
* @constructor
|
||||
* @abstract
|
||||
* @extends {module:ol/Object}
|
||||
* @api
|
||||
*/
|
||||
class Geometry {
|
||||
class Geometry extends BaseObject {
|
||||
constructor() {
|
||||
|
||||
BaseObject.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -251,8 +248,6 @@ class Geometry {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(Geometry, BaseObject);
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} x X.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/GeometryCollection
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {createOrUpdateEmpty, closestSquaredDistanceXY, extend, getCenter} from '../extent.js';
|
||||
@@ -13,15 +12,16 @@ import {clear} from '../obj.js';
|
||||
* @classdesc
|
||||
* An array of {@link module:ol/geom/Geometry} objects.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/Geometry}
|
||||
* @param {Array.<module:ol/geom/Geometry>=} opt_geometries Geometries.
|
||||
* @api
|
||||
*/
|
||||
class GeometryCollection {
|
||||
class GeometryCollection extends Geometry {
|
||||
|
||||
/**
|
||||
* @param {Array.<module:ol/geom/Geometry>=} opt_geometries Geometries.
|
||||
*/
|
||||
constructor(opt_geometries) {
|
||||
|
||||
Geometry.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -281,8 +281,6 @@ class GeometryCollection {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(GeometryCollection, Geometry);
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<module:ol/geom/Geometry>} geometries Geometries.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/LineString
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
@@ -20,18 +19,18 @@ import {douglasPeucker} from '../geom/flat/simplify.js';
|
||||
* @classdesc
|
||||
* Linestring geometry.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/SimpleGeometry}
|
||||
* @param {Array.<module:ol/coordinate~Coordinate>|Array.<number>} coordinates
|
||||
* Coordinates. (For internal use, flat coordinates in combination with
|
||||
* `opt_layout` are also accepted).
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
class LineString {
|
||||
class LineString extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {Array.<module:ol/coordinate~Coordinate>|Array.<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` are also accepted.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -240,7 +239,5 @@ class LineString {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(LineString, SimpleGeometry);
|
||||
|
||||
|
||||
export default LineString;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/LinearRing
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
@@ -17,18 +16,18 @@ import {douglasPeucker} from '../geom/flat/simplify.js';
|
||||
* Linear ring geometry. Only used as part of polygon; cannot be rendered
|
||||
* on its own.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/SimpleGeometry}
|
||||
* @param {Array.<module:ol/coordinate~Coordinate>|Array.<number>} coordinates
|
||||
* Coordinates. (For internal use, flat coordinates in combination with
|
||||
* `opt_layout` are also accepted.)
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
class LinearRing {
|
||||
class LinearRing extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {Array.<module:ol/coordinate~Coordinate>|Array.<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` are also accepted.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -139,7 +138,5 @@ class LinearRing {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(LinearRing, SimpleGeometry);
|
||||
|
||||
|
||||
export default LinearRing;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/MultiLineString
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
@@ -19,19 +18,20 @@ import {douglasPeuckerArray} from '../geom/flat/simplify.js';
|
||||
* @classdesc
|
||||
* Multi-linestring geometry.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/SimpleGeometry}
|
||||
* @api
|
||||
*/
|
||||
class MultiLineString extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {Array.<Array.<module:ol/coordinate~Coordinate>|module:ol/geom~MultiLineString>|Array.<number>} coordinates
|
||||
* Coordinates or LineString geometries. (For internal use, flat coordinates in
|
||||
* combination with `opt_layout` and `opt_ends` are also accepted.)
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @param {Array.<number>} opt_ends Flat coordinate ends for internal use.
|
||||
* @api
|
||||
*/
|
||||
class MultiLineString {
|
||||
constructor(coordinates, opt_layout, opt_ends) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @type {Array.<number>}
|
||||
@@ -270,7 +270,5 @@ class MultiLineString {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MultiLineString, SimpleGeometry);
|
||||
|
||||
|
||||
export default MultiLineString;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/MultiPoint
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY, containsXY} from '../extent.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
@@ -15,17 +14,17 @@ import {squaredDistance as squaredDx} from '../math.js';
|
||||
* @classdesc
|
||||
* Multi-point geometry.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/SimpleGeometry}
|
||||
* @param {Array.<module:ol/coordinate~Coordinate>|Array.<number>} coordinates
|
||||
* Coordinates. (For internal use, flat coordinates in combination with
|
||||
* `opt_layout` are also accepted)
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
class MultiPoint {
|
||||
class MultiPoint extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {Array.<module:ol/coordinate~Coordinate>|Array.<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` are also accepted.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
if (opt_layout && !Array.isArray(coordinates[0])) {
|
||||
this.setFlatCoordinates(opt_layout, coordinates);
|
||||
} else {
|
||||
@@ -168,7 +167,5 @@ class MultiPoint {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MultiPoint, SimpleGeometry);
|
||||
|
||||
|
||||
export default MultiPoint;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/MultiPolygon
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
@@ -24,20 +23,19 @@ import {quantizeMultiArray} from '../geom/flat/simplify.js';
|
||||
* @classdesc
|
||||
* Multi-polygon geometry.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/SimpleGeometry}
|
||||
* @param {Array.<Array.<Array.<module:ol/coordinate~Coordinate>>>|Array.<number>} coordinates
|
||||
* Coordinates. (For internal use, flat coordinats in combination with
|
||||
* `opt_layout` and `opt_endss` are also accepted).
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @param {Array.<number>} opt_endss Array of ends for internal use with flat
|
||||
* coordinates.
|
||||
* @api
|
||||
*/
|
||||
class MultiPolygon {
|
||||
class MultiPolygon extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {Array.<Array.<Array.<module:ol/coordinate~Coordinate>>>|Array.<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinats in combination with `opt_layout` and `opt_endss` are also accepted.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @param {Array.<number>} opt_endss Array of ends for internal use with flat coordinates.
|
||||
*/
|
||||
constructor(coordinates, opt_layout, opt_endss) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @type {Array.<Array.<number>>}
|
||||
@@ -373,7 +371,5 @@ class MultiPolygon {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MultiPolygon, SimpleGeometry);
|
||||
|
||||
|
||||
export default MultiPolygon;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/Point
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {createOrUpdateFromCoordinate, containsXY} from '../extent.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
@@ -12,15 +11,16 @@ import {squaredDistance as squaredDx} from '../math.js';
|
||||
* @classdesc
|
||||
* Point geometry.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/SimpleGeometry}
|
||||
* @param {module:ol/coordinate~Coordinate} coordinates Coordinates.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @api
|
||||
*/
|
||||
class Point {
|
||||
class Point extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {module:ol/coordinate~Coordinate} coordinates Coordinates.
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
*/
|
||||
constructor(coordinates, opt_layout) {
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
this.setCoordinates(coordinates, opt_layout);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,5 @@ class Point {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(Point, SimpleGeometry);
|
||||
|
||||
|
||||
export default Point;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/Polygon
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {extend} from '../array.js';
|
||||
import {closestSquaredDistanceXY, getCenter} from '../extent.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
@@ -25,8 +24,11 @@ import {modulo} from '../math.js';
|
||||
* @classdesc
|
||||
* Polygon geometry.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:ol/geom/SimpleGeometry}
|
||||
* @api
|
||||
*/
|
||||
class Polygon extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {!Array.<Array.<module:ol/coordinate~Coordinate>>|!Array.<number>} coordinates
|
||||
* Array of linear rings that define the polygon. The first linear ring of the
|
||||
* array defines the outer-boundary or surface of the polygon. Each subsequent
|
||||
@@ -35,14 +37,11 @@ import {modulo} from '../math.js';
|
||||
* equivalent. (For internal use, flat coordinates in combination with
|
||||
* `opt_layout` and `opt_ends` are also accepted.)
|
||||
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
|
||||
* @param {Array.<number>=} opt_ends Ends (for internal use with flat
|
||||
* coordinates).
|
||||
* @api
|
||||
* @param {Array.<number>=} opt_ends Ends (for internal use with flat coordinates).
|
||||
*/
|
||||
class Polygon {
|
||||
constructor(coordinates, opt_layout, opt_ends) {
|
||||
|
||||
SimpleGeometry.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @type {Array.<number>}
|
||||
@@ -330,8 +329,6 @@ class Polygon {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(Polygon, SimpleGeometry);
|
||||
|
||||
|
||||
export default Polygon;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/SimpleGeometry
|
||||
*/
|
||||
import {inherits} from '../util.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';
|
||||
import Geometry from '../geom/Geometry.js';
|
||||
@@ -14,15 +13,13 @@ import {clear} from '../obj.js';
|
||||
* Abstract base class; only used for creating subclasses; do not instantiate
|
||||
* in apps, as cannot be rendered.
|
||||
*
|
||||
* @constructor
|
||||
* @abstract
|
||||
* @extends {module:ol/geom/Geometry}
|
||||
* @api
|
||||
*/
|
||||
class SimpleGeometry {
|
||||
class SimpleGeometry extends Geometry {
|
||||
constructor() {
|
||||
|
||||
Geometry.call(this);
|
||||
super();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -257,8 +254,6 @@ class SimpleGeometry {
|
||||
}
|
||||
}
|
||||
|
||||
inherits(SimpleGeometry, Geometry);
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} stride Stride.
|
||||
|
||||
Reference in New Issue
Block a user