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

issues 901 changes #616

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 examples/filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Style } from '../index';
import { LikeAttributes, Style } from '../index';

const pointSimplePoint: Style = {
name: 'Simple Point Filter',
Expand All @@ -9,6 +9,7 @@ const pointSimplePoint: Style = {
['==', 'TEST', null],
['*=', 'TEST2', '*York*'],
['*=', 'TEST1', '*New*'],
['*=', 'TEST1', '%New%', { wildCard: '%', singleChar: '_', escape: '\\' } as LikeAttributes],
['!', ['>', 'POPULATION', '100000']],
['||',
['==', 'TEST2', '1'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "geostyler-style",
"version": "8.1.0",
"version": "8.2.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done by the pipelines. You don't have to care about it. So please revert to 8.1.0. :)

"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
30 changes: 23 additions & 7 deletions style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {
GeoStylerStringFunction
} from './functions';

export interface LikeAttributes {
wildCard: string;
singleChar: string;
escape: string;
}
Comment on lines +8 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an array like structure would fit the geostyler-style more. e.g.:

Suggested change
export interface LikeAttributes {
wildCard: string;
singleChar: string;
escape: string;
}
/**
* The LikeAttributes describe the behaviour of the {@link LikeFilter}.
* [
* wildcard, (default should be `*`),
* singleChar, (default should be `.`),
* escape, (default should be `!`),
* ]
*/
export interface LikeAttributes [string, string, string];

... this was just written freestyle on github so its just for orientation. :)


/**
* The special character to use to indicate a line break.
*/
Expand All @@ -31,8 +37,8 @@ export interface ScaleDenominator {
*/
export interface FunctionCall<T> {
name: T extends string ? GeoStylerStringFunction['name'] :
T extends number ? GeoStylerNumberFunction['name'] :
GeoStylerBooleanFunction['name'];
T extends number ? GeoStylerNumberFunction['name'] :
GeoStylerBooleanFunction['name'];
args: Expression<PropertyType>[];
};

Expand Down Expand Up @@ -85,6 +91,16 @@ export type RangeFilter = [
Expression<number>
];

/**
* A Filter with like attributes.
*/
export type LikeFilter = [
'*=',
Expression<string>,
Expression<string>,
Expression<LikeAttributes>
];

/**
* A ComparisonFilter compares two values.
* If the first argument is a GeoStylerFunction it will be evaluated it.
Expand All @@ -94,7 +110,7 @@ export type ComparisonFilter = [
ComparisonOperator,
Expression<string | number | boolean | null>,
Expression<string | number | boolean | null>
] | RangeFilter;
] | RangeFilter | LikeFilter;

/**
* A CombinationFilter combines N Filters with a logical OR / AND operator.
Expand Down Expand Up @@ -177,10 +193,10 @@ export type FontSpec = `ttf://${string}#0x${string}`;
*
*/
export type WellKnownName = 'circle' | 'square' | 'triangle' | 'star' | 'cross' | 'x'
| 'shape://vertline' | 'shape://horline' | 'shape://slash'
| 'shape://backslash' | 'shape://dot' | 'shape://plus'
| 'shape://times' | 'shape://oarrow' | 'shape://carrow'
| FontSpec;
| 'shape://vertline' | 'shape://horline' | 'shape://slash'
| 'shape://backslash' | 'shape://dot' | 'shape://plus'
| 'shape://times' | 'shape://oarrow' | 'shape://carrow'
| FontSpec;

/**
* Unit that defines how to handle the corresponding symbolizer property.
Expand Down