Skip to content

Commit

Permalink
add warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Aug 14, 2018
1 parent 2284ac9 commit 93a40f9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/symbol/symbol_layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ function addFeature(bucket: SymbolBucket,
}
}

const MAX_PACKED_SIZE = 65535;

function addTextVertices(bucket: SymbolBucket,
anchor: Point,
shapedText: Shaping,
Expand All @@ -292,11 +294,17 @@ function addTextVertices(bucket: SymbolBucket,
textSizeData = [
SIZE_PACK_FACTOR * layer.layout.get('text-size').evaluate(feature, {})
];
if (textSizeData[0] > MAX_PACKED_SIZE) {
warnOnce(`${bucket.layerIds[0]}: Value for "text-size" is >= 256. Reduce your "text-size".`);
}
} else if (sizeData.functionType === 'composite') {
textSizeData = [
SIZE_PACK_FACTOR * sizes.compositeTextSizes[0].evaluate(feature, {}),
SIZE_PACK_FACTOR * sizes.compositeTextSizes[1].evaluate(feature, {})
];
if (textSizeData[0] > MAX_PACKED_SIZE || textSizeData[1] > MAX_PACKED_SIZE) {
warnOnce(`${bucket.layerIds[0]}: Value for "text-size" is >= 256. Reduce your "text-size".`);
}
}

bucket.addSymbols(
Expand Down Expand Up @@ -385,11 +393,17 @@ function addSymbol(bucket: SymbolBucket,
iconSizeData = [
SIZE_PACK_FACTOR * layer.layout.get('icon-size').evaluate(feature, {})
];
if (iconSizeData[0] > MAX_PACKED_SIZE) {
warnOnce(`${bucket.layerIds[0]}: Value for "icon-size" is >= 256. Reduce your "icon-size".`);
}
} else if (sizeData.functionType === 'composite') {
iconSizeData = [
SIZE_PACK_FACTOR * sizes.compositeIconSizes[0].evaluate(feature, {}),
SIZE_PACK_FACTOR * sizes.compositeIconSizes[1].evaluate(feature, {})
];
if (iconSizeData[0] > MAX_PACKED_SIZE || iconSizeData[1] > MAX_PACKED_SIZE) {
warnOnce(`${bucket.layerIds[0]}: Value for "icon-size" is >= 256. Reduce your "icon-size".`);
}
}

bucket.addSymbols(
Expand Down

0 comments on commit 93a40f9

Please sign in to comment.