-
Notifications
You must be signed in to change notification settings - Fork 3
/
Layer.ts
106 lines (90 loc) · 2.85 KB
/
Layer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { FeatureCollection } from 'geojson';
import BaseEntity, { BaseEntityArgs } from './BaseEntity';
import EditFormComponentType from './enum/EditFormComponentType';
import LayerType from './enum/LayerType';
export type DefaultRequestParams = Record<string, string | number | boolean>;
export interface DefaultLayerSourceConfig {
url: string;
layerNames: string;
legendUrl?: string;
tileSize?: number;
tileOrigin?: [number, number];
resolutions?: number[];
attribution?: string;
matrixSet?: string;
requestParams?: DefaultRequestParams;
useBearerToken?: boolean;
wmtsDimensions?: Record<string, string>;
}
export interface DefaultLayerPropertyConfig {
propertyName: string;
displayName?: string;
}
export interface PropertyFormItemReadConfig extends DefaultLayerPropertyConfig {
fieldProps?: any;
}
export interface PropertyFormItemEditConfig extends PropertyFormItemReadConfig {
component: EditFormComponentType;
readOnly?: boolean;
required?: boolean;
}
export interface PropertyFormItemEditDefaultConfig extends PropertyFormItemEditConfig {}
export interface PropertyFormItemEditReferenceTableConfig extends PropertyFormItemEditConfig {
editFormConfig: PropertyFormItemEditConfig[];
tablePropertyName?: string;
}
export interface PropertyFormTabConfig<T extends PropertyFormItemReadConfig> {
title: string;
children?: T[];
}
export interface DownloadConfig {
downloadUrl: string;
formatName?: string;
}
export interface SearchConfig {
attributes?: string[];
displayTemplate?: string;
}
export interface DefaultLayerClientConfig {
crossOrigin?: string;
downloadConfig?: DownloadConfig[];
editFormConfig?: PropertyFormTabConfig<PropertyFormItemEditDefaultConfig |
PropertyFormItemEditReferenceTableConfig>[];
editable?: boolean;
featureInfoFormConfig?: PropertyFormTabConfig<PropertyFormItemReadConfig>[];
hoverable?: boolean;
maxResolution?: number;
minResolution?: number;
opacity?: number;
propertyConfig?: DefaultLayerPropertyConfig[];
searchConfig?: SearchConfig;
searchable?: boolean;
}
export interface LayerArgs<
D extends DefaultLayerClientConfig,
S extends DefaultLayerSourceConfig
> extends BaseEntityArgs {
name: string;
clientConfig?: D;
sourceConfig: S;
features?: FeatureCollection;
type: LayerType;
}
export default class Layer<
D extends DefaultLayerClientConfig = DefaultLayerClientConfig,
S extends DefaultLayerSourceConfig = DefaultLayerSourceConfig,
> extends BaseEntity {
name: string;
clientConfig?: D;
sourceConfig: S;
features?: FeatureCollection;
type: LayerType;
constructor({id, created, modified, clientConfig, features, name, sourceConfig, type}: LayerArgs<D, S>) {
super({id, created, modified});
this.name = name;
this.clientConfig = clientConfig;
this.sourceConfig = sourceConfig;
this.features = features;
this.type = type;
}
}