|
|
|
|
@@ -331,7 +331,7 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#appendFlatCoordinates()', function () {
|
|
|
|
|
describe('#appendFlatLineCoordinates()', function () {
|
|
|
|
|
let replay;
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
replay = new CanvasBuilder(1, [-180, -90, 180, 90], 1, 1, true);
|
|
|
|
|
@@ -339,19 +339,19 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
|
|
|
|
|
it('appends coordinates that are within the max extent', function () {
|
|
|
|
|
const flat = [-110, 45, 110, 45, 110, -45, -110, -45];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('appends polygon coordinates that are within the max extent', function () {
|
|
|
|
|
const flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('appends polygon coordinates that are within the max extent (skipping first)', function () {
|
|
|
|
|
const flat = [-110, 45, 110, 45, 110, -45, -110, -45, -110, 45];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
expect(replay.coordinates).to.eql([
|
|
|
|
|
110,
|
|
|
|
|
45,
|
|
|
|
|
@@ -366,7 +366,7 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
|
|
|
|
|
it('works with a single coordinate (inside)', function () {
|
|
|
|
|
const flat = [-110, 45];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -374,7 +374,7 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
// this could be changed, but to make the code simpler for properly
|
|
|
|
|
// closing rings, we always add the first point
|
|
|
|
|
const flat = [-110, 145];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -382,13 +382,13 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
// this could be changed, but to make the code simpler for properly
|
|
|
|
|
// closing rings, we always add the first point
|
|
|
|
|
const flat = [-110, 145, -110, 145];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('skips first polygon vertex upon request (also when outside)', function () {
|
|
|
|
|
const flat = [-110, 145, -110, 145];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
expect(replay.coordinates).to.eql([-110, 145]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -396,13 +396,13 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
// this means we get a few extra points when coordinates are not
|
|
|
|
|
// part of a linestring or ring, but only a few extra
|
|
|
|
|
const flat = [0, 200, 0, -200];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('appends points when segments cross (top to inside)', function () {
|
|
|
|
|
const flat = [0, 200, 0, 0];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -410,7 +410,7 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
// this could be changed, but to make the code simpler for properly
|
|
|
|
|
// closing rings, we always add the first segment
|
|
|
|
|
const flat = [-10, 200, 10, 200];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -418,67 +418,67 @@ describe('ol.render.canvas.Builder', function () {
|
|
|
|
|
// this could be changed, but to make the code simpler for properly
|
|
|
|
|
// closing rings, we always add the first segment
|
|
|
|
|
const flat = [-10, 200, 10, 200, -10, 200];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('skips first polygon segment upon request (also when outside)', function () {
|
|
|
|
|
const flat = [-10, 200, 10, 200, -10, 200];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
expect(replay.coordinates).to.eql([10, 200, -10, 200]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('eliminates segments outside (and not changing rel)', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 5, 200, 10, 200];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql([0, 0, 0, 200]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('eliminates polygon segments outside (and not changing rel)', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 5, 200, 10, 200, 0, 0];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
expect(replay.coordinates).to.eql([0, 0, 0, 200, 10, 200, 0, 0]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('eliminates polygon segments outside (skipping first and not changing rel)', function () {
|
|
|
|
|
const flat = [0, 0, 0, 10, 0, 200, 5, 200, 10, 200, 0, 0];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
expect(replay.coordinates).to.eql([0, 10, 0, 200, 10, 200, 0, 0]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('eliminates segments outside (and not changing rel)', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 10, 200];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql([0, 0, 0, 200]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('includes polygon segments outside (and not changing rel) when on last segment', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 10, 200, 0, 0];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('includes polygon segments outside (skipping first and not changing rel) when on last segment', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 10, 200, 0, 0];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
expect(replay.coordinates).to.eql([0, 200, 10, 200, 0, 0]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('includes outside segments that change relationship', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 200, 200, 250, 200];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, false, false);
|
|
|
|
|
expect(replay.coordinates).to.eql([0, 0, 0, 200, 200, 200]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('includes outside polygon segments that change relationship when on last segment', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, false);
|
|
|
|
|
expect(replay.coordinates).to.eql(flat);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('includes outside polygon segments that change relationship when on last segment (when skipping first)', function () {
|
|
|
|
|
const flat = [0, 0, 0, 200, 200, 200, 250, 200, 0, 0];
|
|
|
|
|
replay.appendFlatCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
replay.appendFlatLineCoordinates(flat, 0, flat.length, 2, true, true);
|
|
|
|
|
expect(replay.coordinates).to.eql([0, 200, 200, 200, 250, 200, 0, 0]);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|