Skip to content

Commit

Permalink
remove tileUnitDistanceFromAnchor leftover
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Nov 7, 2022
1 parent fb33b04 commit 9a26470
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
7 changes: 3 additions & 4 deletions src/data/array_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,9 @@ register(GlyphOffsetArray, 'GlyphOffsetArray');
/**
* @private
*/
export class SymbolLineVertexArray extends StructArrayLayout3i6 {
getx(index: number): number { return this.int16[index * 3 + 0]; }
gety(index: number): number { return this.int16[index * 3 + 1]; }
gettileUnitDistanceFromAnchor(index: number): number { return this.int16[index * 3 + 2]; }
export class SymbolLineVertexArray extends StructArrayLayout2i4 {
getx(index: number): number { return this.int16[index * 2 + 0]; }
gety(index: number): number { return this.int16[index * 2 + 1]; }
}

register(SymbolLineVertexArray, 'SymbolLineVertexArray');
Expand Down
3 changes: 1 addition & 2 deletions src/data/bucket/symbol_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,5 @@ export const glyphOffset: StructArrayLayout = createLayout([

export const lineVertex: StructArrayLayout = createLayout([
{type: 'Int16', name: 'x'},
{type: 'Int16', name: 'y'},
{type: 'Int16', name: 'tileUnitDistanceFromAnchor'}
{type: 'Int16', name: 'y'}
]);
25 changes: 4 additions & 21 deletions src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,28 +666,11 @@ class SymbolBucket implements Bucket {
}
}

addToLineVertexArray(anchor: Anchor, line: any): LineVertexRange {
addToLineVertexArray(anchor: Anchor, line: Array<Point>): LineVertexRange {
const lineStartIndex = this.lineVertexArray.length;
const segment = anchor.segment;
if (segment !== undefined) {
let sumForwardLength = anchor.dist(line[segment + 1]);
let sumBackwardLength = anchor.dist(line[segment]);
const vertices = {};
for (let i = segment + 1; i < line.length; i++) {
vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength};
if (i < line.length - 1) {
sumForwardLength += line[i + 1].dist(line[i]);
}
}
for (let i = segment || 0; i >= 0; i--) {
vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength};
if (i > 0) {
sumBackwardLength += line[i - 1].dist(line[i]);
}
}
for (let i = 0; i < line.length; i++) {
const vertex = vertices[i];
this.lineVertexArray.emplaceBack(vertex.x, vertex.y, vertex.tileUnitDistanceFromAnchor);
if (anchor.segment !== undefined) {
for (const {x, y} of line) {
this.lineVertexArray.emplaceBack(x, y);
}
}
return {
Expand Down

0 comments on commit 9a26470

Please sign in to comment.