Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import BuilderGroup from '../../../../../src/ol/render/canvas/BuilderGroup.js';
|
||||
import CanvasBuilder from '../../../../../src/ol/render/canvas/Builder.js';
|
||||
import CanvasLineStringBuilder from '../../../../../src/ol/render/canvas/LineStringBuilder.js';
|
||||
import CanvasPolygonBuilder from '../../../../../src/ol/render/canvas/PolygonBuilder.js';
|
||||
import ExecutorGroup from '../../../../../src/ol/render/canvas/ExecutorGroup.js';
|
||||
import Feature from '../../../../../src/ol/Feature.js';
|
||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
||||
import GeometryCollection from '../../../../../src/ol/geom/GeometryCollection.js';
|
||||
import LineString from '../../../../../src/ol/geom/LineString.js';
|
||||
import MultiLineString from '../../../../../src/ol/geom/MultiLineString.js';
|
||||
@@ -6,21 +12,16 @@ import MultiPoint from '../../../../../src/ol/geom/MultiPoint.js';
|
||||
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
||||
import Point from '../../../../../src/ol/geom/Point.js';
|
||||
import Polygon from '../../../../../src/ol/geom/Polygon.js';
|
||||
import CanvasLineStringBuilder from '../../../../../src/ol/render/canvas/LineStringBuilder.js';
|
||||
import CanvasPolygonBuilder from '../../../../../src/ol/render/canvas/PolygonBuilder.js';
|
||||
import CanvasBuilder from '../../../../../src/ol/render/canvas/Builder.js';
|
||||
import BuilderGroup from '../../../../../src/ol/render/canvas/BuilderGroup.js';
|
||||
import ExecutorGroup from '../../../../../src/ol/render/canvas/ExecutorGroup.js';
|
||||
import {renderFeature} from '../../../../../src/ol/renderer/vector.js';
|
||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
||||
import Style from '../../../../../src/ol/style/Style.js';
|
||||
import {create as createTransform, scale as scaleTransform} from '../../../../../src/ol/transform.js';
|
||||
|
||||
describe('ol.render.canvas.BuilderGroup', function() {
|
||||
|
||||
describe('#replay', function() {
|
||||
import {
|
||||
create as createTransform,
|
||||
scale as scaleTransform,
|
||||
} from '../../../../../src/ol/transform.js';
|
||||
import {renderFeature} from '../../../../../src/ol/renderer/vector.js';
|
||||
|
||||
describe('ol.render.canvas.BuilderGroup', function () {
|
||||
describe('#replay', function () {
|
||||
let context, builder, fillCount, transform;
|
||||
let strokeCount, beginPathCount, moveToCount, lineToCount;
|
||||
let feature0, feature1, feature2, feature3;
|
||||
@@ -32,36 +33,82 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
* @param {boolean=} overlaps Whether there is overlaps.
|
||||
*/
|
||||
function execute(builder, pixelRatio, overlaps) {
|
||||
const executor = new ExecutorGroup([-180, -90, 180, 90], 1,
|
||||
pixelRatio || 1, !!overlaps, builder.finish());
|
||||
const executor = new ExecutorGroup(
|
||||
[-180, -90, 180, 90],
|
||||
1,
|
||||
pixelRatio || 1,
|
||||
!!overlaps,
|
||||
builder.finish()
|
||||
);
|
||||
executor.execute(context, transform, 0, false);
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
transform = createTransform();
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 1, false);
|
||||
feature0 = new Feature(new Polygon(
|
||||
[[[-90, 0], [-45, 45], [0, 0], [1, 1], [0, -45], [-90, 0]]]));
|
||||
feature1 = new Feature(new Polygon(
|
||||
[[[-90, -45], [-90, 0], [0, 0], [0, -45], [-90, -45]]]));
|
||||
feature2 = new Feature(new Polygon(
|
||||
[[[90, 45], [90, 0], [0, 0], [0, 45], [90, 45]]]));
|
||||
feature3 = new Feature(new Polygon(
|
||||
[[[-90, -45], [-90, 45], [90, 45], [90, -45], [-90, -45]]]));
|
||||
feature0 = new Feature(
|
||||
new Polygon([
|
||||
[
|
||||
[-90, 0],
|
||||
[-45, 45],
|
||||
[0, 0],
|
||||
[1, 1],
|
||||
[0, -45],
|
||||
[-90, 0],
|
||||
],
|
||||
])
|
||||
);
|
||||
feature1 = new Feature(
|
||||
new Polygon([
|
||||
[
|
||||
[-90, -45],
|
||||
[-90, 0],
|
||||
[0, 0],
|
||||
[0, -45],
|
||||
[-90, -45],
|
||||
],
|
||||
])
|
||||
);
|
||||
feature2 = new Feature(
|
||||
new Polygon([
|
||||
[
|
||||
[90, 45],
|
||||
[90, 0],
|
||||
[0, 0],
|
||||
[0, 45],
|
||||
[90, 45],
|
||||
],
|
||||
])
|
||||
);
|
||||
feature3 = new Feature(
|
||||
new Polygon([
|
||||
[
|
||||
[-90, -45],
|
||||
[-90, 45],
|
||||
[90, 45],
|
||||
[90, -45],
|
||||
[-90, -45],
|
||||
],
|
||||
])
|
||||
);
|
||||
fill0 = new Style({
|
||||
fill: new Fill({color: 'black'})
|
||||
fill: new Fill({color: 'black'}),
|
||||
});
|
||||
fill1 = new Style({
|
||||
fill: new Fill({color: 'red'})
|
||||
fill: new Fill({color: 'red'}),
|
||||
});
|
||||
style1 = new Style({
|
||||
fill: new Fill({color: 'black'}),
|
||||
stroke: new Stroke({color: 'white', width: 1})
|
||||
stroke: new Stroke({color: 'white', width: 1}),
|
||||
});
|
||||
style2 = new Style({
|
||||
fill: new Fill({color: 'white'}),
|
||||
stroke: new Stroke({color: 'black', width: 1, lineDash: [3, 6],
|
||||
lineDashOffset: 2})
|
||||
stroke: new Stroke({
|
||||
color: 'black',
|
||||
width: 1,
|
||||
lineDash: [3, 6],
|
||||
lineDashOffset: 2,
|
||||
}),
|
||||
});
|
||||
fillCount = 0;
|
||||
strokeCount = 0;
|
||||
@@ -69,36 +116,35 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
moveToCount = 0;
|
||||
lineToCount = 0;
|
||||
context = {
|
||||
fill: function() {
|
||||
fill: function () {
|
||||
fillCount++;
|
||||
},
|
||||
stroke: function() {
|
||||
stroke: function () {
|
||||
strokeCount++;
|
||||
},
|
||||
beginPath: function() {
|
||||
beginPath: function () {
|
||||
beginPathCount++;
|
||||
},
|
||||
clip: function() {
|
||||
clip: function () {
|
||||
// remove beginPath, moveTo and lineTo counts for clipping
|
||||
beginPathCount--;
|
||||
moveToCount--;
|
||||
lineToCount -= 3;
|
||||
},
|
||||
moveTo: function() {
|
||||
moveTo: function () {
|
||||
moveToCount++;
|
||||
},
|
||||
lineTo: function() {
|
||||
lineTo: function () {
|
||||
lineToCount++;
|
||||
},
|
||||
closePath: function() {},
|
||||
setLineDash: function() {},
|
||||
save: function() {},
|
||||
restore: function() {}
|
||||
closePath: function () {},
|
||||
setLineDash: function () {},
|
||||
save: function () {},
|
||||
restore: function () {},
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
it('omits lineTo for repeated coordinates', function() {
|
||||
it('omits lineTo for repeated coordinates', function () {
|
||||
renderFeature(builder, feature0, fill0, 1);
|
||||
execute(builder);
|
||||
expect(lineToCount).to.be(4);
|
||||
@@ -108,14 +154,14 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
expect(lineToCount).to.be(3);
|
||||
});
|
||||
|
||||
it('does not omit moveTo for repeated coordinates', function() {
|
||||
it('does not omit moveTo for repeated coordinates', function () {
|
||||
renderFeature(builder, feature0, fill0, 1);
|
||||
renderFeature(builder, feature1, fill1, 1);
|
||||
execute(builder);
|
||||
expect(moveToCount).to.be(2);
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for same style', function() {
|
||||
it('batches fill and stroke instructions for same style', function () {
|
||||
renderFeature(builder, feature1, style1, 1);
|
||||
renderFeature(builder, feature2, style1, 1);
|
||||
renderFeature(builder, feature3, style1, 1);
|
||||
@@ -125,7 +171,7 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
expect(beginPathCount).to.be(1);
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for different styles', function() {
|
||||
it('batches fill and stroke instructions for different styles', function () {
|
||||
renderFeature(builder, feature1, style1, 1);
|
||||
renderFeature(builder, feature2, style1, 1);
|
||||
renderFeature(builder, feature3, style2, 1);
|
||||
@@ -135,7 +181,7 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
expect(beginPathCount).to.be(2);
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for changing styles', function() {
|
||||
it('batches fill and stroke instructions for changing styles', function () {
|
||||
renderFeature(builder, feature1, style1, 1);
|
||||
renderFeature(builder, feature2, style2, 1);
|
||||
renderFeature(builder, feature3, style1, 1);
|
||||
@@ -145,7 +191,7 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
expect(beginPathCount).to.be(3);
|
||||
});
|
||||
|
||||
it('does not batch when overlaps is set to true', function() {
|
||||
it('does not batch when overlaps is set to true', function () {
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
renderFeature(builder, feature1, style1, 1);
|
||||
renderFeature(builder, feature2, style1, 1);
|
||||
@@ -156,23 +202,25 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
expect(beginPathCount).to.be(3);
|
||||
});
|
||||
|
||||
it('applies the pixelRatio to the linedash array and offset', function() {
|
||||
it('applies the pixelRatio to the linedash array and offset', function () {
|
||||
// replay with a pixelRatio of 2
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 2, true);
|
||||
|
||||
let lineDash, lineDashCount = 0,
|
||||
lineDashOffset, lineDashOffsetCount = 0;
|
||||
let lineDash,
|
||||
lineDashCount = 0,
|
||||
lineDashOffset,
|
||||
lineDashOffsetCount = 0;
|
||||
|
||||
context.setLineDash = function(lineDash_) {
|
||||
context.setLineDash = function (lineDash_) {
|
||||
lineDashCount++;
|
||||
lineDash = lineDash_.slice();
|
||||
};
|
||||
|
||||
Object.defineProperty(context, 'lineDashOffset', {
|
||||
set: function(lineDashOffset_) {
|
||||
set: function (lineDashOffset_) {
|
||||
lineDashOffsetCount++;
|
||||
lineDashOffset = lineDashOffset_;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
renderFeature(builder, feature1, style2, 1);
|
||||
@@ -188,10 +236,10 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
expect(lineDashOffset).to.be(4);
|
||||
});
|
||||
|
||||
it('calls the renderer function configured for the style', function() {
|
||||
it('calls the renderer function configured for the style', function () {
|
||||
const calls = [];
|
||||
const style = new Style({
|
||||
renderer: function(coords, state) {
|
||||
renderer: function (coords, state) {
|
||||
calls.push({
|
||||
coords: coords,
|
||||
geometry: state.geometry,
|
||||
@@ -199,22 +247,44 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
context: state.context,
|
||||
pixelRatio: state.pixelRatio,
|
||||
rotation: state.rotation,
|
||||
resolution: state.resolution
|
||||
resolution: state.resolution,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
const point = new Feature(new Point([45, 90]));
|
||||
const multipoint = new Feature(new MultiPoint(
|
||||
[[45, 90], [90, 45]]));
|
||||
const linestring = new Feature(new LineString(
|
||||
[[45, 90], [45, 45], [90, 45]]));
|
||||
const multilinestring = new Feature(new MultiLineString(
|
||||
[linestring.getGeometry().getCoordinates(), linestring.getGeometry().getCoordinates()]));
|
||||
const multipoint = new Feature(
|
||||
new MultiPoint([
|
||||
[45, 90],
|
||||
[90, 45],
|
||||
])
|
||||
);
|
||||
const linestring = new Feature(
|
||||
new LineString([
|
||||
[45, 90],
|
||||
[45, 45],
|
||||
[90, 45],
|
||||
])
|
||||
);
|
||||
const multilinestring = new Feature(
|
||||
new MultiLineString([
|
||||
linestring.getGeometry().getCoordinates(),
|
||||
linestring.getGeometry().getCoordinates(),
|
||||
])
|
||||
);
|
||||
const polygon = feature1;
|
||||
const multipolygon = new Feature(new MultiPolygon(
|
||||
[polygon.getGeometry().getCoordinates(), polygon.getGeometry().getCoordinates()]));
|
||||
const geometrycollection = new Feature(new GeometryCollection(
|
||||
[point.getGeometry(), linestring.getGeometry(), polygon.getGeometry()]));
|
||||
const multipolygon = new Feature(
|
||||
new MultiPolygon([
|
||||
polygon.getGeometry().getCoordinates(),
|
||||
polygon.getGeometry().getCoordinates(),
|
||||
])
|
||||
);
|
||||
const geometrycollection = new Feature(
|
||||
new GeometryCollection([
|
||||
point.getGeometry(),
|
||||
linestring.getGeometry(),
|
||||
polygon.getGeometry(),
|
||||
])
|
||||
);
|
||||
builder = new BuilderGroup(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
renderFeature(builder, point, style, 1);
|
||||
renderFeature(builder, multipoint, style, 1);
|
||||
@@ -249,54 +319,58 @@ describe('ol.render.canvas.BuilderGroup', function() {
|
||||
expect(calls[8].geometry.getCoordinates()[0][0]).to.eql([-90, -45]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.render.canvas.Builder', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new replay batch', function() {
|
||||
describe('ol.render.canvas.Builder', function () {
|
||||
describe('constructor', function () {
|
||||
it('creates a new replay batch', function () {
|
||||
const tolerance = 10;
|
||||
const extent = [-180, -90, 180, 90];
|
||||
const replay = new CanvasBuilder(tolerance, extent, 1, 1, true);
|
||||
expect(replay).to.be.a(CanvasBuilder);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#appendFlatCoordinates()', function() {
|
||||
|
||||
describe('#appendFlatCoordinates()', function () {
|
||||
let replay;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
replay = new CanvasBuilder(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
});
|
||||
|
||||
it('appends coordinates that are within the max extent', 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);
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('appends polygon coordinates that are within the max extent', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('appends polygon coordinates that are within the max extent (skipping first)', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([110, 45, 110, -45, -110, -45, -110, 45]);
|
||||
expect(replay.coordinates).to.eql([
|
||||
110,
|
||||
45,
|
||||
110,
|
||||
-45,
|
||||
-110,
|
||||
-45,
|
||||
-110,
|
||||
45,
|
||||
]);
|
||||
});
|
||||
|
||||
it('works with a single coordinate (inside)', function() {
|
||||
it('works with a single coordinate (inside)', function () {
|
||||
const flat = [-110, 45];
|
||||
replay.appendFlatCoordinates(flat, 0, flat.length, 2, false, false);
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('always appends first point (even if outside)', function() {
|
||||
it('always appends first point (even if outside)', 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];
|
||||
@@ -304,7 +378,7 @@ describe('ol.render.canvas.Builder', function() {
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('always appends first polygon vertex (even if outside)', function() {
|
||||
it('always appends first polygon vertex (even if outside)', 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];
|
||||
@@ -312,13 +386,13 @@ describe('ol.render.canvas.Builder', function() {
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('skips first polygon vertex upon request (also when outside)', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([-110, 145]);
|
||||
});
|
||||
|
||||
it('appends points when segments cross (top to bottom)', function() {
|
||||
it('appends points when segments cross (top to bottom)', 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];
|
||||
@@ -326,13 +400,13 @@ describe('ol.render.canvas.Builder', function() {
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('appends points when segments cross (top to inside)', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('always appends the first segment (even when outside)', function() {
|
||||
it('always appends the first segment (even when outside)', 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];
|
||||
@@ -340,7 +414,7 @@ describe('ol.render.canvas.Builder', function() {
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('always appends the first polygon segment (even when outside)', function() {
|
||||
it('always appends the first polygon segment (even when outside)', 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];
|
||||
@@ -348,110 +422,101 @@ describe('ol.render.canvas.Builder', function() {
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('skips first polygon segment upon request (also when outside)', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([10, 200, -10, 200]);
|
||||
});
|
||||
|
||||
it('eliminates segments outside (and not changing rel)', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([0, 0, 0, 200]);
|
||||
});
|
||||
|
||||
it('eliminates polygon segments outside (and not changing rel)', function() {
|
||||
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);
|
||||
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() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([0, 10, 0, 200, 10, 200, 0, 0]);
|
||||
});
|
||||
|
||||
it('eliminates segments outside (and not changing rel)', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([0, 0, 0, 200]);
|
||||
});
|
||||
|
||||
it('includes polygon segments outside (and not changing rel) when on last segment', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('includes polygon segments outside (skipping first and not changing rel) when on last segment', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([0, 200, 10, 200, 0, 0]);
|
||||
});
|
||||
|
||||
it('includes outside segments that change relationship', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([0, 0, 0, 200, 200, 200]);
|
||||
});
|
||||
|
||||
it('includes outside polygon segments that change relationship when on last segment', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql(flat);
|
||||
});
|
||||
|
||||
it('includes outside polygon segments that change relationship when on last segment (when skipping first)', function() {
|
||||
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);
|
||||
expect(replay.coordinates).to.eql([0, 200, 200, 200, 250, 200, 0, 0]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.render.canvas.LineStringBuilder', function() {
|
||||
|
||||
describe('#getBufferedMaxExtent()', function() {
|
||||
|
||||
it('buffers the max extent to accommodate stroke width', function() {
|
||||
describe('ol.render.canvas.LineStringBuilder', function () {
|
||||
describe('#getBufferedMaxExtent()', function () {
|
||||
it('buffers the max extent to accommodate stroke width', function () {
|
||||
const tolerance = 1;
|
||||
const extent = [-180, -90, 180, 90];
|
||||
const resolution = 10;
|
||||
const replay = new CanvasLineStringBuilder(tolerance, extent,
|
||||
resolution);
|
||||
const replay = new CanvasLineStringBuilder(tolerance, extent, resolution);
|
||||
const stroke = new Stroke({
|
||||
width: 2
|
||||
width: 2,
|
||||
});
|
||||
replay.setFillStrokeStyle(null, stroke);
|
||||
const buffered = replay.getBufferedMaxExtent();
|
||||
expect(buffered).to.eql([-195, -105, 195, 105]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.render.canvas.PolygonBuilder', function() {
|
||||
|
||||
describe('ol.render.canvas.PolygonBuilder', function () {
|
||||
let replay;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
const tolerance = 1;
|
||||
const extent = [-180, -90, 180, 90];
|
||||
const resolution = 10;
|
||||
replay = new CanvasPolygonBuilder(tolerance, extent,
|
||||
resolution);
|
||||
replay = new CanvasPolygonBuilder(tolerance, extent, resolution);
|
||||
});
|
||||
|
||||
describe('#drawFlatCoordinatess_()', function() {
|
||||
it('returns correct offset', function() {
|
||||
describe('#drawFlatCoordinatess_()', function () {
|
||||
it('returns correct offset', function () {
|
||||
const coords = [1, 2, 3, 4, 5, 6, 1, 2, 1, 2, 3, 4, 5, 6, 1, 2];
|
||||
const ends = [7, 14];
|
||||
const stroke = new Stroke({
|
||||
width: 5
|
||||
width: 5,
|
||||
});
|
||||
replay.setFillStrokeStyle(null, stroke);
|
||||
let offset = replay.drawFlatCoordinatess_(coords, 0, ends, 2);
|
||||
@@ -462,17 +527,14 @@ describe('ol.render.canvas.PolygonBuilder', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getBufferedMaxExtent()', function() {
|
||||
|
||||
it('buffers the max extent to accommodate stroke width', function() {
|
||||
describe('#getBufferedMaxExtent()', function () {
|
||||
it('buffers the max extent to accommodate stroke width', function () {
|
||||
const stroke = new Stroke({
|
||||
width: 5
|
||||
width: 5,
|
||||
});
|
||||
replay.setFillStrokeStyle(null, stroke);
|
||||
const buffered = replay.getBufferedMaxExtent();
|
||||
expect(buffered).to.eql([-210, -120, 210, 120]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user