Skip to content
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

Add distance expression support #642

Merged
merged 10 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ dist
.DS_Store
*/**/*.g.ts
.cache
docs/*
coverage/
site/
docs/*
!docs/assets/extra.css
!docs/assets/logo.svg
!docs/README.md
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## main

### ✨ Features and improvements

- Support `distance` expression in web style spec - [#642](https://github.com/maplibre/maplibre-style-spec/pull/642)
- _...Add new stuff here..._

### 🐞 Bug fixes
Expand Down
1 change: 1 addition & 0 deletions build/generate-style-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export type ExpressionSpecification =
...(ExpressionInputType | ExpressionInputType[] | ExpressionSpecification)[], // repeated as above
ExpressionInputType | ExpressionSpecification]
| ['within', unknown | ExpressionSpecification]
| ['distance', unknown | ExpressionSpecification]
// Ramps, scales, curves
| ['interpolate', InterpolationSpecification, number | ExpressionSpecification,
...(number | number[] | ColorSpecification | ExpressionSpecification)[]] // alternating number and number | number[] | ColorSpecification
Expand Down
14 changes: 13 additions & 1 deletion package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@
"@mapbox/unitbezier": "^0.0.1",
"json-stringify-pretty-compact": "^4.0.0",
"minimist": "^1.2.8",
"quickselect": "^2.0.0",
"rw": "^1.3.3",
"sort-object": "^3.0.3"
"sort-object": "^3.0.3",
"tinyqueue": "^2.0.3"
},
"sideEffects": false,
"devDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion src/expression/compound_expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import Literal from './definitions/literal';
import Assertion from './definitions/assertion';
import Coercion from './definitions/coercion';
import Var from './definitions/var';
import Distance from './definitions/distance';

import type {Expression, ExpressionRegistry} from './expression';
import type {Value} from './values';

import type {Type} from './types';

import {typeOf, Color, validateRGBA, toString as valueToString} from './values';
Expand Down Expand Up @@ -664,6 +664,8 @@ function isExpressionConstant(expression: Expression) {
return false;
} else if (expression instanceof Within) {
return false;
} else if (expression instanceof Distance) {
return false;
}

const isTypeAnnotation = expression instanceof Coercion ||
Expand Down Expand Up @@ -715,6 +717,9 @@ function isFeatureConstant(e: Expression) {
if (e instanceof Within) {
return false;
}
if (e instanceof Distance) {
return false;
}

let result = true;
e.eachChild(arg => {
Expand Down
Loading