Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.Circle');
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
describe('ol.geom.Circle', function() {
@@ -9,14 +7,14 @@ describe('ol.geom.Circle', function() {
var circle;
beforeEach(function() {
circle = new ol.geom.Circle([0, 0], 1);
circle = new _ol_geom_Circle_([0, 0], 1);
});
describe('#clone', function() {
it('returns a clone', function() {
var clone = circle.clone();
expect(clone).to.be.an(ol.geom.Circle);
expect(clone).to.be.an(_ol_geom_Circle_);
expect(clone.getCenter()).to.eql(circle.getCenter());
expect(clone.getCenter()).not.to.be(circle.getCenter());
expect(clone.getRadius()).to.be(circle.getRadius());
@@ -92,7 +90,7 @@ describe('ol.geom.Circle', function() {
});
it('maintains Z coordinates', function() {
var circle = new ol.geom.Circle([0, 0, 1], 1);
var circle = new _ol_geom_Circle_([0, 0, 1], 1);
expect(circle.getLayout()).to.be('XYZ');
var closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(3);
@@ -102,7 +100,7 @@ describe('ol.geom.Circle', function() {
});
it('maintains M coordinates', function() {
var circle = new ol.geom.Circle([0, 0, 2], 1,
var circle = new _ol_geom_Circle_([0, 0, 2], 1,
'XYM');
var closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(3);
@@ -112,7 +110,7 @@ describe('ol.geom.Circle', function() {
});
it('maintains Z and M coordinates', function() {
var circle = new ol.geom.Circle([0, 0, 1, 2], 1);
var circle = new _ol_geom_Circle_([0, 0, 1, 2], 1);
expect(circle.getLayout()).to.be('XYZM');
var closestPoint = circle.getClosestPoint([2, 0]);
expect(closestPoint).to.have.length(4);

View File

@@ -1,19 +1,17 @@
goog.require('ol.geom.flat.area');
import _ol_geom_flat_area_ from '../../../../../src/ol/geom/flat/area.js';
describe('ol.geom.flat.area', function() {
describe('ol.geom.flat.area.linearRing', function() {
it('calculates the area of a triangle', function() {
var area = ol.geom.flat.area.linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2);
var area = _ol_geom_flat_area_.linearRing([0, 0, 0.5, 1, 1, 0], 0, 6, 2);
expect(area).to.be(0.5);
});
it('calculates the area of a unit square', function() {
var area =
ol.geom.flat.area.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2);
_ol_geom_flat_area_.linearRing([0, 0, 0, 1, 1, 1, 1, 0], 0, 8, 2);
expect(area).to.be(1);
});
@@ -22,7 +20,7 @@ describe('ol.geom.flat.area', function() {
describe('ol.geom.flat.area.linearRings', function() {
it('calculates the area with holes', function() {
var area = ol.geom.flat.area.linearRings(
var area = _ol_geom_flat_area_.linearRings(
[0, 0, 0, 3, 3, 3, 3, 0, 1, 1, 2, 1, 2, 2, 1, 2], 0, [8, 16], 2);
expect(area).to.be(8);
});

View File

@@ -1,7 +1,5 @@
goog.require('ol.geom.flat.center');
goog.require('ol.geom.MultiPolygon');
import _ol_geom_flat_center_ from '../../../../../src/ol/geom/flat/center.js';
import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js';
describe('ol.geom.flat.center', function() {
@@ -9,10 +7,10 @@ describe('ol.geom.flat.center', function() {
describe('ol.geom.flat.center.linearRingss', function() {
it('calculates the center of a square', function() {
var squareMultiPoly = new ol.geom.MultiPolygon([[
var squareMultiPoly = new _ol_geom_MultiPolygon_([[
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
]]);
var got = ol.geom.flat.center.linearRingss(
var got = _ol_geom_flat_center_.linearRingss(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
@@ -22,7 +20,7 @@ describe('ol.geom.flat.center', function() {
});
it('calculates the centers of two squares', function() {
var squareMultiPoly = new ol.geom.MultiPolygon([
var squareMultiPoly = new _ol_geom_MultiPolygon_([
[
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
],
@@ -30,7 +28,7 @@ describe('ol.geom.flat.center', function() {
[[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]]
]
]);
var got = ol.geom.flat.center.linearRingss(
var got = _ol_geom_flat_center_.linearRingss(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
@@ -40,11 +38,11 @@ describe('ol.geom.flat.center', function() {
});
it('does not care about holes', function() {
var polywithHole = new ol.geom.MultiPolygon([[
var polywithHole = new _ol_geom_MultiPolygon_([[
[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]],
[[1, 1], [1, 4], [4, 4], [4, 1], [1, 1]]
]]);
var got = ol.geom.flat.center.linearRingss(
var got = _ol_geom_flat_center_.linearRingss(
polywithHole.flatCoordinates,
0,
polywithHole.endss_,

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.closest');
import _ol_geom_flat_closest_ from '../../../../../src/ol/geom/flat/closest.js';
describe('ol.geom.flat.closest', function() {
@@ -12,7 +10,7 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getMaxSquaredDelta', function() {
it('returns the expected value in simple cases', function() {
expect(ol.geom.flat.closest.getMaxSquaredDelta(
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9);
});
@@ -21,23 +19,23 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getClosestPoint', function() {
it('returns the expected value', function() {
var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta(
var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0));
expect(maxDelta).to.be(3);
var closestPoint = [NaN, NaN];
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 0, 0, closestPoint, Infinity)).to.be(0);
expect(closestPoint).to.eql([0, 0]);
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 4, 1, closestPoint, Infinity)).to.be(1);
expect(closestPoint).to.eql([4, 0]);
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 5, 2, closestPoint, Infinity)).to.be(4);
expect(closestPoint).to.eql([5, 0]);
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000);
expect(closestPoint).to.eql([10, 0]);
@@ -80,7 +78,7 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.closet.maSquaredDelta', function() {
it('returns the expected value', function() {
expect(ol.geom.flat.closest.getMaxSquaredDelta(
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0)).
to.roughlyEqual(1389.1058, 1e-9);
});
@@ -90,21 +88,21 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getClosestPoint', function() {
it('returns the expected value', function() {
var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta(
var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0));
expect(maxDelta).to.roughlyEqual(Math.sqrt(1389.1058), 1e-9);
var closestPoint = [NaN, NaN];
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 0, 0, closestPoint, Infinity)).
to.roughlyEqual(110902.405, 1e-9);
expect(closestPoint).to.eql([292.41, 159.37]);
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 500, 500, closestPoint, Infinity)).
to.roughlyEqual(106407.905, 1e-9);
expect(closestPoint).to.eql([671.55, 222.55]);
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 1000, 500, closestPoint, Infinity)).
to.roughlyEqual(18229.4425, 1e-9);
@@ -123,11 +121,11 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getClosestPoint', function() {
it('interpolates M coordinates', function() {
var maxDelta = Math.sqrt(ol.geom.flat.closest.getMaxSquaredDelta(
var maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, stride, 0));
expect(maxDelta).to.roughlyEqual(Math.sqrt(8), 1e-9);
var closestPoint = [NaN, NaN];
expect(ol.geom.flat.closest.getClosestPoint(
expect(_ol_geom_flat_closest_.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, stride,
maxDelta, false, 1, 1, closestPoint, Infinity)).
to.roughlyEqual(0, 1e-9);

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.contains');
import _ol_geom_flat_contains_ from '../../../../../src/ol/geom/flat/contains.js';
describe('ol.geom.flat.contains', function() {
@@ -13,27 +11,27 @@ describe('ol.geom.flat.contains', function() {
describe('ol.geom.flat.contains.linearRingContainsXY', function() {
it('returns true for point inside a simple polygon', function() {
expect(ol.geom.flat.contains.linearRingContainsXY(
expect(_ol_geom_flat_contains_.linearRingContainsXY(
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 0.5, 0.5)).to.be(true);
});
it('returns false for point outside a simple polygon', function() {
expect(ol.geom.flat.contains.linearRingContainsXY(
expect(_ol_geom_flat_contains_.linearRingContainsXY(
flatCoordinatesSimple, 0, flatCoordinatesSimple.length, 2, 1.5, 1.5)).to.be(false);
});
it('returns true for point inside a non-simple polygon', function() {
expect(ol.geom.flat.contains.linearRingContainsXY(
expect(_ol_geom_flat_contains_.linearRingContainsXY(
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1, 1)).to.be(true);
});
it('returns true for point inside an overlap of a non-simple polygon', function() {
expect(ol.geom.flat.contains.linearRingContainsXY(
expect(_ol_geom_flat_contains_.linearRingContainsXY(
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 1.5, 2.5)).to.be(true);
});
it('returns false for a point inside a hole of a non-simple polygon', function() {
expect(ol.geom.flat.contains.linearRingContainsXY(
expect(_ol_geom_flat_contains_.linearRingContainsXY(
flatCoordinatesNonSimple, 0, flatCoordinatesNonSimple.length, 2, 2.5, 1.5)).to.be(false);
});

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.deflate');
import _ol_geom_flat_deflate_ from '../../../../../src/ol/geom/flat/deflate.js';
describe('ol.geom.flat.deflate', function() {
@@ -13,7 +11,7 @@ describe('ol.geom.flat.deflate', function() {
});
it('flattens coordinates', function() {
var offset = ol.geom.flat.deflate.coordinates(
var offset = _ol_geom_flat_deflate_.coordinates(
flatCoordinates, 0, [[1, 2], [3, 4]], 2);
expect(offset).to.be(4);
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
@@ -29,7 +27,7 @@ describe('ol.geom.flat.deflate', function() {
});
it('flattens arrays of coordinates', function() {
var ends = ol.geom.flat.deflate.coordinatess(flatCoordinates, 0,
var ends = _ol_geom_flat_deflate_.coordinatess(flatCoordinates, 0,
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], 2);
expect(ends).to.eql([4, 8]);
expect(flatCoordinates).to.eql([1, 2, 3, 4, 5, 6, 7, 8]);

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.flip');
import _ol_geom_flat_flip_ from '../../../../../src/ol/geom/flat/flip.js';
describe('ol.geom.flat.flip', function() {
@@ -8,19 +6,19 @@ describe('ol.geom.flat.flip', function() {
describe('ol.geom.flat.flip.flipXY', function() {
it('can flip XY coordinates', function() {
var flatCoordinates = ol.geom.flat.flip.flipXY([1, 2, 3, 4], 0, 4, 2);
var flatCoordinates = _ol_geom_flat_flip_.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() {
var flatCoordinates = ol.geom.flat.flip.flipXY(
var flatCoordinates = _ol_geom_flat_flip_.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() {
var flatCoordinates = [1, 2, 3, 4];
expect(ol.geom.flat.flip.flipXY(
expect(_ol_geom_flat_flip_.flipXY(
flatCoordinates, 0, 4, 2, flatCoordinates)).to.be(flatCoordinates);
expect(flatCoordinates).to.eql([2, 1, 4, 3]);
});
@@ -28,7 +26,7 @@ describe('ol.geom.flat.flip', function() {
it('can flip XY coordinates in place while preserving other dimensions',
function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
expect(ol.geom.flat.flip.flipXY(
expect(_ol_geom_flat_flip_.flipXY(
flatCoordinates, 0, 9, 3, flatCoordinates)).
to.be(flatCoordinates);
expect(flatCoordinates).to.eql([2, 1, 3, 5, 4, 6, 8, 7, 9]);

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.inflate');
import _ol_geom_flat_inflate_ from '../../../../../src/ol/geom/flat/inflate.js';
describe('ol.geom.flat.inflate', function() {
@@ -8,7 +6,7 @@ describe('ol.geom.flat.inflate', function() {
describe('ol.geom.flat.inflate.coordinates', function() {
it('inflates coordinates', function() {
var coordinates = ol.geom.flat.inflate.coordinates([1, 2, 3, 4], 0, 4, 2);
var coordinates = _ol_geom_flat_inflate_.coordinates([1, 2, 3, 4], 0, 4, 2);
expect(coordinates).to.eql([[1, 2], [3, 4]]);
});
@@ -17,7 +15,7 @@ describe('ol.geom.flat.inflate', function() {
describe('ol.geom.flat.inflate.coordinatess', function() {
it('inflates arrays of coordinates', function() {
var coordinatess = ol.geom.flat.inflate.coordinatess(
var coordinatess = _ol_geom_flat_inflate_.coordinatess(
[1, 2, 3, 4, 5, 6, 7, 8], 0, [4, 8], 2);
expect(coordinatess).to.eql([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
});

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.interpolate');
import _ol_geom_flat_interpolate_ from '../../../../../src/ol/geom/flat/interpolate.js';
describe('ol.geom.flat.interpolate', function() {
@@ -10,14 +8,14 @@ describe('ol.geom.flat.interpolate', function() {
it('returns the expected value for single points', function() {
var flatCoordinates = [0, 1];
var point =
ol.geom.flat.interpolate.lineString(flatCoordinates, 0, 2, 2, 0.5);
_ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 2, 2, 0.5);
expect(point).to.eql([0, 1]);
});
it('returns the expected value for simple line segments', function() {
var flatCoordinates = [0, 1, 2, 3];
var point =
ol.geom.flat.interpolate.lineString(flatCoordinates, 0, 4, 2, 0.5);
_ol_geom_flat_interpolate_.lineString(flatCoordinates, 0, 4, 2, 0.5);
expect(point).to.eql([1, 2]);
});
@@ -25,14 +23,14 @@ describe('ol.geom.flat.interpolate', function() {
'coordinate',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5];
var point = ol.geom.flat.interpolate.lineString(
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([2, 3]);
});
xit('also when vertices are repeated', function() {
var flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5];
var point = ol.geom.flat.interpolate.lineString(
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([2, 3]);
});
@@ -41,14 +39,14 @@ describe('ol.geom.flat.interpolate', function() {
'two existing coordinates',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
var point = ol.geom.flat.interpolate.lineString(
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 8, 2, 0.5);
expect(point).to.eql([3, 4]);
});
xit('also when vertices are repeated', function() {
var flatCoordinates = [0, 1, 2, 3, 2, 3, 4, 5, 6, 7];
var point = ol.geom.flat.interpolate.lineString(
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 8, 2, 0.5);
expect(point).to.eql([3, 4]);
});
@@ -56,7 +54,7 @@ describe('ol.geom.flat.interpolate', function() {
it('returns the expected value when the coordinates are not evenly spaced',
function() {
var flatCoordinates = [0, 1, 2, 3, 6, 7];
var point = ol.geom.flat.interpolate.lineString(
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([3, 4]);
});
@@ -64,7 +62,7 @@ describe('ol.geom.flat.interpolate', function() {
xit('also when vertices are repeated',
function() {
var flatCoordinates = [0, 1, 2, 3, 2, 3, 6, 7];
var point = ol.geom.flat.interpolate.lineString(
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([3, 4]);
});
@@ -72,7 +70,7 @@ describe('ol.geom.flat.interpolate', function() {
it('returns the expected value when using opt_dest',
function() {
var flatCoordinates = [0, 1, 2, 3, 6, 7];
var point = ol.geom.flat.interpolate.lineString(
var point = _ol_geom_flat_interpolate_.lineString(
flatCoordinates, 0, 6, 2, 0.5, [0, 0]);
expect(point).to.eql([3, 4]);
});

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.intersectsextent');
import _ol_geom_flat_intersectsextent_ from '../../../../../src/ol/geom/flat/intersectsextent.js';
describe('ol.geom.flat.intersectsextent', function() {
@@ -13,7 +11,7 @@ describe('ol.geom.flat.intersectsextent', function() {
describe('linestring envelope does not intersect the extent', function() {
it('returns false', function() {
var extent = [3, 3, 4, 4];
var r = ol.geom.flat.intersectsextent.lineString(
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(false);
});
@@ -21,7 +19,7 @@ describe('ol.geom.flat.intersectsextent', function() {
describe('linestring envelope within the extent', function() {
it('returns true', function() {
var extent = [-1, -1, 3, 3];
var r = ol.geom.flat.intersectsextent.lineString(
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
@@ -30,7 +28,7 @@ describe('ol.geom.flat.intersectsextent', function() {
function() {
it('returns true', function() {
var extent = [-0.1, 0.1, 2.1, 0.1];
var r = ol.geom.flat.intersectsextent.lineString(
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
@@ -38,7 +36,7 @@ describe('ol.geom.flat.intersectsextent', function() {
describe('a segment intersects the extent', function() {
it('returns true', function() {
var extent = [-0.5, -0.5, 0.5, 0.5];
var r = ol.geom.flat.intersectsextent.lineString(
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
@@ -46,13 +44,13 @@ describe('ol.geom.flat.intersectsextent', function() {
describe('no segments intersect the extent', function() {
it('returns false', function() {
var extent = [0.5, 1.5, 1, 1.75];
var r = ol.geom.flat.intersectsextent.lineString(
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(false);
});
it('returns false', function() {
var extent = [1, 0.25, 1.5, 0.5];
var r = ol.geom.flat.intersectsextent.lineString(
var r = _ol_geom_flat_intersectsextent_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(false);
});
@@ -67,7 +65,7 @@ describe('ol.geom.flat.intersectsextent', function() {
describe('boundary intersects the extent', function() {
it('returns true', function() {
var extent = [1.5, 0.0, 2.5, 1.0];
var r = ol.geom.flat.intersectsextent.linearRing(
var r = _ol_geom_flat_intersectsextent_.linearRing(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});
@@ -77,7 +75,7 @@ describe('ol.geom.flat.intersectsextent', function() {
function() {
it('returns false', function() {
var extent = [2.0, 0.5, 3, 1.5];
var r = ol.geom.flat.intersectsextent.linearRing(
var r = _ol_geom_flat_intersectsextent_.linearRing(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(false);
});
@@ -85,7 +83,7 @@ describe('ol.geom.flat.intersectsextent', function() {
describe('ring contains the extent', function() {
it('returns true', function() {
var extent = [0.75, -0.25, 1.25, 0.25];
var r = ol.geom.flat.intersectsextent.linearRing(
var r = _ol_geom_flat_intersectsextent_.linearRing(
flatCoordinates, 0, flatCoordinates.length, 2, extent);
expect(r).to.be(true);
});

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.length');
import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js';
describe('ol.geom.flat.length', function() {
@@ -15,7 +13,7 @@ describe('ol.geom.flat.length', function() {
var offset = 0;
var end = 8;
var expected = 3;
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -23,7 +21,7 @@ describe('ol.geom.flat.length', function() {
var offset = 2;
var end = 8;
var expected = 2;
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -31,7 +29,7 @@ describe('ol.geom.flat.length', function() {
var offset = 0;
var end = 4;
var expected = 1;
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -45,7 +43,7 @@ describe('ol.geom.flat.length', function() {
var offset = 0;
var end = 12;
var expected = 3;
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -53,7 +51,7 @@ describe('ol.geom.flat.length', function() {
var offset = 3;
var end = 12;
var expected = 2;
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -61,7 +59,7 @@ describe('ol.geom.flat.length', function() {
var offset = 0;
var end = 6;
var expected = 1;
var got = ol.geom.flat.length.lineString(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.lineString(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -76,7 +74,7 @@ describe('ol.geom.flat.length', function() {
var offset = 0;
var end = 8;
var expected = 4;
var got = ol.geom.flat.length.linearRing(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});
@@ -86,7 +84,7 @@ describe('ol.geom.flat.length', function() {
var offset = 0;
var end = 14;
var expected = 8;
var got = ol.geom.flat.length.linearRing(flatCoords, offset, end, stride);
var got = _ol_geom_flat_length_.linearRing(flatCoords, offset, end, stride);
expect(got).to.be(expected);
});

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.orient');
import _ol_geom_flat_orient_ from '../../../../../src/ol/geom/flat/orient.js';
describe('ol.geom.flat.orient', function() {
@@ -9,14 +7,14 @@ describe('ol.geom.flat.orient', function() {
it('identifies clockwise rings', function() {
var flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(isClockwise).to.be(true);
});
it('identifies anti-clockwise rings', function() {
var flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3];
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(isClockwise).to.be(false);
});
@@ -24,7 +22,7 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.linearRingsAreOriented()', function() {
var oriented = ol.geom.flat.orient.linearRingsAreOriented;
var oriented = _ol_geom_flat_orient_.linearRingsAreOriented;
var rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
@@ -51,7 +49,7 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.linearRingssAreOriented()', function() {
var oriented = ol.geom.flat.orient.linearRingssAreOriented;
var oriented = _ol_geom_flat_orient_.linearRingssAreOriented;
var rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
@@ -82,7 +80,7 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.orientLinearRings()', function() {
var orient = ol.geom.flat.orient.orientLinearRings;
var orient = _ol_geom_flat_orient_.orientLinearRings;
var rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
@@ -119,7 +117,7 @@ describe('ol.geom.flat.orient', function() {
});
describe('ol.geom.flat.orient.orientLinearRingss()', function() {
var orient = ol.geom.flat.orient.orientLinearRingss;
var orient = _ol_geom_flat_orient_.orientLinearRingss;
var rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.reverse');
import _ol_geom_flat_reverse_ from '../../../../../src/ol/geom/flat/reverse.js';
describe('ol.geom.flat.reverse', function() {
@@ -11,35 +9,35 @@ describe('ol.geom.flat.reverse', function() {
it('can reverse empty flat coordinates', function() {
var flatCoordinates = [];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.be.empty();
});
it('can reverse one flat coordinates', function() {
var flatCoordinates = [1, 2];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.eql([1, 2]);
});
it('can reverse two flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.eql([3, 4, 1, 2]);
});
it('can reverse three flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.eql([5, 6, 3, 4, 1, 2]);
});
it('can reverse four flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
expect(flatCoordinates).to.eql([7, 8, 5, 6, 3, 4, 1, 2]);
});
@@ -50,35 +48,35 @@ describe('ol.geom.flat.reverse', function() {
it('can reverse empty flat coordinates', function() {
var flatCoordinates = [];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
expect(flatCoordinates).to.be.empty();
});
it('can reverse one flat coordinates', function() {
var flatCoordinates = [1, 2, 3];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
expect(flatCoordinates).to.eql([1, 2, 3]);
});
it('can reverse two flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
expect(flatCoordinates).to.eql([4, 5, 6, 1, 2, 3]);
});
it('can reverse three flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
expect(flatCoordinates).to.eql([7, 8, 9, 4, 5, 6, 1, 2, 3]);
});
it('can reverse four flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 3);
expect(flatCoordinates).to.eql([10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3]);
});
@@ -89,28 +87,28 @@ describe('ol.geom.flat.reverse', function() {
it('can reverse empty flat coordinates', function() {
var flatCoordinates = [];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
expect(flatCoordinates).to.be.empty();
});
it('can reverse one flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
expect(flatCoordinates).to.eql([1, 2, 3, 4]);
});
it('can reverse two flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
expect(flatCoordinates).to.eql([5, 6, 7, 8, 1, 2, 3, 4]);
});
it('can reverse three flat coordinates', function() {
var flatCoordinates = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
expect(flatCoordinates).to.eql([9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);
});
@@ -118,7 +116,7 @@ describe('ol.geom.flat.reverse', function() {
it('can reverse four flat coordinates', function() {
var flatCoordinates =
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
ol.geom.flat.reverse.coordinates(
_ol_geom_flat_reverse_.coordinates(
flatCoordinates, 0, flatCoordinates.length, 4);
expect(flatCoordinates).to.eql(
[13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1, 2, 3, 4]);

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.segments');
import _ol_geom_flat_segments_ from '../../../../../src/ol/geom/flat/segments.js';
describe('ol.geom.flat.segments', function() {
@@ -19,7 +17,7 @@ describe('ol.geom.flat.segments', function() {
var spy = sinon.spy(function(point1, point2) {
args.push([point1[0], point1[1], point2[0], point2[1]]);
});
var ret = ol.geom.flat.segments.forEach(
var ret = _ol_geom_flat_segments_.forEach(
flatCoordinates, offset, end, stride, spy);
expect(spy.callCount).to.be(3);
expect(args[0][0]).to.be(0);
@@ -44,7 +42,7 @@ describe('ol.geom.flat.segments', function() {
args.push([point1[0], point1[1], point2[0], point2[1]]);
return true;
});
var ret = ol.geom.flat.segments.forEach(
var ret = _ol_geom_flat_segments_.forEach(
flatCoordinates, offset, end, stride, spy);
expect(spy.callCount).to.be(1);
expect(args[0][0]).to.be(0);

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.simplify');
import _ol_geom_flat_simplify_ from '../../../../../src/ol/geom/flat/simplify.js';
describe('ol.geom.flat.simplify', function() {
@@ -86,28 +84,28 @@ describe('ol.geom.flat.simplify', function() {
describe('ol.geom.flat.simplify.lineString', function() {
it('works with empty line strings', function() {
expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, true)).to.
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, true)).to.
eql([]);
expect(ol.geom.flat.simplify.lineString([], 0, 0, 2, 1, false)).to.
expect(_ol_geom_flat_simplify_.lineString([], 0, 0, 2, 1, false)).to.
eql([]);
});
it('works with a line string with a single point', function() {
expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, true)).to.
expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, true)).to.
eql([1, 2]);
expect(ol.geom.flat.simplify.lineString([1, 2], 0, 2, 2, 1, false)).to.
expect(_ol_geom_flat_simplify_.lineString([1, 2], 0, 2, 2, 1, false)).to.
eql([1, 2]);
});
it('returns the expected result with low quality', function() {
var result = ol.geom.flat.simplify.lineString(
var result = _ol_geom_flat_simplify_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, 25, false);
expect(result.length).to.be(simplifiedFlatCoordinates.length);
expect(result).to.eql(simplifiedFlatCoordinates);
});
it('returns the expected result with high quality', function() {
var result = ol.geom.flat.simplify.lineString(
var result = _ol_geom_flat_simplify_.lineString(
flatCoordinates, 0, flatCoordinates.length, 2, 25, true);
expect(result.length).to.be(simplifiedHighQualityFlatCoordinates.length);
expect(result).to.eql(simplifiedHighQualityFlatCoordinates);
@@ -123,63 +121,63 @@ describe('ol.geom.flat.simplify', function() {
});
it('works with empty line strings', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[], 0, 0, 2, 1, dest, 0)).to.be(0);
expect(dest).to.eql([]);
});
it('works with a line string with a single point', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
expect(dest).to.eql([1, 2]);
});
it('works with a line string with two points', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
expect(dest).to.eql([1, 2, 3, 4]);
});
it('works when the points are widely spaced', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
expect(dest).to.eql([0, 0, 1, 0, 2, 0, 3, 0]);
});
it('works when the spacing matches the tolerance', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
});
it('works when the points are closely spaced', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(6);
expect(dest).to.eql([0, 0, 2, 0, 3, 0]);
});
it('works when the line oscillates with widely spaced points', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).
to.be(12);
expect(dest).to.eql([0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]);
});
it('works when the line oscillates with closely spaced points', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).to.be(4);
expect(dest).to.eql([0, 0, 1, 1]);
});
it('works when the line oscillates within the tolerance', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
to.be(2);
expect(dest).to.eql([0, 0]);
});
it('works with real data', function() {
expect(ol.geom.flat.simplify.radialDistance(
expect(_ol_geom_flat_simplify_.radialDistance(
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
to.be(simplifiedRadiallyFlatCoordinates.length);
expect(dest).to.eql(simplifiedRadiallyFlatCoordinates);
@@ -195,93 +193,93 @@ describe('ol.geom.flat.simplify', function() {
});
it('works with empty line strings', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[], 0, 0, 2, 1, dest, 0)).to.be(0);
expect(dest).to.eql([]);
});
it('works with a line string with a single point', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[1, 2], 0, 2, 2, 1, dest, 0)).to.be(2);
expect(dest).to.eql([1, 2]);
});
it('works with a line string with two points', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[1, 2, 3, 4], 0, 4, 2, 1, dest, 0)).to.be(4);
expect(dest).to.eql([1, 2, 3, 4]);
});
it('works when the points are widely spaced', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 0.5, dest, 0)).to.be(4);
expect(dest).to.eql([0, 0, 3, 0]);
});
it('works when the spacing matches the tolerance', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1, dest, 0)).to.be(4);
expect(dest).to.eql([0, 0, 3, 0]);
});
it('works when the points are closely spaced', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 0, 2, 0, 3, 0], 0, 8, 2, 1.5, dest, 0)).to.be(4);
expect(dest).to.eql([0, 0, 3, 0]);
});
it('does not elimnate points outside the tolerance', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 1, 2, 0], 0, 6, 2, 0.5, dest, 0)).to.be(6);
expect(dest).to.eql([0, 0, 1, 1, 2, 0]);
});
it('does eliminate points within the tolerance', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 1, 2, 0], 0, 6, 2, 2, dest, 0)).to.be(4);
expect(dest).to.eql([0, 0, 2, 0]);
});
it('does not eliminate multiple points outside the tolerance', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 0.5, dest, 0)).to.be(8);
expect(dest).to.eql([0, 0, 1, 1, 1, -1, 2, 0]);
});
it('does eliminate multiple points within the tolerance', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 1, 1, -1, 2, 0], 0, 8, 2, 2, dest, 0)).to.be(4);
expect(dest).to.eql([0, 0, 2, 0]);
});
it('works when the line oscillates with widely spaced points', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 1, dest, 0)).to.be(4);
expect(dest).to.eql([0, 0, 1, 1]);
});
it('works when the line oscillates with closely spaced points', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1], 0, 12, 2, 2, dest, 0)).
to.be(4);
expect(dest).to.eql([0, 0, 1, 1]);
});
it('works when the line oscillates within the tolerance', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0], 0, 14, 2, 2, dest, 0)).
to.be(4);
expect(dest).to.eql([0, 0, 0, 0]);
});
it('works on small triangles', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
[3, 0, 4, 1, 5, 2, 5, 0], 0, 8, 2, 1, dest, 0)).to.be(6);
expect(dest).to.eql([3, 0, 5, 2, 5, 0]);
});
it('is the same as high quality simplification', function() {
expect(ol.geom.flat.simplify.douglasPeucker(
expect(_ol_geom_flat_simplify_.douglasPeucker(
flatCoordinates, 0, flatCoordinates.length, 2, 25, dest, 0)).
to.be(simplifiedHighQualityFlatCoordinates.length);
expect(dest).to.eql(simplifiedHighQualityFlatCoordinates);
@@ -293,28 +291,28 @@ describe('ol.geom.flat.simplify', function() {
it('handles empty coordinates', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[], 0, 0, 2, 2, simplifiedFlatCoordinates, 0)).to.be(0);
expect(simplifiedFlatCoordinates).to.be.empty();
});
it('expands points to a zero-length line', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 0, 0], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
});
it('snaps near-by points to the same value', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[0.1, 0, 0, 0.1], 0, 4, 2, 2, simplifiedFlatCoordinates, 0)).to.be(4);
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, 0]);
});
it('eliminates duplicate snapped points', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[0.1, 0, 2, 0, 2.1, 0, 2, 0.1, 1.9, 0, 2, -0.1], 0, 12, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(4);
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0]);
@@ -322,7 +320,7 @@ describe('ol.geom.flat.simplify', function() {
it('eliminates horizontal colinear points', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 2, 0, 4, 0, 6, 0], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(4);
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, 0]);
@@ -330,7 +328,7 @@ describe('ol.geom.flat.simplify', function() {
it('eliminates vertical colinear points', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 0, -2, 0, -4, 0, -6], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(4);
expect(simplifiedFlatCoordinates).to.eql([0, 0, 0, -6]);
@@ -338,7 +336,7 @@ describe('ol.geom.flat.simplify', function() {
it('eliminates diagonal colinear points', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 2, -2, 4, -4, 6, -6], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(4);
expect(simplifiedFlatCoordinates).to.eql([0, 0, 6, -6]);
@@ -346,7 +344,7 @@ describe('ol.geom.flat.simplify', function() {
it('handles switchbacks', function() {
var simplifiedFlatCoordinates = [];
expect(ol.geom.flat.simplify.quantize(
expect(_ol_geom_flat_simplify_.quantize(
[0, 0, 2, 0, 0, 0, 4, 0], 0, 8, 2, 2,
simplifiedFlatCoordinates, 0)).to.be(8);
expect(simplifiedFlatCoordinates).to.eql([0, 0, 2, 0, 0, 0, 4, 0]);

View File

@@ -1,4 +1,4 @@
goog.require('ol.geom.flat.straightchunk');
import _ol_geom_flat_straightchunk_ from '../../../../../src/ol/geom/flat/straightchunk.js';
describe('ol.geom.flat.straightchunk', function() {
@@ -10,12 +10,12 @@ describe('ol.geom.flat.straightchunk', function() {
var stride = 3;
it('returns whole line with angle delta', function() {
var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 6, stride);
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 6, stride);
expect(got).to.eql([0, 6]);
});
it('returns whole line with zero angle delta', function() {
var got = ol.geom.flat.straightchunk.lineString(0, flatCoords, 0, 6, stride);
var got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 6, stride);
expect(got).to.eql([0, 6]);
});
@@ -26,12 +26,12 @@ describe('ol.geom.flat.straightchunk', function() {
var stride = 2;
it('returns whole line if straight enough', function() {
var got = ol.geom.flat.straightchunk.lineString(Math.PI, flatCoords, 0, 8, stride);
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI, flatCoords, 0, 8, stride);
expect(got).to.eql([0, 8]);
});
it('returns first matching chunk if all chunk lengths are the same', function() {
var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 8, stride);
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 8, stride);
expect(got).to.eql([0, 4]);
});
@@ -42,12 +42,12 @@ describe('ol.geom.flat.straightchunk', function() {
var stride = 2;
it('returns stright chunk from within the linestring', function() {
var got = ol.geom.flat.straightchunk.lineString(0, flatCoords, 0, 18, stride);
var got = _ol_geom_flat_straightchunk_.lineString(0, flatCoords, 0, 18, stride);
expect(got).to.eql([10, 16]);
});
it('returns long chunk at the end if angle and length within threshold', function() {
var got = ol.geom.flat.straightchunk.lineString(Math.PI / 4, flatCoords, 0, 18, stride);
var got = _ol_geom_flat_straightchunk_.lineString(Math.PI / 4, flatCoords, 0, 18, stride);
expect(got).to.eql([10, 18]);
});

View File

@@ -1,5 +1,5 @@
goog.require('ol.geom.flat.textpath');
goog.require('ol.geom.flat.length');
import _ol_geom_flat_textpath_ from '../../../../../src/ol/geom/flat/textpath.js';
import _ol_geom_flat_length_ from '../../../../../src/ol/geom/flat/length.js';
describe('textpath', function() {
@@ -16,27 +16,27 @@ describe('textpath', function() {
it('center-aligns text on a horizontal line', function() {
var startM = 50 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
expect(instructions).to.eql([[40, 0, 5, 0, 'foo']]);
});
it('left-aligns text on a horizontal line', function() {
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
horizontal, 0, horizontal.length, 2, 'foo', measure, 0, Infinity);
expect(instructions).to.eql([[5, 0, 5, 0, 'foo']]);
});
it('right-aligns text on a horizontal line', function() {
var startM = 100 - 30;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
horizontal, 0, horizontal.length, 2, 'foo', measure, startM, Infinity);
expect(instructions).to.eql([[75, 0, 5, 0, 'foo']]);
});
it('draws text on a vertical line', function() {
var startM = 50 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
vertical, 0, vertical.length, 2, 'foo', measure, startM, Infinity);
var a = 90 * Math.PI / 180;
expect(instructions).to.eql([[0, 40, 5, a, 'foo']]);
@@ -44,7 +44,7 @@ describe('textpath', function() {
it('draws text on a diagonal line', function() {
var startM = Math.sqrt(2) * 50 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
diagonal, 0, diagonal.length, 2, 'foo', measure, startM, Infinity);
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
expect(instructions.length).to.be(1);
@@ -52,7 +52,7 @@ describe('textpath', function() {
it('draws reverse text on a diagonal line', function() {
var startM = Math.sqrt(2) * 50 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
reverse, 0, reverse.length, 2, 'foo', measure, startM, Infinity);
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
expect(instructions.length).to.be(1);
@@ -60,16 +60,16 @@ describe('textpath', function() {
it('renders long text with extrapolation', function() {
var startM = 50 - 75;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
horizontal, 0, horizontal.length, 2, 'foo-foo-foo-foo', measure, startM, Infinity);
expect(instructions[0]).to.eql([-20, 0, 5, 0, 'foo-foo-foo-foo']);
expect(instructions.length).to.be(1);
});
it('renders angled text', function() {
var length = ol.geom.flat.length.lineString(angled, 0, angled.length, 2);
var length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
var startM = length / 2 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 0, angled.length, 2, 'foo', measure, startM, Infinity);
expect(instructions[0][3]).to.eql(45 * Math.PI / 180);
expect(instructions[0][4]).to.be('fo');
@@ -78,34 +78,34 @@ describe('textpath', function() {
});
it('respects maxAngle', function() {
var length = ol.geom.flat.length.lineString(angled, 0, angled.length, 2);
var length = _ol_geom_flat_length_.lineString(angled, 0, angled.length, 2);
var startM = length / 2 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 0, angled.length, 2, 'foo', measure, startM, Math.PI / 4);
expect(instructions).to.be(null);
});
it('uses the smallest angle for maxAngleDelta', function() {
var length = ol.geom.flat.length.lineString(reverseangled, 0, reverseangled.length, 2);
var length = _ol_geom_flat_length_.lineString(reverseangled, 0, reverseangled.length, 2);
var startM = length / 2 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
reverseangled, 0, reverseangled.length, 2, 'foo', measure, startM, Math.PI);
expect(instructions).to.not.be(undefined);
});
it('respects the offset option', function() {
var length = ol.geom.flat.length.lineString(angled, 2, angled.length, 2);
var length = _ol_geom_flat_length_.lineString(angled, 2, angled.length, 2);
var startM = length / 2 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 2, angled.length, 2, 'foo', measure, startM, Infinity);
expect(instructions[0][3]).to.be(-45 * Math.PI / 180);
expect(instructions.length).to.be(1);
});
it('respects the end option', function() {
var length = ol.geom.flat.length.lineString(angled, 0, 4, 2);
var length = _ol_geom_flat_length_.lineString(angled, 0, 4, 2);
var startM = length / 2 - 15;
var instructions = ol.geom.flat.textpath.lineString(
var instructions = _ol_geom_flat_textpath_.lineString(
angled, 0, 4, 2, 'foo', measure, startM, Infinity);
expect(instructions[0][3]).to.be(45 * Math.PI / 180);
expect(instructions.length).to.be(1);

View File

@@ -1,6 +1,4 @@
goog.require('ol.geom.flat.topology');
import _ol_geom_flat_topology_ from '../../../../../src/ol/geom/flat/topology.js';
describe('ol.geom.flat.topology', function() {
@@ -8,23 +6,23 @@ describe('ol.geom.flat.topology', function() {
it('identifies closed lines aka boundaries', function() {
var flatCoordinates = [0, 0, 3, 0, 0, 3, 0, 0];
var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
expect(isClosed).to.be(true);
});
it('identifies regular linestrings', function() {
var flatCoordinates = [0, 0, 3, 0, 0, 3, 5, 2];
var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
expect(isClosed).to.be(false);
});
it('identifies degenerate boundaries', function() {
var flatCoordinates = [0, 0, 3, 0, 0, 0];
var isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
var isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
expect(isClosed).to.be(false);
flatCoordinates = [0, 0, 1, 1, 3, 3, 5, 5, 0, 0];
isClosed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
isClosed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0, flatCoordinates.length, 2);
expect(isClosed).to.be(false);
});

View File

@@ -1,8 +1,6 @@
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.SimpleGeometry');
goog.require('ol.geom.flat.transform');
import _ol_geom_MultiPolygon_ from '../../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_SimpleGeometry_ from '../../../../../src/ol/geom/SimpleGeometry.js';
import _ol_geom_flat_transform_ from '../../../../../src/ol/geom/flat/transform.js';
describe('ol.geom.flat.transform', function() {
@@ -11,7 +9,7 @@ describe('ol.geom.flat.transform', function() {
it('transforms a Simple Geometry to 2D', function() {
var multiPolygonGeometry = new ol.geom.MultiPolygon([
var multiPolygonGeometry = new _ol_geom_MultiPolygon_([
[[[-80.736061, 28.788576000000006, 0],
[-80.763557, 28.821799999999996, 0],
[-80.817406, 28.895123999999996, 0],
@@ -33,7 +31,7 @@ describe('ol.geom.flat.transform', function() {
0, -0.0004088332670837288,
4480.991370439071, 1529.5752568707105
];
var pixelCoordinates = ol.geom.SimpleGeometry.transform2D(
var pixelCoordinates = _ol_geom_SimpleGeometry_.transform2D(
multiPolygonGeometry, transform, []);
expect(pixelCoordinates[0]).to.roughlyEqual(806.6035275946265, 1e-9);
expect(pixelCoordinates[1]).to.roughlyEqual(160.48916296287916, 1e-9);
@@ -71,13 +69,13 @@ describe('ol.geom.flat.transform', function() {
describe('ol.geom.flat.transform.translate', function() {
it('translates the coordinates array', function() {
var multiPolygon = new ol.geom.MultiPolygon([
var multiPolygon = new _ol_geom_MultiPolygon_([
[[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]],
[[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]);
var flatCoordinates = multiPolygon.getFlatCoordinates();
var deltaX = 1;
var deltaY = 2;
ol.geom.flat.transform.translate(flatCoordinates, 0,
_ol_geom_flat_transform_.translate(flatCoordinates, 0,
flatCoordinates.length, multiPolygon.getStride(),
deltaX, deltaY, flatCoordinates);
expect(flatCoordinates).to.eql([
@@ -88,13 +86,13 @@ describe('ol.geom.flat.transform', function() {
describe('ol.geom.flat.transform.rotate', function() {
it('rotates the coordinates array', function() {
var multiPolygon = new ol.geom.MultiPolygon([
var multiPolygon = new _ol_geom_MultiPolygon_([
[[[0, 0, 2], [0, 1, 2], [1, 1, 2], [1, 0, 2], [0, 0, 2]]],
[[[2, 2, 3], [2, 3, 3], [3, 3, 3], [3, 2, 3], [2, 2, 3]]]]);
var flatCoordinates = multiPolygon.getFlatCoordinates();
var angle = Math.PI / 2;
var anchor = [0, 1];
ol.geom.flat.transform.rotate(flatCoordinates, 0,
_ol_geom_flat_transform_.rotate(flatCoordinates, 0,
flatCoordinates.length, multiPolygon.getStride(),
angle, anchor, flatCoordinates);
expect(flatCoordinates[0]).to.roughlyEqual(1, 1e-9);

View File

@@ -1,10 +1,8 @@
goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryCollection');
goog.require('ol.geom.LineString');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
import _ol_geom_Geometry_ from '../../../../src/ol/geom/Geometry.js';
import _ol_geom_GeometryCollection_ from '../../../../src/ol/geom/GeometryCollection.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.GeometryCollection', function() {
@@ -16,15 +14,15 @@ describe('ol.geom.GeometryCollection', function() {
var line, multi, point, poly;
beforeEach(function() {
point = new ol.geom.Point([10, 20]);
line = new ol.geom.LineString([[10, 20], [30, 40]]);
poly = new ol.geom.Polygon([outer, inner1, inner2]);
multi = new ol.geom.GeometryCollection([point, line, poly]);
point = new _ol_geom_Point_([10, 20]);
line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
multi = new _ol_geom_GeometryCollection_([point, line, poly]);
});
it('creates a geometry collection from an array of geometries', function() {
expect(multi).to.be.a(ol.geom.GeometryCollection);
expect(multi).to.be.a(ol.geom.Geometry);
expect(multi).to.be.a(_ol_geom_GeometryCollection_);
expect(multi).to.be.a(_ol_geom_Geometry_);
});
it('fires a change event when one of its component changes',
@@ -45,7 +43,7 @@ describe('ol.geom.GeometryCollection', function() {
});
it('register new components', function(done) {
var point2 = new ol.geom.Point([10, 20]);
var point2 = new _ol_geom_Point_([10, 20]);
multi.setGeometriesArray([point2]);
multi.on('change', function() {
done();
@@ -58,17 +56,17 @@ describe('ol.geom.GeometryCollection', function() {
describe('#getGeometries', function() {
it('returns a collection of geometries', function() {
var point = new ol.geom.Point([10, 20]);
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
var multi = new ol.geom.GeometryCollection([point, line, poly]);
var point = new _ol_geom_Point_([10, 20]);
var line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
var poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
var multi = new _ol_geom_GeometryCollection_([point, line, poly]);
var geometries = multi.getGeometries();
expect(geometries).to.be.an(Array);
expect(geometries).to.have.length(3);
expect(geometries[0]).to.be.a(ol.geom.Point);
expect(geometries[1]).to.be.a(ol.geom.LineString);
expect(geometries[2]).to.be.a(ol.geom.Polygon);
expect(geometries[0]).to.be.a(_ol_geom_Point_);
expect(geometries[1]).to.be.a(_ol_geom_LineString_);
expect(geometries[2]).to.be.a(_ol_geom_Polygon_);
});
});
@@ -76,10 +74,10 @@ describe('ol.geom.GeometryCollection', function() {
describe('#clone()', function() {
it('has a working clone method', function() {
var point = new ol.geom.Point([10, 20]);
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
var multi = new ol.geom.GeometryCollection([point, line, poly]);
var point = new _ol_geom_Point_([10, 20]);
var line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
var poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
var multi = new _ol_geom_GeometryCollection_([point, line, poly]);
var clone = multi.clone();
expect(clone).to.not.be(multi);
var geometries = clone.getGeometries();
@@ -89,9 +87,9 @@ describe('ol.geom.GeometryCollection', function() {
});
it('does a deep clone', function() {
var point = new ol.geom.Point([30, 40]);
var point = new _ol_geom_Point_([30, 40]);
var originalGeometries = [point];
var multi = new ol.geom.GeometryCollection(originalGeometries);
var multi = new _ol_geom_GeometryCollection_(originalGeometries);
var clone = multi.clone();
var clonedGeometries = clone.getGeometries();
expect(clonedGeometries).not.to.be(originalGeometries);
@@ -107,9 +105,9 @@ describe('ol.geom.GeometryCollection', function() {
describe('#getExtent()', function() {
it('returns the bounding extent', function() {
var point = new ol.geom.Point([10, 2]);
var line = new ol.geom.LineString([[1, 20], [30, 40]]);
var multi = new ol.geom.GeometryCollection([point, line]);
var point = new _ol_geom_Point_([10, 2]);
var line = new _ol_geom_LineString_([[1, 20], [30, 40]]);
var multi = new _ol_geom_GeometryCollection_([point, line]);
var extent = multi.getExtent();
expect(extent[0]).to.be(1);
expect(extent[2]).to.be(30);
@@ -124,10 +122,10 @@ describe('ol.geom.GeometryCollection', function() {
var point, line, poly, multi;
beforeEach(function() {
point = new ol.geom.Point([5, 20]);
line = new ol.geom.LineString([[10, 20], [30, 40]]);
poly = new ol.geom.Polygon([outer, inner1, inner2]);
multi = new ol.geom.GeometryCollection([point, line, poly]);
point = new _ol_geom_Point_([5, 20]);
line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
multi = new _ol_geom_GeometryCollection_([point, line, poly]);
});
it('returns true for intersecting point', function() {
@@ -153,10 +151,10 @@ describe('ol.geom.GeometryCollection', function() {
var line, multi, point, poly;
beforeEach(function() {
point = new ol.geom.Point([10, 20]);
line = new ol.geom.LineString([[10, 20], [30, 40]]);
poly = new ol.geom.Polygon([outer, inner1, inner2]);
multi = new ol.geom.GeometryCollection([point, line, poly]);
point = new _ol_geom_Point_([10, 20]);
line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
multi = new _ol_geom_GeometryCollection_([point, line, poly]);
});
it('fires a change event', function() {
@@ -177,9 +175,9 @@ describe('ol.geom.GeometryCollection', function() {
describe('#scale()', function() {
it('scales a collection', function() {
var geom = new ol.geom.GeometryCollection([
new ol.geom.Point([-1, -2]),
new ol.geom.LineString([[0, 0], [1, 2]])
var geom = new _ol_geom_GeometryCollection_([
new _ol_geom_Point_([-1, -2]),
new _ol_geom_LineString_([[0, 0], [1, 2]])
]);
geom.scale(10);
var geometries = geom.getGeometries();
@@ -188,9 +186,9 @@ describe('ol.geom.GeometryCollection', function() {
});
it('accepts sx and sy', function() {
var geom = new ol.geom.GeometryCollection([
new ol.geom.Point([-1, -2]),
new ol.geom.LineString([[0, 0], [1, 2]])
var geom = new _ol_geom_GeometryCollection_([
new _ol_geom_Point_([-1, -2]),
new _ol_geom_LineString_([[0, 0], [1, 2]])
]);
geom.scale(2, 3);
var geometries = geom.getGeometries();
@@ -199,9 +197,9 @@ describe('ol.geom.GeometryCollection', function() {
});
it('accepts an anchor', function() {
var geom = new ol.geom.GeometryCollection([
new ol.geom.Point([-1, -2]),
new ol.geom.LineString([[0, 0], [1, 2]])
var geom = new _ol_geom_GeometryCollection_([
new _ol_geom_Point_([-1, -2]),
new _ol_geom_LineString_([[0, 0], [1, 2]])
]);
geom.scale(10, 15, [-1, -2]);
var geometries = geom.getGeometries();
@@ -215,17 +213,17 @@ describe('ol.geom.GeometryCollection', function() {
var line, multi, point;
beforeEach(function() {
point = new ol.geom.Point([10, 20]);
line = new ol.geom.LineString([[10, 20], [30, 40]]);
multi = new ol.geom.GeometryCollection([point, line]);
point = new _ol_geom_Point_([10, 20]);
line = new _ol_geom_LineString_([[10, 20], [30, 40]]);
multi = new _ol_geom_GeometryCollection_([point, line]);
});
it('transforms all geometries', function() {
multi.transform('EPSG:4326', 'EPSG:3857');
var geometries = multi.getGeometries();
expect(geometries[0]).to.be.a(ol.geom.Point);
expect(geometries[1]).to.be.a(ol.geom.LineString);
expect(geometries[0]).to.be.a(_ol_geom_Point_);
expect(geometries[1]).to.be.a(_ol_geom_LineString_);
var coords = geometries[0].getCoordinates();
expect(coords[0]).to.roughlyEqual(1113194.90, 1e-2);

View File

@@ -1,14 +1,12 @@
goog.require('ol.extent');
goog.require('ol.geom.LineString');
import _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
describe('ol.geom.LineString', function() {
it('can be constructed with a null geometry', function() {
expect(function() {
return new ol.geom.LineString(null);
return new _ol_geom_LineString_(null);
}).not.to.throwException();
});
@@ -16,7 +14,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString([]);
lineString = new _ol_geom_LineString_([]);
});
it('defaults to layout XY', function() {
@@ -28,7 +26,7 @@ describe('ol.geom.LineString', function() {
});
it('has an empty extent', function() {
expect(ol.extent.isEmpty(lineString.getExtent())).to.be(true);
expect(_ol_extent_.isEmpty(lineString.getExtent())).to.be(true);
});
it('has empty flat coordinates', function() {
@@ -52,7 +50,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString([[1, 2], [3, 4]]);
lineString = new _ol_geom_LineString_([[1, 2], [3, 4]]);
});
it('has the expected layout', function() {
@@ -113,7 +111,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString([[1, 2, 3], [4, 5, 6]]);
lineString = new _ol_geom_LineString_([[1, 2, 3], [4, 5, 6]]);
});
it('has the expected layout', function() {
@@ -158,7 +156,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString(
lineString = new _ol_geom_LineString_(
[[1, 2, 3], [4, 5, 6]], 'XYM');
});
@@ -204,7 +202,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString([[1, 2, 3, 4], [5, 6, 7, 8]]);
lineString = new _ol_geom_LineString_([[1, 2, 3, 4], [5, 6, 7, 8]]);
});
it('has the expected layout', function() {
@@ -248,21 +246,21 @@ describe('ol.geom.LineString', function() {
describe('#scale()', function() {
it('scales a linestring', function() {
var geom = new ol.geom.LineString([[-10, -20], [10, 20]]);
var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]);
geom.scale(10);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-100, -200], [100, 200]]);
});
it('accepts sx and sy', function() {
var geom = new ol.geom.LineString([[-10, -20], [10, 20]]);
var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-20, -60], [20, 60]]);
});
it('accepts an anchor', function() {
var geom = new ol.geom.LineString([[-10, -20], [10, 20]]);
var geom = new _ol_geom_LineString_([[-10, -20], [10, 20]]);
geom.scale(3, 2, [10, 20]);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-50, -60], [10, 20]]);
@@ -274,7 +272,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString(
lineString = new _ol_geom_LineString_(
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
});
@@ -310,7 +308,7 @@ describe('ol.geom.LineString', function() {
it('returns a simplified geometry', function() {
var simplified = lineString.simplify(1);
expect(simplified).to.be.an(ol.geom.LineString);
expect(simplified).to.be.an(_ol_geom_LineString_);
expect(simplified.getCoordinates()).to.eql(
[[0, 0], [3, 3], [5, 1], [7, 5]]);
});
@@ -333,7 +331,7 @@ describe('ol.geom.LineString', function() {
it('returns the expectedResult', function() {
var simplifiedGeometry = lineString.getSimplifiedGeometry(1);
expect(simplifiedGeometry).to.be.an(ol.geom.LineString);
expect(simplifiedGeometry).to.be.an(_ol_geom_LineString_);
expect(simplifiedGeometry.getCoordinates()).to.eql(
[[0, 0], [3, 3], [5, 1], [7, 5]]);
});
@@ -386,7 +384,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString(
lineString = new _ol_geom_LineString_(
[[1, 2, 3], [4, 5, 6]], 'XYM');
});
@@ -415,7 +413,7 @@ describe('ol.geom.LineString', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString([
lineString = new _ol_geom_LineString_([
[0, 0, 0, 0],
[1, -1, 2, 1],
[2, -2, 4, 2],

View File

@@ -1,15 +1,13 @@
goog.require('ol.extent');
goog.require('ol.geom.LineString');
goog.require('ol.geom.MultiLineString');
import _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
describe('ol.geom.MultiLineString', function() {
it('can be constructed with a null geometry', function() {
expect(function() {
return new ol.geom.MultiLineString(null);
return new _ol_geom_MultiLineString_(null);
}).not.to.throwException();
});
@@ -17,7 +15,7 @@ describe('ol.geom.MultiLineString', function() {
var multiLineString;
beforeEach(function() {
multiLineString = new ol.geom.MultiLineString([]);
multiLineString = new _ol_geom_MultiLineString_([]);
});
it('defaults to layout XY', function() {
@@ -29,7 +27,7 @@ describe('ol.geom.MultiLineString', function() {
});
it('has an empty extent', function() {
expect(ol.extent.isEmpty(multiLineString.getExtent())).to.be(true);
expect(_ol_extent_.isEmpty(multiLineString.getExtent())).to.be(true);
});
it('has empty flat coordinates', function() {
@@ -42,11 +40,11 @@ describe('ol.geom.MultiLineString', function() {
it('can append line strings', function() {
multiLineString.appendLineString(
new ol.geom.LineString([[1, 2], [3, 4]]));
new _ol_geom_LineString_([[1, 2], [3, 4]]));
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2], [3, 4]]]);
multiLineString.appendLineString(
new ol.geom.LineString([[5, 6], [7, 8]]));
new _ol_geom_LineString_([[5, 6], [7, 8]]));
expect(multiLineString.getCoordinates()).to.eql(
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
});
@@ -57,7 +55,7 @@ describe('ol.geom.MultiLineString', function() {
var multiLineString;
beforeEach(function() {
multiLineString = new ol.geom.MultiLineString(
multiLineString = new _ol_geom_MultiLineString_(
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
});
@@ -109,7 +107,7 @@ describe('ol.geom.MultiLineString', function() {
var multiLineString;
beforeEach(function() {
multiLineString = new ol.geom.MultiLineString(
multiLineString = new _ol_geom_MultiLineString_(
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]);
});
@@ -141,7 +139,7 @@ describe('ol.geom.MultiLineString', function() {
var multiLineString;
beforeEach(function() {
multiLineString = new ol.geom.MultiLineString(
multiLineString = new _ol_geom_MultiLineString_(
[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],
'XYM');
});
@@ -170,11 +168,11 @@ describe('ol.geom.MultiLineString', function() {
it('can return individual line strings', function() {
var lineString0 = multiLineString.getLineString(0);
expect(lineString0).to.be.an(ol.geom.LineString);
expect(lineString0).to.be.an(_ol_geom_LineString_);
expect(lineString0.getLayout()).to.be('XYM');
expect(lineString0.getCoordinates()).to.eql([[1, 2, 3], [4, 5, 6]]);
var lineString1 = multiLineString.getLineString(1);
expect(lineString1).to.be.an(ol.geom.LineString);
expect(lineString1).to.be.an(_ol_geom_LineString_);
expect(lineString1.getLayout()).to.be('XYM');
expect(lineString1.getCoordinates()).to.eql([[7, 8, 9], [10, 11, 12]]);
});
@@ -289,7 +287,7 @@ describe('ol.geom.MultiLineString', function() {
var multiLineString;
beforeEach(function() {
multiLineString = new ol.geom.MultiLineString(
multiLineString = new _ol_geom_MultiLineString_(
[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]]);
});
@@ -320,21 +318,21 @@ describe('ol.geom.MultiLineString', function() {
describe('#scale()', function() {
it('scales a multi-linestring', function() {
var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
geom.scale(10);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-100, -200], [100, 200]], [[50, -100], [-50, 100]]]);
});
it('accepts sx and sy', function() {
var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-20, -60], [20, 60]], [[10, -30], [-10, 30]]]);
});
it('accepts an anchor', function() {
var geom = new ol.geom.MultiLineString([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
var geom = new _ol_geom_MultiLineString_([[[-10, -20], [10, 20]], [[5, -10], [-5, 10]]]);
geom.scale(3, 2, [10, 20]);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[[-50, -60], [10, 20]], [[-5, -40], [-35, 0]]]);
@@ -345,9 +343,9 @@ describe('ol.geom.MultiLineString', function() {
describe('#setLineStrings', function() {
it('sets the line strings', function() {
var multiLineString = new ol.geom.MultiLineString(null);
var lineString1 = new ol.geom.LineString([[1, 2], [3, 4]]);
var lineString2 = new ol.geom.LineString([[5, 6], [7, 8]]);
var multiLineString = new _ol_geom_MultiLineString_(null);
var lineString1 = new _ol_geom_LineString_([[1, 2], [3, 4]]);
var lineString2 = new _ol_geom_LineString_([[5, 6], [7, 8]]);
multiLineString.setLineStrings([lineString1, lineString2]);
expect(multiLineString.getFlatCoordinates()).to.eql(
[1, 2, 3, 4, 5, 6, 7, 8]);

View File

@@ -1,15 +1,13 @@
goog.require('ol.extent');
goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.Point');
import _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
describe('ol.geom.MultiPoint', function() {
it('can be constructed with a null geometry', function() {
expect(function() {
return new ol.geom.MultiPoint(null);
return new _ol_geom_MultiPoint_(null);
}).not.to.throwException();
});
@@ -17,7 +15,7 @@ describe('ol.geom.MultiPoint', function() {
var multiPoint;
beforeEach(function() {
multiPoint = new ol.geom.MultiPoint([]);
multiPoint = new _ol_geom_MultiPoint_([]);
});
it('defaults to layout XY', function() {
@@ -29,7 +27,7 @@ describe('ol.geom.MultiPoint', function() {
});
it('has an empty extent', function() {
expect(ol.extent.isEmpty(multiPoint.getExtent())).to.be(true);
expect(_ol_extent_.isEmpty(multiPoint.getExtent())).to.be(true);
});
it('has empty flat coordinates', function() {
@@ -41,9 +39,9 @@ describe('ol.geom.MultiPoint', function() {
});
it('can append points', function() {
multiPoint.appendPoint(new ol.geom.Point([1, 2]));
multiPoint.appendPoint(new _ol_geom_Point_([1, 2]));
expect(multiPoint.getCoordinates()).to.eql([[1, 2]]);
multiPoint.appendPoint(new ol.geom.Point([3, 4]));
multiPoint.appendPoint(new _ol_geom_Point_([3, 4]));
expect(multiPoint.getCoordinates()).to.eql([[1, 2], [3, 4]]);
});
@@ -53,7 +51,7 @@ describe('ol.geom.MultiPoint', function() {
var multiPoint;
beforeEach(function() {
multiPoint = new ol.geom.MultiPoint([[1, 2], [3, 4]]);
multiPoint = new _ol_geom_MultiPoint_([[1, 2], [3, 4]]);
});
it('has the expected layout', function() {
@@ -94,7 +92,7 @@ describe('ol.geom.MultiPoint', function() {
var multiPoint;
beforeEach(function() {
multiPoint = new ol.geom.MultiPoint([[1, 2, 3], [4, 5, 6]]);
multiPoint = new _ol_geom_MultiPoint_([[1, 2, 3], [4, 5, 6]]);
});
it('has the expected layout', function() {
@@ -123,7 +121,7 @@ describe('ol.geom.MultiPoint', function() {
var multiPoint;
beforeEach(function() {
multiPoint = new ol.geom.MultiPoint(
multiPoint = new _ol_geom_MultiPoint_(
[[1, 2, 3], [4, 5, 6]], 'XYM');
});
@@ -159,10 +157,10 @@ describe('ol.geom.MultiPoint', function() {
it('can return all points', function() {
var points = multiPoint.getPoints();
expect(points).to.have.length(2);
expect(points[0]).to.be.an(ol.geom.Point);
expect(points[0]).to.be.an(_ol_geom_Point_);
expect(points[0].getLayout()).to.be('XYM');
expect(points[0].getCoordinates()).to.eql([1, 2, 3]);
expect(points[1]).to.be.an(ol.geom.Point);
expect(points[1]).to.be.an(_ol_geom_Point_);
expect(points[1].getLayout()).to.be('XYM');
expect(points[1].getCoordinates()).to.eql([4, 5, 6]);
});
@@ -173,7 +171,7 @@ describe('ol.geom.MultiPoint', function() {
var multiPoint;
beforeEach(function() {
multiPoint = new ol.geom.MultiPoint([[1, 2, 3, 4], [5, 6, 7, 8]]);
multiPoint = new _ol_geom_MultiPoint_([[1, 2, 3, 4], [5, 6, 7, 8]]);
});
it('has the expected layout', function() {
@@ -210,21 +208,21 @@ describe('ol.geom.MultiPoint', function() {
describe('#scale()', function() {
it('scales a multi-point', function() {
var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]);
var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]);
geom.scale(10);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-100, -200], [100, 200]]);
});
it('accepts sx and sy', function() {
var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]);
var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]);
geom.scale(2, 3);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-20, -60], [20, 60]]);
});
it('accepts an anchor', function() {
var geom = new ol.geom.MultiPoint([[-10, -20], [10, 20]]);
var geom = new _ol_geom_MultiPoint_([[-10, -20], [10, 20]]);
geom.scale(3, 2, [-10, -20]);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([[-10, -20], [50, 60]]);
@@ -236,7 +234,7 @@ describe('ol.geom.MultiPoint', function() {
var multi, transform;
beforeEach(function() {
multi = new ol.geom.MultiPoint([[1, 2], [3, 4]]);
multi = new _ol_geom_MultiPoint_([[1, 2], [3, 4]]);
transform = sinon.spy();
});
@@ -273,10 +271,10 @@ describe('ol.geom.MultiPoint', function() {
describe('#transform()', function() {
it('transforms a geometry given CRS identifiers', function() {
var multi = new ol.geom.MultiPoint([[-111, 45], [111, -45]]).transform(
var multi = new _ol_geom_MultiPoint_([[-111, 45], [111, -45]]).transform(
'EPSG:4326', 'EPSG:3857');
expect(multi).to.be.a(ol.geom.MultiPoint);
expect(multi).to.be.a(_ol_geom_MultiPoint_);
var coords = multi.getCoordinates();

View File

@@ -1,14 +1,12 @@
goog.require('ol.geom.MultiPolygon');
goog.require('ol.geom.Polygon');
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.MultiPolygon', function() {
it('can be constructed with a null geometry', function() {
expect(function() {
return new ol.geom.MultiPolygon(null);
return new _ol_geom_MultiPolygon_(null);
}).not.to.throwException();
});
@@ -16,16 +14,16 @@ describe('ol.geom.MultiPolygon', function() {
var multiPolygon;
beforeEach(function() {
multiPolygon = new ol.geom.MultiPolygon(null);
multiPolygon = new _ol_geom_MultiPolygon_(null);
});
it('can append polygons', function() {
multiPolygon.appendPolygon(
new ol.geom.Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql(
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
multiPolygon.appendPolygon(
new ol.geom.Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql([
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
@@ -39,16 +37,16 @@ describe('ol.geom.MultiPolygon', function() {
var multiPolygon;
beforeEach(function() {
multiPolygon = new ol.geom.MultiPolygon([]);
multiPolygon = new _ol_geom_MultiPolygon_([]);
});
it('can append polygons', function() {
multiPolygon.appendPolygon(
new ol.geom.Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql(
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
multiPolygon.appendPolygon(
new ol.geom.Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql([
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
@@ -61,7 +59,7 @@ describe('ol.geom.MultiPolygon', function() {
describe('#scale()', function() {
it('scales a multi-polygon', function() {
var geom = new ol.geom.MultiPolygon([[
var geom = new _ol_geom_MultiPolygon_([[
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]]);
geom.scale(10);
@@ -70,7 +68,7 @@ describe('ol.geom.MultiPolygon', function() {
});
it('accepts sx and sy', function() {
var geom = new ol.geom.MultiPolygon([[
var geom = new _ol_geom_MultiPolygon_([[
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]]);
geom.scale(2, 3);
@@ -79,7 +77,7 @@ describe('ol.geom.MultiPolygon', function() {
});
it('accepts an anchor', function() {
var geom = new ol.geom.MultiPolygon([[
var geom = new _ol_geom_MultiPolygon_([[
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]]);
geom.scale(3, 2, [-1, -2]);
@@ -93,7 +91,7 @@ describe('ol.geom.MultiPolygon', function() {
var multiPolygon;
beforeEach(function() {
multiPolygon = new ol.geom.MultiPolygon([
multiPolygon = new _ol_geom_MultiPolygon_([
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
]);
@@ -101,11 +99,11 @@ describe('ol.geom.MultiPolygon', function() {
it('can return individual polygons', function() {
var polygon0 = multiPolygon.getPolygon(0);
expect(polygon0).to.be.an(ol.geom.Polygon);
expect(polygon0).to.be.an(_ol_geom_Polygon_);
expect(polygon0.getCoordinates()).to.eql(
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
var polygon1 = multiPolygon.getPolygon(1);
expect(polygon1).to.be.an(ol.geom.Polygon);
expect(polygon1).to.be.an(_ol_geom_Polygon_);
expect(polygon1.getCoordinates()).to.eql(
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
});
@@ -114,10 +112,10 @@ describe('ol.geom.MultiPolygon', function() {
var polygons = multiPolygon.getPolygons();
expect(polygons).to.be.an(Array);
expect(polygons).to.have.length(2);
expect(polygons[0]).to.be.an(ol.geom.Polygon);
expect(polygons[0]).to.be.an(_ol_geom_Polygon_);
expect(polygons[0].getCoordinates()).to.eql(
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
expect(polygons[1]).to.be.an(ol.geom.Polygon);
expect(polygons[1]).to.be.an(_ol_geom_Polygon_);
expect(polygons[1].getCoordinates()).to.eql(
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
});
@@ -137,8 +135,8 @@ describe('ol.geom.MultiPolygon', function() {
var cw2 = [[-140, -60], [-140, 60], [140, 60], [140, -60], [-140, -60]];
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
var ccw2 = [[-140, -60], [140, -60], [140, 60], [-140, 60], [-140, -60]];
var right = new ol.geom.MultiPolygon([[ccw, cw], [ccw2, cw2]]);
var left = new ol.geom.MultiPolygon([[cw, ccw], [cw2, ccw2]]);
var right = new _ol_geom_MultiPolygon_([[ccw, cw], [ccw2, cw2]]);
var left = new _ol_geom_MultiPolygon_([[cw, ccw], [cw2, ccw2]]);
it('returns coordinates as they were constructed', function() {
expect(right.getCoordinates()).to.eql([[ccw, cw], [ccw2, cw2]]);
@@ -169,7 +167,7 @@ describe('ol.geom.MultiPolygon', function() {
it('returns the expected result', function() {
var simplifiedGeometry = multiPolygon.getSimplifiedGeometry(1);
expect(simplifiedGeometry).to.be.an(ol.geom.MultiPolygon);
expect(simplifiedGeometry).to.be.an(_ol_geom_MultiPolygon_);
expect(simplifiedGeometry.getCoordinates()).to.eql([
[[[0, 0], [0, 2], [2, 0]]],
[[[3, 0], [5, 2], [5, 0]]]
@@ -198,7 +196,7 @@ describe('ol.geom.MultiPolygon', function() {
describe('#getInteriorPoints', function() {
it('returns XYM multipoint with intersection width as M', function() {
var geom = new ol.geom.MultiPolygon([
var geom = new _ol_geom_MultiPolygon_([
[[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]],
[[[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]]
]);

View File

@@ -1,13 +1,11 @@
goog.require('ol.geom.Point');
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
describe('ol.geom.Point', function() {
it('can be constructed with a null geometry', function() {
expect(function() {
return new ol.geom.Point(null);
return new _ol_geom_Point_(null);
}).not.to.throwException();
});
@@ -15,7 +13,7 @@ describe('ol.geom.Point', function() {
var point;
beforeEach(function() {
point = new ol.geom.Point([1, 2]);
point = new _ol_geom_Point_([1, 2]);
});
it('has the expected layout', function() {
@@ -52,7 +50,7 @@ describe('ol.geom.Point', function() {
var point;
beforeEach(function() {
point = new ol.geom.Point([1, 2, 3], 'XYM');
point = new _ol_geom_Point_([1, 2, 3], 'XYM');
});
it('has the expected layout', function() {
@@ -89,7 +87,7 @@ describe('ol.geom.Point', function() {
var point;
beforeEach(function() {
point = new ol.geom.Point([1, 2, 3, 4]);
point = new _ol_geom_Point_([1, 2, 3, 4]);
});
it('has the expected layout', function() {
@@ -134,21 +132,21 @@ describe('ol.geom.Point', function() {
describe('#scale()', function() {
it('scales a point', function() {
var geom = new ol.geom.Point([1, 2]);
var geom = new _ol_geom_Point_([1, 2]);
geom.scale(10e6);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([1, 2]);
});
it('accepts sx and sy', function() {
var geom = new ol.geom.Point([1, 2]);
var geom = new _ol_geom_Point_([1, 2]);
geom.scale(1e6, -42);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([1, 2]);
});
it('accepts an anchor', function() {
var geom = new ol.geom.Point([1, 2]);
var geom = new _ol_geom_Point_([1, 2]);
geom.scale(10, 15, [0, 0]);
var coordinates = geom.getCoordinates();
expect(coordinates).to.eql([10, 30]);
@@ -160,7 +158,7 @@ describe('ol.geom.Point', function() {
var point, transform;
beforeEach(function() {
point = new ol.geom.Point([1, 2]);
point = new _ol_geom_Point_([1, 2]);
transform = sinon.spy();
});
@@ -195,10 +193,10 @@ describe('ol.geom.Point', function() {
describe('#transform()', function() {
it('transforms a geometry given CRS identifiers', function() {
var point = new ol.geom.Point([-111, 45]).transform(
var point = new _ol_geom_Point_([-111, 45]).transform(
'EPSG:4326', 'EPSG:3857');
expect(point).to.be.a(ol.geom.Point);
expect(point).to.be.a(_ol_geom_Point_);
var coords = point.getCoordinates();
@@ -207,7 +205,7 @@ describe('ol.geom.Point', function() {
});
it('modifies the original', function() {
var point = new ol.geom.Point([-111, 45]);
var point = new _ol_geom_Point_([-111, 45]);
point.transform('EPSG:4326', 'EPSG:3857');
var coords = point.getCoordinates();

View File

@@ -1,16 +1,14 @@
goog.require('ol.extent');
goog.require('ol.geom.Circle');
goog.require('ol.geom.LinearRing');
goog.require('ol.geom.Polygon');
import _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.Polygon', function() {
it('can be constructed with a null geometry', function() {
expect(function() {
return new ol.geom.Polygon(null);
return new _ol_geom_Polygon_(null);
}).not.to.throwException();
});
@@ -18,7 +16,7 @@ describe('ol.geom.Polygon', function() {
var polygon;
beforeEach(function() {
polygon = new ol.geom.Polygon([]);
polygon = new _ol_geom_Polygon_([]);
});
it('defaults to layout XY', function() {
@@ -30,7 +28,7 @@ describe('ol.geom.Polygon', function() {
});
it('has an empty extent', function() {
expect(ol.extent.isEmpty(polygon.getExtent())).to.be(true);
expect(_ol_extent_.isEmpty(polygon.getExtent())).to.be(true);
});
it('has empty flat coordinates', function() {
@@ -43,11 +41,11 @@ describe('ol.geom.Polygon', function() {
it('can append linear rings', function() {
polygon.appendLinearRing(
new ol.geom.LinearRing([[1, 2], [3, 4], [5, 6]]));
new _ol_geom_LinearRing_([[1, 2], [3, 4], [5, 6]]));
expect(polygon.getCoordinates()).to.eql(
[[[1, 2], [3, 4], [5, 6]]]);
polygon.appendLinearRing(
new ol.geom.LinearRing([[7, 8], [9, 10], [11, 12]]));
new _ol_geom_LinearRing_([[7, 8], [9, 10], [11, 12]]));
expect(polygon.getCoordinates()).to.eql(
[[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]);
});
@@ -61,7 +59,7 @@ describe('ol.geom.Polygon', function() {
beforeEach(function() {
outerRing = [[0, 1], [1, 4], [4, 3], [3, 0]];
innerRing = [[2, 2], [3, 2], [3, 3], [2, 3]];
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0, 2, 2, 3, 2, 3, 3, 2, 3];
outsideOuter = [0, 4];
inside = [1.5, 1.5];
@@ -97,16 +95,16 @@ describe('ol.geom.Polygon', function() {
var linearRings = polygon.getLinearRings();
expect(linearRings).to.be.an(Array);
expect(linearRings).to.have.length(2);
expect(linearRings[0]).to.be.an(ol.geom.LinearRing);
expect(linearRings[0]).to.be.an(_ol_geom_LinearRing_);
expect(linearRings[0].getCoordinates()).to.eql(outerRing);
expect(linearRings[1]).to.be.an(ol.geom.LinearRing);
expect(linearRings[1]).to.be.an(_ol_geom_LinearRing_);
expect(linearRings[1].getCoordinates()).to.eql(innerRing);
});
it('does not reverse any rings', function() {
outerRing.reverse();
innerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
var coordinates = polygon.getCoordinates();
expect(coordinates[0]).to.eql(outerRing);
expect(coordinates[1]).to.eql(innerRing);
@@ -128,8 +126,8 @@ describe('ol.geom.Polygon', function() {
var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
var right = new ol.geom.Polygon([ccw, cw]);
var left = new ol.geom.Polygon([cw, ccw]);
var right = new _ol_geom_Polygon_([ccw, cw]);
var left = new _ol_geom_Polygon_([cw, ccw]);
it('returns coordinates as they were constructed', function() {
expect(right.getCoordinates()).to.eql([ccw, cw]);
@@ -152,20 +150,20 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
it('reverses inner rings if necessary', function() {
innerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
it('reverses all rings if necessary', function() {
outerRing.reverse();
innerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -180,7 +178,7 @@ describe('ol.geom.Polygon', function() {
beforeEach(function() {
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6];
outsideOuter = [1, 3];
inside = [3.5, 0.5];
@@ -223,25 +221,25 @@ describe('ol.geom.Polygon', function() {
it('does not intersect outside extent', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([outsideOuter]))).to.be(false);
_ol_extent_.boundingExtent([outsideOuter]))).to.be(false);
});
it('does intersect inside extent', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([inside]))).to.be(true);
_ol_extent_.boundingExtent([inside]))).to.be(true);
});
it('does intersect boundary extent', function() {
var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX,
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
firstMidY]]))).to.be(true);
});
it('does not intersect extent fully contained by inner ring', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([insideInner]))).to.be(false);
_ol_extent_.boundingExtent([insideInner]))).to.be(false);
});
});
@@ -250,20 +248,20 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
it('reverses inner rings if necessary', function() {
innerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
it('reverses all rings if necessary', function() {
outerRing.reverse();
innerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -278,7 +276,7 @@ describe('ol.geom.Polygon', function() {
beforeEach(function() {
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
polygon = new ol.geom.Polygon(
polygon = new _ol_geom_Polygon_(
[outerRing, innerRing], 'XYM');
flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6];
outsideOuter = [1, 3];
@@ -322,25 +320,25 @@ describe('ol.geom.Polygon', function() {
it('does not intersect outside extent', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([outsideOuter]))).to.be(false);
_ol_extent_.boundingExtent([outsideOuter]))).to.be(false);
});
it('does intersect inside extent', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([inside]))).to.be(true);
_ol_extent_.boundingExtent([inside]))).to.be(true);
});
it('does intersect boundary extent', function() {
var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX,
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
firstMidY]]))).to.be(true);
});
it('does not intersect extent fully contained by inner ring', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([insideInner]))).to.be(false);
_ol_extent_.boundingExtent([insideInner]))).to.be(false);
});
});
@@ -349,20 +347,20 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
it('reverses inner rings if necessary', function() {
innerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
it('reverses all rings if necessary', function() {
outerRing.reverse();
innerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -379,7 +377,7 @@ describe('ol.geom.Polygon', function() {
innerRing1 =
[[2, 4, 7, 8], [4, 4, 9, 10], [4, 5, 11, 12], [2, 5, 13, 14]];
innerRing2 = [[3, 2, 15, 16], [4, 3, 17, 18], [2, 3, 19, 20]];
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
flatCoordinates = [
0, 6, 1, 2, 6, 6, 3, 4, 3, 0, 5, 6,
2, 4, 7, 8, 4, 4, 9, 10, 4, 5, 11, 12, 2, 5, 13, 14,
@@ -429,27 +427,27 @@ describe('ol.geom.Polygon', function() {
it('does not intersect outside extent', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([outsideOuter]))).to.be(false);
_ol_extent_.boundingExtent([outsideOuter]))).to.be(false);
});
it('does intersect inside extent', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([inside]))).to.be(true);
_ol_extent_.boundingExtent([inside]))).to.be(true);
});
it('does intersect boundary extent', function() {
var firstMidX = (outerRing[0][0] + outerRing[1][0]) / 2;
var firstMidY = (outerRing[0][1] + outerRing[1][1]) / 2;
expect(polygon.intersectsExtent(ol.extent.boundingExtent([[firstMidX,
expect(polygon.intersectsExtent(_ol_extent_.boundingExtent([[firstMidX,
firstMidY]]))).to.be(true);
});
it('does not intersect extent fully contained by inner ring', function() {
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([insideInner1]))).to.be(false);
_ol_extent_.boundingExtent([insideInner1]))).to.be(false);
expect(polygon.intersectsExtent(
ol.extent.boundingExtent([insideInner2]))).to.be(false);
_ol_extent_.boundingExtent([insideInner2]))).to.be(false);
});
});
@@ -458,14 +456,14 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
it('reverses inner rings if necessary', function() {
innerRing1.reverse();
innerRing2.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -473,7 +471,7 @@ describe('ol.geom.Polygon', function() {
outerRing.reverse();
innerRing1.reverse();
innerRing2.reverse();
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -485,7 +483,7 @@ describe('ol.geom.Polygon', function() {
var polygon;
beforeEach(function() {
polygon = new ol.geom.Polygon(
polygon = new _ol_geom_Polygon_(
[[[3, 0], [1, 3], [0, 6], [2, 6], [3, 7], [4, 6], [6, 6], [4, 3]]]);
});
@@ -493,7 +491,7 @@ describe('ol.geom.Polygon', function() {
it('returns the expected result', function() {
var simplifiedGeometry = polygon.getSimplifiedGeometry(9);
expect(simplifiedGeometry).to.be.an(ol.geom.Polygon);
expect(simplifiedGeometry).to.be.an(_ol_geom_Polygon_);
expect(simplifiedGeometry.getCoordinates()).to.eql(
[[[3, 0], [0, 3], [0, 6], [6, 6], [3, 3]]]);
});
@@ -513,7 +511,7 @@ describe('ol.geom.Polygon', function() {
describe('#scale()', function() {
it('scales a polygon', function() {
var geom = new ol.geom.Polygon([
var geom = new _ol_geom_Polygon_([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(10);
@@ -522,7 +520,7 @@ describe('ol.geom.Polygon', function() {
});
it('accepts sx and sy', function() {
var geom = new ol.geom.Polygon([
var geom = new _ol_geom_Polygon_([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(2, 3);
@@ -531,7 +529,7 @@ describe('ol.geom.Polygon', function() {
});
it('accepts an anchor', function() {
var geom = new ol.geom.Polygon([
var geom = new _ol_geom_Polygon_([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(3, 2, [-1, -2]);
@@ -544,7 +542,7 @@ describe('ol.geom.Polygon', function() {
describe('#getInteriorPoint', function() {
it('returns XYM point with intersection width as M', function() {
var geom = new ol.geom.Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
var geom = new _ol_geom_Polygon_([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
var interiorPoint = geom.getInteriorPoint();
expect(interiorPoint.getType()).to.be('Point');
expect(interiorPoint.layout).to.be('XYM');
@@ -552,7 +550,7 @@ describe('ol.geom.Polygon', function() {
});
it('returns XYM point for donut polygons', function() {
var geom = new ol.geom.Polygon([
var geom = new _ol_geom_Polygon_([
[[0.5, 0.5], [0.5, 2.5], [2.5, 2.5], [2.5, 0.5], [0.5, 0.5]],
[[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]
]);
@@ -566,7 +564,7 @@ describe('ol.geom.Polygon', function() {
describe('ol.geom.Polygon.fromExtent', function() {
it('creates the correct polygon', function() {
var extent = [1, 2, 3, 5];
var polygon = ol.geom.Polygon.fromExtent(extent);
var polygon = _ol_geom_Polygon_.fromExtent(extent);
var flatCoordinates = polygon.getFlatCoordinates();
expect(flatCoordinates).to.eql(
[1, 2, 1, 5, 3, 5, 3, 2, 1, 2]);
@@ -579,8 +577,8 @@ describe('ol.geom.Polygon', function() {
describe('ol.geom.Polygon.fromCircle', function() {
it('creates a regular polygon', function() {
var circle = new ol.geom.Circle([0, 0, 0], 1, 'XYZ');
var polygon = ol.geom.Polygon.fromCircle(circle);
var circle = new _ol_geom_Circle_([0, 0, 0], 1, 'XYZ');
var polygon = _ol_geom_Polygon_.fromCircle(circle);
var coordinates = polygon.getLinearRing(0).getCoordinates();
expect(coordinates[0].length).to.eql(3);
expect(coordinates[0][2]).to.eql(0);
@@ -600,8 +598,8 @@ describe('ol.geom.Polygon', function() {
});
it('creates a regular polygon with custom sides and angle', function() {
var circle = new ol.geom.Circle([0, 0], 1);
var polygon = ol.geom.Polygon.fromCircle(circle, 4, Math.PI / 2);
var circle = new _ol_geom_Circle_([0, 0], 1);
var polygon = _ol_geom_Polygon_.fromCircle(circle, 4, Math.PI / 2);
var coordinates = polygon.getLinearRing(0).getCoordinates();
expect(coordinates[4]).to.eql(coordinates[0]);
expect(coordinates[0][0]).to.roughlyEqual(0, 1e-9);