Rename method used for lines.

This commit is contained in:
Maximilian Krög
2020-09-11 23:53:59 +02:00
parent 6b0471c2dc
commit fb62e7928e
6 changed files with 31 additions and 31 deletions
+3 -3
View File
@@ -149,7 +149,7 @@ class CanvasBuilder extends VectorContext {
* @protected * @protected
* @return {number} My end. * @return {number} My end.
*/ */
appendFlatCoordinates( appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
offset, offset,
end, end,
@@ -211,7 +211,7 @@ class CanvasBuilder extends VectorContext {
drawCustomCoordinates_(flatCoordinates, offset, ends, stride, builderEnds) { drawCustomCoordinates_(flatCoordinates, offset, ends, stride, builderEnds) {
for (let i = 0, ii = ends.length; i < ii; ++i) { for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i]; const end = ends[i];
const builderEnd = this.appendFlatCoordinates( const builderEnd = this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
offset, offset,
end, end,
@@ -290,7 +290,7 @@ class CanvasBuilder extends VectorContext {
type == GeometryType.MULTI_POINT type == GeometryType.MULTI_POINT
) { ) {
flatCoordinates = geometry.getFlatCoordinates(); flatCoordinates = geometry.getFlatCoordinates();
builderEnd = this.appendFlatCoordinates( builderEnd = this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
0, 0,
flatCoordinates.length, flatCoordinates.length,
+1 -1
View File
@@ -108,7 +108,7 @@ class CanvasImageBuilder extends CanvasBuilder {
* @return {number} My end. * @return {number} My end.
*/ */
drawCoordinates_(flatCoordinates, offset, end, stride) { drawCoordinates_(flatCoordinates, offset, end, stride) {
return this.appendFlatCoordinates( return this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
offset, offset,
end, end,
+1 -1
View File
@@ -28,7 +28,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
*/ */
drawFlatCoordinates_(flatCoordinates, offset, end, stride) { drawFlatCoordinates_(flatCoordinates, offset, end, stride) {
const myBegin = this.coordinates.length; const myBegin = this.coordinates.length;
const myEnd = this.appendFlatCoordinates( const myEnd = this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
offset, offset,
end, end,
+3 -3
View File
@@ -40,7 +40,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
for (let i = 0; i < numEnds; ++i) { for (let i = 0; i < numEnds; ++i) {
const end = ends[i]; const end = ends[i];
const myBegin = this.coordinates.length; const myBegin = this.coordinates.length;
const myEnd = this.appendFlatCoordinates( const myEnd = this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
offset, offset,
end, end,
@@ -57,7 +57,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
this.hitDetectionInstructions.push(moveToLineToInstruction); this.hitDetectionInstructions.push(moveToLineToInstruction);
if (stroke) { if (stroke) {
// Performance optimization: only call closePath() when we have a stroke. // Performance optimization: only call closePath() when we have a stroke.
// Otherwise the ring is closed already (see appendFlatCoordinates above). // Otherwise the ring is closed already (see appendFlatLineCoordinates above).
this.instructions.push(closePathInstruction); this.instructions.push(closePathInstruction);
this.hitDetectionInstructions.push(closePathInstruction); this.hitDetectionInstructions.push(closePathInstruction);
} }
@@ -108,7 +108,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
const flatCoordinates = circleGeometry.getFlatCoordinates(); const flatCoordinates = circleGeometry.getFlatCoordinates();
const stride = circleGeometry.getStride(); const stride = circleGeometry.getStride();
const myBegin = this.coordinates.length; const myBegin = this.coordinates.length;
this.appendFlatCoordinates( this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
0, 0,
flatCoordinates.length, flatCoordinates.length,
+1 -1
View File
@@ -276,7 +276,7 @@ class CanvasTextBuilder extends CanvasBuilder {
break; break;
default: default:
} }
end = this.appendFlatCoordinates( end = this.appendFlatLineCoordinates(
flatCoordinates, flatCoordinates,
0, 0,
end, end,
+22 -22
View File
@@ -331,7 +331,7 @@ describe('ol.render.canvas.Builder', function () {
}); });
}); });
describe('#appendFlatCoordinates()', function () { describe('#appendFlatLineCoordinates()', function () {
let replay; let replay;
beforeEach(function () { beforeEach(function () {
replay = new CanvasBuilder(1, [-180, -90, 180, 90], 1, 1, true); 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 () { it('appends coordinates that are within the max extent', function () {
const flat = [-110, 45, 110, 45, 110, -45, -110, -45]; 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); 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]; 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); 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]; 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([ expect(replay.coordinates).to.eql([
110, 110,
45, 45,
@@ -366,7 +366,7 @@ describe('ol.render.canvas.Builder', function () {
it('works with a single coordinate (inside)', function () { it('works with a single coordinate (inside)', function () {
const flat = [-110, 45]; 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); 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 // this could be changed, but to make the code simpler for properly
// closing rings, we always add the first point // closing rings, we always add the first point
const flat = [-110, 145]; 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); 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 // this could be changed, but to make the code simpler for properly
// closing rings, we always add the first point // closing rings, we always add the first point
const flat = [-110, 145, -110, 145]; 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); 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]; 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]); 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 // this means we get a few extra points when coordinates are not
// part of a linestring or ring, but only a few extra // part of a linestring or ring, but only a few extra
const flat = [0, 200, 0, -200]; 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); 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]; 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); 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 // this could be changed, but to make the code simpler for properly
// closing rings, we always add the first segment // closing rings, we always add the first segment
const flat = [-10, 200, 10, 200]; 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); 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 // this could be changed, but to make the code simpler for properly
// closing rings, we always add the first segment // closing rings, we always add the first segment
const flat = [-10, 200, 10, 200, -10, 200]; 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); 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]; 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]); 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]; 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]); 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]; 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]); 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]; 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]); 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]; 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]); 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]; 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); 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]; 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]); 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]; 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]); 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]; 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); 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]; 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]); expect(replay.coordinates).to.eql([0, 200, 200, 200, 250, 200, 0, 0]);
}); });
}); });