Use extends and super for geom

This commit is contained in:
Frederic Junod
2018-07-17 16:18:30 +02:00
parent 44bea898b8
commit c707b4c746
11 changed files with 204 additions and 238 deletions

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/Circle * @module ol/geom/Circle
*/ */
import {inherits} from '../util.js';
import {createOrUpdate, forEachCorner, intersects} from '../extent.js'; import {createOrUpdate, forEachCorner, intersects} from '../extent.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import SimpleGeometry from '../geom/SimpleGeometry.js'; import SimpleGeometry from '../geom/SimpleGeometry.js';
@@ -11,18 +10,19 @@ import {deflateCoordinate} from '../geom/flat/deflate.js';
* @classdesc * @classdesc
* Circle geometry. * 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 * @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) { constructor(center, opt_radius, opt_layout) {
SimpleGeometry.call(this); super();
if (opt_layout !== undefined && opt_radius === undefined) { if (opt_layout !== undefined && opt_radius === undefined) {
this.setFlatCoordinates(opt_layout, center); this.setFlatCoordinates(opt_layout, center);
} else { } else {
@@ -212,8 +212,6 @@ class Circle {
} }
} }
inherits(Circle, SimpleGeometry);
/** /**
* Transform each coordinate of the circle from one coordinate reference system * Transform each coordinate of the circle from one coordinate reference system

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/Geometry * @module ol/geom/Geometry
*/ */
import {inherits} from '../util.js';
import BaseObject from '../Object.js'; import BaseObject from '../Object.js';
import {createEmpty, getHeight, returnOrUpdate} from '../extent.js'; import {createEmpty, getHeight, returnOrUpdate} from '../extent.js';
import {FALSE} from '../functions.js'; import {FALSE} from '../functions.js';
@@ -26,73 +25,71 @@ const tmpTransform = createTransform();
* To get notified of changes to the geometry, register a listener for the * To get notified of changes to the geometry, register a listener for the
* generic `change` event on your geometry instance. * generic `change` event on your geometry instance.
* *
* @constructor
* @abstract * @abstract
* @extends {module:ol/Object}
* @api * @api
*/ */
class Geometry { class Geometry extends BaseObject {
constructor() { constructor() {
BaseObject.call(this); super();
/** /**
* @private * @private
* @type {module:ol/extent~Extent} * @type {module:ol/extent~Extent}
*/ */
this.extent_ = createEmpty(); this.extent_ = createEmpty();
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.extentRevision_ = -1; this.extentRevision_ = -1;
/** /**
* @protected * @protected
* @type {Object.<string, module:ol/geom/Geometry>} * @type {Object.<string, module:ol/geom/Geometry>}
*/ */
this.simplifiedGeometryCache = {}; this.simplifiedGeometryCache = {};
/** /**
* @protected * @protected
* @type {number} * @type {number}
*/ */
this.simplifiedGeometryMaxMinSquaredTolerance = 0; this.simplifiedGeometryMaxMinSquaredTolerance = 0;
/** /**
* @protected * @protected
* @type {number} * @type {number}
*/ */
this.simplifiedGeometryRevision = 0; this.simplifiedGeometryRevision = 0;
} }
/** /**
* Make a complete copy of the geometry. * Make a complete copy of the geometry.
* @abstract * @abstract
* @return {!module:ol/geom/Geometry} Clone. * @return {!module:ol/geom/Geometry} Clone.
*/ */
clone() {} clone() {}
/** /**
* @abstract * @abstract
* @param {number} x X. * @param {number} x X.
* @param {number} y Y. * @param {number} y Y.
* @param {module:ol/coordinate~Coordinate} closestPoint Closest point. * @param {module:ol/coordinate~Coordinate} closestPoint Closest point.
* @param {number} minSquaredDistance Minimum squared distance. * @param {number} minSquaredDistance Minimum squared distance.
* @return {number} Minimum squared distance. * @return {number} Minimum squared distance.
*/ */
closestPointXY(x, y, closestPoint, minSquaredDistance) {} closestPointXY(x, y, closestPoint, minSquaredDistance) {}
/** /**
* Return the closest point of the geometry to the passed point as * Return the closest point of the geometry to the passed point as
* {@link module:ol/coordinate~Coordinate coordinate}. * {@link module:ol/coordinate~Coordinate coordinate}.
* @param {module:ol/coordinate~Coordinate} point Point. * @param {module:ol/coordinate~Coordinate} point Point.
* @param {module:ol/coordinate~Coordinate=} opt_closestPoint Closest point. * @param {module:ol/coordinate~Coordinate=} opt_closestPoint Closest point.
* @return {module:ol/coordinate~Coordinate} Closest point. * @return {module:ol/coordinate~Coordinate} Closest point.
* @api * @api
*/ */
getClosestPoint(point, opt_closestPoint) { getClosestPoint(point, opt_closestPoint) {
const closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN]; const closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
this.closestPointXY(point[0], point[1], closestPoint, Infinity); this.closestPointXY(point[0], point[1], closestPoint, Infinity);
@@ -100,30 +97,30 @@ class Geometry {
} }
/** /**
* Returns true if this geometry includes the specified coordinate. If the * Returns true if this geometry includes the specified coordinate. If the
* coordinate is on the boundary of the geometry, returns false. * coordinate is on the boundary of the geometry, returns false.
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate. * @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
* @return {boolean} Contains coordinate. * @return {boolean} Contains coordinate.
* @api * @api
*/ */
intersectsCoordinate(coordinate) { intersectsCoordinate(coordinate) {
return this.containsXY(coordinate[0], coordinate[1]); return this.containsXY(coordinate[0], coordinate[1]);
} }
/** /**
* @abstract * @abstract
* @param {module:ol/extent~Extent} extent Extent. * @param {module:ol/extent~Extent} extent Extent.
* @protected * @protected
* @return {module:ol/extent~Extent} extent Extent. * @return {module:ol/extent~Extent} extent Extent.
*/ */
computeExtent(extent) {} computeExtent(extent) {}
/** /**
* Get the extent of the geometry. * Get the extent of the geometry.
* @param {module:ol/extent~Extent=} opt_extent Extent. * @param {module:ol/extent~Extent=} opt_extent Extent.
* @return {module:ol/extent~Extent} extent Extent. * @return {module:ol/extent~Extent} extent Extent.
* @api * @api
*/ */
getExtent(opt_extent) { getExtent(opt_extent) {
if (this.extentRevision_ != this.getRevision()) { if (this.extentRevision_ != this.getRevision()) {
this.extent_ = this.computeExtent(this.extent_); this.extent_ = this.computeExtent(this.extent_);
@@ -133,103 +130,103 @@ class Geometry {
} }
/** /**
* Rotate the geometry around a given coordinate. This modifies the geometry * Rotate the geometry around a given coordinate. This modifies the geometry
* coordinates in place. * coordinates in place.
* @abstract * @abstract
* @param {number} angle Rotation angle in radians. * @param {number} angle Rotation angle in radians.
* @param {module:ol/coordinate~Coordinate} anchor The rotation center. * @param {module:ol/coordinate~Coordinate} anchor The rotation center.
* @api * @api
*/ */
rotate(angle, anchor) {} rotate(angle, anchor) {}
/** /**
* Scale the geometry (with an optional origin). This modifies the geometry * Scale the geometry (with an optional origin). This modifies the geometry
* coordinates in place. * coordinates in place.
* @abstract * @abstract
* @param {number} sx The scaling factor in the x-direction. * @param {number} sx The scaling factor in the x-direction.
* @param {number=} opt_sy The scaling factor in the y-direction (defaults to * @param {number=} opt_sy The scaling factor in the y-direction (defaults to
* sx). * sx).
* @param {module:ol/coordinate~Coordinate=} opt_anchor The scale origin (defaults to the center * @param {module:ol/coordinate~Coordinate=} opt_anchor The scale origin (defaults to the center
* of the geometry extent). * of the geometry extent).
* @api * @api
*/ */
scale(sx, opt_sy, opt_anchor) {} scale(sx, opt_sy, opt_anchor) {}
/** /**
* Create a simplified version of this geometry. For linestrings, this uses * Create a simplified version of this geometry. For linestrings, this uses
* the the {@link * the the {@link
* https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm * https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
* Douglas Peucker} algorithm. For polygons, a quantization-based * Douglas Peucker} algorithm. For polygons, a quantization-based
* simplification is used to preserve topology. * simplification is used to preserve topology.
* @function * @function
* @param {number} tolerance The tolerance distance for simplification. * @param {number} tolerance The tolerance distance for simplification.
* @return {module:ol/geom/Geometry} A new, simplified version of the original * @return {module:ol/geom/Geometry} A new, simplified version of the original
* geometry. * geometry.
* @api * @api
*/ */
simplify(tolerance) { simplify(tolerance) {
return this.getSimplifiedGeometry(tolerance * tolerance); return this.getSimplifiedGeometry(tolerance * tolerance);
} }
/** /**
* Create a simplified version of this geometry using the Douglas Peucker * Create a simplified version of this geometry using the Douglas Peucker
* algorithm. * algorithm.
* @see https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm * @see https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
* @abstract * @abstract
* @param {number} squaredTolerance Squared tolerance. * @param {number} squaredTolerance Squared tolerance.
* @return {module:ol/geom/Geometry} Simplified geometry. * @return {module:ol/geom/Geometry} Simplified geometry.
*/ */
getSimplifiedGeometry(squaredTolerance) {} getSimplifiedGeometry(squaredTolerance) {}
/** /**
* Get the type of this geometry. * Get the type of this geometry.
* @abstract * @abstract
* @return {module:ol/geom/GeometryType} Geometry type. * @return {module:ol/geom/GeometryType} Geometry type.
*/ */
getType() {} getType() {}
/** /**
* Apply a transform function to each coordinate of the geometry. * Apply a transform function to each coordinate of the geometry.
* The geometry is modified in place. * The geometry is modified in place.
* If you do not want the geometry modified in place, first `clone()` it and * If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone. * then use this function on the clone.
* @abstract * @abstract
* @param {module:ol/proj~TransformFunction} transformFn Transform. * @param {module:ol/proj~TransformFunction} transformFn Transform.
*/ */
applyTransform(transformFn) {} applyTransform(transformFn) {}
/** /**
* Test if the geometry and the passed extent intersect. * Test if the geometry and the passed extent intersect.
* @abstract * @abstract
* @param {module:ol/extent~Extent} extent Extent. * @param {module:ol/extent~Extent} extent Extent.
* @return {boolean} `true` if the geometry and the extent intersect. * @return {boolean} `true` if the geometry and the extent intersect.
*/ */
intersectsExtent(extent) {} intersectsExtent(extent) {}
/** /**
* Translate the geometry. This modifies the geometry coordinates in place. If * Translate the geometry. This modifies the geometry coordinates in place. If
* instead you want a new geometry, first `clone()` this geometry. * instead you want a new geometry, first `clone()` this geometry.
* @abstract * @abstract
* @param {number} deltaX Delta X. * @param {number} deltaX Delta X.
* @param {number} deltaY Delta Y. * @param {number} deltaY Delta Y.
*/ */
translate(deltaX, deltaY) {} translate(deltaX, deltaY) {}
/** /**
* Transform each coordinate of the geometry from one coordinate reference * Transform each coordinate of the geometry from one coordinate reference
* system to another. The geometry is modified in place. * system to another. The geometry is modified in place.
* For example, a line will be transformed to a line and a circle to a circle. * For example, a line will be transformed to a line and a circle to a circle.
* If you do not want the geometry modified in place, first `clone()` it and * If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone. * then use this function on the clone.
* *
* @param {module:ol/proj~ProjectionLike} source The current projection. Can be a * @param {module:ol/proj~ProjectionLike} source The current projection. Can be a
* string identifier or a {@link module:ol/proj/Projection~Projection} object. * string identifier or a {@link module:ol/proj/Projection~Projection} object.
* @param {module:ol/proj~ProjectionLike} destination The desired projection. Can be a * @param {module:ol/proj~ProjectionLike} destination The desired projection. Can be a
* string identifier or a {@link module:ol/proj/Projection~Projection} object. * string identifier or a {@link module:ol/proj/Projection~Projection} object.
* @return {module:ol/geom/Geometry} This geometry. Note that original geometry is * @return {module:ol/geom/Geometry} This geometry. Note that original geometry is
* modified in place. * modified in place.
* @api * @api
*/ */
transform(source, destination) { transform(source, destination) {
source = getProjection(source); source = getProjection(source);
const transformFn = source.getUnits() == Units.TILE_PIXELS ? const transformFn = source.getUnits() == Units.TILE_PIXELS ?
@@ -251,8 +248,6 @@ class Geometry {
} }
} }
inherits(Geometry, BaseObject);
/** /**
* @param {number} x X. * @param {number} x X.

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/GeometryCollection * @module ol/geom/GeometryCollection
*/ */
import {inherits} from '../util.js';
import {listen, unlisten} from '../events.js'; import {listen, unlisten} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {createOrUpdateEmpty, closestSquaredDistanceXY, extend, getCenter} from '../extent.js'; import {createOrUpdateEmpty, closestSquaredDistanceXY, extend, getCenter} from '../extent.js';
@@ -13,15 +12,16 @@ import {clear} from '../obj.js';
* @classdesc * @classdesc
* An array of {@link module:ol/geom/Geometry} objects. * 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 * @api
*/ */
class GeometryCollection { class GeometryCollection extends Geometry {
/**
* @param {Array.<module:ol/geom/Geometry>=} opt_geometries Geometries.
*/
constructor(opt_geometries) { constructor(opt_geometries) {
Geometry.call(this); super();
/** /**
* @private * @private
@@ -281,8 +281,6 @@ class GeometryCollection {
} }
} }
inherits(GeometryCollection, Geometry);
/** /**
* @param {Array.<module:ol/geom/Geometry>} geometries Geometries. * @param {Array.<module:ol/geom/Geometry>} geometries Geometries.

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/LineString * @module ol/geom/LineString
*/ */
import {inherits} from '../util.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {closestSquaredDistanceXY} from '../extent.js'; import {closestSquaredDistanceXY} from '../extent.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
@@ -20,18 +19,18 @@ import {douglasPeucker} from '../geom/flat/simplify.js';
* @classdesc * @classdesc
* Linestring geometry. * 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 * @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) { constructor(coordinates, opt_layout) {
SimpleGeometry.call(this); super();
/** /**
* @private * @private
@@ -240,7 +239,5 @@ class LineString {
} }
} }
inherits(LineString, SimpleGeometry);
export default LineString; export default LineString;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/LinearRing * @module ol/geom/LinearRing
*/ */
import {inherits} from '../util.js';
import {closestSquaredDistanceXY} from '../extent.js'; import {closestSquaredDistanceXY} from '../extent.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.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 * Linear ring geometry. Only used as part of polygon; cannot be rendered
* on its own. * 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 * @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) { constructor(coordinates, opt_layout) {
SimpleGeometry.call(this); super();
/** /**
* @private * @private
@@ -139,7 +138,5 @@ class LinearRing {
} }
} }
inherits(LinearRing, SimpleGeometry);
export default LinearRing; export default LinearRing;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/MultiLineString * @module ol/geom/MultiLineString
*/ */
import {inherits} from '../util.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {closestSquaredDistanceXY} from '../extent.js'; import {closestSquaredDistanceXY} from '../extent.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
@@ -19,19 +18,20 @@ import {douglasPeuckerArray} from '../geom/flat/simplify.js';
* @classdesc * @classdesc
* Multi-linestring geometry. * Multi-linestring geometry.
* *
* @constructor
* @extends {module:ol/geom/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 * @api
*/ */
class MultiLineString { 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.
*/
constructor(coordinates, opt_layout, opt_ends) { constructor(coordinates, opt_layout, opt_ends) {
SimpleGeometry.call(this); super();
/** /**
* @type {Array.<number>} * @type {Array.<number>}
@@ -270,7 +270,5 @@ class MultiLineString {
} }
} }
inherits(MultiLineString, SimpleGeometry);
export default MultiLineString; export default MultiLineString;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/MultiPoint * @module ol/geom/MultiPoint
*/ */
import {inherits} from '../util.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {closestSquaredDistanceXY, containsXY} from '../extent.js'; import {closestSquaredDistanceXY, containsXY} from '../extent.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
@@ -15,17 +14,17 @@ import {squaredDistance as squaredDx} from '../math.js';
* @classdesc * @classdesc
* Multi-point geometry. * 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 * @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) { constructor(coordinates, opt_layout) {
SimpleGeometry.call(this); super();
if (opt_layout && !Array.isArray(coordinates[0])) { if (opt_layout && !Array.isArray(coordinates[0])) {
this.setFlatCoordinates(opt_layout, coordinates); this.setFlatCoordinates(opt_layout, coordinates);
} else { } else {
@@ -168,7 +167,5 @@ class MultiPoint {
} }
} }
inherits(MultiPoint, SimpleGeometry);
export default MultiPoint; export default MultiPoint;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/MultiPolygon * @module ol/geom/MultiPolygon
*/ */
import {inherits} from '../util.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {closestSquaredDistanceXY} from '../extent.js'; import {closestSquaredDistanceXY} from '../extent.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
@@ -24,20 +23,19 @@ import {quantizeMultiArray} from '../geom/flat/simplify.js';
* @classdesc * @classdesc
* Multi-polygon geometry. * 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 * @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) { constructor(coordinates, opt_layout, opt_endss) {
SimpleGeometry.call(this); super();
/** /**
* @type {Array.<Array.<number>>} * @type {Array.<Array.<number>>}
@@ -373,7 +371,5 @@ class MultiPolygon {
} }
} }
inherits(MultiPolygon, SimpleGeometry);
export default MultiPolygon; export default MultiPolygon;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/Point * @module ol/geom/Point
*/ */
import {inherits} from '../util.js';
import {createOrUpdateFromCoordinate, containsXY} from '../extent.js'; import {createOrUpdateFromCoordinate, containsXY} from '../extent.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import SimpleGeometry from '../geom/SimpleGeometry.js'; import SimpleGeometry from '../geom/SimpleGeometry.js';
@@ -12,15 +11,16 @@ import {squaredDistance as squaredDx} from '../math.js';
* @classdesc * @classdesc
* Point geometry. * Point geometry.
* *
* @constructor
* @extends {module:ol/geom/SimpleGeometry}
* @param {module:ol/coordinate~Coordinate} coordinates Coordinates.
* @param {module:ol/geom/GeometryLayout=} opt_layout Layout.
* @api * @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) { constructor(coordinates, opt_layout) {
SimpleGeometry.call(this); super();
this.setCoordinates(coordinates, opt_layout); this.setCoordinates(coordinates, opt_layout);
} }
@@ -101,7 +101,5 @@ class Point {
} }
} }
inherits(Point, SimpleGeometry);
export default Point; export default Point;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/Polygon * @module ol/geom/Polygon
*/ */
import {inherits} from '../util.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {closestSquaredDistanceXY, getCenter} from '../extent.js'; import {closestSquaredDistanceXY, getCenter} from '../extent.js';
import GeometryLayout from '../geom/GeometryLayout.js'; import GeometryLayout from '../geom/GeometryLayout.js';
@@ -25,24 +24,24 @@ import {modulo} from '../math.js';
* @classdesc * @classdesc
* Polygon geometry. * Polygon geometry.
* *
* @constructor
* @extends {module:ol/geom/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
* linear ring defines a hole in the surface of the polygon. A linear ring is
* an array of vertices' coordinates where the first coordinate and the last are
* 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 * @api
*/ */
class Polygon { 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
* linear ring defines a hole in the surface of the polygon. A linear ring is
* an array of vertices' coordinates where the first coordinate and the last are
* 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).
*/
constructor(coordinates, opt_layout, opt_ends) { constructor(coordinates, opt_layout, opt_ends) {
SimpleGeometry.call(this); super();
/** /**
* @type {Array.<number>} * @type {Array.<number>}
@@ -330,8 +329,6 @@ class Polygon {
} }
} }
inherits(Polygon, SimpleGeometry);
export default Polygon; export default Polygon;

View File

@@ -1,7 +1,6 @@
/** /**
* @module ol/geom/SimpleGeometry * @module ol/geom/SimpleGeometry
*/ */
import {inherits} from '../util.js';
import {FALSE} from '../functions.js'; import {FALSE} from '../functions.js';
import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js'; import {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';
import Geometry from '../geom/Geometry.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 * Abstract base class; only used for creating subclasses; do not instantiate
* in apps, as cannot be rendered. * in apps, as cannot be rendered.
* *
* @constructor
* @abstract * @abstract
* @extends {module:ol/geom/Geometry}
* @api * @api
*/ */
class SimpleGeometry { class SimpleGeometry extends Geometry {
constructor() { constructor() {
Geometry.call(this); super();
/** /**
* @protected * @protected
@@ -257,8 +254,6 @@ class SimpleGeometry {
} }
} }
inherits(SimpleGeometry, Geometry);
/** /**
* @param {number} stride Stride. * @param {number} stride Stride.