-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lazy load of RTL text plugin on GeoJSON sources #9091
Changes from all commits
b6f1145
ab22588
bddc36b
e01d087
315742d
1a1ff6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import {test} from '../../util/test'; | ||
import {createSymbolBucket} from '../../util/create_symbol_layer'; | ||
import Tile from '../../../src/source/tile'; | ||
import GeoJSONWrapper from '../../../src/source/geojson_wrapper'; | ||
import {OverscaledTileID} from '../../../src/source/tile_id'; | ||
|
@@ -263,6 +264,29 @@ test('expiring tiles', (t) => { | |
t.end(); | ||
}); | ||
|
||
test('rtl text detection', (t) => { | ||
t.test('Tile#hasRTLText is true when a tile loads a symbol bucket with rtl text', (t) => { | ||
const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1)); | ||
// Create a stub symbol bucket | ||
const symbolBucket = createSymbolBucket('test', 'Test', 'test', new CollisionBoxArray()); | ||
// symbolBucket has not been populated yet so we force override the value in the stub | ||
symbolBucket.hasRTLText = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have to manually set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, its because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a couple typos in the comment |
||
tile.loadVectorData( | ||
createVectorData({rawTileData: createRawTileData(), buckets: [symbolBucket]}), | ||
createPainter({ | ||
getLayer() { | ||
return symbolBucket.layers[0]; | ||
} | ||
}) | ||
); | ||
|
||
t.ok(tile.hasRTLText); | ||
t.end(); | ||
}); | ||
|
||
t.end(); | ||
}); | ||
|
||
function createRawTileData() { | ||
return fs.readFileSync(path.join(__dirname, '/../../fixtures/mbsv5-6-18-23.vector.pbf')); | ||
} | ||
|
@@ -276,6 +300,6 @@ function createVectorData(options) { | |
}, options); | ||
} | ||
|
||
function createPainter() { | ||
return {style: {}}; | ||
function createPainter(styleStub = {}) { | ||
return {style: styleStub}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import SymbolBucket from '../../src/data/bucket/symbol_bucket'; | ||
import SymbolStyleLayer from '../../src/style/style_layer/symbol_style_layer'; | ||
import featureFilter from '../../src/style-spec/feature_filter'; | ||
|
||
export function createSymbolBucket(layerId, font, text, collisionBoxArray) { | ||
const layer = new SymbolStyleLayer({ | ||
id: layerId, | ||
type: 'symbol', | ||
layout: {'text-font': [font], 'text-field': text}, | ||
filter: featureFilter() | ||
}); | ||
layer.recalculate({zoom: 0, zoomHistory: {}}); | ||
|
||
return new SymbolBucket({ | ||
overscaling: 1, | ||
zoom: 0, | ||
collisionBoxArray, | ||
layers: [layer] | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also test
t.ok(!rtlBucket.isEmpty());
? It seems like that's more of what we want to know, sincehasRTLText
is used to determine if the bucket is empty or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a separate test in 315742d