Merge pull request #9236 from fredj/cleanup

Move params list to the constructor function
This commit is contained in:
Frédéric Junod
2019-02-19 09:26:46 +01:00
committed by GitHub

View File

@@ -22,81 +22,82 @@ const tmpTransform = createTransform();
* Lightweight, read-only, {@link module:ol/Feature~Feature} and {@link module:ol/geom/Geometry~Geometry} like * Lightweight, read-only, {@link module:ol/Feature~Feature} and {@link module:ol/geom/Geometry~Geometry} like
* structure, optimized for vector tile rendering and styling. Geometry access * structure, optimized for vector tile rendering and styling. Geometry access
* through the API is limited to getting the type and extent of the geometry. * through the API is limited to getting the type and extent of the geometry.
*
* @param {GeometryType} type Geometry type.
* @param {Array<number>} flatCoordinates Flat coordinates. These always need
* to be right-handed for polygons.
* @param {Array<number>|Array<Array<number>>} ends Ends or Endss.
* @param {Object<string, *>} properties Properties.
* @param {number|string|undefined} id Feature id.
*/ */
class RenderFeature { class RenderFeature {
/**
* @param {GeometryType} type Geometry type.
* @param {Array<number>} flatCoordinates Flat coordinates. These always need
* to be right-handed for polygons.
* @param {Array<number>|Array<Array<number>>} ends Ends or Endss.
* @param {Object<string, *>} properties Properties.
* @param {number|string|undefined} id Feature id.
*/
constructor(type, flatCoordinates, ends, properties, id) { constructor(type, flatCoordinates, ends, properties, id) {
/** /**
* @private * @private
* @type {import("../extent.js").Extent|undefined} * @type {import("../extent.js").Extent|undefined}
*/ */
this.extent_; this.extent_;
/** /**
* @private * @private
* @type {number|string|undefined} * @type {number|string|undefined}
*/ */
this.id_ = id; this.id_ = id;
/** /**
* @private * @private
* @type {GeometryType} * @type {GeometryType}
*/ */
this.type_ = type; this.type_ = type;
/** /**
* @private * @private
* @type {Array<number>} * @type {Array<number>}
*/ */
this.flatCoordinates_ = flatCoordinates; this.flatCoordinates_ = flatCoordinates;
/** /**
* @private * @private
* @type {Array<number>} * @type {Array<number>}
*/ */
this.flatInteriorPoints_ = null; this.flatInteriorPoints_ = null;
/** /**
* @private * @private
* @type {Array<number>} * @type {Array<number>}
*/ */
this.flatMidpoints_ = null; this.flatMidpoints_ = null;
/** /**
* @private * @private
* @type {Array<number>|Array<Array<number>>} * @type {Array<number>|Array<Array<number>>}
*/ */
this.ends_ = ends; this.ends_ = ends;
/** /**
* @private * @private
* @type {Object<string, *>} * @type {Object<string, *>}
*/ */
this.properties_ = properties; this.properties_ = properties;
} }
/** /**
* Get a feature property by its key. * Get a feature property by its key.
* @param {string} key Key * @param {string} key Key
* @return {*} Value for the requested key. * @return {*} Value for the requested key.
* @api * @api
*/ */
get(key) { get(key) {
return this.properties_[key]; return this.properties_[key];
} }
/** /**
* Get the extent of this feature's geometry. * Get the extent of this feature's geometry.
* @return {import("../extent.js").Extent} Extent. * @return {import("../extent.js").Extent} Extent.
* @api * @api
*/ */
getExtent() { getExtent() {
if (!this.extent_) { if (!this.extent_) {
this.extent_ = this.type_ === GeometryType.POINT ? this.extent_ = this.type_ === GeometryType.POINT ?
@@ -109,8 +110,8 @@ class RenderFeature {
} }
/** /**
* @return {Array<number>} Flat interior points. * @return {Array<number>} Flat interior points.
*/ */
getFlatInteriorPoint() { getFlatInteriorPoint() {
if (!this.flatInteriorPoints_) { if (!this.flatInteriorPoints_) {
const flatCenter = getCenter(this.getExtent()); const flatCenter = getCenter(this.getExtent());
@@ -121,8 +122,8 @@ class RenderFeature {
} }
/** /**
* @return {Array<number>} Flat interior points. * @return {Array<number>} Flat interior points.
*/ */
getFlatInteriorPoints() { getFlatInteriorPoints() {
if (!this.flatInteriorPoints_) { if (!this.flatInteriorPoints_) {
const flatCenters = linearRingssCenter( const flatCenters = linearRingssCenter(
@@ -134,8 +135,8 @@ class RenderFeature {
} }
/** /**
* @return {Array<number>} Flat midpoint. * @return {Array<number>} Flat midpoint.
*/ */
getFlatMidpoint() { getFlatMidpoint() {
if (!this.flatMidpoints_) { if (!this.flatMidpoints_) {
this.flatMidpoints_ = interpolatePoint( this.flatMidpoints_ = interpolatePoint(
@@ -145,8 +146,8 @@ class RenderFeature {
} }
/** /**
* @return {Array<number>} Flat midpoints. * @return {Array<number>} Flat midpoints.
*/ */
getFlatMidpoints() { getFlatMidpoints() {
if (!this.flatMidpoints_) { if (!this.flatMidpoints_) {
this.flatMidpoints_ = []; this.flatMidpoints_ = [];
@@ -165,28 +166,28 @@ class RenderFeature {
} }
/** /**
* Get the feature identifier. This is a stable identifier for the feature and * Get the feature identifier. This is a stable identifier for the feature and
* is set when reading data from a remote source. * is set when reading data from a remote source.
* @return {number|string|undefined} Id. * @return {number|string|undefined} Id.
* @api * @api
*/ */
getId() { getId() {
return this.id_; return this.id_;
} }
/** /**
* @return {Array<number>} Flat coordinates. * @return {Array<number>} Flat coordinates.
*/ */
getOrientedFlatCoordinates() { getOrientedFlatCoordinates() {
return this.flatCoordinates_; return this.flatCoordinates_;
} }
/** /**
* For API compatibility with {@link module:ol/Feature~Feature}, this method is useful when * For API compatibility with {@link module:ol/Feature~Feature}, this method is useful when
* determining the geometry type in style function (see {@link #getType}). * determining the geometry type in style function (see {@link #getType}).
* @return {RenderFeature} Feature. * @return {RenderFeature} Feature.
* @api * @api
*/ */
getGeometry() { getGeometry() {
return this; return this;
} }
@@ -200,17 +201,17 @@ class RenderFeature {
} }
/** /**
* Get the feature properties. * Get the feature properties.
* @return {Object<string, *>} Feature properties. * @return {Object<string, *>} Feature properties.
* @api * @api
*/ */
getProperties() { getProperties() {
return this.properties_; return this.properties_;
} }
/** /**
* @return {number} Stride. * @return {number} Stride.
*/ */
getStride() { getStride() {
return 2; return 2;
} }
@@ -223,21 +224,21 @@ class RenderFeature {
} }
/** /**
* Get the type of this feature's geometry. * Get the type of this feature's geometry.
* @return {GeometryType} Geometry type. * @return {GeometryType} Geometry type.
* @api * @api
*/ */
getType() { getType() {
return this.type_; return this.type_;
} }
/** /**
* Transform geometry coordinates from tile pixel space to projected. * Transform geometry coordinates from tile pixel space to projected.
* The SRS of the source and destination are expected to be the same. * The SRS of the source and destination are expected to be the same.
* *
* @param {import("../proj.js").ProjectionLike} source The current projection * @param {import("../proj.js").ProjectionLike} source The current projection
* @param {import("../proj.js").ProjectionLike} destination The desired projection. * @param {import("../proj.js").ProjectionLike} destination The desired projection.
*/ */
transform(source, destination) { transform(source, destination) {
source = getProjection(source); source = getProjection(source);
const pixelExtent = source.getExtent(); const pixelExtent = source.getExtent();