@emuanalytics/flow-rdf-core 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +207 -4
- package/dist/index.d.ts +207 -4
- package/dist/index.mjs +3 -0
- package/dist/lib/map/flow-core-map.mjs +90 -8
- package/dist/lib/map/plugins/index.d.mts +252 -223
- package/dist/lib/map/plugins/index.d.ts +252 -223
- package/dist/lib/map/plugins/selection/selection.plugin.mjs +73 -7
- package/dist/lib/map/plugins/selection/source-selection.mjs +12 -0
- package/dist/lib/map-style/composite/builder.mjs +31 -0
- package/dist/lib/map-style/composite/editing.mjs +123 -0
- package/dist/lib/map-style/composite/expand.mjs +182 -0
- package/dist/lib/map-style/composite/stored-format.mjs +18 -0
- package/dist/lib/map-style/composite/validate.mjs +376 -0
- package/dist/lib/map-style/map-data-source.mjs +9 -0
- package/dist/lib/map-style/map-layer.mjs +206 -17
- package/dist/lib/map-style/map-style.mjs +125 -11
- package/dist/package.json.mjs +1 -1
- package/dist/shared/{flow-rdf-core.c45eb675.d.mts → flow-rdf-core.62a36d8b.d.mts} +589 -188
- package/dist/shared/{flow-rdf-core.c45eb675.d.ts → flow-rdf-core.62a36d8b.d.ts} +589 -188
- package/package.json +1 -1
|
@@ -868,183 +868,6 @@ interface FlowStyleIssue {
|
|
|
868
868
|
severity: 'error' | 'warning';
|
|
869
869
|
}
|
|
870
870
|
|
|
871
|
-
/**
|
|
872
|
-
* A Flo.w RDF reactive expression - used internally to parse and evaluate {@link MapLayer}
|
|
873
|
-
* style [expressions](/flow-rdf/flow-rdf-core/expression-reference/). An expression can be evaluated
|
|
874
|
-
* and its MapLibre-compatible representation can be generated.
|
|
875
|
-
*
|
|
876
|
-
* @example
|
|
877
|
-
* ```js
|
|
878
|
-
* const ex = new ReactiveExpression('1 + 2');
|
|
879
|
-
* console.log(ex.value); // 3
|
|
880
|
-
* console.log(ex.maplibreExpression); // ['+', 1, 2]
|
|
881
|
-
* ```
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*/
|
|
885
|
-
declare class ReactiveExpression<TState extends StateStore = StateStore, R = any> {
|
|
886
|
-
private static parser;
|
|
887
|
-
private static customFunctions;
|
|
888
|
-
/**
|
|
889
|
-
* Returns `true` if the specified custom function has been registered.
|
|
890
|
-
*
|
|
891
|
-
* @param fn - The custom function name
|
|
892
|
-
*/
|
|
893
|
-
static hasCustomFunction(fn: string): boolean;
|
|
894
|
-
/**
|
|
895
|
-
* Register a custom function to be used in reactive expressions.
|
|
896
|
-
*
|
|
897
|
-
* @param fn - The custom function to register
|
|
898
|
-
*/
|
|
899
|
-
static registerCustomFunction(fn: FlowCoreExpressionCustomFunction): void;
|
|
900
|
-
private _expression;
|
|
901
|
-
private parsedResult;
|
|
902
|
-
private _store;
|
|
903
|
-
/**
|
|
904
|
-
* Parses a program string into a map of properties and their associated {@link ReactiveExpression}.
|
|
905
|
-
*
|
|
906
|
-
* The program string should be a series of property/expression pairs separated by semicolons as follows:
|
|
907
|
-
*
|
|
908
|
-
* ```js
|
|
909
|
-
* const program = `
|
|
910
|
-
* prop1: 1 + 2;
|
|
911
|
-
* prop2: 'a string';
|
|
912
|
-
* prop3: $stateProp * 3;
|
|
913
|
-
* `;
|
|
914
|
-
*
|
|
915
|
-
* const parsedProgram = ReactiveExpression.parseProgram(program);
|
|
916
|
-
* // {
|
|
917
|
-
* // prop1: ReactiveExpression,
|
|
918
|
-
* // prop2: ReactiveExpression,
|
|
919
|
-
* // prop3: ReactiveExpression
|
|
920
|
-
* // }
|
|
921
|
-
*
|
|
922
|
-
* ```
|
|
923
|
-
*
|
|
924
|
-
* @param program - The program to parse
|
|
925
|
-
* @returns A map of property names and their associated expressions.
|
|
926
|
-
*/
|
|
927
|
-
static parseProgram(program: string): {
|
|
928
|
-
[key: string]: ReactiveExpression;
|
|
929
|
-
};
|
|
930
|
-
/**
|
|
931
|
-
* Generates the MapLibre-compatible representation of this expression.
|
|
932
|
-
*
|
|
933
|
-
* This is used internally when creating MapLibre style specifications
|
|
934
|
-
* from Flo.w RDF {@link MapLayer} styles.
|
|
935
|
-
*
|
|
936
|
-
* This getter is a reactive `computed` and will re-evaluate within a
|
|
937
|
-
* reactive context when the expression value changes.
|
|
938
|
-
*
|
|
939
|
-
* @computed
|
|
940
|
-
*
|
|
941
|
-
* @returns The MapLibre-compatible representation of this expression
|
|
942
|
-
*/
|
|
943
|
-
get maplibreExpression(): ParserExpression | undefined;
|
|
944
|
-
/**
|
|
945
|
-
* Evaluates the expression and returns the result.
|
|
946
|
-
*
|
|
947
|
-
* This getter is a reactive `computed` and will re-evaluate within a
|
|
948
|
-
* reactive context when the expression value changes.
|
|
949
|
-
*
|
|
950
|
-
* @example
|
|
951
|
-
* ```js
|
|
952
|
-
* const ex = new ReactiveExpression('1 + 2');
|
|
953
|
-
* console.log(ex.value); // 3
|
|
954
|
-
* ```
|
|
955
|
-
*
|
|
956
|
-
* @computed
|
|
957
|
-
*
|
|
958
|
-
* @returns - The result of evaluating the expression
|
|
959
|
-
*/
|
|
960
|
-
get value(): R;
|
|
961
|
-
/**
|
|
962
|
-
* Returns details of parsing errors if the expression could not be parsed.
|
|
963
|
-
*/
|
|
964
|
-
get parseError(): FlowCoreExpressionError | null;
|
|
965
|
-
/**
|
|
966
|
-
* Returns the original expression string passed to the constructor.
|
|
967
|
-
*/
|
|
968
|
-
get expression(): string;
|
|
969
|
-
/**
|
|
970
|
-
* Returns the state store bound to the expression.
|
|
971
|
-
*/
|
|
972
|
-
get store(): TState | null;
|
|
973
|
-
/**
|
|
974
|
-
* Constructs a new `ReactiveExpression`.
|
|
975
|
-
*
|
|
976
|
-
* @example
|
|
977
|
-
* ```js
|
|
978
|
-
* const ex = new ReactiveExpression('1 + 2');
|
|
979
|
-
* console.log(ex.value); // 3
|
|
980
|
-
* ```
|
|
981
|
-
*
|
|
982
|
-
* @param expression - the string representation of the expression
|
|
983
|
-
* @param parsedExpression - Used internally to bypass parsing when evaluating a program.
|
|
984
|
-
*/
|
|
985
|
-
constructor(expression: string, parsedExpression?: ParserExpression);
|
|
986
|
-
/**
|
|
987
|
-
* Binds a {@link StateStore} to the expression. The state store is used to resolve
|
|
988
|
-
* state variables in the expression.
|
|
989
|
-
*
|
|
990
|
-
* Note: If no state store is bound, the expression will not be able to resolve
|
|
991
|
-
* state variables and will return `null` when evaluated. A console warning will
|
|
992
|
-
* be logged.
|
|
993
|
-
*
|
|
994
|
-
* @param store {@link StateStore} to bind to the expression
|
|
995
|
-
* @returns
|
|
996
|
-
*/
|
|
997
|
-
bindState(store: TState | null): this;
|
|
998
|
-
/**
|
|
999
|
-
* Returns a subscribable stream, which produces the value of the expression
|
|
1000
|
-
* whenever a reactive update causes the expression to re-evaluate.
|
|
1001
|
-
*
|
|
1002
|
-
* @example
|
|
1003
|
-
* ```js
|
|
1004
|
-
* const ex = new ReactiveExpression('$val * 2');
|
|
1005
|
-
* const subscription = ex.toStream().subscribe((value) => console.log(value));
|
|
1006
|
-
* ...
|
|
1007
|
-
* subscription.unsubscribe();
|
|
1008
|
-
* ```
|
|
1009
|
-
*
|
|
1010
|
-
* @param fireImmediately - If `true`, the stream will fire immediately with the current value.
|
|
1011
|
-
* If `false` the stream will only fire when the value changes.
|
|
1012
|
-
*
|
|
1013
|
-
* @returns A subscribable stream of the expression value
|
|
1014
|
-
*/
|
|
1015
|
-
toStream(fireImmediately?: boolean): IObservableStream<R>;
|
|
1016
|
-
private evaluateExpression;
|
|
1017
|
-
private expandCustomFunctions;
|
|
1018
|
-
private isParseError;
|
|
1019
|
-
private isFunctionExpression;
|
|
1020
|
-
private formatName;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
interface FlowCoreExpressionCustomFunction {
|
|
1024
|
-
name: string;
|
|
1025
|
-
initialize?: () => void;
|
|
1026
|
-
fn: FlowCoreExpressionCustomFunctionSignature;
|
|
1027
|
-
}
|
|
1028
|
-
type FlowCoreExpressionCustomFunctionSignature = <TState extends StateStore = any>(expr: ParserFunctionExpression, parentExpression: ReactiveExpression) => ParserExpression;
|
|
1029
|
-
interface FlowCoreExpressionCustomFunctions {
|
|
1030
|
-
[name: string]: FlowCoreExpressionCustomFunction;
|
|
1031
|
-
}
|
|
1032
|
-
type ParserExpression = number | string | boolean | null | ParserFunctionExpression;
|
|
1033
|
-
type ParserFunctionExpression = [string, ...any[]];
|
|
1034
|
-
interface ParserProgram {
|
|
1035
|
-
[key: string]: ParserExpressionWithIndex;
|
|
1036
|
-
}
|
|
1037
|
-
interface ParserExpressionWithIndex {
|
|
1038
|
-
expr: ParserExpression;
|
|
1039
|
-
start: ParserIndex;
|
|
1040
|
-
end: ParserIndex;
|
|
1041
|
-
}
|
|
1042
|
-
interface ParserIndex {
|
|
1043
|
-
offset: number;
|
|
1044
|
-
line: number;
|
|
1045
|
-
column: number;
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
871
|
/**
|
|
1049
872
|
* WARNING - this file is auto generated
|
|
1050
873
|
*/
|
|
@@ -2006,6 +1829,183 @@ declare function layerStyle(layerType: 'raster'): RasterLayerStyleBuilder;
|
|
|
2006
1829
|
declare function layerStyle(layerType: 'hillshade'): HillshadeLayerStyleBuilder;
|
|
2007
1830
|
declare function layerStyle(layerType: 'background'): BackgroundLayerStyleBuilder;
|
|
2008
1831
|
|
|
1832
|
+
/**
|
|
1833
|
+
* A Flo.w RDF reactive expression - used internally to parse and evaluate {@link MapLayer}
|
|
1834
|
+
* style [expressions](/flow-rdf/flow-rdf-core/expression-reference/). An expression can be evaluated
|
|
1835
|
+
* and its MapLibre-compatible representation can be generated.
|
|
1836
|
+
*
|
|
1837
|
+
* @example
|
|
1838
|
+
* ```js
|
|
1839
|
+
* const ex = new ReactiveExpression('1 + 2');
|
|
1840
|
+
* console.log(ex.value); // 3
|
|
1841
|
+
* console.log(ex.maplibreExpression); // ['+', 1, 2]
|
|
1842
|
+
* ```
|
|
1843
|
+
*
|
|
1844
|
+
*
|
|
1845
|
+
*/
|
|
1846
|
+
declare class ReactiveExpression<TState extends StateStore = StateStore, R = any> {
|
|
1847
|
+
private static parser;
|
|
1848
|
+
private static customFunctions;
|
|
1849
|
+
/**
|
|
1850
|
+
* Returns `true` if the specified custom function has been registered.
|
|
1851
|
+
*
|
|
1852
|
+
* @param fn - The custom function name
|
|
1853
|
+
*/
|
|
1854
|
+
static hasCustomFunction(fn: string): boolean;
|
|
1855
|
+
/**
|
|
1856
|
+
* Register a custom function to be used in reactive expressions.
|
|
1857
|
+
*
|
|
1858
|
+
* @param fn - The custom function to register
|
|
1859
|
+
*/
|
|
1860
|
+
static registerCustomFunction(fn: FlowCoreExpressionCustomFunction): void;
|
|
1861
|
+
private _expression;
|
|
1862
|
+
private parsedResult;
|
|
1863
|
+
private _store;
|
|
1864
|
+
/**
|
|
1865
|
+
* Parses a program string into a map of properties and their associated {@link ReactiveExpression}.
|
|
1866
|
+
*
|
|
1867
|
+
* The program string should be a series of property/expression pairs separated by semicolons as follows:
|
|
1868
|
+
*
|
|
1869
|
+
* ```js
|
|
1870
|
+
* const program = `
|
|
1871
|
+
* prop1: 1 + 2;
|
|
1872
|
+
* prop2: 'a string';
|
|
1873
|
+
* prop3: $stateProp * 3;
|
|
1874
|
+
* `;
|
|
1875
|
+
*
|
|
1876
|
+
* const parsedProgram = ReactiveExpression.parseProgram(program);
|
|
1877
|
+
* // {
|
|
1878
|
+
* // prop1: ReactiveExpression,
|
|
1879
|
+
* // prop2: ReactiveExpression,
|
|
1880
|
+
* // prop3: ReactiveExpression
|
|
1881
|
+
* // }
|
|
1882
|
+
*
|
|
1883
|
+
* ```
|
|
1884
|
+
*
|
|
1885
|
+
* @param program - The program to parse
|
|
1886
|
+
* @returns A map of property names and their associated expressions.
|
|
1887
|
+
*/
|
|
1888
|
+
static parseProgram(program: string): {
|
|
1889
|
+
[key: string]: ReactiveExpression;
|
|
1890
|
+
};
|
|
1891
|
+
/**
|
|
1892
|
+
* Generates the MapLibre-compatible representation of this expression.
|
|
1893
|
+
*
|
|
1894
|
+
* This is used internally when creating MapLibre style specifications
|
|
1895
|
+
* from Flo.w RDF {@link MapLayer} styles.
|
|
1896
|
+
*
|
|
1897
|
+
* This getter is a reactive `computed` and will re-evaluate within a
|
|
1898
|
+
* reactive context when the expression value changes.
|
|
1899
|
+
*
|
|
1900
|
+
* @computed
|
|
1901
|
+
*
|
|
1902
|
+
* @returns The MapLibre-compatible representation of this expression
|
|
1903
|
+
*/
|
|
1904
|
+
get maplibreExpression(): ParserExpression | undefined;
|
|
1905
|
+
/**
|
|
1906
|
+
* Evaluates the expression and returns the result.
|
|
1907
|
+
*
|
|
1908
|
+
* This getter is a reactive `computed` and will re-evaluate within a
|
|
1909
|
+
* reactive context when the expression value changes.
|
|
1910
|
+
*
|
|
1911
|
+
* @example
|
|
1912
|
+
* ```js
|
|
1913
|
+
* const ex = new ReactiveExpression('1 + 2');
|
|
1914
|
+
* console.log(ex.value); // 3
|
|
1915
|
+
* ```
|
|
1916
|
+
*
|
|
1917
|
+
* @computed
|
|
1918
|
+
*
|
|
1919
|
+
* @returns - The result of evaluating the expression
|
|
1920
|
+
*/
|
|
1921
|
+
get value(): R;
|
|
1922
|
+
/**
|
|
1923
|
+
* Returns details of parsing errors if the expression could not be parsed.
|
|
1924
|
+
*/
|
|
1925
|
+
get parseError(): FlowCoreExpressionError | null;
|
|
1926
|
+
/**
|
|
1927
|
+
* Returns the original expression string passed to the constructor.
|
|
1928
|
+
*/
|
|
1929
|
+
get expression(): string;
|
|
1930
|
+
/**
|
|
1931
|
+
* Returns the state store bound to the expression.
|
|
1932
|
+
*/
|
|
1933
|
+
get store(): TState | null;
|
|
1934
|
+
/**
|
|
1935
|
+
* Constructs a new `ReactiveExpression`.
|
|
1936
|
+
*
|
|
1937
|
+
* @example
|
|
1938
|
+
* ```js
|
|
1939
|
+
* const ex = new ReactiveExpression('1 + 2');
|
|
1940
|
+
* console.log(ex.value); // 3
|
|
1941
|
+
* ```
|
|
1942
|
+
*
|
|
1943
|
+
* @param expression - the string representation of the expression
|
|
1944
|
+
* @param parsedExpression - Used internally to bypass parsing when evaluating a program.
|
|
1945
|
+
*/
|
|
1946
|
+
constructor(expression: string, parsedExpression?: ParserExpression);
|
|
1947
|
+
/**
|
|
1948
|
+
* Binds a {@link StateStore} to the expression. The state store is used to resolve
|
|
1949
|
+
* state variables in the expression.
|
|
1950
|
+
*
|
|
1951
|
+
* Note: If no state store is bound, the expression will not be able to resolve
|
|
1952
|
+
* state variables and will return `null` when evaluated. A console warning will
|
|
1953
|
+
* be logged.
|
|
1954
|
+
*
|
|
1955
|
+
* @param store {@link StateStore} to bind to the expression
|
|
1956
|
+
* @returns
|
|
1957
|
+
*/
|
|
1958
|
+
bindState(store: TState | null): this;
|
|
1959
|
+
/**
|
|
1960
|
+
* Returns a subscribable stream, which produces the value of the expression
|
|
1961
|
+
* whenever a reactive update causes the expression to re-evaluate.
|
|
1962
|
+
*
|
|
1963
|
+
* @example
|
|
1964
|
+
* ```js
|
|
1965
|
+
* const ex = new ReactiveExpression('$val * 2');
|
|
1966
|
+
* const subscription = ex.toStream().subscribe((value) => console.log(value));
|
|
1967
|
+
* ...
|
|
1968
|
+
* subscription.unsubscribe();
|
|
1969
|
+
* ```
|
|
1970
|
+
*
|
|
1971
|
+
* @param fireImmediately - If `true`, the stream will fire immediately with the current value.
|
|
1972
|
+
* If `false` the stream will only fire when the value changes.
|
|
1973
|
+
*
|
|
1974
|
+
* @returns A subscribable stream of the expression value
|
|
1975
|
+
*/
|
|
1976
|
+
toStream(fireImmediately?: boolean): IObservableStream<R>;
|
|
1977
|
+
private evaluateExpression;
|
|
1978
|
+
private expandCustomFunctions;
|
|
1979
|
+
private isParseError;
|
|
1980
|
+
private isFunctionExpression;
|
|
1981
|
+
private formatName;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
interface FlowCoreExpressionCustomFunction {
|
|
1985
|
+
name: string;
|
|
1986
|
+
initialize?: () => void;
|
|
1987
|
+
fn: FlowCoreExpressionCustomFunctionSignature;
|
|
1988
|
+
}
|
|
1989
|
+
type FlowCoreExpressionCustomFunctionSignature = <TState extends StateStore = any>(expr: ParserFunctionExpression, parentExpression: ReactiveExpression) => ParserExpression;
|
|
1990
|
+
interface FlowCoreExpressionCustomFunctions {
|
|
1991
|
+
[name: string]: FlowCoreExpressionCustomFunction;
|
|
1992
|
+
}
|
|
1993
|
+
type ParserExpression = number | string | boolean | null | ParserFunctionExpression;
|
|
1994
|
+
type ParserFunctionExpression = [string, ...any[]];
|
|
1995
|
+
interface ParserProgram {
|
|
1996
|
+
[key: string]: ParserExpressionWithIndex;
|
|
1997
|
+
}
|
|
1998
|
+
interface ParserExpressionWithIndex {
|
|
1999
|
+
expr: ParserExpression;
|
|
2000
|
+
start: ParserIndex;
|
|
2001
|
+
end: ParserIndex;
|
|
2002
|
+
}
|
|
2003
|
+
interface ParserIndex {
|
|
2004
|
+
offset: number;
|
|
2005
|
+
line: number;
|
|
2006
|
+
column: number;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
2009
|
interface MapLayerOptions {
|
|
2010
2010
|
/** Layer ID. */
|
|
2011
2011
|
id: string;
|
|
@@ -2035,6 +2035,14 @@ interface MapLayerOptions {
|
|
|
2035
2035
|
above?: string;
|
|
2036
2036
|
below?: string;
|
|
2037
2037
|
filter?: string;
|
|
2038
|
+
/**
|
|
2039
|
+
* Shows or hides the layer: a reactive expression, such as `'$showAirports'`, or a boolean. It overrides the
|
|
2040
|
+
* `visibility` of the layer's style, and of every MapLibre layer of a flow layer. Change it with
|
|
2041
|
+
* {@link MapLayer.setVisibility}.
|
|
2042
|
+
*
|
|
2043
|
+
* @experimental
|
|
2044
|
+
*/
|
|
2045
|
+
visibility?: string | boolean;
|
|
2038
2046
|
/**
|
|
2039
2047
|
* Layer style. For a MapLibre layer type, a style program, such as one built with {@link layerStyle}. For a `flow`
|
|
2040
2048
|
* layer, a version 2 {@link FlowStyle}, such as one built with {@link flowLayerStyle}.
|
|
@@ -2051,6 +2059,81 @@ interface MapLayerOptions {
|
|
|
2051
2059
|
*/
|
|
2052
2060
|
metadata?: Record<string, unknown>;
|
|
2053
2061
|
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Options of a composite layer: a {@link MapLayer} with `type: 'composite'`, which renders a
|
|
2064
|
+
* {@link CompositeLayerSpecification}, several sub-layers and the data sources they draw, as one layer. Add one with
|
|
2065
|
+
* `map.addLayer()`, as any other layer.
|
|
2066
|
+
*
|
|
2067
|
+
* - **Data sources**: the spec's data sources are added with the layer, by their own IDs, and shared with every other
|
|
2068
|
+
* composite layer that brings the same ID: the first one added gives the options, and a later one with other
|
|
2069
|
+
* options is reported as a map error. A data source the application has added with the same ID is used instead, and
|
|
2070
|
+
* is never removed. A sub-layer can also draw a data source the application has added. A data source is removed with
|
|
2071
|
+
* the last composite layer that brings it, and `map.removeSource()` throws while a composite layer uses it.
|
|
2072
|
+
* - **Sub-layers**: a sub-layer `points` of the composite layer `user_x` renders as the MapLibre layer
|
|
2073
|
+
* `user_x__points`, with `user_x__points__stroke` and `user_x__points__label` for a flow style that needs them. Each
|
|
2074
|
+
* goes to its type's insertion point in the base style or, with `above` or `below`, the whole composite layer goes
|
|
2075
|
+
* there, in order.
|
|
2076
|
+
* - **Shared settings**: `filter` is ANDed with each sub-layer's own filter; `visibility` overrides the sub-layers'
|
|
2077
|
+
* own; a sub-layer is interactive when both `interactive` and its own rule say so; `minZoom` and `maxZoom` narrow
|
|
2078
|
+
* each sub-layer's range; and `metadata` is merged into every MapLibre layer's metadata, with
|
|
2079
|
+
* `{composite: true, compositeParentLayer: <layer ID>, compositeSubLayer: <sub-layer ID>}`.
|
|
2080
|
+
* - **The composite layer is what you address**: `map.getLayer()` and `map.getLayers()` return it, not its
|
|
2081
|
+
* sub-layers, and click and hover events and the map plugins report a feature from any sub-layer as the composite
|
|
2082
|
+
* layer's.
|
|
2083
|
+
*
|
|
2084
|
+
* A composite layer never throws on bad spec content: the valid sub-layers and data sources render, and
|
|
2085
|
+
* {@link MapLayer.issues} lists the problems, each also emitted once as a map `error`. Edit a composite layer with
|
|
2086
|
+
* {@link MapLayer.setStyle}, and save its {@link MapLayer.compositeSpec}.
|
|
2087
|
+
*
|
|
2088
|
+
* Data source selection options (`selectionMode` and the rest) need the `SelectionPlugin`, and `@@hover` styling
|
|
2089
|
+
* needs the `HoverEffectPlugin`. Without the `SelectionPlugin`, a composite layer that declares selection emits one
|
|
2090
|
+
* map error and renders without selection.
|
|
2091
|
+
*
|
|
2092
|
+
* @example
|
|
2093
|
+
* A stored map layer (version 1), filtered and edited:
|
|
2094
|
+
* ```js
|
|
2095
|
+
* const layer = map.addLayer({
|
|
2096
|
+
* id: row.id,
|
|
2097
|
+
* type: 'composite',
|
|
2098
|
+
* style: row.layerSpec,
|
|
2099
|
+
* filter: queryFilter,
|
|
2100
|
+
* visibility: '$showDiscovery',
|
|
2101
|
+
* below: 'anchor-discovery',
|
|
2102
|
+
* metadata: { mapLayerType: row.type }
|
|
2103
|
+
* });
|
|
2104
|
+
* layer.setStyle(updateCompositeFlowStyle(layer.compositeSpec, 'circle-layer', { fillColor: '#bbff00' }));
|
|
2105
|
+
* save(layer.compositeSpec); // still version 1
|
|
2106
|
+
* ```
|
|
2107
|
+
*
|
|
2108
|
+
* @experimental
|
|
2109
|
+
*/
|
|
2110
|
+
interface CompositeLayerOptions {
|
|
2111
|
+
/** Layer ID. It prefixes the IDs of the layer's MapLibre layers. */
|
|
2112
|
+
id: string;
|
|
2113
|
+
/** Always `composite`. */
|
|
2114
|
+
type: 'composite';
|
|
2115
|
+
/**
|
|
2116
|
+
* The composite layer spec, version 1 or 2: a stored map layer's `layerSpec`, or one built with
|
|
2117
|
+
* {@link compositeLayerSpec}.
|
|
2118
|
+
*/
|
|
2119
|
+
style: CompositeLayerSpecification;
|
|
2120
|
+
/** Filter: a reactive expression, ANDed with each sub-layer's own filter. */
|
|
2121
|
+
filter?: string;
|
|
2122
|
+
/** Shows or hides every sub-layer: a reactive expression or a boolean. It overrides the sub-layers' own visibility. */
|
|
2123
|
+
visibility?: string | boolean;
|
|
2124
|
+
/** Set to `false` to leave every sub-layer out of click and hover results. Defaults to `true`. */
|
|
2125
|
+
interactive?: boolean;
|
|
2126
|
+
/** Minimum visible zoom level. If set, it narrows each sub-layer's own range. */
|
|
2127
|
+
minZoom?: number;
|
|
2128
|
+
/** Maximum visible zoom level. If set, it narrows each sub-layer's own range. */
|
|
2129
|
+
maxZoom?: number;
|
|
2130
|
+
/** ID of a layer to place the composite layer's MapLibre layers above, in order. */
|
|
2131
|
+
above?: string;
|
|
2132
|
+
/** ID of a layer to place the composite layer's MapLibre layers below, in order. */
|
|
2133
|
+
below?: string;
|
|
2134
|
+
/** Metadata merged into the `metadata` of every MapLibre layer of the composite layer. */
|
|
2135
|
+
metadata?: Record<string, unknown>;
|
|
2136
|
+
}
|
|
2054
2137
|
/**
|
|
2055
2138
|
* One MapLibre layer of a {@link MapLayer} that renders as several, given to the layer with
|
|
2056
2139
|
* {@link MapLayer.setSubLayers}. The layer's `filter`, `minZoom`, `maxZoom`, `interactive`, `metadata` and the
|
|
@@ -2125,7 +2208,11 @@ declare class MapLayer {
|
|
|
2125
2208
|
private _layoutProps;
|
|
2126
2209
|
private _visibility;
|
|
2127
2210
|
private _subLayers;
|
|
2211
|
+
private _ownedSources;
|
|
2212
|
+
private _ownedSourcesListeners;
|
|
2128
2213
|
private _flow;
|
|
2214
|
+
private _composite;
|
|
2215
|
+
private _mapSources;
|
|
2129
2216
|
private _issues;
|
|
2130
2217
|
private _invalidInteractive;
|
|
2131
2218
|
/**
|
|
@@ -2163,6 +2250,12 @@ declare class MapLayer {
|
|
|
2163
2250
|
* @internal
|
|
2164
2251
|
*/
|
|
2165
2252
|
get subLayers(): readonly MapSubLayerOptions[] | null;
|
|
2253
|
+
/**
|
|
2254
|
+
* The data sources the layer brings with it (see {@link setOwnedSources}), or `null` for none.
|
|
2255
|
+
*
|
|
2256
|
+
* @internal
|
|
2257
|
+
*/
|
|
2258
|
+
get ownedSources(): readonly MapDataSourceOptions[] | null;
|
|
2166
2259
|
/**
|
|
2167
2260
|
* Layer metadata, copied to the `metadata` of the layer's MapLibre layers.
|
|
2168
2261
|
*
|
|
@@ -2179,9 +2272,22 @@ declare class MapLayer {
|
|
|
2179
2272
|
*/
|
|
2180
2273
|
get flowStyle(): FlowStyle | undefined;
|
|
2181
2274
|
/**
|
|
2182
|
-
*
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2275
|
+
* A composite layer's spec, in its stored format and version (a version 1 spec stays version 1), ready to save. A
|
|
2276
|
+
* copy: change the layer with {@link setStyle}. `undefined` for any other layer type.
|
|
2277
|
+
*
|
|
2278
|
+
* Reading it in a MobX reaction, or a component that renders from state, tracks changes to the spec.
|
|
2279
|
+
*
|
|
2280
|
+
* @experimental
|
|
2281
|
+
*/
|
|
2282
|
+
get compositeSpec(): CompositeLayerSpecification | undefined;
|
|
2283
|
+
/**
|
|
2284
|
+
* The problems with a flow layer's style or a composite layer's spec, updated whenever the style changes. An `error`
|
|
2285
|
+
* means a property, a sub-layer, a data source or the whole style isn't rendered; a `warning` means it is rendered
|
|
2286
|
+
* anyway. Each has the path of the problem in the style or spec, such as `layers[1].style.fillColor`. Empty for a
|
|
2287
|
+
* MapLibre layer, which throws on a bad style instead.
|
|
2288
|
+
*
|
|
2289
|
+
* A composite layer on a map also lists each sub-layer whose data source is neither in the spec nor on the map, and
|
|
2290
|
+
* so isn't rendered, and the map emits each new issue of a composite layer as an `error` event.
|
|
2185
2291
|
*
|
|
2186
2292
|
* The list is observable: read it in a MobX reaction to follow it.
|
|
2187
2293
|
*
|
|
@@ -2190,11 +2296,12 @@ declare class MapLayer {
|
|
|
2190
2296
|
get issues(): FlowStyleIssue[];
|
|
2191
2297
|
get id(): string;
|
|
2192
2298
|
get type(): string;
|
|
2299
|
+
/** The data source the layer displays. Empty for a composite layer, whose sub-layers name their own. */
|
|
2193
2300
|
get source(): string;
|
|
2194
2301
|
get interactive(): boolean;
|
|
2195
2302
|
get above(): string | undefined;
|
|
2196
2303
|
get below(): string | undefined;
|
|
2197
|
-
constructor(options: MapLayerOptions);
|
|
2304
|
+
constructor(options: MapLayerOptions | CompositeLayerOptions);
|
|
2198
2305
|
bindState(state: StateStore | null): this;
|
|
2199
2306
|
setMinZoom(zoom: number): this;
|
|
2200
2307
|
setMaxZoom(zoom: number): this;
|
|
@@ -2209,10 +2316,14 @@ declare class MapLayer {
|
|
|
2209
2316
|
* - **Flow layers**: replaces the whole flow style with a version 2 {@link FlowStyle}, such as one built with
|
|
2210
2317
|
* {@link flowLayerStyle}. The layer's MapLibre layers are updated in place, without reloading the source. Never
|
|
2211
2318
|
* throws: a property with a problem isn't rendered, the rest is, and {@link issues} lists the problems.
|
|
2319
|
+
* - **Composite layers**: replaces the whole spec with a {@link CompositeLayerSpecification}, such as one edited with
|
|
2320
|
+
* {@link updateCompositeFlowStyle}, in one update of the map: MapLibre layers whose IDs persist keep their place
|
|
2321
|
+
* and are restyled, data sources whose options are unchanged aren't reloaded, and a spec equal to the current one
|
|
2322
|
+
* changes nothing. The spec keeps its own version. Never throws: {@link issues} lists the problems.
|
|
2212
2323
|
*
|
|
2213
|
-
* @param style - Style program for a MapLibre layer,
|
|
2324
|
+
* @param style - Style program for a MapLibre layer, flow style for a flow layer, or spec for a composite layer.
|
|
2214
2325
|
*/
|
|
2215
|
-
setStyle(style: string | FlowStyle): void;
|
|
2326
|
+
setStyle(style: string | FlowStyle | CompositeLayerSpecification): void;
|
|
2216
2327
|
/**
|
|
2217
2328
|
* Sets or removes one style property. Its value follows different rules for MapLibre layers and flow layers.
|
|
2218
2329
|
*
|
|
@@ -2225,6 +2336,8 @@ declare class MapLayer {
|
|
|
2225
2336
|
* {@link FlowStyleDataDriven} table makes an expression with the table attached. The layer's MapLibre layers are
|
|
2226
2337
|
* updated in place, without reloading the source, and {@link flowStyle} returns the edited style. Never throws:
|
|
2227
2338
|
* {@link issues} lists any problems.
|
|
2339
|
+
* - **Composite layers**: throws. Edit the spec instead, with {@link updateCompositeFlowStyle}, and give it to
|
|
2340
|
+
* {@link setStyle}.
|
|
2228
2341
|
*
|
|
2229
2342
|
* @example
|
|
2230
2343
|
* The same edit on a MapLibre layer and on a flow layer:
|
|
@@ -2237,12 +2350,22 @@ declare class MapLayer {
|
|
|
2237
2350
|
* @param value - Property value, or `null` to remove the property.
|
|
2238
2351
|
*/
|
|
2239
2352
|
setStyleProperty(property: string, value: FlowValue<string | number | boolean> | FlowStyleExpression<unknown> | null): void;
|
|
2353
|
+
/**
|
|
2354
|
+
* Sets or clears the layer's filter.
|
|
2355
|
+
*
|
|
2356
|
+
* @param expression - Reactive expression that a feature must match to be drawn. Specify `null`, or an empty
|
|
2357
|
+
* string, to clear the filter.
|
|
2358
|
+
* @throws `FlowCoreExpressionError` if the expression doesn't parse.
|
|
2359
|
+
*/
|
|
2240
2360
|
setFilter(expression: string | null): void;
|
|
2241
2361
|
/**
|
|
2242
|
-
* Shows or hides every MapLibre layer of
|
|
2362
|
+
* Shows or hides the layer, and every MapLibre layer of a flow or composite layer, overriding the `visibility` of
|
|
2363
|
+
* their styles.
|
|
2243
2364
|
*
|
|
2244
|
-
* @param visibility - Reactive expression or boolean. Specify `null` to leave visibility
|
|
2245
|
-
*
|
|
2365
|
+
* @param visibility - Reactive expression, such as `'$showAirports'`, or boolean. Specify `null` to leave visibility
|
|
2366
|
+
* to the styles.
|
|
2367
|
+
* @throws `FlowCoreExpressionError` if the expression doesn't parse.
|
|
2368
|
+
* @experimental
|
|
2246
2369
|
*/
|
|
2247
2370
|
setVisibility(visibility: string | boolean | null): void;
|
|
2248
2371
|
/**
|
|
@@ -2257,6 +2380,37 @@ declare class MapLayer {
|
|
|
2257
2380
|
* @internal
|
|
2258
2381
|
*/
|
|
2259
2382
|
setSubLayers(subLayers: readonly MapSubLayerOptions[] | null): void;
|
|
2383
|
+
/**
|
|
2384
|
+
* Declares the data sources the layer brings with it, so that its sub-layers can display them. The map's
|
|
2385
|
+
* `MapStyle` adds each one, by ID, while a layer on the map brings it, and shares it between the layers that
|
|
2386
|
+
* bring the same ID: the first layer added to the map gives its options, and a later one that gives different
|
|
2387
|
+
* options is reported as a style problem. A source the app added with the same ID is used instead, and is never
|
|
2388
|
+
* removed. Changing the list updates the map in place: a source whose options are unchanged keeps its
|
|
2389
|
+
* `MapDataSource`, so it isn't reloaded.
|
|
2390
|
+
*
|
|
2391
|
+
* @param sources - Options of each data source. Specify `null`, or an empty list, to bring none.
|
|
2392
|
+
* @throws {@link FlowCoreError} if two sources have the same ID, or a source's type is invalid. The layer's sources
|
|
2393
|
+
* are then unchanged.
|
|
2394
|
+
* @internal
|
|
2395
|
+
*/
|
|
2396
|
+
setOwnedSources(sources: readonly MapDataSourceOptions[] | null): void;
|
|
2397
|
+
/**
|
|
2398
|
+
* Calls a listener, synchronously, whenever {@link setOwnedSources} is called: `MapStyle` uses it to add and
|
|
2399
|
+
* remove the sources in the same action.
|
|
2400
|
+
*
|
|
2401
|
+
* @returns A function that removes the listener.
|
|
2402
|
+
* @internal
|
|
2403
|
+
*/
|
|
2404
|
+
observeOwnedSources(listener: () => void): () => void;
|
|
2405
|
+
/**
|
|
2406
|
+
* Tells the layer which data sources are on its map, while it is on one: a composite layer lists each sub-layer
|
|
2407
|
+
* whose data source is missing in {@link issues}. `MapStyle` sets it when the layer is added, and clears it when the
|
|
2408
|
+
* layer is removed.
|
|
2409
|
+
*
|
|
2410
|
+
* @param lookup - Whether a data source ID is on the map, read reactively; `null` when the layer isn't on a map.
|
|
2411
|
+
* @internal
|
|
2412
|
+
*/
|
|
2413
|
+
setMapSources(lookup: ((id: string) => boolean) | null): void;
|
|
2260
2414
|
/**
|
|
2261
2415
|
* Loads a version 1 flow style, the legacy stored format, into a flow layer, with its geometry. The layer then keeps
|
|
2262
2416
|
* version 1: {@link setStyleProperty} writes version 1 forms, {@link setStyle} converts a version 2 style to version 1
|
|
@@ -2282,6 +2436,16 @@ declare class MapLayer {
|
|
|
2282
2436
|
private setFlowStyleProperty;
|
|
2283
2437
|
/** Sets a flow layer's style, and renders it as sub-layers. */
|
|
2284
2438
|
private updateFlowLayer;
|
|
2439
|
+
/** Replaces a composite layer's spec: its sources and sub-layers, in the action that calls it. */
|
|
2440
|
+
private replaceCompositeSpec;
|
|
2441
|
+
/**
|
|
2442
|
+
* A composite layer's issues: the expansion's, and, on a map, its sub-layers' missing data sources. A sub-layer
|
|
2443
|
+
* source that isn't in the spec's data sources is a warning in the spec alone; on the map it's nothing if the map
|
|
2444
|
+
* has the source, and an error if it doesn't, since the sub-layer then isn't rendered.
|
|
2445
|
+
*/
|
|
2446
|
+
private get compositeIssues();
|
|
2447
|
+
/** The spec path of the sub-layer that gave a MapLibre layer, from its metadata. */
|
|
2448
|
+
private compositeSubLayerPath;
|
|
2285
2449
|
/** The MapLibre layer specification of a sub-layer, with the layer's shared settings applied. */
|
|
2286
2450
|
private subLayerSpecification;
|
|
2287
2451
|
private visibilityValue;
|
|
@@ -2314,6 +2478,43 @@ interface MapDataSourceOptions {
|
|
|
2314
2478
|
flowHost?: string;
|
|
2315
2479
|
/** Set to override application-wide API key for this data source */
|
|
2316
2480
|
flowApiKey?: string;
|
|
2481
|
+
/**
|
|
2482
|
+
* Selection options for the data source. If specified, the
|
|
2483
|
+
* {@link flow-rdf-core/plugins!SelectionPlugin | SelectionPlugin} enables selection for the data source when the
|
|
2484
|
+
* plugin is installed or the data source is added, in either order, as if
|
|
2485
|
+
* {@link flow-rdf-core/plugins!SelectionPlugin.enableSelection | SelectionPlugin.enableSelection} had been called. A
|
|
2486
|
+
* later `enableSelection` call for the data source replaces it. If not specified, selection is set up only by calling
|
|
2487
|
+
* `enableSelection`.
|
|
2488
|
+
*
|
|
2489
|
+
* The `featureId` property must be set for features to be selected.
|
|
2490
|
+
*
|
|
2491
|
+
* @experimental
|
|
2492
|
+
*/
|
|
2493
|
+
selection?: SelectionOptions;
|
|
2494
|
+
}
|
|
2495
|
+
/**
|
|
2496
|
+
* Selection mode used by {@link SelectionOptions}: `single`, `multi` or `none`. See
|
|
2497
|
+
* {@link flow-rdf-core/plugins!SelectionPlugin | SelectionPlugin} for the behavior of each mode.
|
|
2498
|
+
*/
|
|
2499
|
+
type SelectionMode = 'single' | 'multi' | 'none';
|
|
2500
|
+
/**
|
|
2501
|
+
* Selection options for a map data source, declared with {@link MapDataSourceOptions.selection} or passed to
|
|
2502
|
+
* {@link flow-rdf-core/plugins!SelectionPlugin.enableSelection | SelectionPlugin.enableSelection}. See
|
|
2503
|
+
* {@link flow-rdf-core/plugins!SelectionPlugin | SelectionPlugin} for more details.
|
|
2504
|
+
*/
|
|
2505
|
+
interface SelectionOptions {
|
|
2506
|
+
/** Clear mode for selection */
|
|
2507
|
+
clear?: boolean | 'group';
|
|
2508
|
+
/** Selection group ID - applies when `clear` mode is set to `group`. */
|
|
2509
|
+
group?: string;
|
|
2510
|
+
/** Selection mode: `single` or `multi` */
|
|
2511
|
+
mode: SelectionMode;
|
|
2512
|
+
/** ID of popup to display when selecting a feature. */
|
|
2513
|
+
popup?: string;
|
|
2514
|
+
/** Reactive state property to bind to selection state. */
|
|
2515
|
+
selectionState?: string;
|
|
2516
|
+
/** Map data source layer. Note that this is only required for custom vector data sources. */
|
|
2517
|
+
sourceLayer?: string;
|
|
2317
2518
|
}
|
|
2318
2519
|
interface MapDataSourceSpecification {
|
|
2319
2520
|
type: MapDataSourceType;
|
|
@@ -2349,6 +2550,178 @@ interface MapStyleSpecification {
|
|
|
2349
2550
|
layers: Array<MapLayerSpecification>;
|
|
2350
2551
|
}
|
|
2351
2552
|
|
|
2553
|
+
/**
|
|
2554
|
+
* A composite layer spec: several sub-layers, in flow style or MapLibre style, and the data sources they draw, stored
|
|
2555
|
+
* as one object. It is the stored format of Flo.w Engine map layers (their `layerSpec`).
|
|
2556
|
+
*
|
|
2557
|
+
* There are two versions of the stored format:
|
|
2558
|
+
*
|
|
2559
|
+
* - **Version 2**, the current one, has `version: 2`. Its sub-layers ({@link CompositeSubLayerSpecification}) have the
|
|
2560
|
+
* shape of `MapLayerOptions`: `{type: 'flow', style: FlowStyle}` or a MapLibre type with a style program. Build one
|
|
2561
|
+
* with {@link compositeLayerSpec}.
|
|
2562
|
+
* - **Version 1** is the legacy format CAA Analyser stores. A spec with no `version` is version 1. Its sub-layers
|
|
2563
|
+
* ({@link CompositeSubLayerSpecificationV1}) take their geometry from `type` and wrap their style as
|
|
2564
|
+
* `{type: 'flow', …}` or `{type: 'maplibre', style}`. Version 1 specs are read and written as they are, and are
|
|
2565
|
+
* never upgraded.
|
|
2566
|
+
*
|
|
2567
|
+
* Every object in a spec keeps keys it doesn't know, so a spec read from storage, edited and saved loses nothing.
|
|
2568
|
+
* Check a spec with {@link validateCompositeLayer}, and edit one with {@link updateCompositeFlowStyle} and
|
|
2569
|
+
* {@link setCompositeSubLayerFilter}, which write in the spec's own version.
|
|
2570
|
+
*
|
|
2571
|
+
* @experimental
|
|
2572
|
+
*/
|
|
2573
|
+
interface CompositeLayerSpecification {
|
|
2574
|
+
/** Stored format version. A missing `version` means 1; `2` is required from version 2 on. Any other value is an error. */
|
|
2575
|
+
version?: number;
|
|
2576
|
+
/** ID written by CAA Analyser. Not used: the composite layer's own ID prefixes its MapLibre layers. */
|
|
2577
|
+
id?: string;
|
|
2578
|
+
/**
|
|
2579
|
+
* The sub-layers, in draw order, bottom to top. Required: a spec with no layers, such as an empty object, renders
|
|
2580
|
+
* nothing, and {@link validateCompositeLayer} reports it.
|
|
2581
|
+
*/
|
|
2582
|
+
layers?: (CompositeSubLayerSpecification | CompositeSubLayerSpecificationV1)[];
|
|
2583
|
+
/** The data sources the sub-layers draw. */
|
|
2584
|
+
dataSources?: CompositeDataSourceSpecification[];
|
|
2585
|
+
/** Unknown keys, kept as they are. */
|
|
2586
|
+
[key: string]: unknown;
|
|
2587
|
+
}
|
|
2588
|
+
/**
|
|
2589
|
+
* The options every composite sub-layer has, in both versions of the stored format.
|
|
2590
|
+
*
|
|
2591
|
+
* @experimental
|
|
2592
|
+
*/
|
|
2593
|
+
interface CompositeSubLayerBase {
|
|
2594
|
+
/** Sub-layer ID, unique within the spec. Its MapLibre layers' IDs are `<composite layer ID>__<id>`. */
|
|
2595
|
+
id: string;
|
|
2596
|
+
/** Data source ID: one in the spec's `dataSources`, or a source the application has added to the map. */
|
|
2597
|
+
source: string;
|
|
2598
|
+
/** Filter: a reactive expression, ANDed with the composite layer's. An empty string means no filter. */
|
|
2599
|
+
filter?: string;
|
|
2600
|
+
/**
|
|
2601
|
+
* Set to `false` to leave the sub-layer out of click and hover results. Flow-style sub-layers default to `true`.
|
|
2602
|
+
* MapLibre-style sub-layers default to `true` in version 2 and `false` in version 1, as in legacy.
|
|
2603
|
+
*/
|
|
2604
|
+
interactive?: boolean;
|
|
2605
|
+
/** Minimum visible zoom level. Defaults to `0`. */
|
|
2606
|
+
minZoom?: number;
|
|
2607
|
+
/** Maximum visible zoom level. Defaults to `18`. */
|
|
2608
|
+
maxZoom?: number;
|
|
2609
|
+
/** Unknown keys, kept as they are. */
|
|
2610
|
+
[key: string]: unknown;
|
|
2611
|
+
}
|
|
2612
|
+
/**
|
|
2613
|
+
* A version 2 composite sub-layer. It has the shape of `MapLayerOptions`: either a flow layer, with `type: 'flow'` and a
|
|
2614
|
+
* {@link FlowStyle} (which carries its own geometry and `version`), or a MapLibre layer type with a style program, such
|
|
2615
|
+
* as one built with {@link layerStyle}.
|
|
2616
|
+
*
|
|
2617
|
+
* @example
|
|
2618
|
+
* ```js
|
|
2619
|
+
* const points = { id: 'points', type: 'flow', source: 'uk_airports', style: flowLayerStyle('circle').build() };
|
|
2620
|
+
* const icons = { id: 'icons', type: 'symbol', source: 'uk_airports', style: "icon-image: 'airport';" };
|
|
2621
|
+
* ```
|
|
2622
|
+
*
|
|
2623
|
+
* @experimental
|
|
2624
|
+
*/
|
|
2625
|
+
type CompositeSubLayerSpecification = (CompositeSubLayerBase & {
|
|
2626
|
+
/** Always `flow`. */
|
|
2627
|
+
type: 'flow';
|
|
2628
|
+
/** Version 2 flow style. */
|
|
2629
|
+
style: FlowStyle;
|
|
2630
|
+
}) | (CompositeSubLayerBase & {
|
|
2631
|
+
/** MapLibre layer type. */
|
|
2632
|
+
type: MapLayerType;
|
|
2633
|
+
/** Style program, such as one built with {@link layerStyle}. */
|
|
2634
|
+
style: string;
|
|
2635
|
+
});
|
|
2636
|
+
/**
|
|
2637
|
+
* A version 1 composite sub-layer, the legacy stored format. Its `type` is the geometry, and its style is wrapped:
|
|
2638
|
+
* `{type: 'flow', …}` for a version 1 flow style, drawn with that geometry, or `{type: 'maplibre', style}` for a style
|
|
2639
|
+
* program. A `symbol` sub-layer needs a MapLibre style.
|
|
2640
|
+
*
|
|
2641
|
+
* MapLibre-style sub-layers are interactive only with `interactive: true`, as in legacy.
|
|
2642
|
+
*
|
|
2643
|
+
* @experimental
|
|
2644
|
+
*/
|
|
2645
|
+
interface CompositeSubLayerSpecificationV1 extends CompositeSubLayerBase {
|
|
2646
|
+
/** Geometry. */
|
|
2647
|
+
type: 'circle' | 'line' | 'fill' | 'symbol';
|
|
2648
|
+
/** Stored but not used, as in legacy: the composite layer's own `above` places all its sub-layers. */
|
|
2649
|
+
above?: string;
|
|
2650
|
+
/** Stored but not used, as in legacy: the composite layer's own `below` places all its sub-layers. */
|
|
2651
|
+
below?: string;
|
|
2652
|
+
/** The style: a version 1 flow style, or a MapLibre style program. */
|
|
2653
|
+
style: {
|
|
2654
|
+
type: 'flow';
|
|
2655
|
+
[key: string]: unknown;
|
|
2656
|
+
} | {
|
|
2657
|
+
type: 'maplibre';
|
|
2658
|
+
/** Style program. */
|
|
2659
|
+
style: string;
|
|
2660
|
+
[key: string]: unknown;
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
/**
|
|
2664
|
+
* A data source of a composite layer spec. Its ID isn't prefixed with the composite layer's, so composite layers that
|
|
2665
|
+
* name the same data source share it.
|
|
2666
|
+
*
|
|
2667
|
+
* @experimental
|
|
2668
|
+
*/
|
|
2669
|
+
interface CompositeDataSourceSpecification {
|
|
2670
|
+
/** Data source ID, shared by every composite layer that uses it. */
|
|
2671
|
+
id: string;
|
|
2672
|
+
/** Data source type. A version 1 data source without `type` is `vector`, as in legacy. */
|
|
2673
|
+
type: MapDataSourceType;
|
|
2674
|
+
/** Dataset or tile source ID, or a URL, taken literally; or, starting with `$`, an application state property. */
|
|
2675
|
+
src: string;
|
|
2676
|
+
/** Feature property to use as the unique feature ID. Selection needs it. */
|
|
2677
|
+
featureId?: string;
|
|
2678
|
+
/** Limit applied to dataset queries. */
|
|
2679
|
+
limit?: number;
|
|
2680
|
+
/** API key for this data source, in place of the application's. */
|
|
2681
|
+
apiKey?: string;
|
|
2682
|
+
/** Set to `true` to cluster GeoJSON points. */
|
|
2683
|
+
cluster?: boolean;
|
|
2684
|
+
/** Cluster radius, for GeoJSON point clustering. */
|
|
2685
|
+
clusterRadius?: number;
|
|
2686
|
+
/** Maximum zoom level to cluster points on, for GeoJSON point clustering. */
|
|
2687
|
+
clusterMaxZoom?: number;
|
|
2688
|
+
/** Selection mode: `single`, `multi` or `none` (the default). Selection needs `featureId` and the `SelectionPlugin`. */
|
|
2689
|
+
selectionMode?: SelectionMode;
|
|
2690
|
+
/** Application state property bound to the selection. A leading `$` is ignored. */
|
|
2691
|
+
selectionState?: string;
|
|
2692
|
+
/** Whether selecting a feature of another data source clears this one's selection: always, never or by group. */
|
|
2693
|
+
selectionClear?: boolean | 'group';
|
|
2694
|
+
/** Selection group, for `selectionClear: 'group'`. */
|
|
2695
|
+
selectionGroup?: string;
|
|
2696
|
+
/** Unknown keys, kept as they are. */
|
|
2697
|
+
[key: string]: unknown;
|
|
2698
|
+
}
|
|
2699
|
+
/**
|
|
2700
|
+
* Builds a version 2 {@link CompositeLayerSpecification}. Create one with {@link compositeLayerSpec}.
|
|
2701
|
+
*
|
|
2702
|
+
* @experimental
|
|
2703
|
+
*/
|
|
2704
|
+
interface CompositeLayerSpecBuilder {
|
|
2705
|
+
/**
|
|
2706
|
+
* Adds a data source.
|
|
2707
|
+
*
|
|
2708
|
+
* @param source - Data source.
|
|
2709
|
+
*/
|
|
2710
|
+
dataSource(source: CompositeDataSourceSpecification): this;
|
|
2711
|
+
/**
|
|
2712
|
+
* Adds a sub-layer on top of those already added.
|
|
2713
|
+
*
|
|
2714
|
+
* @param layer - Version 2 sub-layer.
|
|
2715
|
+
*/
|
|
2716
|
+
layer(layer: CompositeSubLayerSpecification): this;
|
|
2717
|
+
/**
|
|
2718
|
+
* Returns the spec in its stored format, with `version` always set.
|
|
2719
|
+
*
|
|
2720
|
+
* @returns The composite layer spec.
|
|
2721
|
+
*/
|
|
2722
|
+
build(): CompositeLayerSpecification;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2352
2725
|
interface FlowEngineEndpoint {
|
|
2353
2726
|
host: string;
|
|
2354
2727
|
apiKey?: string;
|
|
@@ -2362,6 +2735,13 @@ declare class MapDataSource {
|
|
|
2362
2735
|
get id(): string;
|
|
2363
2736
|
get type(): MapDataSourceType;
|
|
2364
2737
|
get featureId(): string | undefined;
|
|
2738
|
+
/**
|
|
2739
|
+
* Selection options the data source declares, which the
|
|
2740
|
+
* {@link flow-rdf-core/plugins!SelectionPlugin | SelectionPlugin} enables. See {@link MapDataSourceOptions.selection}.
|
|
2741
|
+
*
|
|
2742
|
+
* @experimental
|
|
2743
|
+
*/
|
|
2744
|
+
get selection(): SelectionOptions | undefined;
|
|
2365
2745
|
get dataSourceSpecification(): MapDataSourceSpecification;
|
|
2366
2746
|
constructor(options: MapDataSourceOptions);
|
|
2367
2747
|
bindState(state: StateStore | null): this;
|
|
@@ -3129,6 +3509,9 @@ declare class FlowCoreMap<TState extends StateStore = StateStore> extends EventE
|
|
|
3129
3509
|
private _style;
|
|
3130
3510
|
private _styleUpdateSubscription;
|
|
3131
3511
|
private _reportedStyleProblems;
|
|
3512
|
+
private _reportedCompositeIssues;
|
|
3513
|
+
private _checkedCompositeSelection;
|
|
3514
|
+
private _compositeLayerReaction;
|
|
3132
3515
|
private _throttledMouseMove;
|
|
3133
3516
|
private _maplibreMap;
|
|
3134
3517
|
/**
|
|
@@ -3247,8 +3630,11 @@ declare class FlowCoreMap<TState extends StateStore = StateStore> extends EventE
|
|
|
3247
3630
|
* .build()
|
|
3248
3631
|
* });
|
|
3249
3632
|
* ```
|
|
3633
|
+
*
|
|
3634
|
+
* A composite layer (`type: 'composite'`, see {@link CompositeLayerOptions}) brings its own data sources, and never
|
|
3635
|
+
* throws on its spec: {@link MapLayer.issues} lists the problems, and the map emits each as an `error` event.
|
|
3250
3636
|
*/
|
|
3251
|
-
addLayer(layerOptions: MapLayerOptions): MapLayer;
|
|
3637
|
+
addLayer(layerOptions: MapLayerOptions | CompositeLayerOptions): MapLayer;
|
|
3252
3638
|
/**
|
|
3253
3639
|
* Adds a {@link MapDataSource} to the map.
|
|
3254
3640
|
*/
|
|
@@ -3544,6 +3930,8 @@ declare class FlowCoreMap<TState extends StateStore = StateStore> extends EventE
|
|
|
3544
3930
|
* @param plugins - Array of plugin constructors to register
|
|
3545
3931
|
*/
|
|
3546
3932
|
usePlugins(plugins: PluginConstructor[]): void;
|
|
3933
|
+
/** Makes a source use the map's Flo.w endpoint to expand dataset and tile source IDs to URLs. */
|
|
3934
|
+
private prepareSource;
|
|
3547
3935
|
private get formattedName();
|
|
3548
3936
|
private bindMapEvents;
|
|
3549
3937
|
private featureFromMaplibreFeature;
|
|
@@ -3552,6 +3940,19 @@ declare class FlowCoreMap<TState extends StateStore = StateStore> extends EventE
|
|
|
3552
3940
|
* is the one drawn on top. A feature from a sub-layer reports the {@link MapLayer} it belongs to.
|
|
3553
3941
|
*/
|
|
3554
3942
|
private queryFeatures;
|
|
3943
|
+
/**
|
|
3944
|
+
* Follows the composite layers on the map: emits each new issue of each one as a map error, and checks that a
|
|
3945
|
+
* composite layer that declares selection has the SelectionPlugin to enable it.
|
|
3946
|
+
*/
|
|
3947
|
+
private watchCompositeLayers;
|
|
3948
|
+
/** Emits each issue of a composite layer that wasn't among its issues when last reported. */
|
|
3949
|
+
private reportCompositeIssues;
|
|
3950
|
+
/**
|
|
3951
|
+
* Emits one error for each composite layer that declares selection while the SelectionPlugin isn't installed. The
|
|
3952
|
+
* check waits for the code that added the layer to finish, so that it can install the plugin after the layer.
|
|
3953
|
+
*/
|
|
3954
|
+
private checkCompositeSelection;
|
|
3955
|
+
private hasPlugin;
|
|
3555
3956
|
/** Reports each new problem that {@link MapStyle} found while building the style as a map error. */
|
|
3556
3957
|
private reportStyleProblems;
|
|
3557
3958
|
private featureQueryBox;
|
|
@@ -3937,4 +4338,4 @@ declare class FlowContext<TState extends StateStore = StateStore> {
|
|
|
3937
4338
|
evaluateExpression(expr: string): any;
|
|
3938
4339
|
}
|
|
3939
4340
|
|
|
3940
|
-
export {
|
|
4341
|
+
export { expr as $, type Annotation as A, type FlowStyleNamedSize as B, type CompositeLayerSpecBuilder as C, DEFAULT_CONTEXT_ID as D, type FlowStyleProperty as E, type FlowStyle as F, type FlowStyleSize as G, type FlowValue as H, type FlowEngineEndpoint as I, type MapLayerType as J, FillLayerStyleBuilder as K, LineLayerStyleBuilder as L, MapDataSource as M, SymbolLayerStyleBuilder as N, CircleLayerStyleBuilder as O, type ParserExpression as P, QueryRegistry as Q, ReactiveExpression as R, StateStore as S, HeatmapLayerStyleBuilder as T, FillExtrusionLayerStyleBuilder as U, RasterLayerStyleBuilder as V, HillshadeLayerStyleBuilder as W, BackgroundLayerStyleBuilder as X, layerStyle as Y, MapLayerStyleBuilder as Z, StyleExpression as _, type CompositeLayerSpecification as a, type MapLayerOptions as a0, type CompositeLayerOptions as a1, type MapSubLayerOptions as a2, type MapLayerExpression as a3, type MapLayerSpecification as a4, type MapLayerPropertyMetadataIndex as a5, type MapDataSourceType as a6, type MapDataSourceOptions as a7, type SelectionMode as a8, type SelectionOptions as a9, type QueryResultFormat as aA, type QueryAttribute as aB, type QueryWhereClauses as aC, type QueryExtraParams as aD, type QueryOrderClause as aE, type QuerySampleOptions as aF, type QueryDefinition as aG, type QueryOptions as aH, type QueryDefinitionFn as aI, type QueryResultTransformFn as aJ, traceReaction as aK, type Path as aL, type PathValue as aM, type StoreConstructor as aN, type StoreAnnotations as aO, type SerializationFormat as aP, MapPluginBase as aQ, PluginManager as aR, type PartialBy as aS, type MapFeatureId as aT, type PluginOptionsType as aU, type PluginEventsType as aV, type PluginConstructor as aW, type EventHandlers as aX, type MapDataSourceSpecification as aa, type MapGeojsonData as ab, type MapAnimationOptions as ac, type MapCenterOptions as ad, type MapFeature as ae, type MapFeatureIdentifier as af, type MapPaddingOptions as ag, type MapSourceIdentifier as ah, MapFeatureStream as ai, type FeatureStreamOptions as aj, type MapOptions as ak, FlowCoreMap as al, type MapEventTypes as am, type MapEventType as an, MapEvent as ao, MapMouseEvent as ap, MapSourceEvent as aq, MapLoadingEvent as ar, MapStyleChangeEvent as as, type MapPopupTemplateFn as at, type MapPopupOptions as au, MapPopup as av, Query as aw, query as ax, queryMany as ay, queryOne as az, type FlowStyleIssue as b, type FlowStyleLayerType as c, type FlowLayerStyleBuilder as d, type FlowStyleDataDriven as e, type MapStyleSpecification as f, MapLayer as g, type FlowContextOptions as h, FlowContext as i, FlowCoreError as j, FlowCoreExpressionError as k, FlowMapError as l, MapRegistry as m, type FlowCoreExpressionCustomFunction as n, type FlowCoreExpressionCustomFunctionSignature as o, type FlowCoreExpressionCustomFunctions as p, type ParserExpressionWithIndex as q, type ParserFunctionExpression as r, type ParserIndex as s, type ParserProgram as t, type CompositeDataSourceSpecification as u, type CompositeSubLayerBase as v, type CompositeSubLayerSpecification as w, type CompositeSubLayerSpecificationV1 as x, type FlowStyleDataDrivenOptions as y, type FlowStyleExpression as z };
|