Skip to content

Commit

Permalink
Website updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Oct 25, 2023
1 parent 4f8fef1 commit 6d67aad
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/en/main/examples/common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/en/main/examples/common.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/en/main/examples/offscreen-canvas.worker.worker.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/en/main/ol/dist/ol.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/en/main/ol/dist/ol.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions dist/en/main/ol/expr/cpu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @property {Object} properties The values for properties used in 'get' expressions.
* @property {Object} variables The values for variables used in 'var' expressions.
* @property {number} resolution The map resolution.
* @property {string|number|null} featureId The feature id.
*/
/**
* @return {EvaluationContext} A new evaluation context.
Expand Down Expand Up @@ -59,6 +60,10 @@ export type EvaluationContext = {
* The map resolution.
*/
resolution: number;
/**
* The feature id.
*/
featureId: string | number | null;
};
export type ExpressionEvaluator = (arg0: EvaluationContext) => import("./expression.js").LiteralValue;
export type BooleanEvaluator = (arg0: EvaluationContext) => boolean;
Expand Down
2 changes: 1 addition & 1 deletion dist/en/main/ol/expr/cpu.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions dist/en/main/ol/expr/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {lchaToRgba, normalize, rgbaToLcha, withAlpha} from '../color.js';
* @property {Object} properties The values for properties used in 'get' expressions.
* @property {Object} variables The values for variables used in 'var' expressions.
* @property {number} resolution The map resolution.
* @property {string|number|null} featureId The feature id.
*/

/**
Expand All @@ -34,6 +35,7 @@ export function newEvaluationContext() {
variables: {},
properties: {},
resolution: NaN,
featureId: null,
};
}

Expand Down Expand Up @@ -108,6 +110,9 @@ function compileExpression(expression, context) {
case Ops.Var: {
return compileAccessorExpression(expression, context);
}
case Ops.Id: {
return (expression) => expression.featureId;
}
case Ops.Concat: {
const args = expression.args.map((e) => compileExpression(e, context));
return (context) =>
Expand Down
5 changes: 5 additions & 0 deletions dist/en/main/ol/expr/expression.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function isType(type: number, expected: number): boolean;
* @typedef {Object} ParsingContext
* @property {Set<string>} variables Variables referenced with the 'var' operator.
* @property {Set<string>} properties Properties referenced with the 'get' operator.
* @property {boolean} featureId The style uses the feature id.
* @property {import("../style/literal").LiteralStyle} style The style being parsed
*/
/**
Expand Down Expand Up @@ -91,6 +92,10 @@ export type ParsingContext = {
* Properties referenced with the 'get' operator.
*/
properties: Set<string>;
/**
* The style uses the feature id.
*/
featureId: boolean;
/**
* The style being parsed
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/en/main/ol/expr/expression.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions dist/en/main/ol/expr/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class CallExpression {
* @typedef {Object} ParsingContext
* @property {Set<string>} variables Variables referenced with the 'var' operator.
* @property {Set<string>} properties Properties referenced with the 'get' operator.
* @property {boolean} featureId The style uses the feature id.
* @property {import("../style/literal").LiteralStyle} style The style being parsed
*/

Expand All @@ -124,6 +125,7 @@ export function newParsingContext() {
return {
variables: new Set(),
properties: new Set(),
featureId: false,
style: {},
};
}
Expand Down Expand Up @@ -228,6 +230,7 @@ export const Ops = {
String: 'string',
Array: 'array',
Color: 'color',
Id: 'id',
};

/**
Expand All @@ -241,6 +244,7 @@ export const Ops = {
const parsers = {
[Ops.Get]: createParser(AnyType, withArgsCount(1, 1), withGetArgs),
[Ops.Var]: createParser(AnyType, withArgsCount(1, 1), withVarArgs),
[Ops.Id]: createParser(NumberType | StringType, withNoArgs, usesFeatureId),
[Ops.Concat]: createParser(
StringType,
withArgsCount(2, Infinity),
Expand Down Expand Up @@ -487,6 +491,13 @@ function withVarArgs(encoded, context) {
return [arg];
}

/**
* @type ArgValidator
*/
function usesFeatureId(encoded, context) {
context.featureId = true;
}

/**
* @type ArgValidator
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/en/main/ol/render/canvas/style.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions dist/en/main/ol/render/canvas/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export function rulesToStyleFunction(rules) {
return function (feature, resolution) {
evaluationContext.properties = feature.getPropertiesInternal();
evaluationContext.resolution = resolution;
if (parsingContext.featureId) {
const id = feature.getId();
if (id !== undefined) {
evaluationContext.featureId = id;
} else {
evaluationContext.featureId = null;
}
}
return evaluator(evaluationContext);
};
}
Expand Down Expand Up @@ -109,6 +117,14 @@ export function flatStylesToStyleFunction(flatStyles) {
return function (feature, resolution) {
evaluationContext.properties = feature.getPropertiesInternal();
evaluationContext.resolution = resolution;
if (parsingContext.featureId) {
const id = feature.getId();
if (id !== undefined) {
evaluationContext.featureId = id;
} else {
evaluationContext.featureId = null;
}
}
let nonNullCount = 0;
for (let i = 0; i < length; ++i) {
const style = evaluators[i](evaluationContext);
Expand Down

0 comments on commit 6d67aad

Please sign in to comment.