From 2e98eec48dc4993560d45195ec404ac854147991 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 17 Dec 2017 02:05:46 -0700 Subject: [PATCH] Rename _ol_format_Polyline_ to Polyline --- examples/feature-move-animation.js | 4 +- src/ol/format/Polyline.js | 64 ++++++++++++++-------------- test/spec/ol/format/polyline.test.js | 36 ++++++++-------- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/examples/feature-move-animation.js b/examples/feature-move-animation.js index 875d30323c..644b9425e5 100644 --- a/examples/feature-move-animation.js +++ b/examples/feature-move-animation.js @@ -1,7 +1,7 @@ import _ol_Feature_ from '../src/ol/Feature.js'; import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; -import _ol_format_Polyline_ from '../src/ol/format/Polyline.js'; +import Polyline from '../src/ol/format/Polyline.js'; import Point from '../src/ol/geom/Point.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; @@ -57,7 +57,7 @@ var polyline = [ '~@ym@yjA??a@cFd@kBrCgDbAUnAcBhAyAdk@et@??kF}D??OL' ].join(''); -var route = /** @type {ol.geom.LineString} */ (new _ol_format_Polyline_({ +var route = /** @type {ol.geom.LineString} */ (new Polyline({ factor: 1e6 }).readGeometry(polyline, { dataProjection: 'EPSG:4326', diff --git a/src/ol/format/Polyline.js b/src/ol/format/Polyline.js index d4c421eddb..c42d1a88cd 100644 --- a/src/ol/format/Polyline.js +++ b/src/ol/format/Polyline.js @@ -24,7 +24,7 @@ import {get as getProjection} from '../proj.js'; * Optional configuration object. * @api */ -var _ol_format_Polyline_ = function(opt_options) { +var Polyline = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -49,7 +49,7 @@ var _ol_format_Polyline_ = function(opt_options) { options.geometryLayout : GeometryLayout.XY; }; -inherits(_ol_format_Polyline_, _ol_format_TextFeature_); +inherits(Polyline, _ol_format_TextFeature_); /** @@ -65,7 +65,7 @@ inherits(_ol_format_Polyline_, _ol_format_TextFeature_); * @return {string} The encoded string. * @api */ -_ol_format_Polyline_.encodeDeltas = function(numbers, stride, opt_factor) { +Polyline.encodeDeltas = function(numbers, stride, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; var d; @@ -85,7 +85,7 @@ _ol_format_Polyline_.encodeDeltas = function(numbers, stride, opt_factor) { } } - return _ol_format_Polyline_.encodeFloats(numbers, factor); + return Polyline.encodeFloats(numbers, factor); }; @@ -100,7 +100,7 @@ _ol_format_Polyline_.encodeDeltas = function(numbers, stride, opt_factor) { * @return {Array.} A list of n-dimensional points. * @api */ -_ol_format_Polyline_.decodeDeltas = function(encoded, stride, opt_factor) { +Polyline.decodeDeltas = function(encoded, stride, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; var d; @@ -110,7 +110,7 @@ _ol_format_Polyline_.decodeDeltas = function(encoded, stride, opt_factor) { lastNumbers[d] = 0; } - var numbers = _ol_format_Polyline_.decodeFloats(encoded, factor); + var numbers = Polyline.decodeFloats(encoded, factor); var i, ii; for (i = 0, ii = numbers.length; i < ii;) { @@ -137,14 +137,14 @@ _ol_format_Polyline_.decodeDeltas = function(encoded, stride, opt_factor) { * @return {string} The encoded string. * @api */ -_ol_format_Polyline_.encodeFloats = function(numbers, opt_factor) { +Polyline.encodeFloats = function(numbers, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { numbers[i] = Math.round(numbers[i] * factor); } - return _ol_format_Polyline_.encodeSignedIntegers(numbers); + return Polyline.encodeSignedIntegers(numbers); }; @@ -157,9 +157,9 @@ _ol_format_Polyline_.encodeFloats = function(numbers, opt_factor) { * @return {Array.} A list of floating point numbers. * @api */ -_ol_format_Polyline_.decodeFloats = function(encoded, opt_factor) { +Polyline.decodeFloats = function(encoded, opt_factor) { var factor = opt_factor ? opt_factor : 1e5; - var numbers = _ol_format_Polyline_.decodeSignedIntegers(encoded); + var numbers = Polyline.decodeSignedIntegers(encoded); var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { numbers[i] /= factor; @@ -176,13 +176,13 @@ _ol_format_Polyline_.decodeFloats = function(encoded, opt_factor) { * @param {Array.} numbers A list of signed integers. * @return {string} The encoded string. */ -_ol_format_Polyline_.encodeSignedIntegers = function(numbers) { +Polyline.encodeSignedIntegers = function(numbers) { var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { var num = numbers[i]; numbers[i] = (num < 0) ? ~(num << 1) : (num << 1); } - return _ol_format_Polyline_.encodeUnsignedIntegers(numbers); + return Polyline.encodeUnsignedIntegers(numbers); }; @@ -192,8 +192,8 @@ _ol_format_Polyline_.encodeSignedIntegers = function(numbers) { * @param {string} encoded An encoded string. * @return {Array.} A list of signed integers. */ -_ol_format_Polyline_.decodeSignedIntegers = function(encoded) { - var numbers = _ol_format_Polyline_.decodeUnsignedIntegers(encoded); +Polyline.decodeSignedIntegers = function(encoded) { + var numbers = Polyline.decodeUnsignedIntegers(encoded); var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { var num = numbers[i]; @@ -209,11 +209,11 @@ _ol_format_Polyline_.decodeSignedIntegers = function(encoded) { * @param {Array.} numbers A list of unsigned integers. * @return {string} The encoded string. */ -_ol_format_Polyline_.encodeUnsignedIntegers = function(numbers) { +Polyline.encodeUnsignedIntegers = function(numbers) { var encoded = ''; var i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { - encoded += _ol_format_Polyline_.encodeUnsignedInteger(numbers[i]); + encoded += Polyline.encodeUnsignedInteger(numbers[i]); } return encoded; }; @@ -225,7 +225,7 @@ _ol_format_Polyline_.encodeUnsignedIntegers = function(numbers) { * @param {string} encoded An encoded string. * @return {Array.} A list of unsigned integers. */ -_ol_format_Polyline_.decodeUnsignedIntegers = function(encoded) { +Polyline.decodeUnsignedIntegers = function(encoded) { var numbers = []; var current = 0; var shift = 0; @@ -251,7 +251,7 @@ _ol_format_Polyline_.decodeUnsignedIntegers = function(encoded) { * @param {number} num Unsigned integer that should be encoded. * @return {string} The encoded string. */ -_ol_format_Polyline_.encodeUnsignedInteger = function(num) { +Polyline.encodeUnsignedInteger = function(num) { var value, encoded = ''; while (num >= 0x20) { value = (0x20 | (num & 0x1f)) + 63; @@ -274,13 +274,13 @@ _ol_format_Polyline_.encodeUnsignedInteger = function(num) { * @return {ol.Feature} Feature. * @api */ -_ol_format_Polyline_.prototype.readFeature; +Polyline.prototype.readFeature; /** * @inheritDoc */ -_ol_format_Polyline_.prototype.readFeatureFromText = function(text, opt_options) { +Polyline.prototype.readFeatureFromText = function(text, opt_options) { var geometry = this.readGeometryFromText(text, opt_options); return new _ol_Feature_(geometry); }; @@ -296,13 +296,13 @@ _ol_format_Polyline_.prototype.readFeatureFromText = function(text, opt_options) * @return {Array.} Features. * @api */ -_ol_format_Polyline_.prototype.readFeatures; +Polyline.prototype.readFeatures; /** * @inheritDoc */ -_ol_format_Polyline_.prototype.readFeaturesFromText = function(text, opt_options) { +Polyline.prototype.readFeaturesFromText = function(text, opt_options) { var feature = this.readFeatureFromText(text, opt_options); return [feature]; }; @@ -317,15 +317,15 @@ _ol_format_Polyline_.prototype.readFeaturesFromText = function(text, opt_options * @return {ol.geom.Geometry} Geometry. * @api */ -_ol_format_Polyline_.prototype.readGeometry; +Polyline.prototype.readGeometry; /** * @inheritDoc */ -_ol_format_Polyline_.prototype.readGeometryFromText = function(text, opt_options) { +Polyline.prototype.readGeometryFromText = function(text, opt_options) { var stride = SimpleGeometry.getStrideForLayout(this.geometryLayout_); - var flatCoordinates = _ol_format_Polyline_.decodeDeltas( + var flatCoordinates = Polyline.decodeDeltas( text, stride, this.factor_); _ol_geom_flat_flip_.flipXY( flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates); @@ -348,13 +348,13 @@ _ol_format_Polyline_.prototype.readGeometryFromText = function(text, opt_options * @return {ol.proj.Projection} Projection. * @api */ -_ol_format_Polyline_.prototype.readProjection; +Polyline.prototype.readProjection; /** * @inheritDoc */ -_ol_format_Polyline_.prototype.writeFeatureText = function(feature, opt_options) { +Polyline.prototype.writeFeatureText = function(feature, opt_options) { var geometry = feature.getGeometry(); if (geometry) { return this.writeGeometryText(geometry, opt_options); @@ -368,7 +368,7 @@ _ol_format_Polyline_.prototype.writeFeatureText = function(feature, opt_options) /** * @inheritDoc */ -_ol_format_Polyline_.prototype.writeFeaturesText = function(features, opt_options) { +Polyline.prototype.writeFeaturesText = function(features, opt_options) { return this.writeFeatureText(features[0], opt_options); }; @@ -382,13 +382,13 @@ _ol_format_Polyline_.prototype.writeFeaturesText = function(features, opt_option * @return {string} Geometry. * @api */ -_ol_format_Polyline_.prototype.writeGeometry; +Polyline.prototype.writeGeometry; /** * @inheritDoc */ -_ol_format_Polyline_.prototype.writeGeometryText = function(geometry, opt_options) { +Polyline.prototype.writeGeometryText = function(geometry, opt_options) { geometry = /** @type {ol.geom.LineString} */ (FeatureFormat.transformWithOptions( geometry, true, this.adaptOptions(opt_options))); @@ -396,6 +396,6 @@ _ol_format_Polyline_.prototype.writeGeometryText = function(geometry, opt_option var stride = geometry.getStride(); _ol_geom_flat_flip_.flipXY( flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates); - return _ol_format_Polyline_.encodeDeltas(flatCoordinates, stride, this.factor_); + return Polyline.encodeDeltas(flatCoordinates, stride, this.factor_); }; -export default _ol_format_Polyline_; +export default Polyline; diff --git a/test/spec/ol/format/polyline.test.js b/test/spec/ol/format/polyline.test.js index 70e5f9826f..205f7ee9ca 100644 --- a/test/spec/ol/format/polyline.test.js +++ b/test/spec/ol/format/polyline.test.js @@ -1,5 +1,5 @@ import _ol_Feature_ from '../../../../src/ol/Feature.js'; -import _ol_format_Polyline_ from '../../../../src/ol/format/Polyline.js'; +import Polyline from '../../../../src/ol/format/Polyline.js'; import LineString from '../../../../src/ol/geom/LineString.js'; import {get as getProjection, transform} from '../../../../src/ol/proj.js'; @@ -14,7 +14,7 @@ describe('ol.format.Polyline', function() { var points3857; function resetTestingData() { - format = new _ol_format_Polyline_(); + format = new Polyline(); points = [ [-120.20000, 38.50000], [-120.95000, 40.70000], @@ -60,7 +60,7 @@ describe('ol.format.Polyline', function() { describe('encodeDeltas', function() { it('returns expected value', function() { - var encodeDeltas = _ol_format_Polyline_.encodeDeltas; + var encodeDeltas = Polyline.encodeDeltas; expect(encodeDeltas(flippedFlatPoints, 2)).to.eql(encodedFlatPoints); }); @@ -68,7 +68,7 @@ describe('ol.format.Polyline', function() { describe('decodeDeltas', function() { it('returns expected value', function() { - var decodeDeltas = _ol_format_Polyline_.decodeDeltas; + var decodeDeltas = Polyline.decodeDeltas; expect(decodeDeltas(encodedFlatPoints, 2)).to.eql(flippedFlatPoints); }); @@ -77,7 +77,7 @@ describe('ol.format.Polyline', function() { describe('encodeFloats', function() { it('returns expected value', function() { - var encodeFloats = _ol_format_Polyline_.encodeFloats; + var encodeFloats = Polyline.encodeFloats; expect(encodeFloats(smallFloats)).to.eql(encodedFloats); @@ -90,7 +90,7 @@ describe('ol.format.Polyline', function() { describe('decodeFloats', function() { it('returns expected value', function() { - var decodeFloats = _ol_format_Polyline_.decodeFloats; + var decodeFloats = Polyline.decodeFloats; expect(decodeFloats(encodedFloats)).to.eql(smallFloats); expect(decodeFloats(encodedFloats, 1e5)).to.eql(smallFloats); @@ -101,7 +101,7 @@ describe('ol.format.Polyline', function() { describe('encodeSignedIntegers', function() { it('returns expected value', function() { - var encodeSignedIntegers = _ol_format_Polyline_.encodeSignedIntegers; + var encodeSignedIntegers = Polyline.encodeSignedIntegers; expect(encodeSignedIntegers( signedIntegers)).to.eql(encodedSignedIntegers); @@ -110,7 +110,7 @@ describe('ol.format.Polyline', function() { describe('decodeSignedIntegers', function() { it('returns expected value', function() { - var decodeSignedIntegers = _ol_format_Polyline_.decodeSignedIntegers; + var decodeSignedIntegers = Polyline.decodeSignedIntegers; expect(decodeSignedIntegers( encodedSignedIntegers)).to.eql(signedIntegers); @@ -120,7 +120,7 @@ describe('ol.format.Polyline', function() { describe('encodeUnsignedIntegers', function() { it('returns expected value', function() { - var encodeUnsignedIntegers = _ol_format_Polyline_.encodeUnsignedIntegers; + var encodeUnsignedIntegers = Polyline.encodeUnsignedIntegers; expect(encodeUnsignedIntegers( unsignedIntegers)).to.eql(encodedUnsignedIntegers); @@ -129,7 +129,7 @@ describe('ol.format.Polyline', function() { describe('decodeUnsignedIntegers', function() { it('returns expected value', function() { - var decodeUnsignedIntegers = _ol_format_Polyline_.decodeUnsignedIntegers; + var decodeUnsignedIntegers = Polyline.decodeUnsignedIntegers; expect(decodeUnsignedIntegers( encodedUnsignedIntegers)).to.eql(unsignedIntegers); @@ -139,7 +139,7 @@ describe('ol.format.Polyline', function() { describe('encodeFloat', function() { it('returns expected value', function() { - var encodeFloats = _ol_format_Polyline_.encodeFloats; + var encodeFloats = Polyline.encodeFloats; expect(encodeFloats([0.00000])).to.eql('?'); expect(encodeFloats([-0.00001])).to.eql('@'); @@ -162,7 +162,7 @@ describe('ol.format.Polyline', function() { describe('decodeFloat', function() { it('returns expected value', function() { - var decodeFloats = _ol_format_Polyline_.decodeFloats; + var decodeFloats = Polyline.decodeFloats; expect(decodeFloats('?')).to.eql([0.00000]); expect(decodeFloats('@')).to.eql([-0.00001]); @@ -186,7 +186,7 @@ describe('ol.format.Polyline', function() { describe('encodeSignedInteger', function() { it('returns expected value', function() { - var encodeSignedIntegers = _ol_format_Polyline_.encodeSignedIntegers; + var encodeSignedIntegers = Polyline.encodeSignedIntegers; expect(encodeSignedIntegers([0])).to.eql('?'); expect(encodeSignedIntegers([-1])).to.eql('@'); @@ -204,7 +204,7 @@ describe('ol.format.Polyline', function() { describe('decodeSignedInteger', function() { it('returns expected value', function() { - var decodeSignedIntegers = _ol_format_Polyline_.decodeSignedIntegers; + var decodeSignedIntegers = Polyline.decodeSignedIntegers; expect(decodeSignedIntegers('?')).to.eql([0]); expect(decodeSignedIntegers('@')).to.eql([-1]); @@ -223,7 +223,7 @@ describe('ol.format.Polyline', function() { describe('encodeUnsignedInteger', function() { it('returns expected value', function() { - var encodeUnsignedInteger = _ol_format_Polyline_.encodeUnsignedInteger; + var encodeUnsignedInteger = Polyline.encodeUnsignedInteger; expect(encodeUnsignedInteger(0)).to.eql('?'); expect(encodeUnsignedInteger(1)).to.eql('@'); @@ -243,7 +243,7 @@ describe('ol.format.Polyline', function() { describe('decodeUnsignedInteger', function() { it('returns expected value', function() { - var decodeUnsignedIntegers = _ol_format_Polyline_.decodeUnsignedIntegers; + var decodeUnsignedIntegers = Polyline.decodeUnsignedIntegers; expect(decodeUnsignedIntegers('?')).to.eql([0]); expect(decodeUnsignedIntegers('@')).to.eql([1]); @@ -320,12 +320,12 @@ describe('ol.format.Polyline', function() { }); it('parses XYZ linestring', function() { - var xyz = _ol_format_Polyline_.encodeDeltas([ + var xyz = Polyline.encodeDeltas([ 38.500, -120.200, 100, 40.700, -120.950, 200, 43.252, -126.453, 20 ], 3); - var format = new _ol_format_Polyline_({ + var format = new Polyline({ geometryLayout: 'XYZ' });