Skip to content

Commit 4305e63

Browse files
Revert conservative glyph placement
1 parent de75c11 commit 4305e63

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/symbol/collision_index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ class CollisionIndex {
112112
const lineOffsetX = symbol.lineOffsetX * labelPlaneFontScale;
113113
const lineOffsetY = symbol.lineOffsetY * labelPlaneFontScale;
114114

115-
// Use conservative placement to cover both flipped and non-flipped cases as the final usage is not known yet
116-
const conservativePlacement = true;
117-
118115
const firstAndLastGlyph = projection.placeFirstAndLastGlyph(
119116
labelPlaneFontScale,
120117
glyphOffsetArray,
@@ -126,8 +123,7 @@ class CollisionIndex {
126123
symbol,
127124
lineVertexArray,
128125
labelPlaneMatrix,
129-
projectionCache,
130-
conservativePlacement);
126+
projectionCache);
131127

132128
let collisionDetected = false;
133129
let inGrid = false;

src/symbol/projection.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,13 @@ function updateLineLabels(bucket: SymbolBucket,
207207
}
208208
}
209209

210-
function placeFirstAndLastGlyph(fontScale: number, glyphOffsetArray: GlyphOffsetArray, lineOffsetX: number, lineOffsetY: number, flip: boolean, anchorPoint: Point, tileAnchorPoint: Point, symbol: any, lineVertexArray: SymbolLineVertexArray, labelPlaneMatrix: mat4, projectionCache: any, conservativePlacement: boolean) {
210+
function placeFirstAndLastGlyph(fontScale: number, glyphOffsetArray: GlyphOffsetArray, lineOffsetX: number, lineOffsetY: number, flip: boolean, anchorPoint: Point, tileAnchorPoint: Point, symbol: any, lineVertexArray: SymbolLineVertexArray, labelPlaneMatrix: mat4, projectionCache: any) {
211211
const glyphEndIndex = symbol.glyphStartIndex + symbol.numGlyphs;
212212
const lineStartIndex = symbol.lineStartIndex;
213213
const lineEndIndex = symbol.lineStartIndex + symbol.lineLength;
214214

215-
let firstGlyphOffset = glyphOffsetArray.getoffsetX(symbol.glyphStartIndex);
216-
let lastGlyphOffset = glyphOffsetArray.getoffsetX(glyphEndIndex - 1);
217-
218-
if (conservativePlacement) {
219-
const maxOffset = Math.max(Math.abs(firstGlyphOffset), Math.abs(lastGlyphOffset));
220-
firstGlyphOffset = -maxOffset;
221-
lastGlyphOffset = maxOffset;
222-
}
215+
const firstGlyphOffset = glyphOffsetArray.getoffsetX(symbol.glyphStartIndex);
216+
const lastGlyphOffset = glyphOffsetArray.getoffsetX(glyphEndIndex - 1);
223217

224218
const firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment,
225219
lineStartIndex, lineEndIndex, lineVertexArray, labelPlaneMatrix, projectionCache);
@@ -268,7 +262,7 @@ function placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, la
268262

269263
// Place the first and the last glyph in the label first, so we can figure out
270264
// the overall orientation of the label and determine whether it needs to be flipped in keepUpright mode
271-
const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, false);
265+
const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache);
272266
if (!firstAndLastGlyph) {
273267
return {notEnoughRoom: true};
274268
}

0 commit comments

Comments
 (0)