Named exports from ol/geom/flat/flip
This commit is contained in:
@@ -9,7 +9,7 @@ import TextFeature from '../format/TextFeature.js';
|
||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import LineString from '../geom/LineString.js';
|
||||
import {getStrideForLayout} from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_flip_ from '../geom/flat/flip.js';
|
||||
import {flipXY} from '../geom/flat/flip.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
@@ -326,8 +326,7 @@ Polyline.prototype.readGeometry;
|
||||
Polyline.prototype.readGeometryFromText = function(text, opt_options) {
|
||||
const stride = getStrideForLayout(this.geometryLayout_);
|
||||
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
||||
_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
const coordinates = _ol_geom_flat_inflate_.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
|
||||
@@ -392,8 +391,7 @@ Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
|
||||
(transformWithOptions(geometry, true, this.adaptOptions(opt_options)));
|
||||
const flatCoordinates = geometry.getFlatCoordinates();
|
||||
const stride = geometry.getStride();
|
||||
_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
return encodeDeltas(flatCoordinates, stride, this.factor_);
|
||||
};
|
||||
export default Polyline;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/flat/flip
|
||||
*/
|
||||
const _ol_geom_flat_flip_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,7 +12,7 @@ const _ol_geom_flat_flip_ = {};
|
||||
* @param {number=} opt_destOffset Destination offset.
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
_ol_geom_flat_flip_.flipXY = function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) {
|
||||
export function flipXY(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) {
|
||||
let dest, destOffset;
|
||||
if (opt_dest !== undefined) {
|
||||
dest = opt_dest;
|
||||
@@ -33,5 +32,4 @@ _ol_geom_flat_flip_.flipXY = function(flatCoordinates, offset, end, stride, opt_
|
||||
}
|
||||
dest.length = destOffset;
|
||||
return dest;
|
||||
};
|
||||
export default _ol_geom_flat_flip_;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_flip_ from '../../../../../src/ol/geom/flat/flip.js';
|
||||
import {flipXY} from '../../../../../src/ol/geom/flat/flip.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.flip', function() {
|
||||
@@ -6,29 +6,25 @@ describe('ol.geom.flat.flip', function() {
|
||||
describe('ol.geom.flat.flip.flipXY', function() {
|
||||
|
||||
it('can flip XY coordinates', function() {
|
||||
const flatCoordinates = _ol_geom_flat_flip_.flipXY([1, 2, 3, 4], 0, 4, 2);
|
||||
const flatCoordinates = flipXY([1, 2, 3, 4], 0, 4, 2);
|
||||
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates while preserving other dimensions', function() {
|
||||
const flatCoordinates = _ol_geom_flat_flip_.flipXY(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8], 0, 8, 4);
|
||||
const flatCoordinates = flipXY([1, 2, 3, 4, 5, 6, 7, 8], 0, 8, 4);
|
||||
expect(flatCoordinates).to.eql([2, 1, 3, 4, 6, 5, 7, 8]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates in place', function() {
|
||||
const flatCoordinates = [1, 2, 3, 4];
|
||||
expect(_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
|
||||
expect(flipXY(flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
|
||||
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
|
||||
});
|
||||
|
||||
it('can flip XY coordinates in place while preserving other dimensions',
|
||||
function() {
|
||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
expect(_ol_geom_flat_flip_.flipXY(
|
||||
flatCoordinates, 0, 9, 3, flatCoordinates)).
|
||||
to.be(flatCoordinates);
|
||||
expect(flipXY(flatCoordinates, 0, 9, 3, flatCoordinates)).to.be(flatCoordinates);
|
||||
expect(flatCoordinates).to.eql([2, 1, 3, 5, 4, 6, 8, 7, 9]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user