Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
MINOR: Do not filter styles by minZoomLevel in StyleSetEvaluator.
Browse files Browse the repository at this point in the history
The zoom level passed to StyleSetEvaluator through the environment is not
accurate for mixed LOD, the actual zoom level might be higher.
Partially fixes MAPSJS-2831.
  • Loading branch information
atomicsulfate committed Feb 5, 2021
1 parent 716a3bc commit ffdb21c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 4 additions & 4 deletions @here/harp-datasource-protocol/lib/StyleSetEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,8 @@ export class StyleSetEvaluator {
if (style.minZoomLevel !== undefined) {
let minZoomLevel: Value = style.minZoomLevel;

if (style._minZoomLevelExpr) {
// the constraint is defined as expression, evaluate it and
// use its value
if (style._minZoomLevelExpr?.isDynamic() === false) {
// Only filter by zoom level if the expression is not dynamic.
try {
minZoomLevel = style._minZoomLevelExpr.evaluate(
env,
Expand All @@ -677,7 +676,8 @@ export class StyleSetEvaluator {
if (style.maxZoomLevel !== undefined) {
let maxZoomLevel: Value = style.maxZoomLevel;

if (style._maxZoomLevelExpr) {
if (style._maxZoomLevelExpr?.isDynamic() === false) {
// Only filter by zoom level if the expression is not dynamic.
try {
maxZoomLevel = style._maxZoomLevelExpr.evaluate(
env,
Expand Down
21 changes: 21 additions & 0 deletions @here/harp-datasource-protocol/test/StyleSetEvaluatorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,27 @@ describe("StyleSetEvaluator", function () {
}
])
);

// Techniques are not filtered if min/maxZoomLevel are dynamic expressions.
assert.isNotEmpty(
getMatchingTechniques({ ...defaultProperties, $zoom: 14, minLevel: 15 }, [
{
when: ["==", ["geometry-type"], "Polygon"],
technique: "extruded-polygon",
minZoomLevel: ["get", "minLevel", ["dynamic-properties"]]
}
])
);

assert.isNotEmpty(
getMatchingTechniques({ ...defaultProperties, $zoom: 15, maxLevel: 14 }, [
{
when: ["==", ["geometry-type"], "Polygon"],
technique: "extruded-polygon",
maxZoomLevel: ["case", true, ["get", "maxLevel"], ["zoom"]]
}
])
);
});

it("serialization of vector properties", () => {
Expand Down

0 comments on commit ffdb21c

Please sign in to comment.