Change TextFeature#getText_ to a static function

This commit is contained in:
Frederic Junod
2017-12-22 15:10:57 +01:00
parent 2130ce7481
commit a0b68010b9
+8 -14
View File
@@ -24,16 +24,15 @@ inherits(TextFeature, FeatureFormat);
/** /**
* @param {Document|Node|Object|string} source Source. * @param {Document|Node|Object|string} source Source.
* @private
* @return {string} Text. * @return {string} Text.
*/ */
TextFeature.prototype.getText_ = function(source) { function getText(source) {
if (typeof source === 'string') { if (typeof source === 'string') {
return source; return source;
} else { } else {
return ''; return '';
} }
}; }
/** /**
@@ -48,8 +47,7 @@ TextFeature.prototype.getType = function() {
* @inheritDoc * @inheritDoc
*/ */
TextFeature.prototype.readFeature = function(source, opt_options) { TextFeature.prototype.readFeature = function(source, opt_options) {
return this.readFeatureFromText( return this.readFeatureFromText(getText(source), this.adaptOptions(opt_options));
this.getText_(source), this.adaptOptions(opt_options));
}; };
@@ -67,8 +65,7 @@ TextFeature.prototype.readFeatureFromText = function(text, opt_options) {};
* @inheritDoc * @inheritDoc
*/ */
TextFeature.prototype.readFeatures = function(source, opt_options) { TextFeature.prototype.readFeatures = function(source, opt_options) {
return this.readFeaturesFromText( return this.readFeaturesFromText(getText(source), this.adaptOptions(opt_options));
this.getText_(source), this.adaptOptions(opt_options));
}; };
@@ -86,8 +83,7 @@ TextFeature.prototype.readFeaturesFromText = function(text, opt_options) {};
* @inheritDoc * @inheritDoc
*/ */
TextFeature.prototype.readGeometry = function(source, opt_options) { TextFeature.prototype.readGeometry = function(source, opt_options) {
return this.readGeometryFromText( return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
this.getText_(source), this.adaptOptions(opt_options));
}; };
@@ -105,7 +101,7 @@ TextFeature.prototype.readGeometryFromText = function(text, opt_options) {};
* @inheritDoc * @inheritDoc
*/ */
TextFeature.prototype.readProjection = function(source) { TextFeature.prototype.readProjection = function(source) {
return this.readProjectionFromText(this.getText_(source)); return this.readProjectionFromText(getText(source));
}; };
@@ -140,8 +136,7 @@ TextFeature.prototype.writeFeatureText = function(feature, opt_options) {};
/** /**
* @inheritDoc * @inheritDoc
*/ */
TextFeature.prototype.writeFeatures = function( TextFeature.prototype.writeFeatures = function(features, opt_options) {
features, opt_options) {
return this.writeFeaturesText(features, this.adaptOptions(opt_options)); return this.writeFeaturesText(features, this.adaptOptions(opt_options));
}; };
@@ -159,8 +154,7 @@ TextFeature.prototype.writeFeaturesText = function(features, opt_options) {};
/** /**
* @inheritDoc * @inheritDoc
*/ */
TextFeature.prototype.writeGeometry = function( TextFeature.prototype.writeGeometry = function(geometry, opt_options) {
geometry, opt_options) {
return this.writeGeometryText(geometry, this.adaptOptions(opt_options)); return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
}; };