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
+80 -82
View File
@@ -32,30 +32,98 @@ import {get as getProjection} from '../proj.js';
* @param {module:ol/format/Polyline~Options=} opt_options Optional configuration object.
* @api
*/
const Polyline = function(opt_options) {
class Polyline {
constructor(opt_options) {
const options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
TextFeature.call(this);
TextFeature.call(this);
/**
* @inheritDoc
*/
this.dataProjection = getProjection('EPSG:4326');
/**
* @private
* @type {number}
*/
this.factor_ = options.factor ? options.factor : 1e5;
/**
* @private
* @type {module:ol/geom/GeometryLayout}
*/
this.geometryLayout_ = options.geometryLayout ?
options.geometryLayout : GeometryLayout.XY;
}
/**
* @inheritDoc
*/
this.dataProjection = getProjection('EPSG:4326');
readFeatureFromText(text, opt_options) {
const geometry = this.readGeometryFromText(text, opt_options);
return new Feature(geometry);
}
/**
* @private
* @type {number}
* @inheritDoc
*/
this.factor_ = options.factor ? options.factor : 1e5;
readFeaturesFromText(text, opt_options) {
const feature = this.readFeatureFromText(text, opt_options);
return [feature];
}
/**
* @private
* @type {module:ol/geom/GeometryLayout}
* @inheritDoc
*/
this.geometryLayout_ = options.geometryLayout ?
options.geometryLayout : GeometryLayout.XY;
};
readGeometryFromText(text, opt_options) {
const stride = getStrideForLayout(this.geometryLayout_);
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
const coordinates = inflateCoordinates(flatCoordinates, 0, flatCoordinates.length, stride);
return (
/** @type {module:ol/geom/Geometry} */ (transformWithOptions(
new LineString(coordinates, this.geometryLayout_),
false,
this.adaptOptions(opt_options)
))
);
}
/**
* @inheritDoc
*/
writeFeatureText(feature, opt_options) {
const geometry = feature.getGeometry();
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
} else {
assert(false, 40); // Expected `feature` to have a geometry
return '';
}
}
/**
* @inheritDoc
*/
writeFeaturesText(features, opt_options) {
return this.writeFeatureText(features[0], opt_options);
}
/**
* @inheritDoc
*/
writeGeometryText(geometry, opt_options) {
geometry = /** @type {module:ol/geom/LineString} */
(transformWithOptions(geometry, true, this.adaptOptions(opt_options)));
const flatCoordinates = geometry.getFlatCoordinates();
const stride = geometry.getStride();
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
return encodeDeltas(flatCoordinates, stride, this.factor_);
}
}
inherits(Polyline, TextFeature);
@@ -277,15 +345,6 @@ export function encodeUnsignedInteger(num) {
Polyline.prototype.readFeature;
/**
* @inheritDoc
*/
Polyline.prototype.readFeatureFromText = function(text, opt_options) {
const geometry = this.readGeometryFromText(text, opt_options);
return new Feature(geometry);
};
/**
* Read the feature from the source. As Polyline sources contain a single
* feature, this will return the feature in an array.
@@ -299,15 +358,6 @@ Polyline.prototype.readFeatureFromText = function(text, opt_options) {
Polyline.prototype.readFeatures;
/**
* @inheritDoc
*/
Polyline.prototype.readFeaturesFromText = function(text, opt_options) {
const feature = this.readFeatureFromText(text, opt_options);
return [feature];
};
/**
* Read the geometry from the source.
*
@@ -320,25 +370,6 @@ Polyline.prototype.readFeaturesFromText = function(text, opt_options) {
Polyline.prototype.readGeometry;
/**
* @inheritDoc
*/
Polyline.prototype.readGeometryFromText = function(text, opt_options) {
const stride = getStrideForLayout(this.geometryLayout_);
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
const coordinates = inflateCoordinates(flatCoordinates, 0, flatCoordinates.length, stride);
return (
/** @type {module:ol/geom/Geometry} */ (transformWithOptions(
new LineString(coordinates, this.geometryLayout_),
false,
this.adaptOptions(opt_options)
))
);
};
/**
* Read the projection from a Polyline source.
*
@@ -350,28 +381,6 @@ Polyline.prototype.readGeometryFromText = function(text, opt_options) {
Polyline.prototype.readProjection;
/**
* @inheritDoc
*/
Polyline.prototype.writeFeatureText = function(feature, opt_options) {
const geometry = feature.getGeometry();
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
} else {
assert(false, 40); // Expected `feature` to have a geometry
return '';
}
};
/**
* @inheritDoc
*/
Polyline.prototype.writeFeaturesText = function(features, opt_options) {
return this.writeFeatureText(features[0], opt_options);
};
/**
* Write a single geometry in Polyline format.
*
@@ -384,15 +393,4 @@ Polyline.prototype.writeFeaturesText = function(features, opt_options) {
Polyline.prototype.writeGeometry;
/**
* @inheritDoc
*/
Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
geometry = /** @type {module:ol/geom/LineString} */
(transformWithOptions(geometry, true, this.adaptOptions(opt_options)));
const flatCoordinates = geometry.getFlatCoordinates();
const stride = geometry.getStride();
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
return encodeDeltas(flatCoordinates, stride, this.factor_);
};
export default Polyline;