Named exports from ol/geom/flat/reverse
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/orient
|
* @module ol/geom/flat/orient
|
||||||
*/
|
*/
|
||||||
import _ol_geom_flat_reverse_ from '../flat/reverse.js';
|
import {coordinates as reverseCoordinates} from '../flat/reverse.js';
|
||||||
const _ol_geom_flat_orient_ = {};
|
const _ol_geom_flat_orient_ = {};
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ _ol_geom_flat_orient_.orientLinearRings = function(flatCoordinates, offset, ends
|
|||||||
(right && isClockwise) || (!right && !isClockwise) :
|
(right && isClockwise) || (!right && !isClockwise) :
|
||||||
(right && !isClockwise) || (!right && isClockwise);
|
(right && !isClockwise) || (!right && isClockwise);
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
_ol_geom_flat_reverse_.coordinates(flatCoordinates, offset, end, stride);
|
reverseCoordinates(flatCoordinates, offset, end, stride);
|
||||||
}
|
}
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/geom/flat/reverse
|
* @module ol/geom/flat/reverse
|
||||||
*/
|
*/
|
||||||
const _ol_geom_flat_reverse_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +9,7 @@ const _ol_geom_flat_reverse_ = {};
|
|||||||
* @param {number} end End.
|
* @param {number} end End.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_reverse_.coordinates = function(flatCoordinates, offset, end, stride) {
|
export function coordinates(flatCoordinates, offset, end, stride) {
|
||||||
while (offset < end - stride) {
|
while (offset < end - stride) {
|
||||||
for (let i = 0; i < stride; ++i) {
|
for (let i = 0; i < stride; ++i) {
|
||||||
const tmp = flatCoordinates[offset + i];
|
const tmp = flatCoordinates[offset + i];
|
||||||
@@ -20,5 +19,4 @@ _ol_geom_flat_reverse_.coordinates = function(flatCoordinates, offset, end, stri
|
|||||||
offset += stride;
|
offset += stride;
|
||||||
end -= stride;
|
end -= stride;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_reverse_;
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ol_geom_flat_reverse_ from '../../../../../src/ol/geom/flat/reverse.js';
|
import {coordinates as reverseCoordinates} from '../../../../../src/ol/geom/flat/reverse.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.geom.flat.reverse', function() {
|
describe('ol.geom.flat.reverse', function() {
|
||||||
@@ -9,36 +9,31 @@ describe('ol.geom.flat.reverse', function() {
|
|||||||
|
|
||||||
it('can reverse empty flat coordinates', function() {
|
it('can reverse empty flat coordinates', function() {
|
||||||
const flatCoordinates = [];
|
const flatCoordinates = [];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
|
||||||
expect(flatCoordinates).to.be.empty();
|
expect(flatCoordinates).to.be.empty();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse one flat coordinates', function() {
|
it('can reverse one flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2];
|
const flatCoordinates = [1, 2];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
|
||||||
expect(flatCoordinates).to.eql([1, 2]);
|
expect(flatCoordinates).to.eql([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse two flat coordinates', function() {
|
it('can reverse two flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4];
|
const flatCoordinates = [1, 2, 3, 4];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
|
||||||
expect(flatCoordinates).to.eql([3, 4, 1, 2]);
|
expect(flatCoordinates).to.eql([3, 4, 1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse three flat coordinates', function() {
|
it('can reverse three flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4, 5, 6];
|
const flatCoordinates = [1, 2, 3, 4, 5, 6];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
|
||||||
expect(flatCoordinates).to.eql([5, 6, 3, 4, 1, 2]);
|
expect(flatCoordinates).to.eql([5, 6, 3, 4, 1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse four flat coordinates', function() {
|
it('can reverse four flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 2);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
|
||||||
expect(flatCoordinates).to.eql([7, 8, 5, 6, 3, 4, 1, 2]);
|
expect(flatCoordinates).to.eql([7, 8, 5, 6, 3, 4, 1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -48,36 +43,31 @@ describe('ol.geom.flat.reverse', function() {
|
|||||||
|
|
||||||
it('can reverse empty flat coordinates', function() {
|
it('can reverse empty flat coordinates', function() {
|
||||||
const flatCoordinates = [];
|
const flatCoordinates = [];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
|
||||||
expect(flatCoordinates).to.be.empty();
|
expect(flatCoordinates).to.be.empty();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse one flat coordinates', function() {
|
it('can reverse one flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3];
|
const flatCoordinates = [1, 2, 3];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
|
||||||
expect(flatCoordinates).to.eql([1, 2, 3]);
|
expect(flatCoordinates).to.eql([1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse two flat coordinates', function() {
|
it('can reverse two flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4, 5, 6];
|
const flatCoordinates = [1, 2, 3, 4, 5, 6];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
|
||||||
expect(flatCoordinates).to.eql([4, 5, 6, 1, 2, 3]);
|
expect(flatCoordinates).to.eql([4, 5, 6, 1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse three flat coordinates', function() {
|
it('can reverse three flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
|
||||||
expect(flatCoordinates).to.eql([7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
expect(flatCoordinates).to.eql([7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse four flat coordinates', function() {
|
it('can reverse four flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 3);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 3);
|
|
||||||
expect(flatCoordinates).to.eql([10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
expect(flatCoordinates).to.eql([10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -87,37 +77,32 @@ describe('ol.geom.flat.reverse', function() {
|
|||||||
|
|
||||||
it('can reverse empty flat coordinates', function() {
|
it('can reverse empty flat coordinates', function() {
|
||||||
const flatCoordinates = [];
|
const flatCoordinates = [];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
|
||||||
expect(flatCoordinates).to.be.empty();
|
expect(flatCoordinates).to.be.empty();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse one flat coordinates', function() {
|
it('can reverse one flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4];
|
const flatCoordinates = [1, 2, 3, 4];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
|
||||||
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
|
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse two flat coordinates', function() {
|
it('can reverse two flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
|
||||||
expect(flatCoordinates).to.eql([5, 6, 7, 8, 1, 2, 3, 4]);
|
expect(flatCoordinates).to.eql([5, 6, 7, 8, 1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse three flat coordinates', function() {
|
it('can reverse three flat coordinates', function() {
|
||||||
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
const flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
|
||||||
expect(flatCoordinates).to.eql([9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
expect(flatCoordinates).to.eql([9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can reverse four flat coordinates', function() {
|
it('can reverse four flat coordinates', function() {
|
||||||
const flatCoordinates =
|
const flatCoordinates =
|
||||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
|
||||||
_ol_geom_flat_reverse_.coordinates(
|
reverseCoordinates(flatCoordinates, 0, flatCoordinates.length, 4);
|
||||||
flatCoordinates, 0, flatCoordinates.length, 4);
|
|
||||||
expect(flatCoordinates).to.eql(
|
expect(flatCoordinates).to.eql(
|
||||||
[13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
[13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user